Hey, just for fun don't forget the new file() built-in introduced in Python 2.2!
file_as_list = open(filename, 'rb').readlines()
can be written as
file_as_list = file(filename, 'rb').readlines()
BTW, 'open' is now considered to be an alias for 'file'.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com
----- Original Message ----- From: "Martin Krueger" <martin.krueger@chello.at>
To: <wxPython-users@lists.wxwindows.org>
Sent: Thursday, February 27, 2003 3:57 PM
Subject: Re: [wxPython-users] Sorry, LAST Question from Python - Array
Hi!
You don't need wxPython for this, just use a plain Python list:
def loadFile(filename):
file_as_list = open(filename, 'rb').readlines()
This reads the lines of the file into the list file_as_list and you're done. (BTW, 'rb' means that the file is read in binary mode, just 'r' does conversion of the Unix/Windows newline, more infos in the tutorials)
Look up any Python tutorial, lists are a central piece of the language and are extensively covered. Take a look at the tutorial that comes with the Python distribution for more information/details. Another good tutorial can be found at www.diveintopython.org.
Good luck
martin
Kepes Krisztian wrote:
Hi !
Sorry
I cannot find documentation/example about the usage of Array, or wxArray in Python.
I am very lamer, newbie, and other in Python, and I want to Load an Text File to an array, and process it's data.
But how can I use an LIST/ARRAY/etc in Python/wx ?
I want to do this:
1. define an 1 dimensional string array
2. load the text file to it (enough the example of access the items in array A, or the add/and get the count of items)
3. define an 2 dimensional string array
4. (enough the example of access the items in array B)
If you have an example of usage the arrays/lists, send me to my private mail address.
Please help me !
10000000000000000000000 Thanx:
KK
...
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org