naming-conventions

The naming rules for your virtual environments in python

The naming rules for your virtual environments in python Question: I’m looking for some sort of naming scheme for my virtual environments. How do you usually name them? Is there naming convention for python virtual environments? Asked By: Michael || Source Answers: If you are storing your environment inside the project folder some common names …

Total answers: 1

Python: variable naming convention – file, path, filepath, file_path

Python: variable naming convention – file, path, filepath, file_path Question: I would like to know the correct naming convention for the following variables in Python which I couldn’t find one from Google Style Guide and PEP8 (Let’s say I have the following Python code) output_file = open(output_file_path, ‘w’) What would be the best variable name …

Total answers: 2

Python boolean methods naming convention

Python boolean methods naming convention Question: I’m a Rubyist learning Python and I’m wondering if there is a convention in Python along the lines of the following. In Ruby, methods that return booleans are supposed to always end in a ?. For example, def palindrome?(string) # some code that tests whether string is a palindrome …

Total answers: 3

How to use reserved keyword as the name of variable in python?

How to use reserved keyword as the name of variable in python? Question: I want to use reserved keyword “from” as the name of variable. I have it in my arguments parser: parser.add_argument(“–from”) args = parser.parse_args() print(args.from) but this isn’t working because “from” is reserved. It is important to have this variable name, I don’t …

Total answers: 1

Should Python class filenames also be camelCased?

Should Python class filenames also be camelCased? Question: I know that classes in Python are typically cased using camelCase. Is it also the normal convention to have the file that contains the class also be camelCase’d especially if the file only contains the class? For example, should class className also be stored in className.py instead …

Total answers: 5

Underscore after a variable name in Python

Underscore after a variable name in Python Question: I am deciphering someone else’s code and I see the following: def get_set_string(set_): if PY3: return str(set_) else: return str(set_) Does the underscore AFTER the variable mean anything or is this just a part of the variable’s name and means nothing? Asked By: nanachan || Source Answers: …

Total answers: 2

What does "rc" in matplotlib's rcParams stand for?

What does "rc" in matplotlib's rcParams stand for? Question: matplotlibrc configuration files are used to customize all kinds of properties in matplotlib. One can change the rc settings to customize the default parameters e.g: matplotlib.rcParams[‘font.family’] = ‘times new roman’ … but what does "rc" stand for? I can’t find any explanation in the docs Asked …

Total answers: 1

Python predicate function name convention

Python predicate function name convention Question: Does Python have some convention for names of predicate functions? For example predicate function names end with p for Common Lisp or ? for Scheme. Sometimes are used prefixes like is_ or has_, …, but they may not be appropriate in some cases (they can be quite long to …

Total answers: 1

Why does Pylint object to single-character variable names?

Why does Pylint object to single-character variable names? Question: I’m still getting used to Python conventions and using Pylint to make my code more Pythonic, but I’m puzzled by the fact that Pylint doesn’t like single character variable names. I have a few loops like this: for x in x_values: my_list.append(x) and when I run …

Total answers: 7