PEP 313 - Roman numeral literals

Beni Cherniavsky cben at techunix.technion.ac.il
Thu Apr 3 12:51:43 EST 2003


Mike Meyer wrote on 2003-04-01:

> PEP: 313

PEP: CCCXIII you mean?  I think this would make the PEP index much
more convenient to navigate :-).

> [snip]

> Compatability Issues
>
>     No new keywords are introduced by this proposal.  Programs that
>     use variable names that are all upper case and contain only the
>     characters M, D, C, L, X, V and I will be affected by the new
>     literals.  These programs will now have syntax errors when those
>     variables are assigned, and either syntax errors or subtle bugs
>     when those variables are referenced in expressions.  Since such
>     variable names violate PEP 8 [3], the code is already broken, it
>     just wasn't generating exceptions. This proposal corrects that
>     oversight in the language.
>
While I sympatise with the "broken" sentiment, that's clearly not
Python's way to handle such changes.  The right thing is obviously::

    Python MMM (#I Apr 1 2003 12:00-48)
    [GCC III.V (Red Hat Linux VI^H^HEMACS;)]
    >>> III = 'example'
    >>> III
    'example'
    >>> # ---vvvvvvvv-----------------------
    >>>
    >>> from __past__ import roman_numerals
    >>>
    >>> # ---^^^^^^^^----------------------
    >>> III
    3
    >>> III = 'bad'
    SyntaxError: can't assign to literal

Yes, I know __past__ is reserved for the past in Python's development,
not the surrounding universe's past; importing from it would encourage
keeping obsolete baggage, so it will never be implemented; that means
you can't do::

    from __future__ import __past__

to test the above code in current or soon-to-appear Pythons...
Perhaps something like::

    from __never__ import __past__

would be nice to have for such situations...  I wonder if pymacs
together with emacs' `M-x do`_ would allow time-travel access from
Python, that would at least relieve some burden from the devolopers, I
think.

.. M-x do:
   http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/etc/
   future-bug?rev=HEAD&content-type=text/vnd.viewcvs-markup

Another approach altogether would be to give actual meaning to the
`__date__` module attribute: python would run the program according to
the current Python documentation at this date.  That should fix
compatibility issues once and for all.  Of course, this depends on
your system's ``/dev/time`` being seekable in both directions...

was-doing-homeworkds-on-April-fools-day-ly y'rs
  Beni Cherniavsky <cben at tx.technion.ac.il>

If I don't code for myself, who will?
And if I don't GPL it, what am I?





More information about the Python-list mailing list