Re: Python deepcopy to while statement

2014-06-12 Thread hito koto
2014年6月13日金曜日 12時47分19秒 UTC+9 hito koto: > Hi, all > > > > I want to make the function use while statement,and without a deepcopy > functions. > > > > this is my use deepcopy function correct codes, So, how can i to do a > different way and use whil

Re: Python deepcopy to while statement

2014-06-12 Thread hito koto
2014年6月13日金曜日 12時47分19秒 UTC+9 hito koto: > Hi, all > > > > I want to make the function use while statement,and without a deepcopy > functions. > > > > this is my use deepcopy function correct codes, So, how can i to do a > different way and use whil

Python deepcopy to while statement

2014-06-12 Thread hito koto
Hi, all I want to make the function use while statement,and without a deepcopy functions. this is my use deepcopy function correct codes, So, how can i to do a different way and use while statement: def foo(x): if not isinstance(x, list): return x return [foo(y) for y in x

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:57 AM, Chris Angelico wrote: def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::][::-1] if len(L)==0: done=True Why not just "while L"? OK, here it is with Chris' excellent adv

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:57 AM, Chris Angelico wrote: On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris wrote: Consider this generator variation: def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::][::-1]

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:55 AM, Marko Rauhamaa wrote: while not done: Better Python and not bad English, either. ... and taking Marko's good advice, what I think you really wanted: >>> def poplist(L): done = False while not done: yield L[::-1][:1:] L

Re: About python while statement and pop()

2014-06-12 Thread Marko Rauhamaa
> while done==False: Correction: while not done: Better Python and not bad English, either. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: About python while statement and pop()

2014-06-12 Thread Chris Angelico
On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris wrote: > Consider this generator variation: > def poplist(L): > done = False > while done==False: > > yield L[::-1][:1:] > L = L[::-1][1::][::-1] > if len(L)==0: done=True Why not j

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/11/14 10:12 PM, hito koto wrote: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y Consider this generator variation: >>> def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::]

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/11/14 10:12 PM, hito koto wrote: i want to change this is code: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y Consider this generator (all kinds of permutations on the idea): >>> L1 [1, 2, 3, 4, 5, 6, 7] >>> def poplist(L): while True:

Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > >>>> def foo(x): > > > ... y

Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > >>>> def foo(x): > > > ... y

Re: About python while statement and pop()

2014-06-11 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > >>>> def foo(x): > > > ... y

