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


Groups > comp.lang.python > #34100

Re: amazing scope?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=674d5ed43=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.043
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; '(except': 0.05; 'parameter': 0.07; 'cc:addr:python-list': 0.10; 'def': 0.10; 'anyway': 0.11; 'executed,': 0.16; 'guilty': 0.16; 'module': 0.19; 'bit': 0.21; 'fine,': 0.22; 'defined': 0.22; 'cheers,': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'url:mailman': 0.29; 'function': 0.30; 'url:python': 0.32; '-----': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'another': 0.33; 'subject:?': 0.35; 'something': 0.35; 'really': 0.36; 'url:org': 0.36; 'thank': 0.36; 'subject:: ': 0.38; 'store': 0.38; 'url:mail': 0.40; 'you.': 0.61; 'received:194': 0.61; 'information': 0.63; 'person,': 0.65; 'disclose': 0.69; 'notice:': 0.71; 'privileged.': 0.72; 'suprise': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.83,348,1352070000"; d="scan'208";a="951967"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Fri, 30 Nov 2012 17:47:17 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To andrea crotti <andrea.crotti.0@gmail.com>
In-Reply-To <CAF_E5JbeoJ__WTMy-omFPrWP23E=yyeEJ8ABaEJ5jaFP9vFbPw@mail.gmail.com>
Subject Re: amazing scope?
MIME-Version 1.0
X-Mailer Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC7 (Linux)/7.2.0_GA_2669)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org, Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.386.1354294010.29569.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354294010 news.xs4all.nl 6849 [2001:888:2000:d::a6]:41304
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34100

Show key headers only | View raw


----- Original Message -----
> Well I knew that this works fine, even if I feel a bit guilty to do
> this, and better is:
> 
> foo = 'bar' if some_condition else 'baz'
> 
> Anyway for me the suprise is that something that is defined *later*
> at
> the module scope is found in a function which is defined *earlier*.
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

What really matters for function is when they're executed, not defined (except for their parameter default value).

foo = 'I am foo'
bar = 'I am bar'

def funcA(param1=foo):
    print param1
    print bar

foo = 'I am another foo'
bar = 'I am another bar'

def funcB(param1=foo):
    print param1
    print bar
    
funcA()
funcB()

   


I am foo
I am another bar
I am another foo
I am another bar


cheers,

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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


Thread

Re: amazing scope? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-11-30 17:47 +0100

csiph-web