PEP 312 (and thus 308) implemented with a black magic trick

Steven Taschuk staschuk at telusplanet.net
Mon Mar 17 20:54:53 EST 2003


Quoth Erik Max Francis:
> Michele Simionato wrote:
  [...]
> > ~x as a shortcut for lambda :x
  [...]
> How does this suggestion different from the use of a single colon in PEP
> 312, except that this invalidates a previously existing legitimate
> behavior?  It has exactly the same benefits and drawbacks of PEP 312,
> except with the introduction of an additional drawback.

I wonder if you read the implementation, which emphasizes the
"dirty trick" aspect, and strongly suggests taking Simionato's
post as a joke.

But, if you insist, two unique advantages: first, the technique
requires no language changes whatsoever; second, it enables the
use of the special syntax on a class-by-class basis.

> Furthermore, if you change the meaning of ~, what operator now becomes
> used to represent bitwise negation?

Any code not in a class hacked as in Simionato's post can continue
to use ~ as before.

-- 
Steven Taschuk                           staschuk at telusplanet.net
"I'm always serious, never more so than when I'm being flippant."
                            -- _Look to Windward_, Iain M. Banks





More information about the Python-list mailing list