Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Kiuhnm
overns the order of evaluation of a group of operators *OF THE SAME PRECEDENCE*. If you write 2**3**4 only the fact the '**' is right associative will tell you that the order is 2**(3**4) and not (2**3)**4 I remind you that 2^(3^4) != (2^3)^4. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Kiuhnm
s outdated? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-01 Thread Kiuhnm
On 3/1/2012 1:02, Xah Lee wrote: i missed a point in my original post. That is, when the same operator are adjacent. e.g. 「3 ▲ 6 ▲ 5」. This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw. Thanks. though, i disagree the way they expressed it, or any sense this is different

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-02 Thread Kiuhnm
On 3/2/2012 14:12, Xah Lee wrote: On Mar 1, 3:00 am, Kiuhnm wrote: They did not make up the terminology, if that is what you are saying. The concepts of left and right associativity are well-known and accepted in TCS (Theoretical CS). Aho, Sethi and Ullman explain it this way in "Comp

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Kiuhnm
eft and right-associative. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-12 Thread Kiuhnm
On 3/12/2012 20:00, Albert van der Horst wrote: In article<[email protected]>, Kiuhnm wrote: On 3/12/2012 12:27, Albert van der Horst wrote: Interestingly in mathematics associative means that it doesn't matter whether you use (a.b).c or a.(b.c)

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm
On 3/12/2012 20:00, Albert van der Horst wrote: In article<[email protected]>, Kiuhnm wrote: On 3/12/2012 12:27, Albert van der Horst wrote: Interestingly in mathematics associative means that it doesn't matter whether you use (a.b).c or a.(b.c)

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm
On 3/12/2012 20:00, Albert van der Horst wrote: In article<[email protected]>, Kiuhnm wrote: On 3/12/2012 12:27, Albert van der Horst wrote: Interestingly in mathematics associative means that it doesn't matter whether you use (a.b).c or a.(b.c)

Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-13 Thread Kiuhnm
On 3/12/2012 20:00, Albert van der Horst wrote: [...] Sorry for triple posting. I hadn't noticed the follow up and I was blaming my newsserver. BTW, Python is the next language (right after Perl) I'm going to learn. Then I'll probably have a look at Ruby... Kiuhnm -- http://

Python is readable

2012-03-14 Thread Kiuhnm
27;s no need to misrepresent Perl that way. Now I'm wondering whether the author will show me "good" or "bad" Python code throughout the book. Should I keep reading? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Kiuhnm
e. List comprehensions are not immediately obvious to new Python users. The functionality of 'with' requires an understanding of context managers. Python's readability has more to do with simplifying code maintenance. Let's try that. Show me an example of "list comprehe

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 11:50, Chris Angelico wrote: On Thu, Mar 15, 2012 at 9:44 PM, Kiuhnm wrote: Let's try that. Show me an example of "list comprehensions" and "with" (whatever they are). I'll do a list comp, because they lend themselves well to one-liners. what_a

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 12:14, Thomas Rachel wrote: Am 15.03.2012 11:44 schrieb Kiuhnm: Let's try that. Show me an example of "list comprehensions" and "with" (whatever they are). with open("filename", "w") as f: f.write(stuff) Here f is created b

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 12:47, Chris Angelico wrote: On Thu, Mar 15, 2012 at 10:27 PM, Kiuhnm Your first example suggests that range(n) is a sequence iterator which returns, if queried n times, 0,...,n-1 (which is a bit counterintuitive, IMHO). It's a little odd, perhaps, if seen in a vacuum

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 13:21, Chris Angelico wrote: On Thu, Mar 15, 2012 at 10:59 PM, Kiuhnm wrote: On 3/15/2012 12:47, Chris Angelico wrote: It's a little odd, perhaps, if seen in a vacuum. But everything counts from zero - list indices, etc - so it makes sense for range(len(lst)) to return in

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:06, Mark Lawrence wrote: On 15/03/2012 11:48, Kiuhnm wrote: On 3/15/2012 12:14, Thomas Rachel wrote: Am 15.03.2012 11:44 schrieb Kiuhnm: Let's try that. Show me an example of "list comprehensions" and "with" (whatever they are). with open("

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:23, Duncan Booth wrote: Kiuhnm wrote: BTW, aren't those ':' redundant? They are required by the grammar, but in a sense you are correct. You could modify Python's grammar to make the colons optional and still keep it unambiguous but that would make it ha

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:29, Chris Angelico wrote: On Fri, Mar 16, 2012 at 1:16 AM, Kiuhnm wrote: Don't worry. Soon you'll be using C++0x :))) I use gcc/g++ with most of the new features enabled. There's some pretty handy features in it. Frankly, though, if I'd known about Cytho

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:28, Tim Golden wrote: On 15/03/2012 14:19, Kiuhnm wrote: On 3/15/2012 15:06, Mark Lawrence wrote: On 15/03/2012 11:48, Kiuhnm wrote: BTW, aren't those ':' redundant? Kiuhnm Nope. Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on w

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:48, Chris Angelico wrote: On Fri, Mar 16, 2012 at 1:30 AM, Kiuhnm wrote: Sorry, but I can't see how it would make it harder for humans to understand. Are there particular situations you're referring to? In a trivial example, it's mostly just noise: if a == b

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 15:43, Robert Kern wrote: On 3/15/12 2:30 PM, Kiuhnm wrote: On 3/15/2012 15:23, Duncan Booth wrote: Kiuhnm wrote: BTW, aren't those ':' redundant? They are required by the grammar, but in a sense you are correct. You could modify Python's grammar to make

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 16:08, Chris Angelico wrote: On Fri, Mar 16, 2012 at 1:55 AM, Kiuhnm wrote: By the way, the more elaborate parsing consists of looking for an END_OF_LINE followed by one or more spaces. It doesn't sound that complicated. Only in the trivial case. What if you want to break

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/15/2012 23:17, Michael Torrie wrote: On 03/15/2012 09:18 AM, Kiuhnm wrote: > After early user testing without the colon, it was discovered that the meaning of the indentation was unclear to beginners being taught the first steps of programming.< The addition of the

