Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python variables naming convention

Tags:

python

pep8

So I am trying to switch to PEP8 notation (from a rather personal CamelCase notation) and I was wondering how you guys are tackling the cases where existing functions/variables would be overwritten?

e.g. having something like:

open, high, low, close, sum = row

would already overwrite the "open" and "sum" functions. First, if I wouldn't use a good IDE, I wouldn't even notice that I've just overwritten important basic functions. Second, how would you name the variables instead? In this example I would have used apps hungarian and wouldn't have encountered any potential problem at all.

Thanks!

like image 914
Muppet Avatar asked Jan 03 '12 15:01

Muppet


1 Answers

Why not just pick non-conflicting names? Such as opening_price, closing_price and total if that's what they represent. While it's possible to qualify the namespace as in the other replies, surely that shouldn't be needed for local variables. Whatever language you program in it's your job to know the reserved words; there aren't that many of them.

like image 90
Sideshow Bob Avatar answered Sep 19 '22 17:09

Sideshow Bob