Re: ANNOUNCE: 'goto' for Python

Discussion in 'Python' started by Camilo Olarte, Apr 1, 2004.

  1. >> Entrian Solutions is pleased to announce version 1.0 of the 'goto'
    >> module.
    >>
    >> This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    >> flexibility to Python's control flow mechanisms and allowing Python
    >> programmers to use many common control flow idioms that were previously
    >> denied to them.


    >>>>>> What is the day today ? Oh yes the first of April ! <<<<<<


    OOUCH ! I Almost believe it!

    :)

    Camilo Olarte
    Telesat, más fácil...más Internet.
    http://www.telesat.com.co/
     
    Camilo Olarte, Apr 1, 2004
    #1
    1. Advertising

  2. Camilo Olarte <> writes:

    > >> Entrian Solutions is pleased to announce version 1.0 of the 'goto'
    > >> module.
    > >>
    > >> This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    > >> flexibility to Python's control flow mechanisms and allowing Python
    > >> programmers to use many common control flow idioms that were previously
    > >> denied to them.

    >
    > >>>>>> What is the day today ? Oh yes the first of April ! <<<<<<

    >
    > OOUCH ! I Almost believe it!


    There's nothing to believe: it works!

    Cheers,
    mwh

    --
    "Sturgeon's Law (90% of everything is crap) applies to Usenet."
    "Nothing guarantees that the 10% isn't crap, too."
    -- Gene Spafford's Axiom #2 of Usenet, and a corollary
     
    Michael Hudson, Apr 1, 2004
    #2
    1. Advertising

  3. Camilo Olarte

    Daniel Yoo Guest

    Michael Hudson <> wrote:
    : Camilo Olarte <> writes:

    :> >> Entrian Solutions is pleased to announce version 1.0 of the 'goto'
    :> >> module.
    :> >>
    :> >> This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    :> >> flexibility to Python's control flow mechanisms and allowing Python
    :> >> programmers to use many common control flow idioms that were previously
    :> >> denied to them.
    :>
    :> >>>>>> What is the day today ? Oh yes the first of April ! <<<<<<
    :>
    :> OOUCH ! I Almost believe it!

    : There's nothing to believe: it works!


    Hello,


    It doesn't work from the interactive interpreter, though:

    ###
    >>> from goto import goto, label

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/local/lib/python2.3/site-packages/goto.py", line 255, in _trace
    _addToCaches(filename)
    File "/usr/local/lib/python2.3/site-packages/goto.py", line 229, in _addToCaches
    for tokenType, tokenString, (startRow, startCol), (endRow, endCol), line \
    IOError: [Errno 2] No such file or directory: '<stdin>'
    ###


    I haven't looked at the code closely enough to understand exactly how
    to fix this. But in the meantime, here's a patch to at least give an
    error message when one tries to use it interactively:



    --- goto.py Tue Mar 30 12:24:28 2004
    +++ goto-fixed.py Thu Apr 1 13:37:10 2004
    @@ -208,6 +208,15 @@
    # Source filenames -> comefrom label names -> line numbers of those comefroms.
    _comefromNameCache = {}

    +
    +def _openModuleFilename(moduleFilename):
    + """Opens up the file named by moduleFilename. In the special case where
    + the file is <stdin>, we raise an IOError."""
    + if moduleFilename == '<stdin>':
    + raise IOError, "module cannot be used on sys.stdin."
    + return open(moduleFilename, 'r')
    +
    +
    def _addToCaches(moduleFilename):
    """Finds the labels and gotos in a module and adds them to the caches."""

    @@ -227,7 +236,7 @@
    # Tokenize the module; 'window' is the last two (type, string) pairs.
    window = [(None, ''), (None, '')]
    for tokenType, tokenString, (startRow, startCol), (endRow, endCol), line \
    - in tokenize.generate_tokens(open(moduleFilename, 'r').readline):
    + in tokenize.generate_tokens(_openModuleFilename(moduleFilename).readline):
    # Plain goto: "goto .x"
    if window == plainGotoPattern:
    _plainGotoCache[moduleFilename][startRow] = tokenString



    Hope this helps!
     
    Daniel Yoo, Apr 1, 2004
    #3
  4. [Daniel]
    > It doesn't work from the interactive interpreter, though:


    I know - I did point that out in my original announcement. :cool:

    > in the meantime, here's a patch to at least give an
    > error message when one tries to use it interactively:


    Thanks very much - I'll incorporate that (or something similar) into the
    next release).

    --
    Richie Hindle
     
    Richie Hindle, Apr 1, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richie Hindle

    ANNOUNCE: 'goto' for Python

    Richie Hindle, Apr 1, 2004, in forum: Python
    Replies:
    20
    Views:
    1,071
    Alan James Salmoni
    Apr 4, 2004
  2. Richie Hindle

    Re: ANNOUNCE: 'goto' for Python

    Richie Hindle, Apr 1, 2004, in forum: Python
    Replies:
    1
    Views:
    323
    Cousin Stanley
    Apr 2, 2004
  3. Andreas Otto
    Replies:
    0
    Views:
    309
    Andreas Otto
    Sep 25, 2009
  4. Andreas Otto
    Replies:
    0
    Views:
    365
    Andreas Otto
    Sep 25, 2009
  5. Andreas Otto
    Replies:
    0
    Views:
    371
    Andreas Otto
    Sep 25, 2009
Loading...

Share This Page