Comments on my first script?
bruno.desthuilliers at gmail.com
bruno.desthuilliers at gmail.com
Sat Jun 14 16:17:43 EDT 2008
On 13 juin, 17:24, Lie <Lie.1... at gmail.com> wrote:
> On Jun 13, 3:19 pm, Bruno Desthuilliers <bruno.> 42.desthuilli... at websiteburo.invalid> wrote:
> > Phillip B Oldham a écrit :
>
(snip)
> > > try:
> > > for line in rec.split("\n"):
> > > bits = line.split(': ')
> > > a = bits.pop(0)
> > > b = bits.pop(0)
>
> > if you expect only one ': ', then:
> > a, b = line.split(': ')
>
> > if you can have many but don't care about the others:
> > bits = line.split(': ')
> > a, b = bits[0], bits[1]
>
> or:
> a, b = line.split(': ')[:1]
>
ValueError: need more than 1 value to unpack
You probably meant:
a, b = line.split(': ')[:2]
More information about the Python-list
mailing list