With thanks to all who made suggestions, this was what I settled on
f = open('testfile')
#(testfile consisting of 2 columns of data, as per Kent's suggestion)
data = []
for line in f:
line_data = [int(x) for x in line.split()]
data.append(line_data)
data.sort(key=lambda x:x[0])
print "sort by f
If you mean the external shell (say, "bash" under Linux or the DOS
command line in Windows, or similar) then you can only input strings --
everything is a string in such shells.
Yes, I meant capturing data from bash
There are two ways to conv
Owain Clarke wrote:
Please excuse the obviousness of my question (if it is), but I have
searched the documentation for how to generate a list e.g. [(1,2),
(3,4)] from a string "[(1,2), (3,4)]". I wonder if someone could point
me in the right direction.
Many thanks
Ow
I have solved it myself - must search more before posting!
If anyone at my kind of level is interested:-
>>> mystring = "[(1,2), (3,4)]"
>>> mylist = eval(mystring)
>>> mylist
[(1,2), (3,4)]
>>> type(mylist)
Thanks
Owain Clarke wrote:
Please e
Please excuse the obviousness of my question (if it is), but I have
searched the documentation for how to generate a list e.g. [(1,2),
(3,4)] from a string "[(1,2), (3,4)]". I wonder if someone could point
me in the right direction.
Many thanks
Ow
Thanks to all. I will now try to absorb suggestions and follow up links
- and no doubt get back to you with my next problem!
Owain
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/li
On Thu, Feb 4, 2010 at 5:43 AM, Owain Clarke wrote:
My question is, that if I proceed like this I will end up with a single list
of potentially several hundred strings of the form "frword:engword". In
terms of performance, is this a reasonable way to do it, or will the program
in
ot; % (engword, frword)
aimer - love
parler - speak
But if one word has different meanings in the other
language, you may need to use a list of words as the values.
Cheers!!
Albert-Jan
~~~~~~
p vocabulary tests.
My question is, that if I proceed like this I will end up with a single
list of potentially several hundred strings of the form
"frword:engword". In terms of performance, is this a reasonable way to
do it, or will the p