Re: Python is readable

2012-03-15 Thread Kiuhnm
On 3/16/2012 0:00, Arnaud Delobelle wrote: On 15 March 2012 22:35, Ben Finney wrote: Kiuhnm writes: Moreover, I think that if ( ): is not very readable anyway. I agree, and am

Re: Python is readable

2012-03-16 Thread Kiuhnm
On 3/16/2012 0:58, Mark Lawrence wrote: On 15/03/2012 23:46, Kiuhnm wrote: On 3/16/2012 0:00, Arnaud Delobelle wrote: On 15 March 2012 22:35, Ben Finney wrote: Kiuhnm writes: Moreover, I think that if ( ): is not

Re: Python is readable

2012-03-16 Thread Kiuhnm
On 3/16/2012 4:55, Steven D'Aprano wrote: On Fri, 16 Mar 2012 00:32:52 +0100, Kiuhnm wrote: Pick up two math books about the same topic but on two different levels (e.g. under-graduated and graduated). If you compare the proofs you'll see that those in the higher-level book are alm

Re: Python is readable

2012-03-16 Thread Kiuhnm
On 3/16/2012 0:52, Steven D'Aprano wrote: On Fri, Mar 16, 2012 at 1:30 AM, Kiuhnm wrote: Sorry, but I can't see how it would make it harder for humans to understand. Are there particular situations you're referring to? In a trivial example, it's mostly just noise: if a

Re: Python is readable

2012-03-16 Thread Kiuhnm
On 3/16/2012 2:53, Steven D'Aprano wrote: On Thu, 15 Mar 2012 00:34:47 +0100, Kiuhnm wrote: I've just started to read The Quick Python Book (2nd ed.) Is this the one? http://manning.com/ceder/ The author claims that Python code is more readable than Perl code and pro

Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm
f(a, b) ?-) That would be f (a b) # Haskell f(a(b)) # Python Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm
lways forget if it should be f a b or f ( a b ) You wouldn't, because Haskel's way is more regular and makes a lot of sense: parentheses are for grouping and that's it. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-16 Thread Kiuhnm
On 3/16/2012 17:25, Steven D'Aprano wrote: On Fri, 16 Mar 2012 13:55:06 +0100, Kiuhnm wrote: I don't understand the reason for $arg1 and $arg2. Is there some reason why the code couldn't do this instead? my(@list1, @list2) = @_; @_ contains references to arrays. You

Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm
On 3/16/2012 17:45, Steven D'Aprano wrote: On Fri, 16 Mar 2012 17:31:06 +0100, Kiuhnm wrote: You wouldn't, because Haskel's way is more regular and makes a lot of sense: parentheses are for grouping and that's it. If f is a function which normally takes (for the sake

Currying in Python

2012-03-16 Thread Kiuhnm
vel + 1); printTree(func(1), level + 1); printTree(f); print("\n--\n"); def f2(*args): print(", ".join(["%3d"%(x) for x in args])); def stress(f, n): if n: stress(f(n), n - 1) else: f(); # enough is enough stress(cur(f2), 100); <--- Kiuhnm -- 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 Kiuhnm
clear way to program Knuth with Python is the following kind of a construct. [...] Your way is easy, but the result is poor. Your should try to rewrite it. Decompilers do exactly that. Kiuhnm -- 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 Kiuhnm
On 3/17/2012 16:01, Michael Torrie wrote: On 03/17/2012 08:45 AM, Kiuhnm wrote: Your way is easy, but the result is poor. In what way? The resulting code is inefficient, difficult to comprehend and to mantain. What is your recommended way? One should rewrite the code. There is a reason

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

