[Tutor] (no subject)

Deirdre Saoirse deirdre@deirdre.net
Wed, 21 Mar 2001 14:11:09 -0800 (PST)


On Wed, 21 Mar 2001, Glen Bunting wrote:

> 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?

It means that one of your lines doesn't have two elements when split.

You can fix this by:
 try:
  key, value = string.split(eachLine, ';')
 else:
  key = eachLine
  value = ''



--
_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