Assignment to None

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-03-26T11:29:31Z Indexed on 2010/03/26 11:33 UTC
Read the original article Hit count: 363

Filed under:

Hello,

I have a function which returns 3 numbers, e.g.:

def numbers():
   return 1,2,3

usually I call this function to receive all three returned numbers e.g.:

a,b,c=numbers()

However, I have one case in which I only need the first returned number. I tried using:

a, None None = numbers()

But I receive "SyntaxError: assignment to None".

I know, of course, that i can use the first option I mentioned and then not use "b" and "c", but only "a". However, this seems like a "waste" of two vars and feels like wrong programming.

Any ideas?

Thanks,

Joek

© Stack Overflow or respective owner

Related posts about python