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


Groups > comp.lang.python > #8046

Re: Python scoping

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'rules.': 0.07; 'type,': 0.07; 'python': 0.08; '21,': 0.09; 'bind': 0.09; 'object.': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'declared,': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'tue,': 0.17; 'writes:': 0.19; 'header:In-Reply-To:1': 0.21; 'variable': 0.21; 'objects,': 0.23; 'received:209.85.210.174': 0.23; 'received:mail- iy0-f174.google.com': 0.23; 'objects': 0.23; "doesn't": 0.25; 'like.': 0.25; 'message-id:@mail.gmail.com': 0.28; '(the': 0.28; 'bound': 0.29; 'variables': 0.29; 'fairly': 0.30; 'value.': 0.32; 'does': 0.33; 'to:addr:python-list': 0.33; 'assignment': 0.35; 'languages': 0.35; 'using': 0.35; 'reference': 0.35; 'hold': 0.36; 'rules': 0.37; 'similar': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'instead,': 0.37; 'references': 0.37; 'but': 0.38; 'data': 0.38; 'though': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'automatic': 0.73; '10:39': 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:content-transfer-encoding; bh=FNr/nO2ha+hAjxHmKWziL5f6TDueK21/XPf+b4+iOBw=; b=FTIjN7XMcQma40Te7sFMXRkqIEfM3r2OxaTkwLBI8eHdXwlDS/tQFd22F0UXZ5c24C NaJoXsuVSdnofJJ5Q53r66tthuX/633DmZFPUpRHH4OIfhWcA5Q0bJcQXy2A1GGeYv9+ FUPev60xxE+DdWVkpQ1wmsZvWwW3CBuFOvW8I=
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:content-transfer-encoding; b=C4dz2/qqCQd54cnfn6f7IB4yvvLrXS9GrCv/nh/iakEu7qJOzD97PZV2gUe3ZkzLFh WUnXLtz/mw9Sr0/6kKhPJ+0WfWJfjBablRDDbOJbyXyquM+VK9FJZiLKcBKUcf6lb3eg saSm/63+kMIubMw75LH/90u++fUnzkCAxzpzY=
MIME-Version 1.0
In-Reply-To <87ei2oqaqe.fsf@benfinney.id.au>
References <2f69dda9-9532-4fd1-af06-ba85cc2a0e33@v5g2000yqn.googlegroups.com> <87ei2oqaqe.fsf@benfinney.id.au>
Date Tue, 21 Jun 2011 10:55:55 +1000
Subject Re: Python scoping
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding quoted-printable
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.205.1308617759.1164.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1308617759 news.xs4all.nl 49177 [::ffff:82.94.164.166]:35509
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8046

Show key headers only | View raw


On Tue, Jun 21, 2011 at 10:39 AM, Ben Finney <ben+python@benfinney.id.au> wrote:
> gervaz <gervaz@gmail.com> writes:
> Python doesn't have variables the way C or many other languages have
> them.
>
> Instead, Python has objects, and references to those objects so you can
> get at them. The Python documentation, much to my frustration, calls
> these references “variables” even though that gives exactly the wrong
> implication of how they'd behave.

But variable names in C and variable names in Python follow fairly
similar rules. Yes, there's the whole thing of automatic sharing and
automatic deallocation, but the name still follows rules of scoping
that are very similar - but more flexible in C.

> With the assignment statements (the statements using ‘txt = …’), the
> name ‘txt’ is bound as a reference to a value. It's not a C-like
> variable; it doesn't have a type, it doesn't need to be declared, etc.
> It's just a name, that you can bind to exactly one value any time you
> like.

It does have a type. It's a Python object. That data type can hold any
one "thing". :)

ChrisA

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


Thread

Python scoping gervaz <gervaz@gmail.com> - 2011-06-20 15:35 -0700
  Re: Python scoping Chris Angelico <rosuav@gmail.com> - 2011-06-21 08:52 +1000
  Re: Python scoping Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 10:39 +1000
    Re: Python scoping Chris Angelico <rosuav@gmail.com> - 2011-06-21 10:55 +1000
      Re: Python scoping Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 12:38 +1000
        Re: Python scoping Chris Angelico <rosuav@gmail.com> - 2011-06-21 13:21 +1000
          Re: Python scoping Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 14:06 +1000
            Re: Python scoping gervaz <gervaz@gmail.com> - 2011-06-21 02:05 -0700
  Re: Python scoping Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-21 00:57 +0000

csiph-web