Most probably a stupid question, but I still want to ask

Fillmore fillmore_remove at hotmail.com
Sun Apr 10 18:51:02 EDT 2016


let's look at this:

$ python3.4
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> line1 = '"String1" | bla'
 >>> parts1 = line1.split(" | ")
 >>> parts1
['"String1"', 'bla']
 >>> tokens1 = eval(parts1[0])
 >>> tokens1
'String1'
 >>> tokens1[0]
'S'

and now this

 >>> line2 = '"String1","String2" | bla'
 >>> parts2 = line2.split(" | ")
 >>> tokens2 = eval(parts2[0])
 >>> tokens2
('String1', 'String2')
 >>> tokens2[0]
'String1'
 >>> type(tokens1)
<class 'str'>
 >>> type(tokens2)
<class 'tuple'>
 >>>


the question is: at which point did the language designers decide to betray the
"path of least surprise" principle and create a 'discontinuity' in the language?
Open to the idea that I am getting something fundamentally wrong. I'm new to Python...

Thanks





More information about the Python-list mailing list