On 12/06/11 10:47:01, Steven D'Aprano wrote:
On Sat, 11 Jun 2011 21:28:40 -0500, Andrew Berg wrote:
On 2011.06.11 09:13 PM, Steven D'Aprano wrote:
A second, more subtle risk: not all objects have a __dict__. But if you
obey the rule about never updating from arbitrary objects you don't
know,
On 06/11/2011 08:32 PM, Andrew Berg wrote:
I'm pretty happy that I can copy variables and their value from one
object's namespace to another object's namespace with the same variable
names automatically:
b.__dict__.update(a.__dict__)
The reason I'm posting this is to ask what to watch out for w
On Sat, 11 Jun 2011 21:28:40 -0500, Andrew Berg wrote:
> On 2011.06.11 09:13 PM, Steven D'Aprano wrote:
>> A second, more subtle risk: not all objects have a __dict__. But if you
>> obey the rule about never updating from arbitrary objects you don't
>> know, then you won't be surprised by an obje
On Sat, Jun 11, 2011 at 10:32 PM, Andrew Berg wrote:
> On 2011.06.11 10:40 PM, Ben Finney wrote:
>> It's exactly the same as with an ordinary assignment (‘a = b’) in
>> Python.
> Fair enough.
>> > How would I make actual copies?
>> At what level?
> Level? I just want to be able to create an object
On 2011.06.11 10:40 PM, Ben Finney wrote:
> It's exactly the same as with an ordinary assignment (‘a = b’) in
> Python.
Fair enough.
> > How would I make actual copies?
> At what level?
Level? I just want to be able to create an object b with values from
dictionary a, and not have changes to a refl
Andrew Berg writes:
> On 2011.06.11 10:08 PM, Ian Kelly wrote:
> > For immutable objects such as ints, this doesn't matter. For mutable
> > objects such as lists, it can:
> Well, that's confusing.
It's exactly the same as with an ordinary assignment (‘a = b’) in
Python. You will likely want to w
On 2011.06.11 10:08 PM, Ian Kelly wrote:
> For immutable objects such as
> ints, this doesn't matter. For mutable objects such as lists, it can:
Well, that's confusing. How would I make actual copies?
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Jun 11, 2011 at 8:21 PM, Andrew Berg wrote:
> On 2011.06.11 09:12 PM, Terry Reedy wrote:
>> On 6/11/2011 9:32 PM, Andrew Berg wrote:
>> > I'm pretty happy that I can copy variables and their value from one
>>
>> You are copying names and their associations, but not the objects or
>> thier
On 2011.06.11 09:13 PM, Steven D'Aprano wrote:
> So never update from a random object you don't know well.
Of course. In the project I'm working on, this will be used in the
__init__() method of a class that accepts a pair of dictionaries or
possibly **kwargs (for flexibility and to avoid the very
On 2011.06.11 09:12 PM, Terry Reedy wrote:
> On 6/11/2011 9:32 PM, Andrew Berg wrote:
> > I'm pretty happy that I can copy variables and their value from one
>
> You are copying names and their associations, but not the objects or
> thier values.
Associations? The update() method copies the values
On Sat, 11 Jun 2011 20:32:37 -0500, Andrew Berg wrote:
> I'm pretty happy that I can copy variables and their value from one
> object's namespace to another object's namespace with the same variable
> names automatically:
>
> class simpleObject():
> pass
>
> a = simpleObject()
> b = simpleOb
On 6/11/2011 9:32 PM, Andrew Berg wrote:
I'm pretty happy that I can copy variables and their value from one
You are copying names and their associations, but not the objects or
thier values.
object's namespace to another object's namespace with the same variable
names automatically:
class
I'm pretty happy that I can copy variables and their value from one
object's namespace to another object's namespace with the same variable
names automatically:
class simpleObject():
pass
a = simpleObject()
b = simpleObject()
a.val1 = 1
a.val2 = 2
b.__dict__.update(a.__dict__)
a.val1 = 'a'
13 matches
Mail list logo