2012-03-17 Thread Kiuhnm
On 3/17/2012 16:53, Michael Torrie wrote: > On 03/17/2012 09:12 AM, Kiuhnm wrote: >> On 3/17/2012 16:01, Michael Torrie wrote: >>> On 03/17/2012 08:45 AM, Kiuhnm wrote: >>>> Your way is easy, but the result is poor. >>> >>> In what way? >&

Re: Python is readable

2012-03-17 Thread Kiuhnm
On 3/16/2012 17:48, Steven D'Aprano wrote: On Fri, 16 Mar 2012 13:10:12 +0100, Kiuhnm wrote: Maybe we should define *exactly* what readability is (in less then 500 lines, if possible). If you can't be bothered to read my post before replying, save yourself some more time and don&#

Re: Python is readable

2012-03-17 Thread Kiuhnm
pply the grammatical rules used by people in real life. You know the ones: linguists." Then how do you know that there's nothing ungrammatical about "If you can: take the bus" if people don't use it? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-17 Thread Kiuhnm
ould not precede a list unless it follows a complete sentence; however, the colon is a style choice that some publications allow." http://www.grammarbook.com/punctuation/colons.asp Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-17 Thread Kiuhnm
On 3/17/2012 0:39, Michael Torrie wrote: For someone who claims he's merely examining the language and seeking to learn about it, Kiuhnm is jumping awfully quickly into the realm of trolling. I'm speechless... thanks, man! Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-17 Thread Kiuhnm
On 3/17/2012 22:20, Chris Angelico wrote: On Sun, Mar 18, 2012 at 6:59 AM, Kiuhnm wrote: Could you please explain to me in which way mov eax, 3 should be less readable than for i in x: print(i) ? They are equally readable. The first one sets EAX to 3; the second displays all

Re: Currying in Python

2012-03-18 Thread Kiuhnm
On 3/17/2012 2:21, Kiuhnm wrote: Here we go. I wrote an article about my approach to currying: http://mtomassoli.wordpress.com/2012/03/18/currying-in-python/ Beginners should be able to understand it as well. Experienced programmers will probably want to skip some sections. Kiuhnm -- http

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

2012-03-18 Thread Kiuhnm
rding labels and state, I simply meant that they're completely different things, in fact this program has two labels but infinitely many states: A1: cur = cur + 1 A2: goto A1 I was being pedantic, to say it your way ;) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

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

2012-03-19 Thread Kiuhnm
On 3/19/2012 6:02, Dennis Lee Bieber wrote: On Mon, 19 Mar 2012 02:02:23 +0100, Kiuhnm declaimed the following in gmane.comp.python.general: Many ASM languages don't have structured control flow statements but only jmps, which are roughly equivalent to gotos. A good decompiler will ne

Re: Python is readable

2012-03-19 Thread Kiuhnm
On 3/18/2012 0:04, Michael Torrie wrote: On 03/17/2012 03:28 PM, Kiuhnm wrote: They are equally readable. The first one sets EAX to 3; the second displays all elements of x on the console. Assembly is readable on a very low level, but it's by nature verbose at a high level, and thus

Re: Python is readable

2012-03-19 Thread Kiuhnm
On 3/18/2012 2:36, Steven D'Aprano wrote: On Sat, 17 Mar 2012 20:59:34 +0100, Kiuhnm wrote: Ok, so length and readability are orthogonal properties. Could you please explain to me in which way mov eax, 3 should be less readable than for i in x: print(i) ? "mov eax, 3

Re: Python is readable

2012-03-19 Thread Kiuhnm
On 3/18/2012 2:46, Steven D'Aprano wrote: On Sat, 17 Mar 2012 21:23:45 +0100, Kiuhnm wrote: On 3/16/2012 14:03, Steven D'Aprano wrote: A one line routine is still a routine. There is nothing ungrammatical about "If you can: take the bus.", although it is non-idiomatic E

