Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99724
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: variable vs. object |
| Date | Mon, 30 Nov 2015 19:19:18 +1100 |
| Lines | 38 |
| Message-ID | <mailman.22.1448871561.14615.python-list@python.org> (permalink) |
| References | <2b4696d5-c9fb-4ca6-92a3-564e47712d59@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de jEovOWuPSSioMLwBBp8Z6wbZrfCLDPPxZQtaVxRYMuoA== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'float': 0.05; "'a'": 0.07; 'extent': 0.07; 'cc:addr:python- list': 0.09; '"a"': 0.09; 'exception,': 0.09; 'integer,': 0.09; 'integers': 0.09; 'methods,': 0.09; 'python': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:7 20': 0.16; 'specific,': 0.16; 'subject:object': 0.16; 'subject:variable': 0.16; 'too?': 0.16; 'wrote:': 0.16; 'integer': 0.18; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'do.': 0.22; 'fraction': 0.22; 'object.': 0.22; 'terminate': 0.22; 'bit': 0.23; 'header:In-Reply- To:1': 0.24; 'all.': 0.24; 'mon,': 0.24; 'sort': 0.25; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'object,': 0.27; 'skip:( 20': 0.28; 'looks': 0.29; 'silence': 0.29; 'objects': 0.29; 'raise': 0.29; 'asked': 0.29; 'up.': 0.32; '[1]': 0.32; 'case,': 0.34; 'equal': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'nov': 0.35; 'sometimes': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'difference': 0.38; 'received:209': 0.38; 'anything': 0.38; 'does': 0.39; 'some': 0.40; 'yes': 0.62; '30,': 0.63; 'between': 0.65; 'subject:. ': 0.67; 'chrisa': 0.84; 'odd,': 0.84; 'princess': 0.84; 'returns.': 0.84; 'to:none': 0.91; 'yes!': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=aQz09sjxSHn9RDbr5qtWq35kJDNvAnKnF+0bNo62zcE=; b=ueXXa1Tw0/MakF+Ydkt8SMRD14pEK+xtu7yxaayzmK1ylv38WC5b9VZk7yK92jiDpX TKD4cSthkwCclroyCeHa/NKbrO1wiyfV5w6XlkVoKo/FSkK7FQFD+pkD8dJK2O18lSnj vYbUI80obgnIR+LJKqsUjP3JcAWqKbj9+jlCxzXkEnf7RT0siy3Jr5I8f2QVsHxD4qC9 nrHJxw+/JjyyB+FVxI8LGUMg2fsyRORBdOMvXv8Av9e5GXbywtwPgEUQqTCraC1at3Ox 27FUJxiJsn1yfJQlYsB0dpfvpficOu0+8HNe7Lh+OjaUbhYh7QXMPDK6Y2RKeWnooRV3 BL9Q== |
| X-Received | by 10.107.16.84 with SMTP id y81mr52397177ioi.19.1448871558194; Mon, 30 Nov 2015 00:19:18 -0800 (PST) |
| In-Reply-To | <2b4696d5-c9fb-4ca6-92a3-564e47712d59@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:99724 |
Show key headers only | View raw
On Mon, Nov 30, 2015 at 1:06 PM, fl <rxjwg98@gmail.com> wrote: > For example, > > a=10 > > 'a' is an integer. Is it an object too? Other people have explained the difference between the name "a" and the object it's bound to... but to the extent that "a" is an integer, yes it most definitely is an object. To be specific, the integer 10 is an object, as you can see thus: >>> a = 10 >>> a.to_bytes(4, "big") b'\x00\x00\x00\n' >>> (a*12+8).to_bytes(4,"big") b'\x00\x00\x00\x80' Every expression [1] in Python has a value which is some sort of object, so you can do method calls on anything at all. Sometimes this looks a bit odd, but it does work: >>> 7.25.as_integer_ratio() (29, 4) The floating-point number 7.25 is represented in Python as a float object, and float objects have methods, same as all objects do. In this case, I've asked Python to tell me what this number would be as a fraction (ratio) of integers - 29/4 is equal to 7.25, so that's what it returns. So yes! It is an object. Everything is an object! ChrisA [1] To silence the nitpickers: An expression could raise an exception, or not terminate at all. As Grandpa said in The Princess Bride, you're very clever, now shut up.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
variable vs. object fl <rxjwg98@gmail.com> - 2015-11-29 18:06 -0800
Re: variable vs. object Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-29 21:16 -0500
Re: variable vs. object André Roberge <andre.roberge@gmail.com> - 2015-11-29 18:24 -0800
Re: variable vs. object Ben Finney <ben+python@benfinney.id.au> - 2015-11-30 13:45 +1100
Re: variable vs. object Ben Finney <ben+python@benfinney.id.au> - 2015-11-30 13:41 +1100
Re: variable vs. object Marko Rauhamaa <marko@pacujo.net> - 2015-11-30 07:28 +0200
Re: variable vs. object Nagy László Zsolt <gandalf@shopzeus.com> - 2015-11-30 09:09 +0100
Re: variable vs. object Chris Angelico <rosuav@gmail.com> - 2015-11-30 19:19 +1100
csiph-web