![]() |
|
[b]"How do I properly set up a python configure page for my project?"[/b]
or
[b]"What's the best way to create a p - Printable Version +- Proxy Community (https://proxycommunity.com/forum) +-- Forum: Technical Community Support (https://proxycommunity.com/forum/forum-technical-community-support) +--- Forum: API and Development (https://proxycommunity.com/forum/forum-api-and-development) +--- Thread: [b]"How do I properly set up a python configure page for my project?"[/b] or [b]"What's the best way to create a p (/thread-b-how-do-i-properly-set-up-a-python-configure-page-for-my-project-b-%0A%0Aor-%0A%0A-b-what-s-the-best-way-to-create-a-p) |
[b]"How do I properly set up a python configure page for my project?"[/b] or [b]"What's the best way to create a p - maskedCircuitX - 15-05-2024 Subject: What's the best way to create a python configure page for custom settings? Hey folks! I'm working on a project and need to set up a python configure page to handle user settings. Not sure if I'm overcomplicating it or missing something obvious. Do y'all have any go-to methods? Like, should I use configparser, JSON, or something else? Also, how do you make it *easy* for users to edit without breaking stuff? Kinda stuck here—any tips or examples would be awesome. Thanks in advance! (PS: If there's a "standard" way to build a python configure page, pls lmk. I don't wanna reinvent the wheel!) “” - dataNomadX99 - 11-12-2024 I'd say JSON is the way to go for a python configure page—super easy to read and edit. You can use the `json` module to load/save settings, and if you wanna make it user-friendly, throw in some basic validation. Check out `pydantic` for fancy validation stuff. Works like a charm! “” - dataTorX99 - 03-01-2025 Honestly, configparser is underrated for simple stuff. If your settings are basic key-value pairs, it’s built-in and does the job. No need to overcomplicate. But if you’ve got nested configs, yeah, JSON or YAML might be better. “” - GhostWarpX - 15-01-2025 For a python configure page, I’d recommend TOML! It’s human-readable and has great lib support (`tomllib` in Py3.11+). Plus, it’s what `pyproject.toml` uses, so it’s kinda becoming a standard. Here’s a quick example: ```python import tomllib with open("config.toml", "rb") as f: config = tomllib.load(f) ``` “” - deepVoy77 - 23-01-2025 Why not just use environment variables? `python-dotenv` makes it stupid simple. Less file editing for users, and it’s super portable. But if you *need* a file, JSON + `jsonschema` for validation is my go-to. “” - maskedVoyX99 - 08-02-2025 Dude, if you want a full-blown UI for your python configure page, try `PySimpleGUI`. You can whip up a settings window in like 20 lines. Users get dropdowns, checkboxes, etc.—no manual file edits. Game-changer for non-tech users. “” - DarkDrifter77 - 08-03-2025 YAML fan here! `ruamel.yaml` preserves comments and formatting, so users won’t wreck the file accidentally. Way cleaner than JSON for complex configs. Example: ```yaml # settings.yaml theme: dark plugins: [cool, stuff] ``` “” - dataTorX99 - 08-03-2025 If you’re worried about users breaking things, maybe split the config into two files: 1. Defaults (read-only, shipped with your app) 2. User overrides (editable) Merge them at runtime. `configparser` or `json` both work for this. “” - maskedCircuitX - 13-03-2025 Wow, thanks for all the suggestions! I tried JSON + `pydantic` like some of you said, and it’s working great so far. But now I’m curious—any tips for auto-generating docs from the config? Like, so users know what each setting does without digging into code? (Also, `PySimpleGUI` looks dope—gonna play with that next!) “” - NexusHider - 18-03-2025 For a python configure page, I’d avoid reinventing the wheel. Django’s settings system is *chef’s kiss*—maybe steal ideas from there? Or just use `dynaconf` if you want something standalone. Handles multiple formats and env vars. |