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

Sean Ross sross at connectmail.carleton.ca
Tue Mar 18 02:38:22 CET 2003


Hi.

"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E766255.5D06489A at alcyone.com...
>
> How does this suggestion different from the use of a single colon in PEP
312, ...


Actually, it wasn't a suggestion, it was merely a hack. The OP was just
trying to see if it could be done,
as they stated in their post...

"Michele Simionato" <mis6 at pitt.edu> wrote...
> I am not suggesting it. This is simply a proof of concept.

They were not suggesting an alternative syntax to PEP312, they were playing
around with code.
'~' just happens to be easier than ':' to intelligently isolate and replace
in Python code because it
has fewer possible uses/meanings.

"Erik Max Francis" <max at alcyone.com> wrote:
>...except that this invalidates a previously existing legitimate
> behavior?  ...

This is beside the point, but while we're here:

    Actually, it only 'overrides' the previously existing behaviour of '~'
inside of a class that inherits from
    'RecognizesImplicitLambdas'. Meaning the behaviour of '~' will remain
unaffected in any class that
    does not subclass 'RecognizesImplicitlambdas', and in every other scope,
other than inside a class that
    _does_ subclass 'RecognizesImplicitlambdas'.

    Meaning, if you don't use it, nothing is changed.
    And, if you do use it,  you'll just have to ensure that there are no
requirements for bitwise negation
    inside of your class.  i.e.,
                If you want to soak yourself in gasoline, go right ahead.
And if you don't, don't.  But, if you do,
                and you then insist on lighting matches...well...don't come
crying to me...


"Erik Max Francis" <max at alcyone.com> wrote:
> Furthermore, if you change the meaning of ~, what operator now becomes
> used to represent bitwise negation?

That's really not the point. If the OP were suggesting that that his hack be
added to the language,
then this would be a valid concern. However, no such suggestion has been
made  (in fact, quite
the opposite).

"Michele Simionato" <mis6 at pitt.edu> wrote...
> ...changing the semantics of the language is never a good idea...

The OP was not suggesting that their code be used, they were simply
presenting the community with
a neat little toy.  And, they even took the time to label it with "Choking
Hazard" tags.






More information about the Python-list mailing list