.0 in name

Avi Gross avigross at verizon.net
Fri May 13 18:02:01 EDT 2022


Bryan,
As has been pointed out, it is very common in possibly all programming languages to not allow digits at the start of many identifiers. It makes it hard to parse for numbers which tend to start with digits. Some languages even have special rules on not starting a number with a zero unless you mean for it to be seen as octal (or 0x for hexadecimal) and many other rules exist.

There are languages where 12x means 12*x so even the lack of an operator ...

There are exceptions that often are not really exceptions. You can use all kinds of unusual variables in some quoted context. It is valid (albeit not encouraged) to use backquoted

The following is perfectly allowed in R:

> `5x^2 + 2.3x` <- 666 > `+-+-+` <- 1000 > 1 + 2 * `5x^2 + 2.3x` + `+-+-+` [1] 2333 
And there are often issued when you do things like create the name of a column of data in a data.frame with embedded spaces and other anomalies requiring special handling.
So why you wonder where it is documented that variables cannot be what you feel like is a bit puzzling! 


-----Original Message-----
From: bryangan41 <bryangan41 at gmail.com>
To: python-list at python.org
Sent: Fri, May 13, 2022 12:47 pm
Subject: .0 in name

May I know (1) why can the name start with a number?(2) where in the doc is it?!>>> import pdb>>> pdb.run('(a for a in "")')> <string>(1)<module>()(Pdb) s--Call--> <string>(1)<genexpr>()(Pdb) a.0 = <str_iterator object at 0xb685b100>(Pdb) c>>>Sent from Samsung tablet.
-- 
https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list