Boy do I hate when I see my code mangled by the stupid AOL mailer.

Not that anyone cares, but the code should be read with each line starting with 
the "> " prompt.

If I leave lots of blank lines, it may work, but as the illustration is not in 
python, I will now remove the prompts:


`5x^2 + 2.3x` <- 666

`+-+-+` <- 1000

1 + 2 * `5x^2 + 2.3x` + `+-+-+`

output: 2333 

There are rarely good reasons for such silly variable names but as long as you 
let it know to leave the quoted regions alone when parsing and look them us as 
exact entries in various environments, it works fine.

To add to what others already wrote, many languages have serious requirements 
you need to be aware of and not assume otherwise. Some allow underscores in 
names and may limit that in the first part or may in some cases suggest or 
require it. Some have rules about whether a variable of one kind should start 
with an uppercase letter. Some allow periods in names although an initial 
period may make it invisible for some purposes. And, some newer languages allow 
all kinds of UNICODE characters and perhaps even some that can be seen as 
numeric but aren't exactly 0-9. 

① ② ③
 ... ❽ ❽



-----Original Message-----
From: Avi Gross via Python-list <python-list@python.org>
To: python-list@python.org <python-list@python.org>
Sent: Fri, May 13, 2022 6:02 pm
Subject: Re: .0 in name

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 <bryanga...@gmail.com>
To: python-list@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
-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to