Re: Re: Django Python roop
On Wed, Jun 11, 2014 at 8:12 AM, moqianc...@gmail.comwrote: > write right code, write clean code, It's a basic rule for our develope > work. for that you have to learn what the code means. "while x !=[]:" will always be an endless loop. the "[]" doesn't do what you think. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFkDaoR%2B4Ho8EBOJXs1eyn0NrrJGhfBa%2Bke7RSMT4Q4dut_LOw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
Ok, thank you! 2014年6月11日水曜日 21時52分54秒 UTC+9 Qiancong: > > > Hi, hito koto: > I think the problems you asked should be post in python-lang mail-list. > For python program, I prefer "for", not "while"; It's more simpler. > But if you like while, I think the following code maybe helpful: > > *def fff(x):* > *y = []* > *i = 0* > *xlen = len(x)* > *while i< xlen:* > *y.append(x[i])* > *i += 1* > *return y* > > but I more like the follow writing: > *def fff(x):* > *return x[:]* > > or you just do as following: > *y = x[:]* > > python is a power & beautiful language, > please read the https://docs.python.org/2/tutorial/ at first like > François said. > > With Regards. > > -- > moqia...@gmail.com > > *From:* hito koto > *Date:* 2014-06-11 19:21 > *To:* django-users > *Subject:* Django Python roop > Hello, all > > I want to change to while statement from for statement, so how can i do > to? > > this is my correct for statement codes: > > def fff(x): > y = [] > for i in range(len(x)): > y.append(x[i]) > return y > > and i want change to while statement > > So, this code have erroes: > TypeError: list indices must be integers, not list > def fff(x): > y = [] > while x !=[]: >for i in x: >y.append(x[i]) > return y > > -- > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ce0d9d2a-4b22-4126-8802-b085daa3bcec%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
Den 11/06/2014 kl. 14.49 skrev hito koto: > MemoryError , Why? idon't know. > I try this have Traceback (most recent call last): > File "", line 1, in > File "", line 5, in foo > MemoryError errors: > > I'm change to this code: have the Memory Error, > > def foo(x): > y = [] > while x != []: > for i in range(len(x)): > y.append(x[i]) > return y Your function doesn't modify "x", so "x != []" is always true. You created an endless loop which appends "y" until memory is exhausted. Hence the MemoryError. These aren't Django-specific questions anymore, so you should head over to a Python mailing list to get further help with basic Python programming. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CC989AD0-05AB-4DF5-972E-8B0347009F8B%40cederstrand.dk. For more options, visit https://groups.google.com/d/optout.
Re: Re: Django Python roop
Sometimes, I have to use while statement too. But any time, I think write right code, write clean code, It's a basic rule for our develope work. moqianc...@gmail.com From: hito koto Date: 2014-06-11 21:05 To: django-users Subject: Re: Django Python roop Hi, qiancong: Thank you, Do you not use the while statement to Django? 2014年6月11日水曜日 21時52分54秒 UTC+9 Qiancong: Hi, hito koto: I think the problems you asked should be post in python-lang mail-list. For python program, I prefer "for", not "while"; It's more simpler. But if you like while, I think the following code maybe helpful: def fff(x): y = [] i = 0 xlen = len(x) while i< xlen: y.append(x[i]) i += 1 return y but I more like the follow writing: def fff(x): return x[:] or you just do as following: y = x[:] python is a power & beautiful language, please read the https://docs.python.org/2/tutorial/ at first like François said. With Regards. moqia...@gmail.com From: hito koto Date: 2014-06-11 19:21 To: django-users Subject: Django Python roop Hello, all I want to change to while statement from for statement, so how can i do to? this is my correct for statement codes: def fff(x): y = [] for i in range(len(x)): y.append(x[i]) return y and i want change to while statement So, this code have erroes: TypeError: list indices must be integers, not list def fff(x): y = [] while x !=[]: for i in x: y.append(x[i]) return y -- -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8afde78f-9910-4d26-b1e6-e5f1eaaca63b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2014061121121170324647%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Re: Django Python roop
In your function, if x is not a empty list, then while will be a infinite loop, x always not be []; then the inner for-loop will append many many items into y list, Then your computer will say "have the Memory Error", to tell you the memory not enought. moqianc...@gmail.com From: hito koto Date: 2014-06-11 20:49 To: django-users Subject: Re: Django Python roop MemoryError , Why? idon't know. I try this have Traceback (most recent call last): File "", line 1, in File "", line 5, in foo MemoryError errors: I'm change to this code: have the Memory Error, def foo(x): y = [] while x != []: for i in range(len(x)): y.append(x[i]) return y 2014年6月11日水曜日 20時21分42秒 UTC+9 hito koto: Hello, all I want to change to while statement from for statement, so how can i do to? this is my correct for statement codes: def fff(x): y = [] for i in range(len(x)): y.append(x[i]) return y and i want change to while statement So, this code have erroes: TypeError: list indices must be integers, not list def fff(x): y = [] while x !=[]: for i in x: y.append(x[i]) return y -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cae941c1-3af8-4ba7-9a1c-2d1232dbed9b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2014061121074166965044%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
Hi, qiancong: Thank you, Do you not use the while statement to Django? 2014年6月11日水曜日 21時52分54秒 UTC+9 Qiancong: > > > Hi, hito koto: > I think the problems you asked should be post in python-lang mail-list. > For python program, I prefer "for", not "while"; It's more simpler. > But if you like while, I think the following code maybe helpful: > > *def fff(x):* > *y = []* > *i = 0* > *xlen = len(x)* > *while i< xlen:* > *y.append(x[i])* > *i += 1* > *return y* > > but I more like the follow writing: > *def fff(x):* > *return x[:]* > > or you just do as following: > *y = x[:]* > > python is a power & beautiful language, > please read the https://docs.python.org/2/tutorial/ at first like > François said. > > With Regards. > > -- > moqia...@gmail.com > > *From:* hito koto > *Date:* 2014-06-11 19:21 > *To:* django-users > *Subject:* Django Python roop > Hello, all > > I want to change to while statement from for statement, so how can i do > to? > > this is my correct for statement codes: > > def fff(x): > y = [] > for i in range(len(x)): > y.append(x[i]) > return y > > and i want change to while statement > > So, this code have erroes: > TypeError: list indices must be integers, not list > def fff(x): > y = [] > while x !=[]: >for i in x: >y.append(x[i]) > return y > > -- > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8afde78f-9910-4d26-b1e6-e5f1eaaca63b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
hi, Ilya Kazakevich: I would like to change the while statement from the for statement 2014年6月11日水曜日 21時49分32秒 UTC+9 hito koto: > > MemoryError , Why? idon't know. > I try this have Traceback (most recent call last): > File "", line 1, in > File "", line 5, in foo > MemoryError errors: > > I'm change to this code: have the Memory Error, > > def foo(x): > y = [] > while x != []: > for i in range(len(x)): > y.append(x[i]) > return y > > > > 2014年6月11日水曜日 20時21分42秒 UTC+9 hito koto: >> >> Hello, all >> >> I want to change to while statement from for statement, so how can i do >> to? >> >> this is my correct for statement codes: >> >> def fff(x): >> y = [] >> for i in range(len(x)): >> y.append(x[i]) >> return y >> >> and i want change to while statement >> >> So, this code have erroes: >> TypeError: list indices must be integers, not list >> def fff(x): >> y = [] >> while x !=[]: >>for i in x: >>y.append(x[i]) >> return y >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c80b24ff-aae8-4554-bcc9-056c36b2cf4d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
Hi, hito koto: I think the problems you asked should be post in python-lang mail-list. For python program, I prefer "for", not "while"; It's more simpler. But if you like while, I think the following code maybe helpful: def fff(x): y = [] i = 0 xlen = len(x) while i< xlen: y.append(x[i]) i += 1 return y but I more like the follow writing: def fff(x): return x[:] or you just do as following: y = x[:] python is a power & beautiful language, please read the https://docs.python.org/2/tutorial/ at first like François said. With Regards. moqianc...@gmail.com From: hito koto Date: 2014-06-11 19:21 To: django-users Subject: Django Python roop Hello, all I want to change to while statement from for statement, so how can i do to? this is my correct for statement codes: def fff(x): y = [] for i in range(len(x)): y.append(x[i]) return y and i want change to while statement So, this code have erroes: TypeError: list indices must be integers, not list def fff(x): y = [] while x !=[]: for i in x: y.append(x[i]) return y -- -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2014061120521739307138%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Python roop
MemoryError , Why? idon't know. I try this have Traceback (most recent call last): File "", line 1, in File "", line 5, in foo MemoryError errors: I'm change to this code: have the Memory Error, def foo(x): y = [] while x != []: for i in range(len(x)): y.append(x[i]) return y 2014年6月11日水曜日 20時21分42秒 UTC+9 hito koto: > > Hello, all > > I want to change to while statement from for statement, so how can i do > to? > > this is my correct for statement codes: > > def fff(x): > y = [] > for i in range(len(x)): > y.append(x[i]) > return y > > and i want change to while statement > > So, this code have erroes: > TypeError: list indices must be integers, not list > def fff(x): > y = [] > while x !=[]: >for i in x: >y.append(x[i]) > return y > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cae941c1-3af8-4ba7-9a1c-2d1232dbed9b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
RE: Django Python roop
Hello, What are you trying to do? Split string? Copy array? You probably need to use builtin functions for that. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googlegroups.com] On Behalf Of hito koto >Sent: Wednesday, June 11, 2014 3:22 PM >To: django-users@googlegroups.com >Subject: Django Python roop > >Hello, all > >I want to change to while statement from for statement, so how can i do to? > >this is my correct for statement codes: > >def fff(x): >y = [] >for i in range(len(x)): >y.append(x[i]) >return y > >and i want change to while statement > >So, this code have erroes: >TypeError: list indices must be integers, not list def fff(x): >y = [] >while x !=[]: > for i in x: > y.append(x[i]) >return y > > >-- >You received this message because you are subscribed to the Google Groups >"Django users" group. >To unsubscribe from this group and stop receiving emails from it, send an email >to django-users+unsubscr...@googlegroups.com. >To post to this group, send email to django-users@googlegroups.com. >Visit this group at http://groups.google.com/group/django-users. >To view this discussion on the web visit >https://groups.google.com/d/msgid/django-users/1f5ae7ed-6fa2-4cf0-8ba7-d59 >088ba1cf5%40googlegroups.com ><https://groups.google.com/d/msgid/django-users/1f5ae7ed-6fa2-4cf0-8ba7-d5 >9088ba1cf5%40googlegroups.com?utm_medium=email_source=footer> . >For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/007601cf8573%244aa27dd0%24dfe77970%24%40JetBrains.com. For more options, visit https://groups.google.com/d/optout.
Django Python roop
Hello, all I want to change to while statement from for statement, so how can i do to? this is my correct for statement codes: def fff(x): y = [] for i in range(len(x)): y.append(x[i]) return y and i want change to while statement So, this code have erroes: TypeError: list indices must be integers, not list def fff(x): y = [] while x !=[]: for i in x: y.append(x[i]) return y -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1f5ae7ed-6fa2-4cf0-8ba7-d59088ba1cf5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.