l = range(int(1E9))

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun May 3 06:56:36 EDT 2015


On Sun, 3 May 2015 07:28 am, Tony the Tiger wrote:

> On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote:
> 
>> use "l" as a variable name, as it looks too much like 1
> 
> If you use a better font, they are very different. Besides, a variable
> name cannot start with a digit (nor can it be a single digit), so it's a
> given that it's an 'l'.

How do you know its a variable?

x+1

Is that 1 the constant or l the variable?

Yes, "use a better font" is good advice, if you can -- you don't always have
control over the machine you are working on, and the fonts which you have
access to -- but even with a better font, they still look two similar for
comfort. It's just common sense[1] to avoid easily confusable names
whenever possible:

advice = 23
advise = 23
makenewhttpfactorywidgetcreator = True
makenewhttpfactoryuidgetcreator = False

regardless of how awesome your font is. Unless you're spelling out each word
letter by letter, sometimes you will misread words.

Another one is rn versus m, especially at small text sizes, or if you're
silly or unlucky enough to be using Arial.




[1] So rare it's a superpower:

http://i0.wp.com/lolzombie.com/wp-content/uploads/2010/10/8eqf.jpeg




-- 
Steven




More information about the Python-list mailing list