Common LISP-style closures with Python

2012-02-03 Thread Antti J Ylikoski
In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: - # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 4:47, Chris Rebert wrote: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 12:14, Antti J Ylikoski wrote: On 4.2.2012 4:47, Chris Rebert wrote: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 12:58, Arnaud Delobelle wrote: On 4 February 2012 10:14, Antti J Ylikoski wrote: On 4.2.2012 4:47, Chris Rebert wrote: Out of curiosity, what would be non-Common-Lisp-style closures? Cheers, Chris I understand that a "closure" is something which is typical of

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 5.2.2012 3:31, John O'Hagan wrote: On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1(): n = 0 def f2(): nonlocal n n += 1 ret

Re: Common LISP-style closures with Python

2012-02-05 Thread Antti J Ylikoski
On 5.2.2012 22:58, Ian Kelly wrote: On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: I'm not sure how naughty this is, but the same thing can be done without using nonlocal by storing the local state as an attribute of the enclosed function object: ... Yes, I do know that, but

Re: how to read serial stream of data [newbie]

2012-02-07 Thread Antti J Ylikoski
On 7.2.2012 14:13, Jean Dupont wrote: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) In Python, if you want to continue the source line into the next text line, you must end the line to be continued with a backslash '\'. So you should write: s

Re: how to read serial stream of data [newbie]

2012-02-07 Thread Antti J Ylikoski
On 7.2.2012 16:02, Peter Otten wrote: Antti J Ylikoski wrote: On 7.2.2012 14:13, Jean Dupont wrote: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) In Python, if you want to continue the source line into the next text line, you must end the

Programming D. E. Knuth in Python with the Deterministic Finite Automaton construct

2012-03-17 Thread Antti J Ylikoski
hile k < l: temp = a[k] a[k] = a[l] a[l] = temp k += 1 l -= 1 nextStat = "L1" continueLoop = 1 else: continueLoop = 0 error("Impossible -- I quit!\n") return(listofPerm) kind regards, Antti J Ylikoski Helsinki, Finland, the EU -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming D. E. Knuth in Python with the Deterministic Finite Automaton construct

2012-03-17 Thread Antti J Ylikoski
On 17.3.2012 17:47, Roy Smith wrote: In article, Antti J Ylikoski wrote: I came across the problem, which would be the clearest way to program such algorithms with a programming language such as Python, which has no GOTO statement. It struck me that the above construction actually is a

Re: New learner of Python--any suggestion on studying it?

2012-03-19 Thread Antti J Ylikoski
On 19.3.2012 8:30, yan xianming wrote: Hello all, I'm a new learning of Python. Can someone give me some suggestion about it? thanks xianming The best textbooks on Python that I have come across are: Learning Python by Mark Lutz, O'Reilly, http://oreilly.com, ISBN 978-0-596-15806-4 Progr

Donald E. Knuth in Python, cont'd

2012-04-11 Thread Antti J Ylikoski
uite a ballet between integers and floats, but I wanted to do this as meticulously as possible. # Date of Easter from D. E. Knuth. Antti J Ylikoski 04-11-2012. # # See Donald E. Knuth: The Art of Computer Programming, V

Re: Donald E. Knuth in Python, cont'd

2012-04-11 Thread Antti J Ylikoski
On 11.4.2012 16:23, Grant Edwards wrote: On 2012-04-11, Antti J Ylikoski wrote: I wrote about a straightforward way to program D. E. Knuth in Python, Yikes. I think if you're going to try to write AI in Pyton, you might want to start out programming something a bit si

Re: functions which take functions

2012-04-11 Thread Antti J Ylikoski
nvx,1.0,2.0,.1)) print("Exact value ln(2): ", math.log(2.0)) print("Value of epsilon : ", .1) -------- kind regards, Antti J Ylikoski Helsinki, Finland, the EU http://www.tkk.fi/~ajy/ http://www.tkk.fi/~

Re: Donald E. Knuth in Python, cont'd

2012-04-11 Thread Antti J Ylikoski
On 11.4.2012 23:20, John Nagle wrote: On 4/11/2012 6:03 AM, Antti J Ylikoski wrote: I wrote about a straightforward way to program D. E. Knuth in Python, and received an excellent communcation about programming Deterministic Finite Automata (Finite State Machines) in Python. The following

Algorithms in Python, cont'd

2012-05-03 Thread Antti J Ylikoski
have been straightforward but too time-consuming. yours, and V/R, Antti J Ylikoski Helsinki, Finland, the EU -- http://mail.python.org/mailman/listinfo/python-list

Algorithms in Python, #n+1

2012-05-16 Thread Antti J Ylikoski
chi_squared_test(random.random, 1000, 100, "Mersenne") chi2_Linear = chi_squared_test(rand_x.rand, 1000, 100, "Linear") chi2_Mersenne.run_test() chi2_Linear.run_test() chi2_Mersenne.chi2test() chi2_Linear.chi2test() --- yours and V/R, Antti J Ylikoski Helsinki, Finland, the E.U. -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-20 Thread Antti J Ylikoski
On 20.5.2011 3:38, Pascal J. Bourguignon wrote: t...@sevak.isi.edu (Thomas A. Russ) writes: "Pascal J. Bourguignon" writes: t...@sevak.isi.edu (Thomas A. Russ) writes: This will only work if there is a backpointer to the parent. No, you don't need backpointers; some cases have been menti

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-23 Thread Antti J Ylikoski
On 23.5.2011 16:39, Pascal J. Bourguignon wrote: torb...@diku.dk (Torben Ægidius Mogensen) writes: Xah Lee writes: Functional Programing: stop using recursion, cons. Use map& vectors. 〈Guy Steele on Parallel Programing〉 http://xahlee.org/comp/Guy_Steele_parallel_computing.html This is m

Python 2 or 3

2011-12-02 Thread Antti J Ylikoski
I'm in the process of learning Python. I already can code objet-oriented programs with the language. I have in my hands the O'Reilly book by Mark Lutz, Programming Python, in two versions: the 2nd Edition, which covers Python 2, and the 4th edition, which covers Python 3. In the "official Pyth