can't add variables to instances of built-in classes

Chris Angelico rosuav at gmail.com
Wed Jul 20 02:19:28 EDT 2016


On Wed, Jul 20, 2016 at 9:58 AM, Lawrence D’Oliveiro
<lawrencedo99 at gmail.com> wrote:
> On Wednesday, July 20, 2016 at 9:24:57 AM UTC+12, bream... at 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... at 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? 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.

ChrisA



More information about the Python-list mailing list