About 699,000 results
Open links in new tab
  1. What's the best practice using a settings(config) file in Python?

    The goal is to simplify using many arguments in a Python program by writing a config (settings) file that dynamically can add an item. What is the best practice for using a settings (config) file or importing a …

  2. What is the naming convention in Python for variables and functions ...

    As the Style Guide for Python Code admits, The naming conventions of Python's library are a bit of a mess, so we'll never get this completely consistent Note that this refers just to Python's standard …

  3. How do I write good/correct package __init__.py files

    Although all the functionality is implemented in modules and subpackages, your package docstring is the place to document where to start. For example, consider the python email package. The package …

  4. What is the best practice for imports when developing a Python …

    Jan 1, 2023 · To conclude the question: What is the best practice to import modules and sub-packages freely and nicely from within sub-directories of a Python package that is currently under construction? …

  5. What's the best way to initialise and use constants across Python ...

    Oct 16, 2018 · Here's how I am declaring constants and using them across different Python classes: # project/constants.py GOOD = 1 BAD = 2 AWFUL = 3 # project/question.py from constants import …

  6. Best Practices Python - Where to store API KEYS/TOKENS

    Jul 11, 2019 · Best practices for api key safety, BY OPENAI. As they suggested, use environment variables in place of your API key. There are a lot of tutorials, such as How to set environment …

  7. What's the common practice for enums in Python? [duplicate]

    Apr 1, 2009 · How can I implement an enumeration type (spelled enum in some languages) in Python? What is the common practice to get this functionality?

  8. Python best practice in terms of logging - Stack Overflow

    Apr 14, 2023 · 44 When using the logging module from python for logging purposes. Is it best-practice to define a logger for each class? Considering some things would be redundant such as file log …

  9. Best practice in python for return value on error vs. success

    My question is, what is the best practice in areas like this, and not just for lists?Return whatever the heck I want and make sure I document it for a user to read? :-) What do most of you folks do: If on …

  10. Absolute vs. explicit relative import of Python module

    An important caveat is that because of PEP 338 and PEP 366, relative imports require the python file to be imported as a module - you cannot execute a file.py that has a relative import or you'll get a …