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


Groups > comp.lang.python > #50266

Re: Help with 'self' and 'set_usage'

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <robotsondrugs@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; 'python,': 0.02; 'cpython': 0.05; 'assign': 0.07; 'attribute': 0.07; 'dynamically': 0.07; 'initialize': 0.07; 'interpreter.': 0.07; "subject:' ": 0.07; 'variables': 0.07; 'subject:Help': 0.11; 'python': 0.11; 'windows': 0.15; '__slots__': 0.16; 'defined.': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'example': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'mention': 0.26; 'certain': 0.27; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'quickly': 0.29; 'work.': 0.31; '(which': 0.31; 'code': 0.31; 'anyone': 0.31; 'class': 0.32; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'anywhere': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'simply': 0.61; 'advanced': 0.63; 'name': 0.63; 'great': 0.65; 'note:': 0.66; '9.1': 0.84; 'freebsd': 0.84; 'subject:self': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=hf3+y0fmIZ/Tp3HW/9BE1HRJ/jwHyv9Z+x1a4xGL4rU=; b=u5vRKgDztveoj4k5gcAYC9Iwe+eF0eVeDJWC29zhdPugGRsk1AfvYTWSgXYUUSQdPF a9vB/JTEDYHYidDAtuPxuUBKlquS00VkqjlgrMiujIhE/f1OwKqWoKLBcD/NV66icZ4i OQu7QQq4Ipfyhx1N+XdwO6o+hZoCNbRPdlDcoSBRvpDatj0+1gPZznnsnjnrU8ODhYHh vQjdgz8ReyxmfaWCsb0Y7qwdxfC7VaboHGqDLxAne4+uC8ithv+zKCy65TeEyH5xSeHE oTGW6uLD/TQ6xzpE1c1x7Yt7B62bjvefKIkOPqoGMOwBXMJduNoCrptVYtEOmuDEZC+8 SYPQ==
X-Received by 10.52.66.242 with SMTP id i18mr14005410vdt.3.1373391126705; Tue, 09 Jul 2013 10:32:06 -0700 (PDT)
Date Tue, 09 Jul 2013 12:32:06 -0500
From Andrew Berg <robotsondrugs@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
MIME-Version 1.0
To "comp.lang.python" <python-list@python.org>
Subject Re: Help with 'self' and 'set_usage'
References <de7c4d2c-817e-4237-b312-0795c1c43888@googlegroups.com>
In-Reply-To <de7c4d2c-817e-4237-b312-0795c1c43888@googlegroups.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
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.4465.1373391134.3114.python-list@python.org> (permalink)
Lines 11
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373391134 news.xs4all.nl 15959 [2001:888:2000:d::a6]:38955
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50266

Show key headers only | View raw


On 2013.07.09 12:03, L O'Shea wrote:
> Could anyone shed some light on this? I can't find mention of this anywhere in any Python documentation or anywhere else in the code where usage_str might be defined.
In Python, you don't declare or initialize variables before using them. In the example you gave, that is where usage_str is defined. You
simply assign an object to a name or attribute (which may or may not have existed previously). You can then change it to anything else you
want; Python is dynamically typed, so the object you assign to it can be of any type.

Note: a class with __slots__ defined is the exception to this, but that's a bit of an advanced topic.

BTW, you can play with objects in the interactive interpreter. It's a great way to quickly learn how certain things work.
-- 
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1

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


Thread

Help with 'self' and 'set_usage' "L O'Shea" <lo0446@my.bristol.ac.uk> - 2013-07-09 10:03 -0700
  Re: Help with 'self' and 'set_usage' Ethan Furman <ethan@stoneleaf.us> - 2013-07-09 10:19 -0700
  Re: Help with 'self' and 'set_usage' Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-07-09 19:24 +0200
  Re: Help with 'self' and 'set_usage' Andrew Berg <robotsondrugs@gmail.com> - 2013-07-09 12:32 -0500
  Re: Help with 'self' and 'set_usage' "L O'Shea" <lo0446@my.bristol.ac.uk> - 2013-07-10 01:23 -0700

csiph-web