Re: Currying in Python

2012-03-19 Thread Kiuhnm
On 3/20/2012 0:20, Ian Kelly wrote: I hope you don't mind if I critique your code a bit! Not at all. Thank you for your time. On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm wrote: Here we go. ---> def genCur(f, unique = True, minArgs = -1): [...] I'll update my code following you

Re: Currying in Python

2012-03-20 Thread Kiuhnm
note, "nonlocal" isn't needed in my code, in fact I removed it right after my first post. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Currying in Python

2012-03-20 Thread Kiuhnm
On 3/20/2012 8:11, Arnaud Delobelle wrote: On 19 March 2012 23:20, Ian Kelly wrote: I hope you don't mind if I critique your code a bit! On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm wrote: Here we go. ---> def genCur(f, unique = True, minArgs = -1): It is customary in Python for un

Re: Python is readable

2012-03-20 Thread Kiuhnm
us because "nobody says them". Nobody says "hesitant teapots sleep artistically". Let's not mix syntax with semantics. "If I'm ok: I'll go." represents all the possible sentences where the if-clause and the then-clause are separated by a colon. I believe

Re: Python is readable

2012-03-20 Thread Kiuhnm
s - walk the dog That's perfectly fine. Commas are conveniently omitted. As a side note, titles of movies, newspapers etc... don't follow common rules. Articles may be omitted, verbs may be missing, etc... They're just titles. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd strip behavior

2012-03-22 Thread Kiuhnm
r.py his is a es his is a tes Why wasnt the t removed ? Because it's not a leading or trailing character. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Stream programming

2012-03-23 Thread Kiuhnm
x27;), ge('med'))\ - ['same', 'same'] - streams(cat) - 'same' It reads as "take a list of numbers - save it - compute the average and named it 'med' - restore the flow - create two streams which have, respect., the numbers less than &#x

Re: Stream programming

2012-03-23 Thread Kiuhnm
On 3/23/2012 17:00, Kiuhnm wrote: I've been writing a little library for handling streams as an excuse for doing a little OOP with Python. I don't share some of the views on readability expressed on this ng. Indeed, I believe that a piece of code may very well start as complete gib

Re: Stream programming

2012-03-23 Thread Kiuhnm
y sequence. Flows can be saved (push) and restored (pop) : [1,2,3,4] - push - by(2) - 'double' - pop | val('double') <=> [1,2,3,4] | [2,4,6,8] There are easier ways to achieve the same result, of course: [1,2,3,4] - [id, by(2)] You are grasping

Re: Stream programming

2012-03-23 Thread Kiuhnm
at I wanted to do and, in fact, I did. I'm afraid your cup is too full to understand simple things as the one I wrote in my OP. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Stream programming

2012-03-23 Thread Kiuhnm
On 3/23/2012 22:12, Ethan Furman wrote: Kiuhnm wrote: On 3/23/2012 17:33, Nathan Rice wrote: Given the examples you pose here, it is clear that you are assuming that the streams are synchronized in discrete time. Since you do not provide any mechanism for temporal alignment of streams you are

Re: Stream programming

2012-03-23 Thread Kiuhnm
stead of posting a message stating that you have a superior way to compose code, you might want to try to solve a problem and ask others their opinion of the structure and techniques in your code. Never said it was superior. We've been talking about readability a lot, haven't we? I was just proposing something different. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Stream programming

2012-03-23 Thread Kiuhnm
On 3/24/2012 0:32, Ray Song wrote: On Fri, Mar 23, 2012 at 05:00:23PM +0100, Kiuhnm wrote: I've been writing a little library for handling streams as an excuse for doing a little OOP with Python. I don't share some of the views on readability expressed on this ng. Indeed, I beli

Re: Stream programming

2012-03-24 Thread Kiuhnm
On 3/24/2012 4:23, Steven D'Aprano wrote: On Fri, 23 Mar 2012 17:00:23 +0100, Kiuhnm wrote: I've been writing a little library for handling streams as an excuse for doing a little OOP with Python. I don't share some of the views on readability expressed on this ng. Indeed, I

verbs in comments [OT]

2012-03-24 Thread Kiuhnm
Why do you write // Print the number of words... def printNumWords(): ... and not // Prints the number of words... def printNumWords(): ... where "it" is understood? Is that an imperative or a base form or something else? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: verbs in comments [OT]

