Hi all,
This interested me:
[color=blue][color=green][color=darkred]
>>> a1 = a2 = {}
>>> a1['blah'] = 1
>>> a2[/color][/color][/color]
{'blah': 1}[color=blue][color=green][color=darkred]
>>> a1 == a2[/color][/color][/color]
True
Whereas ...
[color=blue][color=green][color=darkred]
>>> b1 = b2 = 0
>>> b1 += 1
>>> b2[/color][/color][/color]
0[color=blue][color=green][color=darkred]
>>> b1 == b2[/color][/color][/color]
False
So how should one create a robust alias for a numeric type?
This bit me when I was trying to do the following in a class:
def __init__(self, data):
a = self.a = {}
b = self.b = {}
c = self.c = 0
# and increment them here ...
Best regards,
Ed Schofield
This interested me:
[color=blue][color=green][color=darkred]
>>> a1 = a2 = {}
>>> a1['blah'] = 1
>>> a2[/color][/color][/color]
{'blah': 1}[color=blue][color=green][color=darkred]
>>> a1 == a2[/color][/color][/color]
True
Whereas ...
[color=blue][color=green][color=darkred]
>>> b1 = b2 = 0
>>> b1 += 1
>>> b2[/color][/color][/color]
0[color=blue][color=green][color=darkred]
>>> b1 == b2[/color][/color][/color]
False
So how should one create a robust alias for a numeric type?
This bit me when I was trying to do the following in a class:
def __init__(self, data):
a = self.a = {}
b = self.b = {}
c = self.c = 0
# and increment them here ...
Best regards,
Ed Schofield
Comment