On Mar 29, 8:43 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, Dag wrote:
> > I have a problem which is probaly very simple to solve, but I can't
> > find a nice solution.
> > I have the following code
>
> > class Test:
> >     def __init__(self):
> >         self.a=[1,2,3,4]
> >         self.b=self.a
>
>           self.b = list(self.a)
>
> BTW this is about instance variable, not class variables.
>
> Ciao,
>         Marc 'BlackJack' Rintsch

One of the many ways to do this:

class Test:
    def __init__(self):
        self.a=[1,2,3,4]
        #self.b=self.a
    def swap(self):
        self.a[0],self.a[3]=self.a[3],self.a[0]
        return self.a
    def prnt(self):
        print self.a
        x = self.swap()
        print x

c=Test()
c.prnt()


Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to