2012-03-24 Thread Kiuhnm
On 3/24/2012 21:24, MRAB wrote: On 24/03/2012 19:36, Kiuhnm wrote: Why do you write // Print the number of words... def printNumWords(): ... and not // Prints the number of words... def printNumWords(): ... where "it" is understood? Is that an imperative or a base form or something e

Re: multiprocessing & itertools.product Iterator

2012-03-25 Thread Kiuhnm
ce_example_combos() print("tesdata generated") q = Queue() p = Pool(10, calc_init, [q]) results = p.imap(calc, combos) p.close() p.join() for r in results: print(q.get()) print(r) input("") < Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation, assignment in expression.

2012-03-25 Thread Kiuhnm
n() and end(). Note the ampersand which means "get the reference of". Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation, assignment in expression.

2012-03-25 Thread Kiuhnm
; in mathematics. The "right" operator would have been "<-". Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation, assignment in expression.

2012-03-26 Thread Kiuhnm
On 3/26/2012 10:52, Devin Jeanpierre wrote: On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm wrote: On 3/25/2012 15:48, Tim Chase wrote: The old curmudgeon in me likes the Pascal method of using "=" for equality-testing, and ":=" for assignment which feels a little closer to

Re: Stream programming

2012-03-26 Thread Kiuhnm
On 3/26/2012 11:27, Jean-Michel Pichavant wrote: Kiuhnm wrote: [snip] numbers - push - avrg - 'med' - pop - filter(lt('med'), ge('med'))\ - ['same', 'same'] - streams(cat) - 'same' It reads as "take a list of numbers - sa

Re: Documentation, assignment in expression.

2012-03-26 Thread Kiuhnm
On 3/26/2012 13:13, Jussi Piitulainen wrote: Kiuhnm writes: On 3/26/2012 10:52, Devin Jeanpierre wrote: On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm wrote: On 3/25/2012 15:48, Tim Chase wrote: The old curmudgeon in me likes the Pascal method of using "=" for equality-testing, an

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Kiuhnm
r a string. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: python segfault

2012-03-28 Thread Kiuhnm
ange(200): print ( get_steps2() ) print("done") input("") <--- Now the limit is 1267650600228229401496703205376. I hope that's enough. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Pipelining in Python

2012-03-30 Thread Kiuhnm
notPropMult = cur(lambda n, x : x <= n or x % n, 2) def findPrimes(upTo): if (upTo <= 5): return [2, 3, 5] filterAll = (findPrimes(floor(sqrt(upTo))) >> map(lambda x : filter(notPropMult(x))) >> reduce(lambda f, g : f - g)) return list(range(2, upTo + 1)) >> filterAll findPrimes(1000) >> my_print print("---") # Example 8 # Finds the approximate number of hrefs in a web page. def do(proc, arg): proc() return arg do = cur(do) cprint = cur(print) ("http://python.org"; >> do(cprint("The page http://python.org has about... ", end = '')) >> do(sys.stdout.flush) >> urlopen >> cur(lambda x : x.read()) >> findall(b"href=\"") >> cur(len) >> cur("{} hrefs.".format) >> cprint) <--- Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

multithreading

2012-04-07 Thread Kiuhnm
't mix multi-threading libraries. Is Python one of them? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading

2012-04-07 Thread Kiuhnm
example is a job for dict.setdefault(). [...] That was just an example for the sake of the discussion. My question is this: can I use 'threading' without interfering with the program which will import my module? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading

2012-04-08 Thread Kiuhnm
On 4/8/2012 7:04, Bryan wrote: Kiuhnm wrote: My question is this: can I use 'threading' without interfering with the program which will import my module? Yes. The things to avoid are described at the bottom of: http://docs.python.org/library/threading.html On platforms witho

ast.parse

2012-04-09 Thread Kiuhnm
Is it a known fact that ast.parse doesn't handle line continuations and some multi-line expressions? For instance, he doesn't like for (x, y) in each([1, 2]): print(1) at all. Is there a workaround besides "repairing" the code on the

Re: ast.parse

2012-04-09 Thread Kiuhnm
On 4/9/2012 14:43, Irmen de Jong wrote: On 9-4-2012 13:53, Kiuhnm wrote: Is it a known fact that ast.parse doesn't handle line continuations and some multi-line expressions? For instance, he doesn't like for (x, y) in each([1, 2]): print

Re: functions which take functions

2012-04-10 Thread Kiuhnm
On 4/10/2012 14:29, Ulrich Eckhardt wrote: Am 09.04.2012 20:57, schrieb Kiuhnm: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? Take a look at decorators, they not only take non

