Vincent Gulinao wrote:
> Haha. Cool.
>
> I think it's better than...
>
> if str.find(" "):
> str1, str2, str3 = str.split(" ", 3)
> else:
> str1, str2, str3, rest = str, None, None, None
Less buggy, too - your version will fail if str="1 2" or "1 2 3 4"
BTW don't use str as the name of a string, it is already the name of the string
*type*. In general you should avoid using the names of built-ins for variable
names.
Kent
PS Please reply on list so others can benefit
>
> On 10/18/05, *Kent Johnson* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> wrote:
> AFAIK there is no pretty solution but this works:
> str1, str2, str3 = (s.split(" ", 3) + [None]*3)[:3]
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor