Re: Django python fuction

2014-06-11 Thread hito koto
ic, set, tuple , etc .. > > moqia...@gmail.com > > > > From: François Schiettecatte > > Date: 2014-06-10 22:07 > > To: django-users > > Subject: Re: Django python fuction > > You need to use .append() to add elements to a list, I suggest

Re: Re: Django python fuction

2014-06-11 Thread hito koto
y does for list. > > -- > moqia...@gmail.com > > *From:* François Schiettecatte > *Date:* 2014-06-11 00:21 > *To:* django-users > *Subject:* Re: Django python fuction > Wouldn't the deep copy module handle this for you: > > https://docs.python.org/2/library/copy.htm

Re: Re: Django python fuction

2014-06-10 Thread moqianc...@gmail.com
Subject: Re: Django python fuction Wouldn't the deep copy module handle this for you: https://docs.python.org/2/library/copy.html François On Jun 10, 2014, at 12:17 PM, hito koto <hitokoto2...@gmail.com> wrote: > Hi, Qiancong : > > I was looking for exactly this、 > Thank you ver m

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
function only deep copy for list. You can change code as what I did > for dic, set, tuple , etc .. > moqia...@gmail.com > > From: François Schiettecatte > Date: 2014-06-10 22:07 > To: django-users > Subject: Re: Django python fuction > You need to use .append() to add elemen

Re: Re: Django python fuction

2014-06-10 Thread hito koto
014-06-10 22:07 > *To:* django-users > *Subject:* Re: Django python fuction > You need to use .append() to add elements to a list, I suggest you take > a look at the python tutorial: > > https://docs.python.org/2/tutorial/ > > Not quite sure what you are doing with i or e

Re: Re: Django python fuction

2014-06-10 Thread moqianc...@gmail.com
, etc .. moqianc...@gmail.com From: François Schiettecatte Date: 2014-06-10 22:07 To: django-users Subject: Re: Django python fuction You need to use .append() to add elements to a list, I suggest you take a look at the python tutorial: https://docs.python.org/2/tutorial/ Not quite sure what you

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
You need to use .append() to add elements to a list, I suggest you take a look at the python tutorial: https://docs.python.org/2/tutorial/ Not quite sure what you are doing with i or elem either. François On Jun 10, 2014, at 10:01 AM, hito koto wrote: > So, I

Re: Django python fuction

2014-06-10 Thread hito koto
So, I also have errors: >>> def foo(x): ... myList = [] ... if isinstance(x, list): ... for i in x: ... elem = i ... return myList + foo(elem) ... else: ... return 1 ... >>> >>> foo(a) Traceback (most

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
You are redefining 'list' on line 2, rename list to myList as follows: def foo(x): myList = [] if isinstance(x, list): for i in x: elem = i return myList + foo(i) else: return 1 And take this to a

Re: Django python fuction

2014-06-10 Thread hito koto
hi, I have this erroes: >>> def foo(x): ... list = [] ... if isinstance(x, list): ... for i in x: ... elem = i ... return list + foo(i) ... else: ... return 1 ... >>> foo(a) Traceback (most recent call last): File "", line 1, in File "",

Re: Django python fuction

2014-06-10 Thread Andrew Farrell
In general, I recommend adding the line "import pdb;pdb.set_trace()" to the top of your function and walking through it to see why it doesn't work. def foo(x): import pdb;pdb.set_trace() list = [] if isinstance(x, list): for i in x: elem = i return

Django python fuction

2014-06-10 Thread hito koto
Hello, I don't know how can i do to change to write python function I want to following code change to write python function or change to write recursive definition >>> y = [10, 12, [13, [14, 9], 16], 7] >>> z = copy.deepcopy(y) >>> y [10, 12, [13, [14, 9], 16], 7] >>> z [10, 12, [13, [14, 9],