Parse variable into variables >Re: Apology

Timothy Rue threeseas at earthlink.net
Tue Feb 26 23:13:48 EST 2002


On 25-Feb-02 21:33:40 Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>Courageous wrote:
>>
>> >>> s = "a,b,c,d"
>> >>> tple = s.split(",")
>> >>> tple
>> ['a', 'b', 'c', 'd']

>One further tip: you can then "unpack" the tuple
>into variables, if you wish, like this:

>   var1, var2, var3, var4 = tple


testfile = open('test','r')

varset = testfile.readline()
tple = varset.split()
vic['AI']['1'], vic['AI']['2'], vic['AI']['3'] = tple

I assume this will work???

if so it Seems like this can be shortened to:

vic['AI']['1'], vic['AI']['2'], vic['AI']['3'] = varset.split()


is there a way to add the readline() into this line?

..... = testfile.readline().split()


???


A bit to tired to think ATM.

And thanks to everyone that responded.

---
*3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!*
   *~ ~ ~      Advancing How we Perceive and Use the Tool of Computers!*
Timothy Rue      What's *DONE* in all we do?  *AI PK OI IP OP SF IQ ID KE*
Email @ mailto:timrue at mindspring.com      >INPUT->(Processing)->OUTPUT>v
Web @ http://www.mindspring.com/~timrue/  ^<--------<----9----<--------<




More information about the Python-list mailing list