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


Groups > comp.lang.python > #97363

Re: Instance method for converting int to str - str() and __str__()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'subject:()': 0.09; 'subject:method': 0.09; 'url:releases': 0.09; 'python.': 0.11; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'equivalents': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'str()': 0.16; 'laura': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'seems': 0.23; 'passing': 0.23; 'implemented': 0.24; 'url:download': 0.24; 'wondering': 0.25; 'fri,': 0.27; '-0700,': 0.29; 'helpful.': 0.29; 'methods.': 0.29; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'classes': 0.30; 'that.': 0.30; 'url:mailman': 0.30; 'certain': 0.31; 'url:python': 0.33; 'url:listinfo': 0.34; 'skip:> 10': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; "wasn't": 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'why': 0.39; 'rather': 0.39; 'resources': 0.39; 'url:mail': 0.40; 'some': 0.40; 'header :Message-Id:1': 0.61; 'more': 0.63; 'different': 0.63; 'information': 0.63; 'here:': 0.63; 'header:In-reply-to:1': 0.84; 'popular.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=openend.se; s=default; t=1443861083; bh=GUlqJwrMJhmdeI6l0eaIczpbCMtXYLm14BYE6m1U0NA=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=2VV4W0eDiIPWQT2A+jnZdAbHH8UKP+tyRo0hkGiT/dCdKoZe/DbCgeTkkx+YD46yC 4a08cqaz85Y8XI+Mk9jbbbFvtlrnHnwEsdP2ZQ/ZZ/rwfZeynhA0fLX3X39auD/Us9 UCbFydtamIT9Y/GHUmpg9tZbfxv+lYyT8jdA44HA=
To neubyr <neubyr@gmail.com>
cc python-list@python.org, lac@openend.se
From Laura Creighton <lac@openend.se>
Subject Re: Instance method for converting int to str - str() and __str__()
In-reply-to <CALFxCvyGUC+Sz+d23hNAv6HnFeZKEFdAexZFC9Uj3T3vHyYLtQ@mail.gmail.com>
References <CALFxCvyGUC+Sz+d23hNAv6HnFeZKEFdAexZFC9Uj3T3vHyYLtQ@mail.gmail.com>
Comments In-reply-to neubyr <neubyr@gmail.com> message dated "Fri, 02 Oct 2015 23:35:28 -0700."
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-ID <32126.1443861081.1@fido>
Date Sat, 03 Oct 2015 10:31:21 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Sat, 03 Oct 2015 10:31:23 +0200 (CEST)
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>
Newsgroups comp.lang.python
Message-ID <mailman.357.1443861094.28679.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1443861094 news.xs4all.nl 23825 [2001:888:2000:d::a6]:43151
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97363

Show key headers only | View raw


In a message of Fri, 02 Oct 2015 23:35:28 -0700, neubyr writes:
>I was wondering if there is any resource that explains why certain methods
>like str() and type() were implemented the way they are, rather than
>.to_string() or .type() instance/object methods.
>
>I find instance/object methods more intuitive for this cases, but I am
>wondering why it wasn't implemented it like that.
>
>I know there are equivalents like  __str__() and __class__ , but passing
>object to str() or type() seems more popular.
>
>Any resources for reading or some background information would be helpful.
>
>- CS
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list
>

start reading here:
https://www.python.org/download/releases/2.2/descrintro/
and keep searching and reading about type-class unification in Python.

The answer is, because types and classes used to be very different
things, and you _couldn't_.

Laura

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


Thread

Re: Instance method for converting int to str - str() and __str__() Laura Creighton <lac@openend.se> - 2015-10-03 10:31 +0200

csiph-web