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


Groups > comp.lang.python > #7784

Re: break in a module

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'imports': 0.07; '===': 0.09; 'conditional': 0.09; 'etc).': 0.09; 'inclined': 0.09; 'namespace': 0.09; 'def': 0.12; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'keyword': 0.19; 'header :In-Reply-To:1': 0.21; 'right.': 0.22; 'fri,': 0.23; 'thus': 0.23; "what's": 0.23; 'pass': 0.27; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'needed,': 0.29; 'import': 0.29; 'module': 0.30; 'annoying': 0.30; 'done,': 0.32; 'steven': 0.32; 'used,': 0.32; 'to:addr:python-list': 0.33; 'actually': 0.33; "isn't": 0.33; 'rather': 0.34; '17,': 0.35; "d'aprano": 0.35; 'quite': 0.36; 'certain': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'assuming': 0.37; 'could': 0.38; 'subject:: ': 0.38; 'perhaps': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'alternative': 0.71; 'extras': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=2WVzBTRYJznVQVPeOpgfJsgiNqGKqLiw8uiChFGutDk=; b=VDbdDVbii6OauR3lDz7M5KtWvb4Fvet7qWDMzHz3wXuZ/HSz1A0bjQza1JoSuN1n65 Au7sQQdhQz/UNYWZQ/Ahh8LooGCIxYi4G2YeHWO/9k28FYoHGraemO0xyIOS+Qqf7wew 1jNhpzXqa0NLmggnOqRNte39gU4z0Eq4Zm9rs=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=r1gWnMgpw3En1T4fXBbqmbLpyD7niANHPIdJxFTz4A+GzdkQxkf1xk9Us53l0fn6JV LJd52YOvpYY/zwD3hltg7pzqG85dRv8yY9bHPBk9KHa2EEXvfmaalI1anw0Grap6j1GG 0yyX4FBosZZamtlx5r+1/Arcw47ACFyDJk2g0=
MIME-Version 1.0
In-Reply-To <4dfaa441$0$30002$c3e8da3$5496439d@news.astraweb.com>
References <BANLkTinfUsHXuF5j5XjTMhiQXQKNi4ZSGA@mail.gmail.com> <4DF7E75E.9000907@mrabarnett.plus.com> <mailman.240.1308093309.11593.python-list@python.org> <qaWdnQmQzemLaWrQnZ2dnUVZ5vidnZ2d@giganews.com> <mailman.247.1308099095.11593.python-list@python.org> <6NWdnfBF0rgB42fQnZ2dnUVZ5h2dnZ2d@giganews.com> <4dfaa441$0$30002$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 17 Jun 2011 10:57:52 +1000
Subject Re: break in a module
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.51.1308272276.1164.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 82.94.164.166
X-Trace 1308272276 news.xs4all.nl 49038 [::ffff:82.94.164.166]:36679
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7784

Show key headers only | View raw


On Fri, Jun 17, 2011 at 10:48 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Perhaps the most sensible alternative is conditional importing:
>
> # === module extras.py ===
>
> def ham(): pass
> def cheese(): pass
> def salad(): pass
>
>
> # === module other.py ===
>
> def spam(): pass
>
> if not some_condition: from extras import *
>

This would, if I understand imports correctly, have ham() operate in
one namespace and spam() in another. Depending on what's being done,
that could be quite harmless, or it could be annoying (no sharing
module-level constants, etc).

As to which keyword is used, I would be inclined to go with 'return'
rather than 'break'. The module is thus a procedure in its own right.
Of course, that's assuming the feature's actually needed, which isn't
certain by any means.

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