On 2017-07-23 01:06, Anish Tambe wrote:
for line in file:
This line is not required as the you have opened your file to 'f'.
'file' is a built-in class. Type -
help(file)
on the interpreter to know more about it.
This appears to be true in python2x but not in python3:
alex@X301n3:~$ python3
Python 3.4.3 (default, Nov 17 2016, 01:11:57)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
help(file)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'file' is not defined
exit()
alex@X301n3:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:32:47)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
help(file)
Help on class file in module __builtin__:
class file(object)
| file(name[, mode[, buffering]]) -> file object
|
...
Also puzzling is that the 'intro' to python2 declares itself to be 'on
linux2' vs just 'on linux' in the case of python3. (Something I'd not
previously noticed.)
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor