Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7887

Re: break in a module

References <4dfaed89$0$30002$c3e8da3$5496439d@news.astraweb.com> <mailman.103.1308364612.1164.python-list@python.org> <4dfc2084$0$30002$c3e8da3$5496439d@news.astraweb.com> <mailman.108.1308371514.1164.python-list@python.org> <4dfc2e42$0$30002$c3e8da3$5496439d@news.astraweb.com>
Date 2011-06-18 15:06 +1000
Subject Re: break in a module
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.110.1308373610.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jun 18, 2011 at 2:49 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Not quite. In my config language, "ignored" means ignored. There was no
> way of accessing the rest of the file, short of guessing the file name,
> opening it and reading it as text.
>
> In Perl, the __END__ and __DATA__ keywords mark the end of the Perl
> program, and leave the rest of the document visible to the caller via a
> special file handle:

Sure, but if you don't use that handle, it comes to the same thing.
It's like a function's return value when you just want its side
effects, or using re.match and ignoring all but whether it evaluates
as True or False. In REXX, you can access any part of the source file
using the sourceline() function - sometimes I've done things like
this:

/*
Usage: scriptname [arg] [arg] [arg]
arg: specifies the number of times to yell Argh
arg: specifies the type of black beast to kill you
arg: chooses an Abstract Resource Group

Use this only in cases of blargh.
*/
.
.
.
.
usage:
do i=2 to sourceline() until sourceline(i)="*/"; say sourceline(i); end

Does this mean that the comment isn't ignored? Nope. It's ignored, but
it can be retrieved through in-language means.

Anyhow, it's not uncommon to abuse language features to do different
things. I've heard that it's faster in MS-DOS Batch to put comments
with a leading colon (making them labels for goto) than to use the REM
(remark) command...

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: break in a module Ethan Furman <ethan@stoneleaf.us> - 2011-06-14 16:28 -0700
  Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-14 16:51 -0700
    Re: break in a module Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-14 18:51 -0600
      Re: break in a module Ben Finney <ben+python@benfinney.id.au> - 2011-06-15 11:33 +1000
        Re: break in a module Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-14 20:21 -0600
          Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 15:09 -0700
        Re: break in a module Dave Angel <davea@ieee.org> - 2011-06-15 00:02 -0400
      Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 15:07 -0700
        Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-17 09:27 +1000
          Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 16:29 -0700
            Re: break in a module Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-16 18:00 -0600
            Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-17 10:01 +1000
              Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 18:13 -0700
                Re: break in a module Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 19:17 -0700
                Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 21:21 -0700
                Re: break in a module Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-16 22:53 -0600
        Re: break in a module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-17 00:48 +0000
          Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-17 10:57 +1000
            Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 18:21 -0700
              Re: break in a module Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 19:11 -0700
              Re: break in a module Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-16 19:58 -0600
                Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 21:24 -0700
                Re: break in a module Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-16 22:50 -0600
                Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-16 22:20 -0700
                Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-17 15:56 +1000
                Re: break in a module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-17 06:00 +0000
                Re: break in a module Erik Max Francis <max@alcyone.com> - 2011-06-17 00:09 -0700
                Re: break in a module Cameron Simpson <cs@zip.com.au> - 2011-06-18 12:36 +1000
                Re: break in a module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-18 03:50 +0000
                Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-18 14:31 +1000
                Re: break in a module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-18 04:49 +0000
                Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-18 15:06 +1000
                Re: break in a module Cameron Simpson <cs@zip.com.au> - 2011-06-21 20:04 +1000
                Re: break in a module Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-17 00:25 -0600
    Re: break in a module Chris Angelico <rosuav@gmail.com> - 2011-06-15 11:33 +1000

csiph-web