A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033719.html below:

[Python-Dev] Code Generation Idea Was: Bytecode idea

[Python-Dev] Code Generation Idea Was: Bytecode idea [Python-Dev] Code Generation Idea Was: Bytecode ideaPaul Hughett Paul Hughett <hughett@bbl.med.upenn.edu>
Wed, 26 Feb 2003 11:04:12 -0500
    Guido> Problem with this is that there's currently lots of code out
    Guido> there that was recently modified to read

    Guido>   try:
    Guido>     True
    Guido>   except NameError:
    Guido>     True = 1
    Guido>     False = 0

    Guido> That would become a syntax error if True/False were true
    Guido> constants. :-(

> Hmmm...  Those code blocks would only be executed on older versions of the
> interpreter.  Is there some way to use that knowledge to finesse the
> problem?  It would be a real hack, but if the compiler recognized precisely
> the above construct (or at least assignment in an except block guarded by
> NameError), it could shut up about the assignment.

Would it be simpler to institute a special rule that True = 1 is silently
ignored, but True = anything else generates an error message?  Or am I
overlooking something important?

If you want to handle assigning to True an expression whose value is
known only at run time, translate it into

   if expression != 1 :
      raise Exception, "Attempt to assign invalid value to True"

which would give a run-time error without costing cycles anywhere else.


Paul Hughett



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4