On Tue, 09 Jan 2018 16:14:27 +0200, Frank Millman wrote:
> Maybe I was not clear. The Context instance is passed as an argument to
> many methods. The methods can access the attributes of the instance. The
> instance has no methods of its own.
Ah, I see, I misunderstood.
[...]
>> Alternatively,
On 01/09/2018 07:30 AM, Steven D'Aprano wrote:
> If you have a class with only data, and you access the attributes via the
> instance's __dict__, why not use an ordinary dict?
Or even subclass dict.
class MyClass(dict):
VAR = 5
m = MyClass()
m['newvar'] = "Something"
I do this and wrap thing
"Steven D'Aprano" wrote in message news:p32g4v$v88$2...@blaine.gmane.org...
On Tue, 09 Jan 2018 11:28:03 +0200, Frank Millman wrote:
> I have a class call Context containing only data, not methods. Instances
> are passed around a lot in my application, with various methods
> accessing various
On Tue, 09 Jan 2018 11:28:03 +0200, Frank Millman wrote:
> I have a class call Context containing only data, not methods. Instances
> are passed around a lot in my application, with various methods
> accessing various attributes.
That contradicts itself... your Context class has data, but no meth
"Frank Millman" wrote in message news:p321rb$9ct$1...@blaine.gmane.org...
"Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org...
Frank Millman wrote:
> Hi all
>
> I have read that one should not call dunder methods in application code.
>
"Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org...
Frank Millman wrote:
> Hi all
>
> I have read that one should not call dunder methods in application code.
>
> Does the same apply to dunder variables? I am thinking of the instance
> attr
ame as the operation you
probably want. For example, `x + y` may not be the same as `x.__add__(y)`
or `y.__radd__(x)`. Better to use `operator.add(x, y)` instead.
> Does the same apply to dunder variables? I am thinking of the instance
> attribute __dict__, which allows access to the conte
Frank Millman wrote:
> Hi all
>
> I have read that one should not call dunder methods in application code.
>
> Does the same apply to dunder variables? I am thinking of the instance
> attribute __dict__, which allows access to the contents of the instance.
>
> I only wa
Hi all
I have read that one should not call dunder methods in application code.
Does the same apply to dunder variables? I am thinking of the instance
attribute __dict__, which allows access to the contents of the instance.
I only want to read from __dict__, not update it. Is this frowned