Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a bad practice to use accent in python class name?

I'm developing an app in Python3 and need to create a class that represents a diary. Well, I want to name it in my language, and it has an accent. Is it a bad practice? Will I have problems because of this character?

class Diário(Base): pass

like image 528
Arthur Julião Avatar asked Feb 17 '26 04:02

Arthur Julião


2 Answers

I'm going to assume you're using Python 3, given the tag.

It's good practice for your code to be clear and communicative. If the program you're writing is, for example, proprietary software developed by programmers who speak your language, then of course name the class Diário, and not Diario. There is no sense in murdering your own language and making things difficult to understand.

You can read PEP8, but its comments on encoding are primarily intended for programmers contributing to the Python standard library (which I'm guessing you're not). PEP8 is not nearly as strict as some make out - it simply insists on English for the standard library and then states that:

Open source projects with a global audience are encouraged to adopt a similar policy.

You should take this to mean that your code (and comments!) be in English unless you're very sure it won't be read by a wider audience. That's all the good practice you need to know about - err on the side of caution, and use English unless you're sure it's not necessary. Only you can decide what the best practice is in your case.

like image 200
Stephan Avatar answered Feb 18 '26 17:02

Stephan


Yes, Python 2.7 won't allow that (will throw SyntaxError). Also, naming your variables, classes, or whatever in another language that is not English is a bad practice.

See PEP8 for more details.

like image 21
cdonts Avatar answered Feb 18 '26 16:02

cdonts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!