Question about references/copies

Anthony Baxter anthonybaxter at gmail.com
Sat Aug 28 04:11:46 EDT 2004


On Sat, 28 Aug 2004 09:52:36 +0200, Henning Kage <c0dec at gmx.de> wrote:
> I'm using Python only for some months now and I'm wondering, whether such
> assignments as above are creating bitwise copies of an object or just
> recieve a reference. That means I wanted to know, wheter Python in general
> differs between references and copies:

It's all references. If you want a copy, use the copy module.

> class someclass:
>   def __init__( self, otherobject):
>     self.someattribute = otherobject
> 
> And my second question is, whether I should use a cast in such cases or
> not (I know, a cast isn't mandatory here...)

A cast? Python has no static typing, so I'm unsure how or why you'd do a cast.



More information about the Python-list mailing list