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

Joal Heagney s713221 at student.gu.edu.au
Thu Jul 26 13:15:16 CEST 2001


Bruce Sass wrote:
> 
> 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

Others have given reasons why/why not. Would this do what you wanted to
do?

a = int(divmod(5.01,2)[0])

Or are you specificially after integer a, with b at the same time?
-- 
      Joal Heagney is: _____           _____
   /\ _     __   __ _    |     | _  ___  |
  /__\|\  ||   ||__ |\  || |___|/_\|___] |
 /    \ \_||__ ||___| \_|! |   |   \   \ !



More information about the Python-list mailing list