Re: functions which take functions

2012-04-11 Thread Kiuhnm
On 4/10/2012 23:43, Eelco wrote: On Apr 10, 3:36 am, Kiuhnm wrote: On 4/10/2012 14:29, Ulrich Eckhardt wrote: Am 09.04.2012 20:57, schrieb Kiuhnm: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/11/2012 16:01, Antti J Ylikoski wrote: On 9.4.2012 21:57, Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? Thank you. Kiuhnm A function to numerically integrate

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/12/2012 8:07, Tim Roberts wrote: Kiuhnm wrote: That won't do. A good example is when you pass a function to re.sub, for instance. This is an odd request. All shall be revealed :) I often pass functions to functions in order to simulate a C switch statement, such as in a lan

Re: Zipping a dictionary whose values are lists

2012-04-12 Thread Kiuhnm
], [1,2,3,4])) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Deep merge two dicts?

2012-04-12 Thread Kiuhnm
tes, but this could be the intended behavior. For instance, with the 'a' and 'b' above, the result would be {'a':1} Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/12/2012 19:29, Jan Kuiken wrote: On 4/9/12 20:57 , Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? I don't use it daily but the first argument of list.sort

Re: Zipping a dictionary whose values are lists

2012-04-13 Thread Kiuhnm
On 4/13/2012 17:58, Alexander Blinne wrote: Am 12.04.2012 18:38, schrieb Kiuhnm: Almost. Since d.values() = [[1,2], [1,2,3], [1,2,3,4]], you need to use list(zip(*d.values())) which is equivalent to list(zip([1,2], [1,2,3], [1,2,3,4])) Kiuhnm While this accidently works in this

escaping

2012-04-15 Thread Kiuhnm
This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? This wo

python module

2012-04-16 Thread Kiuhnm
I'd like to share a module of mine with the Python community. I'd like to encourage bug reports, suggestions, etc... Where should I upload it to? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 12:03, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 17:14, Jon Clements wrote: On Monday, 16 April 2012 11:03:31 UTC+1, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', &#x

Re: python module

2012-04-16 Thread Kiuhnm
On 4/16/2012 13:02, Thomas Rachel wrote: Am 16.04.2012 12:23 schrieb Kiuhnm: I'd like to share a module of mine with the Python community. I'd like to encourage bug reports, suggestions, etc... Where should I upload it to? Kiuhnm There are several ways to do this. One of the

Re: python module

2012-04-16 Thread Kiuhnm
On 4/17/2012 1:23, Steven D'Aprano wrote: [...] Wherever you host the code itself, you should also register it on PyPI. Ok, thanks. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Bug in Python

2012-04-17 Thread Kiuhnm
I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: ---> print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() <--- If I debug this code with python -m pdb script.py and I issue the comman

Re: Bug in Python

2012-04-18 Thread Kiuhnm
On 4/18/2012 6:47, Hans Mulder wrote: On 18/04/12 03:08:08, Kiuhnm wrote: print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() I get the same result with Pythin 3.3.0a0 on MacOS X 10.6: 93> ./python.ex

Re: Bug in Python

2012-04-18 Thread Kiuhnm
The bug was confirmed and a patch is now available: http://bugs.python.org/issue14612 Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Framework for a beginner

2012-04-19 Thread Kiuhnm
to defend your language against "infidels". Python is a very good language, but so is Ruby, Scala and many other languages. Denying that fact is deluding oneself. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in Python

2012-04-19 Thread Kiuhnm
On 4/18/2012 3:08, Kiuhnm wrote: I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: ---> print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() <--- If I debug this code with python -m pdb script

Re: Framework for a beginner

2012-04-19 Thread Kiuhnm
On 4/19/2012 14:02, Roy Smith wrote: In article<[email protected]>, Kiuhnm wrote: I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that'

Re: with statement

2012-04-19 Thread Kiuhnm
On 4/19/2012 20:02, Jacob MacDonald wrote: On Thursday, April 19, 2012 10:15:23 AM UTC-7, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. Am I forgetting something? Kiuhnm That sounds about right to me. However

code blocks in Python 2 and 3

2012-04-20 Thread Kiuhnm
Read about it here: http://mtomassoli.wordpress.com/2012/04/20/code-blocks-in-python/ or just download the module from here: https://bitbucket.org/mtomassoli/codeblocks/ The module codeblocks (codeblocks.py) includes a detailed docstring. Kiuhnm -- http://mail.python.org/mailman/listinfo

  1   2   >