tobakudan
tobakudan

Reputation: 35

Python Naming Convention for Variables that should be Classes

If I'm writing a function that takes a class as input, should it be any different than usual?

def func(convention_for_variables):

Or should it be aligned with the naming convention for classes to indicate that it should be a class?

def func(ClassVariable):

Upvotes: 1

Views: 1321

Answers (1)

lyxal
lyxal

Reputation: 1118

I would personally use the first option:

def func(cls):
    ...

If in doubt, you can read PEP8 (link here: https://www.python.org/dev/peps/pep-0008/#function-and-variable-names). It's a programming style guide which covers topics such as Variable names and conventions

Upvotes: 3

Related Questions