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


Groups > comp.lang.python > #81709

Re: Can you use self in __str__

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <i@introo.me>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.146
X-Spam-Level *
X-Spam-Evidence '*H*': 0.71; '*S*': 0.00; 'cpython': 0.05; 'namespace': 0.09; 'cc:addr:python-list': 0.11; 'all?': 0.16; 'enough.': 0.16; 'readability': 0.16; 'wrote:': 0.18; 'dependent': 0.19; 'first.': 0.19; 'cc:addr:python.org': 0.22; 'specify': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'fri,': 0.33; 'received:74.125.82': 0.34; 'case,': 0.35; 'form.': 0.35; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; "i'll": 0.36; 'project': 0.37; 'nov': 0.38; 'pm,': 0.38; 'received:74.125': 0.39; 'bad': 0.39; 'sure': 0.39; 'even': 0.60; 'subject:Can': 0.60; 'most': 0.60; 'first': 0.61; 'show': 0.63; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'charset:iso-2022-jp': 0.65; 'to:addr:gmail.com': 0.65; 'hand.': 0.84; 'skip:\x1b 30': 0.84; 'subject:self': 0.84; 'subject:you': 0.87
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=PUn4xvjYbNYIa0AJ2/ZfvOU7ZxqFU1TaEYVPj46zFCc=; b=PRxOXDb676C051gz1IWz0aLbjDscnkaXwmietjJTVmtEElSSStPdjxrWeBZtrXtyvp KMGDLqgs3BsDSY0ovEwxmY/Jq8LfMagMYiuXz84V+ZpPNnY1HRJ1SYAOGxwVxo5rGz7f /Ez0BvuOhv4ZYEnbv8hIa18DH4eldScvurFv6k7LGw2Zxh3m1LYLUSy1IeIN0/A0U8Ne QlA8RcakA+1UlrPzJQTJ7EiVz0wyhc7t8aC3UbyOwpOWQjjN1aelYbbcx3FnbFNKVM9i xjIiuJSvp8U2KVQuafV5XdJF2yhk3mC78G39+et5MMitpaWQNanS4l5yW2OAClPXYA6a y0jA==
X-Gm-Message-State ALoCoQlejtVZA0Q4jI9bJVq58SukNHJMdoUCDm5Z0F5PuLhHoTl05I54MVQG4d3RpGa93IGHgQi1
MIME-Version 1.0
X-Received by 10.180.90.165 with SMTP id bx5mr23647460wib.15.1417231015674; Fri, 28 Nov 2014 19:16:55 -0800 (PST)
X-Originating-IP [143.89.96.87]
In-Reply-To <CAPTjJmok2qfERwgyS7PqfFLg7tjYu9koiBHdfQN3DanZ00p1Mw@mail.gmail.com>
References <9oif7apuou9fbaqjk0i3l2pq1theuso4un@4ax.com> <CAJQX3DwmK2FedvbVMUq5Mm2yMSfD5QQWz3qqph5oj2_tzZyMvA@mail.gmail.com> <CAPTjJmok2qfERwgyS7PqfFLg7tjYu9koiBHdfQN3DanZ00p1Mw@mail.gmail.com>
Date Sat, 29 Nov 2014 11:16:55 +0800
Subject Re: Can you use self in __str__
From Shiyao Ma <i@introo.me>
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding 7bit
Cc Python <python-list@python.org>
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.16422.1417231400.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417231400 news.xs4all.nl 2874 [2001:888:2000:d::a6]:35072
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81709

Show key headers only | View raw


2014-11-28 13:00 GMT+08:00 Chris Angelico <rosuav@gmail.com>:
> On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma <i@introo.me> wrote:
>> What if it's in the local namespace of a function or method? IDK, try
>> to get that thing first.
>
Sure enough. I will even avoid using "id" as it's dependent on CPython
implementation. :)

> What if it's in multiple namespaces? What if it's not in any at all?
> Your solution is not going to work in the general case, AND it's a bad
> idea.
> Please don't do this in any code that I'll ever have to
> maintain.
No way. You will never get my project code in such a form. I am way
more peculiar about readability and robustness than most of my other
ppl.
The point is, the bpate is just for demonstration to show there is a
*possible* way to find the name even you didn't specify it at first
hand.




-- 

吾輩は猫である。ホームーページはhttp://introo.me。

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


Thread

Can you use self in __str__ Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-27 20:26 -0500
  Re: Can you use self in __str__ Dave Angel <davea@davea.name> - 2014-11-27 21:49 -0500
    Re: Can you use self in __str__ Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-27 22:31 -0500
      Re: Can you use self in __str__ Dave Angel <davea@davea.name> - 2014-11-28 04:37 -0500
  Re: Can you use self in __str__ Shiyao Ma <i@introo.me> - 2014-11-28 11:04 +0800
    Re: Can you use self in __str__ Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-27 22:35 -0500
      Re: Can you use self in __str__ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-28 18:44 +1100
  Re: Can you use self in __str__ Chris Angelico <rosuav@gmail.com> - 2014-11-28 16:00 +1100
  Re: Can you use self in __str__ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-28 19:25 +1100
  Re: Can you use self in __str__ Chris Angelico <rosuav@gmail.com> - 2014-11-28 12:43 +1100
  Re: Can you use self in __str__ Dave Angel <davea@davea.name> - 2014-11-28 06:43 -0500
  Re: Can you use self in __str__ Rustom Mody <rustompmody@gmail.com> - 2014-11-28 06:21 -0800
    Re: Can you use self in __str__ Rustom Mody <rustompmody@gmail.com> - 2014-11-28 08:37 -0800
  Re: Can you use self in __str__ Shiyao Ma <i@introo.me> - 2014-11-29 11:16 +0800
  Re: Can you use self in __str__ Chris Angelico <rosuav@gmail.com> - 2014-11-29 14:36 +1100
  Re: Can you use self in __str__ Shiyao Ma <i@introo.me> - 2014-11-29 11:55 +0800

csiph-web