PySpice
PySpice copied to clipboard
Document coding style
References:
- https://pep8.org/#descriptive-naming-styles
- https://dbader.org/blog/meaning-of-underscores-in-python
Constants use capital letters
name_ used by convention to avoid conflicts with Python keyword or name clash / I use sometimes _name
_name internal use in module or class
cls.__name is mangled in order to avoid naming conflicts in subclasses (overriding) Generally, double leading underscores should be used only to avoid name conflicts with attributes in classes designed to be subclassed.
double_leading_and_trailing_underscore “magic” objects or attributes that live in user-controlled namespaces. E.g. init, import or file. Never invent such names; only use them as documented. see also "Dunder"
name are not mangled !!!
cons: clash with future language change
All theses class attributes should be unmangled internals (there any mangled attribute name)
grep -R __ PySpice | grep '__ =' | sed -e 's/.*: *//' | sed -e 's/ =.*//' | sort | uniq
__alias__
__analysis_name__
__as_unit__
__base_units__
__binary_operator_map__
__classes__
__declaration_order__
__default_unit__
__git_sha__
__git_tag__
__hash_map__
__is_si__
__long_alias__
__MAX_COMMAND_LENGTH__
__name__ ?
__name_to_unit__
__nodes__
__number_of_operands__
__operator__
__operators__
__optional_parameters__
__parameters_from_args__
__pins__
__positional_parameters__
__power__
__precedence__
__prefix__
__prefixed_unit_map__
__prefixes__
__quantity__
__si_unit__
__spice_prefix__
__spice_to_parameters__
__unary_operator_map__
__unit_map__
__unit_name__
__units__
__unit_suffix__
__value_ctor__
__values_ctor__
__variable_cls__
It makes sense to rename the legacy dunders (could not myself explain the tradition ...) to internal class attributes (some are immutable)
but check '__' attributes filtering !!!