Re: About python while statement and pop()

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > I want to use while statement, > > for example: >>>> def foo(x): > ... y = [] > ... while x !=[]: > ... y.append(x.pop()) > ... return y > ... >>>> print foo(a) > [[10

Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 2:56 PM, hito koto wrote: > I want to use while statement, This sounds like homework. Go back to your teacher/tutor for assistance, rather than asking us to do the work for you; or at very least, word your question in such a way that we can help you to learn, rather t

Re: About python while statement and pop()

2014-06-11 Thread hito koto
2014年6月12日木曜日 12時58分27秒 UTC+9 Chris Angelico: > On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre > > wrote: > > > Le 12/06/2014 05:12, hito koto a écrit : > > > > > >> Hello,all > > >> I'm first time, > > >> >

Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre wrote: > Le 12/06/2014 05:12, hito koto a écrit : > >> Hello,all >> I'm first time, >> >> I want to make a while statement which can function the same x.pop () and >> without the use of pop、how can i t

Re: About python while statement and pop()

2014-06-11 Thread Vincent Vande Vyvre
Le 12/06/2014 05:12, hito koto a écrit : Hello,all I'm first time, I want to make a while statement which can function the same x.pop () and without the use of pop、how can i to do? i want to change this is code: def foo(x): y = [] while x !=[]: y.append(

Re:About python while statement and pop()

2014-06-11 Thread Dave Angel
hito koto Wrote in message: > Hello,all > I'm first time, > > I want to make a while statement which can function the same x.pop () and > without the use of pop、how can i to do? No idea what the question means. Are you just trying to rewrite the loop in a python impleme

About python while statement and pop()

2014-06-11 Thread hito koto
Hello,all I'm first time, I want to make a while statement which can function the same x.pop () and without the use of pop、how can i to do? i want to change this is code: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y -- https://mail.python.org/ma

Re: Error invalid syntax while statement

2011-01-08 Thread Terry Reedy
15 print("counter: ", counter 16 17 while (end == 0): # <---returns syntax error on this while statement Among other responses, there is no indent after print. should be print() while x:

Re: Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
On Fri, Jan 7, 2011 at 8:55 PM, Chris Rebert wrote: > On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton > wrote: > > > 1 #!/bin/bash/python > > > What is > > wrong with my shebang line? > > Its path is invalid (unless you're using a *very* weird system). > /bin/bash is the bash shell executable

Re: Error invalid syntax while statement

2011-01-07 Thread Chris Rebert
On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton wrote: >   1 #!/bin/bash/python > What is > wrong with my shebang line? Its path is invalid (unless you're using a *very* weird system). /bin/bash is the bash shell executable; bash is completely unrelated to Python. Further, /bin/bash is a file, n

Re: Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
unt: ", count) 14 print("count1: ", count1) 15 print("counter: ", counter) 16 17 while end == 0: # <---returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.

Re: Error invalid syntax while statement

2011-01-07 Thread Ned Deily
In article , Garland Fulton wrote: > I don't understand what I'm doing wrong i've tried several different cases > for what i am doing here. Will someone please point my error out. > 15 print("counter: ", counter Missing ")" on line 15. -- Ned Deily, n...@acm.org -- http://mail.p

Re: Error invalid syntax while statement

2011-01-07 Thread Chris Rebert
x27;s the closing parenthesis? >  17               while (end == 0):                              # > <---returns syntax error on this while statement Always include the exact error message + traceback in the future. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
print("counter: ", counter 16 17 while (end == 0): # <---returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.pow(count, 2) + math.pow(count1, 2)

Re: While Statement

2009-05-22 Thread Mike Kazantsev
On Fri, 22 May 2009 21:33:05 +1000 Joel Ross wrote: > changed it to "float(number)/total*100" and it worked thanks for all > your help appreciated I believe operator.truediv function also deserves a mention here, since line "op.truediv(number, total) * 100" somehow seem to make more sense to me

Re: While Statement

2009-05-22 Thread J. Cliff Dyer
On Fri, 2009-05-22 at 09:59 -0400, Dave Angel wrote: > > Tim Wintle wrote: > > On Fri, 2009-05-22 at 13:19 +0200, Andre Engels wrote: > > > >> number/total = 998/999 = 0 > >> number/total*100 = 0*100 = 0 > >> float(number/total*100) = float(0) = 0.0 > >> > >> Change "float(number/total*100)" to

Re: While Statement

2009-05-22 Thread Tim Wintle
On Fri, 2009-05-22 at 09:59 -0400, Dave Angel wrote: > > Tim Wintle wrote: > > On Fri, 2009-05-22 at 13:19 +0200, Andre Engels wrote: > >> Change "float(number/total*100)" to "float(number)/total*100" and it > >> should work: > >> > > > > I'd use: > > > > (number * 100.)/total > > > > - wor

Re: While Statement

2009-05-22 Thread Joel Ross
Dave Angel wrote: Tim Wintle wrote: On Fri, 2009-05-22 at 13:19 +0200, Andre Engels wrote: number/total = 998/999 = 0 number/total*100 = 0*100 = 0 float(number/total*100) = float(0) = 0.0 Change "float(number/total*100)" to "float(number)/total*100" and it should work: I'd use: (n

Re: While Statement

2009-05-22 Thread Dave Angel
Tim Wintle wrote: On Fri, 2009-05-22 at 13:19 +0200, Andre Engels wrote: number/total = 998/999 = 0 number/total*100 = 0*100 = 0 float(number/total*100) = float(0) = 0.0 Change "float(number/total*100)" to "float(number)/total*100" and it should work: I'd use: (number * 100.)/tota

Re: While Statement

2009-05-22 Thread Tim Wintle
On Fri, 2009-05-22 at 13:19 +0200, Andre Engels wrote: > number/total = 998/999 = 0 > number/total*100 = 0*100 = 0 > float(number/total*100) = float(0) = 0.0 > > Change "float(number/total*100)" to "float(number)/total*100" and it > should work: I'd use: (number * 100.)/total - works because

Re: While Statement

2009-05-22 Thread Joel Ross
Andre Engels wrote: On Fri, May 22, 2009 at 12:35 PM, Joel Ross wrote: Im using 2.6 python and when running this class progess(): def __init__(self, number, total, char): percentage = float(number/total*100) percentage = int(round(percentage)) char = char * percenta

Re: While Statement

2009-05-22 Thread Andre Engels
On Fri, May 22, 2009 at 12:35 PM, Joel Ross wrote: > Im using 2.6 python and when running this > > class progess(): > >    def __init__(self, number, total,  char): > >        percentage = float(number/total*100) >        percentage = int(round(percentage)) >        char = char * percentage >    

RE: While Statement

2009-05-22 Thread Andreas Tawn
> Im using 2.6 python and when running this > > class progess(): > > def __init__(self, number, total, char): > > percentage = float(number/total*100) > percentage = int(round(percentage)) > char = char * percentage > print char > > progess(1

Re: While Statement

2009-05-22 Thread Joel Ross
Andre Engels wrote: On Fri, May 22, 2009 at 11:17 AM, Joel Ross wrote: Hi all, I have this piece of code class progess(): def __init__(self, number, char): total = number percentage = number while percentage > 0 : percentage = int(number/total*100)

Re: While Statement

2009-05-22 Thread Joel Ross
Joel Ross wrote: Hi all, I have this piece of code class progess(): def __init__(self, number, char): total = number percentage = number while percentage > 0 : percentage = int(number/total*100) number-=1 char+="*" p

Re: While Statement

2009-05-22 Thread Andre Engels
On Fri, May 22, 2009 at 11:17 AM, Joel Ross wrote: > Hi all, > > I have this piece of code > > class progess(): > >    def __init__(self, number,  char): > >        total = number >        percentage = number >        while percentage > 0 : >            percentage = int(number/total*100) >        

Re: While Statement

2009-05-22 Thread Kushal Kumaran
On Fri, May 22, 2009 at 2:47 PM, Joel Ross wrote: > Hi all, > > I have this piece of code > > class progess(): > >    def __init__(self, number,  char): > >        total = number >        percentage = number >        while percentage > 0 : >            percentage = int(number/total*100) >        

While Statement

2009-05-22 Thread Joel Ross
Hi all, I have this piece of code class progess(): def __init__(self, number, char): total = number percentage = number while percentage > 0 : percentage = int(number/total*100) number-=1 char+="*" print char progess

Re: having problems with a multi-conditional while statement

2009-01-07 Thread Hendrik van Rooyen
"Philip Semanchuk" wrote: 8< nice explanation > Change the "and" to an "or" and you'll get the result you expected. Also google for "De Morgan", or "De Morgan's laws" Almost everybody stumbles over this or one of it's corollaries at least once in their careers

Re: having problems with a multi-conditional while statement

2009-01-06 Thread bowman.jos...@gmail.com
roups.com>, > > > >  "bowman.jos...@gmail.com" wrote: > > Hi, > > > I'm trying to write a multi-conditional while statement, and am having > > problems. I've broken it down to this simple demo. > > > #!/usr/bin/python2.5 > > > condition1 = False

Re: having problems with a multi-conditional while statement

2009-01-06 Thread Ned Deily
In article <40a44d6b-c638-464d-b166-ef66496a0...@l16g2000yqo.googlegroups.com>, "bowman.jos...@gmail.com" wrote: > Hi, > > I'm trying to write a multi-conditional while statement, and am having > problems. I've broken it down to this simple demo. >

Re: having problems with a multi-conditional while statement

2009-01-06 Thread Philip Semanchuk
On Jan 6, 2009, at 7:18 PM, bowman.jos...@gmail.com wrote: Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5 condition1 = False condition2 = False while not condition1 and not

having problems with a multi-conditional while statement

2009-01-06 Thread bowman.jos...@gmail.com
Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5 condition1 = False condition2 = False while not condition1 and not condition2: print 'conditions met' if condition1

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Charlton Wilbur
> "b" == brianr <[EMAIL PROTECTED]> writes: b> (As a matter of interest, is this sequence of posts intended to b> demonstrate ignorance of both languages, or just one?) Intentional fallacy -- there's no necessary correlation between what he *intends* to do and what he actually succee

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Abigail
Xah Lee ([EMAIL PROTECTED]) wrote on CLIII September MCMXCIII in news:[EMAIL PROTECTED]>: .. # here's a while statement in python. .. .. a,b = 0,1 .. while b < 20: .. print b IndentationError: expected an indented block .. a,b = b,a+b You have already proven you don'

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Steven Bethard
Xah Lee wrote: # here's a while statement in python. a,b = 0,1 while b < 20: print b a,b = b,a+b --- # here's the same code in perl ($a,$b)=(0,1); while ($b<20) { print $b, "\n"; ($a,$b)= ($b, $a+$b); } Because you're posting this to newsgroups, it

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Peter Hansen
Steven Bethard wrote: Xah Lee wrote: [some Python code] Because you're posting this to newsgroups, it would be advisable to use only spaces for indentation -- tabs are removed by a lot of newsreaders, which means your Python readers are going to complain about IndentationErrors. Unfortunately, t

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Peter Maas
[EMAIL PROTECTED] schrieb: "Xah Lee" <[EMAIL PROTECTED]> writes: [...] (As a matter of interest, is this sequence of posts intended to demonstrate ignorance of both languages, or just one?) :) This sequence of posts is intended to stir up a debate just for the sake of a debate. It's a time sink. It

Re: [perl-python] 20050112 while statement

2005-01-13 Thread brianr
"Xah Lee" <[EMAIL PROTECTED]> writes: > # here's a while statement in python. > > a,b = 0,1 > while b < 20: > print b > a,b = b,a+b > > --- > # here's the same code in perl > > ($a,$b)=(0,1); > while ($b<20) { > p

Re: [perl-python] 20050112 while statement

2005-01-13 Thread Michael Hoffman
Xah Lee wrote: # here's a while statement in python. > [...] > # here's the same code in perl [...] So? -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] 20050112 while statement

2005-01-13 Thread Xah Lee
# here's a while statement in python. a,b = 0,1 while b < 20: print b a,b = b,a+b --- # here's the same code in perl ($a,$b)=(0,1); while ($b<20) { print $b, "\n"; ($a,$b)= ($b, $a+$b); } Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html