int(a), b = divmod(x, y)

Ken Seehof kens at sightreader.com
Thu Jul 26 03:00:50 CEST 2001


No, it's just that the syntax makes no sense in python.

It would also, of course, be invalid to say:
int(a) = 5.2    # hoping for a=5

This is not the same as a = int(5.2) and it would seem really wierd to
me if it were.  Then again, from a C++ point of view, any syntax that
is currently illegal is a natural candidate for a new syntax feature :-).
But python is not C++, so I'm afraid you'll have to settle for something
less terse and more clear.

a,b = divmod(x,y)
a = int(a)

- Ken

----- Original Message ----- 
From: "Bruce Sass" <bsass at freenet.edmonton.ab.ca>
To: <python-list at python.org>
Sent: Wednesday, July 25, 2001 2:31 PM
Subject: int(a), b = divmod(x, y)


> How nasty would it be to allow one to do...
> 
> >>> int(a), b = divmod(5.01, 2)
> >>> print a, b
> 2 1.01
> 
> ...instead of the current...
> 
> >>> int(a), b = divmod(5.01, 2)
> SyntaxError: can't assign to function call
> 
> 
> On the surface, it looks as simple as postponing the function call
> until after the assignment.  Would it be a one-time hit when the
> pseudo-ops are generated, a runtime performance issue that would
> affect all function calls, just too hairy to implement, or something
> else?
> 
> 
> - Bruce
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list