No swap function in Python?

Remco Gerlich scarblac at pino.selwerd.nl
Thu May 31 14:15:24 EDT 2001


Gawain Bolton <boltong at nortelnetworks.com> wrote in comp.lang.python:
> This is why I think it might be an idea to have a "swap" function in Python.
> Besides making for more readable code - ok ok, I have not done a survey and
> have no statistical or theoretical data to support this claim but let's
> pretend humans understand words more readily than symbolic notation - a swap
> function could generate the optimized code without any need for peephole
> optimization.

A swap function is impossible in Python. A function cannot rebind names in
the caller's namespace. This is why del is a statement and not a function,
for instance.

-- 
Remco Gerlich



More information about the Python-list mailing list