|
|
Subscribe / Log in / New account

Python identifiers, PEP 8, and consistency

Python identifiers, PEP 8, and consistency

Posted Dec 1, 2021 19:35 UTC (Wed) by NYKevin (subscriber, #129325)
In reply to: Python identifiers, PEP 8, and consistency by epa
Parent article: Python identifiers, PEP 8, and consistency

Having spent a fair amount of time working in a case-insensitive Pascal-like language (hello, Skyrim modding!), this is actually a lot less painful than it sounds.* However, your capitalization will get irregular if you don't have a standard style and some kind of automated enforcement mechanism. If your language supports variable shadowing (which Papyrus does not, but Python obviously does), then it might be more painful because you will have a larger set of variables potentially "in scope" and there is greater potential for collisions, which the compiler will not warn you about.

> That doesn’t do much for studlyCaps versus underscores, I admit. I guess if you must have aliases, they should be declared specially so that linter tools (and the compiler’s own diagnostics) can help the programmer. They should not just be a bunch of wrapper functions.

You don't need wrapper functions in Python. Python functions and classes are first-class objects, so you can just do this:

def original_name(args...): ...

alias = original_name

If a linter is unable to figure that out, it needs to be redesigned from the ground up.

* Except for the case-insensitive strings. Those are terrible.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds