Re: Syntax question

2020-08-16 Thread Manfred Lotz
On Sun, 16 Aug 2020 06:09:17 -0500 Skip Montanaro wrote: > > Typing is not required by > > Python. However, you may find the extra error-checking helpful... > > I haven't used type hints much, if at all, but my understanding is > that the "extra error-checking" of which you speak is gotten thr

Re: Syntax question

2020-08-16 Thread Skip Montanaro
> Typing is not required by > Python. However, you may find the extra error-checking helpful... I haven't used type hints much, if at all, but my understanding is that the "extra error-checking" of which you speak is gotten through other static checkers, correct? I know the syntax was developed wi

Re: Syntax question

2020-08-16 Thread Manfred Lotz
On Sun, 16 Aug 2020 10:12:04 +0200 Klaus Jantzen wrote: > Hi, > > the other day I came across the book "Classic Computer Science > Problems in Python" by David Kopec. > > The function definitions in the examples  like > > = > def fib2(n: int) -> int: >     if n < 2:  # base case >   

Re: Syntax question

2020-08-16 Thread dn via Python-list
On 16/08/2020 20:12, Klaus Jantzen wrote: Hi, the other day I came across the book "Classic Computer Science Problems in Python" by David Kopec. The function definitions in the examples  like = def fib2(n: int) -> int:     if n < 2:  # base case     return n     return fib2(n - 2)

Re: syntax question

2018-06-02 Thread Chris Angelico
On Sat, Jun 2, 2018 at 9:08 PM, Sharan Basappa wrote: > Can anyone please tell me what the following line in a python program does: > > line = lambda x: x + 3 > > I have pasted the entire code below for reference: > > from scipy.optimize import fsolve > import numpy as np > line = lambda x: x + 3

Re: syntax question

2018-06-02 Thread Timo Furrer
>From the Python documentation at https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions > Small anonymous functions can be created with the lambda keyword. This function returns the sum of its two arguments: lambda a, b

Re: Syntax question

2010-06-02 Thread pmz
On 2 Cze, 20:07, Matteo Landi wrote: > Anyway I suggest you to use a syntax like: > > >>>b = list(a) > > in order to copy a list, it should be better than slicing. > > > > > > On Wed, Jun 2, 2010 at 7:56 PM, geremy condra wrote: > > On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: > >> Dear Group, >

Re: Syntax question

2010-06-02 Thread Matteo Landi
Yes it is; d[i:j] is equal to "give me the array from the d[i] to d[j - 1]", and if you omit i and j then the i and j are respectively assumed as 0 and len(d) - 1. On Wed, Jun 2, 2010 at 8:01 PM, pmz wrote: > On 2 Cze, 19:56, geremy condra wrote: >> On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: >

Re: Syntax question

2010-06-02 Thread Matteo Landi
Anyway I suggest you to use a syntax like: >>>b = list(a) in order to copy a list, it should be better than slicing. On Wed, Jun 2, 2010 at 7:56 PM, geremy condra wrote: > On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: >> Dear Group, >> >> It's really rookie question, but I'm currently helping my

Re: Syntax question

2010-06-02 Thread pmz
On 2 Cze, 19:56, geremy condra wrote: > On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: > > Dear Group, > > > It's really rookie question, but I'm currently helping my wife in some > > python-cases, where I'm non-python developer and some of syntax-diffs > > make me a bit confused. > > > Could anyone

Re: Syntax question

2010-06-02 Thread geremy condra
On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: > Dear Group, > > It's really rookie question, but I'm currently helping my wife in some > python-cases, where I'm non-python developer and some of syntax-diffs > make me a bit confused. > > Could anyone give some light on line, as following: > "ds = d[:

Re: Syntax question

2010-06-02 Thread Chris Rebert
On Wed, Jun 2, 2010 at 10:40 AM, pmz wrote: > Dear Group, > > It's really rookie question, but I'm currently helping my wife in some > python-cases, where I'm non-python developer and some of syntax-diffs > make me a bit confused. > > Could anyone give some light on line, as following: > "ds = d[:

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Changed Date: 2009-10-10) I can't reproduce your failure. What are the exact commands you are using? CFLAGS='-O3 -mtune=native -msse2 -pipe' CXXFLAGS=$C

Re: Syntax question

2009-10-10 Thread Benjamin Peterson
Helmut Jarausch skynet.be> writes: > As I said, it's 'make' in Python's source directory > (SVN revision 75309 Last Changed Date: 2009-10-10) I can't reproduce your failure. What are the exact commands you are using? -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: Hi, I'm trying to build the recent Python-3.2a (SVN). It fails in Lib/tokenize.py (line 87) How are you invoking it? As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Changed Date: 2009-10-10) If it

Re: Syntax question

2009-10-10 Thread Benjamin Peterson
Helmut Jarausch skynet.be> writes: > > Hi, > > I'm trying to build the recent Python-3.2a (SVN). > It fails in > Lib/tokenize.py (line 87) How are you invoking it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax Question - list multiplication

2007-08-19 Thread James Stroud
MC wrote: > Classic Thanks Michel, but maybe this bit of programming jargon needs some translation for the uninitiated: Classic \Clas"sic\ (kl[a^]s"s[i^]k), Classical \Clas"sic*al\, a. 0. Read the FAQ 1. First rate 2. Greek 3. Refined James -- James Stroud UCLA-DOE Institute for Genomics and

Re: Syntax Question - list multiplication

2007-08-19 Thread Duncan Smith
Roel Schroeven wrote: > Pablo Torres schreef: > >> Hi guys! >> >> I am working on Conway's Game of Life right now and I've run into a >> little problem. >> I represent dead cells with 0s and live ones with 1s. Check this out: >> >> >>> grid = [[0] * 3] * 3 >> >>> grid >> [[0, 0, 0], [0

Re: Syntax Question - list multiplication

2007-08-19 Thread Pablo Torres
Thanks everyone. Now I see why every row in my grid were actually the same object. Pablo -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax Question - list multiplication

2007-08-19 Thread Roel Schroeven
Pablo Torres schreef: > Hi guys! > > I am working on Conway's Game of Life right now and I've run into a > little problem. > I represent dead cells with 0s and live ones with 1s. Check this out: > > >>> grid = [[0] * 3] * 3 > >>> grid > [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >

Re: Syntax Question - list multiplication

2007-08-19 Thread Thomas Jollans
On Sunday 19 August 2007, Pablo Torres wrote: > Hi guys! > > I am working on Conway's Game of Life right now and I've run into a > little problem. > > I represent dead cells with 0s and live ones with 1s. Check this out: > >>> grid = [[0] * 3] * 3 > >>> grid > > [[0, 0, 0], [0, 0,

Re: Syntax Question - list multiplication

2007-08-19 Thread MC
Classic -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-28 Thread Christopher Subich
Steve Holden wrote: >> On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: >> >>> Not quite because if something(3) fails, I still want something(4) to >>> run. > Then the obvious extension: > > for i in range(20): >... > > but I get the idea that Gregory was thinking of different statement

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread James Stroud
On Thursday 27 October 2005 11:16, Carsten Haese wrote: > On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: > > Not quite because if something(3) fails, I still want something(4) to > > run. > > def something_ignore_exceptions(x): > try: something(x) > except: pass > > something_ignore_excepti

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Steve Holden
Carsten Haese wrote: > On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: > >>Not quite because if something(3) fails, I still want something(4) to >>run. > > > def something_ignore_exceptions(x): > try: something(x) > except: pass > > something_ignore_exceptions(1) > something_ignore_exc

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Carsten Haese
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: > Not quite because if something(3) fails, I still want something(4) to > run. def something_ignore_exceptions(x): try: something(x) except: pass something_ignore_exceptions(1) something_ignore_exceptions(2) # etc... HTH, Carsten Haese

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
Not quite because if something(3) fails, I still want something(4) to run.  On 10/27/05, Micah Elliott <[EMAIL PROTECTED]> wrote: If you just want to ignore the exceptions while saving space/typing,you could equivalently do::try:something(1)something(2)# ...except: 

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Micah Elliott
On Oct 27, Gregory Piñero wrote: > >my goal really was to do: >try:something(1);except:pass >try:something(2);except:pass >try:something(3);except:pass >... >for about 20 lines. If you just want to ignore the exceptions while saving space/typing, you could equivalently do:

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
That's interesting, Simon.  However, my goal really was to do: try:something(1);except:pass try:something(2);except:pass try:something(3);except:pass ... for about 20 lines.  I figured this would be more readable because if I reader sees 20 lines of nearly identical text he'll understand that it

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Simon Brunning
On 27/10/05, Gregory Piñero <[EMAIL PROTECTED]> wrote: > So much for writing my whole program on one line :-( http://www.unixuser.org/~euske/pyone/ But you didn't hear it from me, OK? ;-) -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread W.H.Offenbach
Gregory Piñero wrote: > So much for writing my whole program on one line :-( Why bother with one liners? "The number of meaningful lines and pages a writer produces is a measure for his writer-ship" -- my old Literature professor -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Gregory Piñero
So much for writing my whole program on one line :-( j/k -GregOn 10/26/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Gregory Piñero wrote:> Any idea why I can't say:>> if 1:print 'a';else:print 'b'>> all in one line like that?because ";" can only be used to separate simple statements, not the diff

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-26 Thread Fredrik Lundh
Gregory Piñero wrote: > Any idea why I can't say: > > if 1:print 'a';else:print 'b' > > all in one line like that? because ";" can only be used to separate simple statements, not the different parts in a compound statement. see the grammar for details: http://docs.python.org/ref/grammar.txt