How to add a current string into an already existing list

Nick the Gr33k nikos.gr33k at gmail.com
Tue Nov 5 16:39:50 CET 2013


Στις 5/11/2013 3:15 μμ, ο/η Dave Angel έγραψε:
> On Tue, 05 Nov 2013 14:25:41 +0200, Nick the Gr33k
> <nikos.gr33k at gmail.com> wrote:
>> i tried inserting a type function to notify me of the datatype of
> 'data'
>> but that didnt help too.
>
> What did that print show ? In what way didn't it help?
>
> It said the type was Charles
> It didn'tprint anything
> It gave some other error
> It formattedmy drive
>
> How far did you get on the exercise I suggested?
>



nikos at superhost.gr [~]# who
nikos    pts/0        Nov  5 09:57 (176.92.96.218)
nikos at superhost.gr [~]# who > myfile.txt
nikos at superhost.gr [~]# cat myfile.txt
nikos    pts/0        Nov  5 09:57 (176.92.96.218)
nikos at superhost.gr [~]# python
Python 3.3.2 (default, Aug 26 2013, 06:41:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> infile = open("myfile.txt")
>>> data = infile.readlines
>>> for line in data:
... print( line )
   File "<stdin>", line 2
     print( line )
         ^
IndentationError: expected an indented block
>>> for line in data:
...     print( line )
...
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: 'builtin_function_or_method' object is not iterable

You said that i should try it locally but on my 8.1 i do not have python 
installed i test and run everything on server.

So, i tried it at the interpreter and it gave me the same error.



More information about the Python-list mailing list