[Tutor] (no subject)
Glen Bunting
Glen@ihello-inc.com
Wed, 21 Mar 2001 14:05:32 -0800
When I make the changes:
>>> import string
>>> CONFIG = open('webconf.txt').readlines()
>>> for eachLine in CONFIG:
... key, value = string.split(eachLine, ';')
... print 'The key is : ', key
...
Traceback (innermost last):
File "<stdin>", line 2, in ?
ValueError: unpack list of wrong size
What does that mean and what am I doing wrong?
Glen
-----Original Message-----
From: Deirdre Saoirse [mailto:deirdre@deirdre.net]
Sent: Wednesday, March 21, 2001 1:56 PM
To: Glen Bunting
Cc: 'Daniel Yoo'; 'tutor@python.org'
Subject: RE: [Tutor] (no subject)
On Wed, 21 Mar 2001, Glen Bunting wrote:
> When I try :
>
> >>> import string
> >>> CONFIG = open('webconf.txt').read()
> >>> for 1 in CONFIG:
> ... key, value = string.split(1, ';')
> ... print 'The key is : ', key
> ... print 'The value is : ', value
>
> SyntaxError: Can't assign to literal
You probably want:
for l in CONFIG:
1 is a number and can't be assigned a value.
Also, likely you want .readlines() rather than .read()
--
_Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams