Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111665
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: can't add variables to instances of built-in classes |
| Date | Wed, 20 Jul 2016 09:26:08 +0200 |
| Organization | None |
| Lines | 65 |
| Message-ID | <mailman.3.1468999586.22221.python-list@python.org> (permalink) |
| References | <4f796d95-0e87-4610-a0a8-1eff07c60ace@googlegroups.com> <nmfqrg$ea7$1@ger.gmane.org> <mailman.63.1468755660.2307.python-list@python.org> <b24bede0-be29-4c45-856e-90e6a63c99d0@googlegroups.com> <578b9e62$0$22141$c3e8da3$5496439d@news.astraweb.com> <3e934f83-2076-407d-b85b-686ecdec6ff8@googlegroups.com> <nmi127$r0e$1@ger.gmane.org> <mailman.70.1468827536.2307.python-list@python.org> <2bc29306-ac90-4424-84c2-64be494c5a75@googlegroups.com> <bff64f31-d618-4d47-a81b-aa817db8c456@googlegroups.com> <230d1aff-b1a3-4f16-b9a6-b5d9fd07e4b4@googlegroups.com> <62dd86d4-74f7-4e97-a29c-7e45aced77d9@googlegroups.com> <f988e9a1-beba-41f3-bd11-8ed4c7a69a81@googlegroups.com> <CAPTjJmrup=D9pP5buOytY7x1zQYC6Nh-R=WkaXcJBAfbD+_JJA@mail.gmail.com> <mailman.1.1468995572.22221.python-list@python.org> <cadcdba3-61a0-4803-afc5-894d8de4f0cc@googlegroups.com> <nmn92l$4jh$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | news.uni-berlin.de 2Kb2ZDHow/H8JVQ9v2cdGg3c0TERJuXUf+oU/Klh2/Rw== |
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'context': 0.05; 'fixes': 0.05; 'imply': 0.07; 'wednesday,': 0.07; '__init__': 0.09; 'grep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tuple': 0.09; 'url:github': 0.09; 'def': 0.13; 'wed,': 0.15; '2016': 0.16; '__slots__': 0.16; 'accidental': 0.16; 'exactly?': 0.16; 'how,': 0.16; 'integer.': 0.16; 'properties,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'traceback.': 0.16; 'tuple,': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'debugging': 0.18; 'detect': 0.18; '>>>': 0.20; 'settings': 0.20; 'candidates': 0.21; 'work,': 0.21; 'lawrence': 0.22; 'trying': 0.22; 'am,': 0.23; 'defined': 0.23; 'all.': 0.24; 'sort': 0.25; 'wondering': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'appear': 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'chris': 0.26; 'error': 0.27; 'cat': 0.29; 'that.': 0.30; "we're": 0.30; 'programmers': 0.30; "i'd": 0.31; 'fixed': 0.31; 'skip:_ 10': 0.32; 'class': 0.33; 'problem': 0.33; 'controls': 0.33; "i'll": 0.33; 'something': 0.35; 'problem.': 0.35; 'but': 0.36; 'instead': 0.36; 'lines': 0.36; 'monday,': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'say': 0.37; 'received:org': 0.37; 'thank': 0.38; 'why': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'called': 0.40; 'future': 0.60; 'email addr:gmail.com': 0.62; 'complete': 0.63; 'you.': 0.64; '20,': 0.66; '>>>>>': 0.66; 'skip:\xe2 10': 0.70; 'jul': 0.72; '8bit%:46': 0.76; 'sounds': 0.76; 'cult': 0.84; 'wasn\xe2\x80\x99t': 0.84; 'subject:add': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | p57bd86d9.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <nmn92l$4jh$1@ger.gmane.org> |
| X-Mailman-Original-References | <4f796d95-0e87-4610-a0a8-1eff07c60ace@googlegroups.com> <nmfqrg$ea7$1@ger.gmane.org> <mailman.63.1468755660.2307.python-list@python.org> <b24bede0-be29-4c45-856e-90e6a63c99d0@googlegroups.com> <578b9e62$0$22141$c3e8da3$5496439d@news.astraweb.com> <3e934f83-2076-407d-b85b-686ecdec6ff8@googlegroups.com> <nmi127$r0e$1@ger.gmane.org> <mailman.70.1468827536.2307.python-list@python.org> <2bc29306-ac90-4424-84c2-64be494c5a75@googlegroups.com> <bff64f31-d618-4d47-a81b-aa817db8c456@googlegroups.com> <230d1aff-b1a3-4f16-b9a6-b5d9fd07e4b4@googlegroups.com> <62dd86d4-74f7-4e97-a29c-7e45aced77d9@googlegroups.com> <f988e9a1-beba-41f3-bd11-8ed4c7a69a81@googlegroups.com> <CAPTjJmrup=D9pP5buOytY7x1zQYC6Nh-R=WkaXcJBAfbD+_JJA@mail.gmail.com> <mailman.1.1468995572.22221.python-list@python.org> <cadcdba3-61a0-4803-afc5-894d8de4f0cc@googlegroups.com> |
| Xref | csiph.com comp.lang.python:111665 |
Show key headers only | View raw
Lawrence D’Oliveiro wrote:
> On Wednesday, July 20, 2016 at 6:19:45 PM UTC+12, Chris Angelico wrote:
>>
>> On Wed, Jul 20, 2016 at 9:58 AM, Lawrence D’Oliveiro wrote:
>>>
>>> On Wednesday, July 20, 2016 at 9:24:57 AM UTC+12, bream...@gmail.com
>>> wrote:
>>>>
>>>> On Tuesday, July 19, 2016 at 3:54:12 AM UTC+1, Lawrence D’Oliveiro
>>>> wrote:
>>>>>
>>>>> On Tuesday, July 19, 2016 at 11:12:52 AM UTC+12, bream...@gmail.com
>>>>> wrote:
>>>>>>
>>>>>> On Monday, July 18, 2016 at 10:48:15 PM UTC+1, Lawrence D’Oliveiro
>>>>>> wrote:
>>>>>>>
>>>>>>> <https://github.com/ldo/qahirah>
>>>>>>> When you have lots of read/write properties, I find __slots__ to be
>>>>>>> a good idea.
>>>>>>
>>>>>> Please explain why, thank you.
>>>>>
>>>>> I was trying something like
>>>>>
>>>>> ctx.dashes = ((0.1, 0.03, 0.03, 0.03), 0)
>>>>>
>>>>> and wondering why it wasn’t working...
>>>>
>>>> This makes no sense to me at all. You appear to be trying to create a
>>>> tuple, which contains a tuple and an integer. You then say it doesn't
>>>> work, but imply that using __slots__ fixes the problem. So please
>>>> explain exactly what you were trying to achieve, the exact error you
>>>> got, with the complete traceback, and how using __slots__ fixed the
>>>> problem.
>>>
>>> No traceback. The lines were simply coming out solid, instead of dashed.
>>
>> And __slots__ fixed the problem how, exactly?
>
> The Context attribute that controls the dash settings is called “dash”,
> not “dashes”.
>
>> This sounds like the sort of cargo cult debugging that I'd expect of PHP
>> programmers ("I put addslashes around everything and now it works, so in
>> future I'll use addslashes everywhere"), but around here, we're better
>> than that.
>
> OK, boss.
pylint can detect candidates for accidental attribute creation:
$ cat attrib.py
class Context:
def __init__(self):
self.dashes = None
ctx = Context()
ctx.dasehs = ("foo", "bar")
$ pylint attrib | grep dasehs
W: 6, 4: Attribute 'dasehs' defined outside __init__ (attribute-defined-
outside-init)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
can't add variables to instances of built-in classes Kent Tong <kent.tong.mo@gmail.com> - 2016-07-17 03:57 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-17 13:40 +0200
Re: can't add variables to instances of built-in classes Wilson Ong <wilsonokw@gmail.com> - 2016-07-17 04:50 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-17 22:02 +1000
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-18 01:04 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-17 20:00 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-18 09:38 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-18 14:48 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-18 16:12 -0700
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-18 19:53 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-19 14:24 -0700
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-19 16:58 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-20 16:19 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-19 23:45 -0700
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-20 17:22 +1000
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-20 09:26 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 01:50 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-20 11:15 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 15:11 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-21 12:29 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-03 19:34 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-08-04 13:00 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-04 16:57 -0700
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-21 12:48 +1000
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-20 22:10 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 14:48 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-20 18:04 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-21 08:59 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 02:10 -0700
Re: can't add variables to instances of built-in classes Ethan Furman <ethan@stoneleaf.us> - 2016-07-18 06:10 -0700
Re: can't add variables to instances of built-in classes Kent Tong <kent.tong.mo@gmail.com> - 2016-07-17 04:53 -0700
csiph-web