Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61349
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.04; 'root': 0.05; '(except': 0.07; 'subject:help': 0.08; "'a'": 0.09; 'methods,': 0.09; 'python:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'cc:name:python list': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inheritance': 0.16; 'janssen': 0.16; 'object()': 0.16; 'repetition': 0.16; 'sorts': 0.16; 'subject:object': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'pieces': 0.19; 'work,': 0.20; '>>>': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'dec': 0.30; 'list:': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'steven': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'maybe': 0.34; 'subject:the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'useful': 0.36; 'two': 0.37; 'pm,': 0.38; 'does': 0.39; 'itself': 0.39; 'most': 0.60; 'mentioned': 0.61; 'simple': 0.61; 'default': 0.69; 'therefore': 0.72; 'lowest': 0.74; 'functions:': 0.84; 'subject:base': 0.84; 'to:none': 0.92; 'directly.': 0.95; '2013': 0.98 |
| 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=1pwwpbstzkj1nz+9DXK2qYyOUvrnm9KksclwXF0vSIY=; b=CxQcVtNqv1KlYbCskpbScE4PcYb5VxD2FgloZ//GYGZOoGsxevEr1CCOIxkqIFIHXr dVvuQgyHpF3bAH/Z/AKBWPq2uZOWI4XJTE/vJyT3O6Ax2t7e9Ki9PCmNaPlajKH9jxkJ K9g4w3FLSrZB6r0Hk6ZUbVN3zh2x7zp8Fq4wG/E08t+eCyPG3k1MaPF8DdH+I53E+g/y XZARKYw/mLAFZ3G0c6iZV9LuGmevTn9E8hBJfe5UOf3Ua+WQpE98qGzPxbt/EuXNijju Zu1uUxWenwDwjBLhZ18G13sTfEYSVufg5LREbesVrzAInJbzHwFrFwWDhZM9BWfoWSwS xWKA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.111.33 with SMTP id if1mr18266437pbb.31.1386557848820; Sun, 08 Dec 2013 18:57:28 -0800 (PST) |
| In-Reply-To | <CAMjeLr_PGfGv_uYbuH6Li77bFG-5FCi9GEiLevqjrfAD5SDbAA@mail.gmail.com> |
| References | <l7t00b$hp7$1@ger.gmane.org> <l7tu0b$s3o$1@ger.gmane.org> <mailman.3748.1386546562.18130.python-list@python.org> <l833rs$jik$1@dont-email.me> <mailman.3752.1386553439.18130.python-list@python.org> <52a52b98$0$2762$c3e8da3$76491128@news.astraweb.com> <CAMjeLr_PGfGv_uYbuH6Li77bFG-5FCi9GEiLevqjrfAD5SDbAA@mail.gmail.com> |
| Date | Mon, 9 Dec 2013 13:57:28 +1100 |
| Subject | Re: interactive help on the base object |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | Python List <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3755.1386557858.18130.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386557858 news.xs4all.nl 2858 [2001:888:2000:d::a6]:58046 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61349 |
Show key headers only | View raw
On Mon, Dec 9, 2013 at 1:41 PM, Mark Janssen <dreamingforward@gmail.com> wrote:
>>> What methods, if any does it provide? Are they all abstract? etc???
>>
>> Pretty much nothing useful :-)
>>
>> py> dir(object)
>> [...]
>>
>
> So (prodding the student), Why does everything inherit from Object if
> it provides no functionality?
>
> Practicality-beats-purity-yours?
Nothing useful to call directly. An int has some useful methods in Python:
>>> (258).to_bytes(2,"little")
b'\x02\x01'
So does a list:
>>> [1,4,1,5,9].count(1)
2
But there's nothing you'd normally want to call from object itself
(except maybe __repr__). There *are*, however, important pieces of
default functionality. Steven mentioned __eq__, and there's also its
pair __hash__. The default system works because the root type provides
implementations of those two functions:
>>> a = object()
>>> b = object()
>>> a == b
False
>>> d = {a:"A", b:"B"}
>>> d[a]
'A'
And it's important that these sorts of things work, because otherwise
a simple Python class would look like this:
class Foo:
def __new__(self): pass
def __init__(self): pass
def __hash__(self): return id(self)
def __eq__(self, other): return self is other
# ...
This repetition is exactly what inheritance is good at solving.
Therefore putting that functionality into a base class makes sense;
and since everything MUST have these functions to be able to be used
plausibly, putting them in the lowest base class of all makes the most
sense.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: interactive help on the base object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-08 23:48 +0000
Re: interactive help on the base object Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-09 00:45 +0000
Re: interactive help on the base object Mark Janssen <dreamingforward@gmail.com> - 2013-12-08 17:09 -0800
Re: interactive help on the base object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 01:38 +0000
Re: interactive help on the base object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 01:43 +0000
Re: interactive help on the base object Steven D'Aprano <steve@pearwood.info> - 2013-12-09 02:31 +0000
Re: interactive help on the base object Mark Janssen <dreamingforward@gmail.com> - 2013-12-08 18:41 -0800
Re: interactive help on the base object rusi <rustompmody@gmail.com> - 2013-12-08 18:58 -0800
Re: interactive help on the base object Steven D'Aprano <steve@pearwood.info> - 2013-12-09 04:16 +0000
Re: interactive help on the base object rusi <rustompmody@gmail.com> - 2013-12-08 20:46 -0800
Re: interactive help on the base object rurpy@yahoo.com - 2013-12-08 21:26 -0800
Re: interactive help on the base object rusi <rustompmody@gmail.com> - 2013-12-08 22:44 -0800
Re: interactive help on the base object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 09:44 +0000
Re: interactive help on the base object Steven D'Aprano <steve@pearwood.info> - 2013-12-09 05:44 +0000
Re: interactive help on the base object Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2013-12-09 02:31 -0500
Re: interactive help on the base object Chris Angelico <rosuav@gmail.com> - 2013-12-09 18:39 +1100
Re: interactive help on the base object Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2013-12-10 00:34 -0500
Re: interactive help on the base object Chris Angelico <rosuav@gmail.com> - 2013-12-10 16:44 +1100
Re: interactive help on the base object Chris Angelico <rosuav@gmail.com> - 2013-12-09 13:57 +1100
Re: interactive help on the base object Terry Reedy <tjreedy@udel.edu> - 2013-12-09 00:00 -0500
Re: interactive help on the base object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 23:48 +0000
Re: interactive help on the base object Steven D'Aprano <steve@pearwood.info> - 2013-12-09 01:58 +0000
csiph-web