Re: creating class objects inside methods

2009-10-03 Thread horos11
> It's not a bug.  In Python classes and global variables share the same > namespace. > > Don't you think you should learn a bit more about how Python manages > objects and namespaces before going around calling things bugs? > > Carl Banks No, I don't think so.. Say you went to another country,

Re: defaults for function arguments bound only once(??)

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 11:29 PM, horos11 wrote: > All, > > Another one, this time a bit shorter. > > It looks like defaults for arguments are only bound once, and every > subsequent call reuses the first reference created. Hence the > following will print '[10,2]' instead of the expected '[1,2]'.

defaults for function arguments bound only once(??)

2009-10-03 Thread horos11
All, Another one, this time a bit shorter. It looks like defaults for arguments are only bound once, and every subsequent call reuses the first reference created. Hence the following will print '[10,2]' instead of the expected '[1,2]'. Now my question - exactly why is 'default_me()' only called

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
And this code time limits (no matter with or without Psyco): import psyco psyco.full() import sys def foo(): ##sys.stdin = open('D:/1583.txt', 'rt') sys.stdin.readline() while 1: try: x, y = sys.stdin.readline().split() sys.stdout.write(str(int(x) * in

Re: creating class objects inside methods

2009-10-03 Thread horos11
Carl, Thanks for the info, but a couple of points: 1. it wasn't meant to be production code, simply a way to teach python. 2. this should either be a compile time or a runtime error. 'Actions at a distance' like this are deadly both to productivity and to correctness - not only is this

Re: creating class objects inside methods

2009-10-03 Thread Carl Banks
On Oct 3, 10:34 pm, horos11 wrote: > Anyways, I see what's going on here: > > With the line, > > for state in curstate.next_states(): >     if not state.to_string() in seen_states: >         dq.append(state) > > Inadvertently using the name of a module as a variable seems to be > causing this. No

Re: creating class objects inside methods

2009-10-03 Thread Carl Banks
On Oct 3, 10:12 pm, horos11 wrote: > > >>> a > > > <__main__.Myclass instance at 0x95cd3ec b > > > <__main__.Myclass instance at 0x95cd5ac> > > > What's the problem? > > Like I said, the code was a sample of what I was trying to do, not the > entire thing.. I just wanted to see if the metaphor

Re: Threaded GUI slowing method execution?

2009-10-03 Thread Aaron Hoover
On Oct 2, 2009, at 1:18 PM, sturlamolden wrote: On 2 Okt, 21:30, Dave Angel wrote: There could very well be multiprocess support in wxPython. I'd check there first, before re-inventing the wheel. I don't think there is. But one can easily make a thread in the subprocess that polls a pipe

Re: Enormous Input and Output Test

2009-10-03 Thread John Yeung
On Oct 3, 11:58 pm, n00m wrote: > > Do you know how big the input data set actually is? > > Of course, I don't know exact size of input. > It's several MBs, I guess. And mind the fact: > their testing machines are PIII (750MHz). You know the maximum size of the input, if you can trust the problem

Re: creating class objects inside methods

2009-10-03 Thread horos11
Anyways, I see what's going on here: With the line, for state in curstate.next_states(): if not state.to_string() in seen_states: dq.append(state) Inadvertently using the name of a module as a variable seems to be causing this. In any case, this shouldn't cause issues with construct

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
And *without* Psyco the above code gets TLE verdict... A kind of mystery :( -- http://mail.python.org/mailman/listinfo/python-list

Re: creating class objects inside methods

2009-10-03 Thread horos11
> >>> a > > <__main__.Myclass instance at 0x95cd3ec b > > <__main__.Myclass instance at 0x95cd5ac> > > What's the problem? Like I said, the code was a sample of what I was trying to do, not the entire thing.. I just wanted to see if the metaphor was kosher. It sounds to me from your answer t

Re: Identify runs in list

2009-10-03 Thread Paul Rubin
"skorpi...@gmail.com" writes: > Any suggestions would be appreciated Look at the docs of the groupby function in the itertools module. -- http://mail.python.org/mailman/listinfo/python-list

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
> On my machine, the above code handles ~50MB in ~10sec. Means their input > 40-50MB 2. I just see: two guys did it in Python and I feel myself curious "how on earth?". -- http://mail.python.org/mailman/listinfo/python-list

Re: Enormous Input and Output Test

2009-10-03 Thread alex23
On Oct 4, 1:58 pm, n00m wrote: > > Do you know how big the input data set actually is? > > Of course, I don't know exact size of input. > It's several MBs, I guess. And mind the fact: > their testing machines are PIII (750MHz). Well, then, that's moved the problem from "challenging" to "ludicrous

Re: Dictionary with Lists

2009-10-03 Thread John Nagle
Shaun wrote: Hi, I'm trying to create a dictionary with lists as the value for each key. I was looking for the most elegant way of doing it... Try using a tuple, instead of a list, for each key. Tuples are immutable, so there's no issue about a key changing while being used in a dictiona

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
> Do you know how big the input data set actually is? Of course, I don't know exact size of input. It's several MBs, I guess. And mind the fact: their testing machines are PIII (750MHz). -- http://mail.python.org/mailman/listinfo/python-list

Re: creating class objects inside methods

2009-10-03 Thread Simon Forman
On Sat, Oct 3, 2009 at 11:32 PM, horos11 wrote: > All, > > I've got a strange one.. > > I'm trying to create a class object inside another class object by > using the code template below (note.. this isn't the exact code.. I'm > having difficulty reproducing it without posting the whole thing) > >

Re: Enormous Input and Output Test

2009-10-03 Thread alex23
On Oct 3, 11:54 pm, n00m wrote: > I need your help to understand howhttp://www.spoj.pl/problems/INOUTEST/ > can be passed in Python. > > My code for this is: > === > import psyco > psyco.full() > > import sys > > def noo(b): >     b = b.split() >     return

creating class objects inside methods

2009-10-03 Thread horos11
All, I've got a strange one.. I'm trying to create a class object inside another class object by using the code template below (note.. this isn't the exact code.. I'm having difficulty reproducing it without posting the whole thing) Anyways, the upshot is that the first time the Myclass() constr

Re: The Python: Rag October issue available

2009-10-03 Thread TerryP
On Oct 3, 4:29 pm, Bernie wrote: > Hi, no -its just put on the website.  Unless there's a method you can > suggest? Not to butt in, but off the top of my head, you could probably set up a mailing list and post the link to the file every cycle - simple but effective. -- http://mail.python.org/mai

Re: Identify runs in list

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 7:53 PM, skorpi...@gmail.com wrote: > On Oct 3, 10:36 pm, Chris Rebert wrote: >> Since this sounds like homework, I won't give actual code, but here's >> a gameplan: >> >> 1. Split the list into sublists based on where the runs of zeros stop and >> start. >> 2. Categorize

Re: Identify runs in list

2009-10-03 Thread skorpi...@gmail.com
On Oct 3, 10:36 pm, Chris Rebert wrote: > On Sat, Oct 3, 2009 at 7:21 PM, skorpi...@gmail.com > wrote: > > Hi all, > > > I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 > > 5 0 0 7 0 0 0 0 0 12 0 0 4] > > > I would like to extract three list from this data: > > > 1) runsOfZ

Re: Identify runs in list

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 7:21 PM, skorpi...@gmail.com wrote: > Hi all, > > I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 > 5 0 0 7 0 0 0 0 0 12 0 0 4] > > I would like to extract three list from this data: > > 1) runsOfZero: [3 4 5] > 2) runsOfNonZero: [3 8 4] > 3) SumOfRunsO

Identify runs in list

2009-10-03 Thread skorpi...@gmail.com
Hi all, I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 5 0 0 7 0 0 0 0 0 12 0 0 4] I would like to extract three list from this data: 1) runsOfZero: [3 4 5] 2) runsOfNonZero: [3 8 4] 3) SumOfRunsOfNonZero: [8 17 16] Any suggestions would be appreciated -- http://mail.pyt

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
PS Time Limit for this problem = 20s -- http://mail.python.org/mailman/listinfo/python-list

Re: Enormous Input and Output Test

2009-10-03 Thread n00m
On Oct 4, 2:29 am, Chris Rebert wrote: > > That line is probably a Very Bad Idea (TM) as it reads the *entire* > enormous file into memory *at once*. It would probably be much better > to iterate over the file, thus only reading one individual line at a > time. I'm betting the massive malloc()ing

Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-03 Thread Grant Edwards
On 2009-10-03, ryniek90 wrote: > So, whether it is or has been planned the core Python > implementation of *scanf()* ? One of the fist things I remember being taught as a C progrmmer was to never use scanf. Programs that use scanf tend to fail in rather spectacular ways when presented with simp

Re: Calendar yr-mnth-day data to day since data

2009-10-03 Thread skorpi...@gmail.com
On Oct 3, 6:35 am, Piet van Oostrum wrote: > > "skorpi...@gmail.com" (sc) wrote: > >sc> Hi all, > >sc> I have some calendar data in three arrays corresponding to yr, month, > >sc> day that I would like to convert to day since data and be consistent > >sc> with changes in leap year. I've inclu

Problem with subprocess module on Windows with open file in append mode

2009-10-03 Thread Andrew Savige
When I run this little test program on Linux: import subprocess subprocess.call(["python","-V"], stderr=open("log.tmp","a")) the file log.tmp is appended to each time I run it. When I run it on Windows, however, the file log.tmp gets overwritten each time I run it. Though I can make it append on

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Michel Alexandre Salim
On Oct 2, 7:33 pm, Xah Lee wrote: > Haskell has a new logo. A fantastic one. Beautiful. For creator, > context, detail, see bottom of: > > • A Lambda Logo Tour >  http://xahlee.org/UnixResource_dir/lambda_logo.html Interesting.. rant. Thanks for the logo collection, though, some of them are visua

Re: Enormous Input and Output Test

2009-10-03 Thread Terry Reedy
n00m wrote: Hi, py.folk! I need your help to understand how http://www.spoj.pl/problems/INOUTEST/ can be passed in Python. I see two guys who managed to get accepted: http://www.spoj.pl/ranks/INOUTEST/lang=PYTH My code for this is: === import psyco psyco

Re: Enormous Input and Output Test

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 6:54 AM, n00m wrote: > Hi, py.folk! > > I need your help to understand how > http://www.spoj.pl/problems/INOUTEST/ > can be passed in Python. > def foo(): >    ##sys.stdin = open('D:/1583.txt', 'rt') >    a = sys.stdin.readlines() That line is probably a Very Bad Idea (TM)

Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-03 Thread MRAB
ryniek90 wrote: Hi I know that in python, we can do the same with regexps or *.split()*, but thats longer and less practical method than *scanf()*. I also found that ( http://code.activestate.com/recipes/502213/ ), but the code doesn't looks so simple for beginners. So, whether it is or has b

Re: Dictionary with Lists

2009-10-03 Thread Mel
Shaun wrote: > testDict = {} > ... > testDict [1] = testDict.get (1, []).append ("Test0") # 1 does not > exist, create empty array > print testDict > testDict [1] = testDict.get (1, []).append ("Test1") > print testDict > [ ... ] > However, the first printout gives {1: None} instead of the desir

Re: Dictionary with Lists

2009-10-03 Thread Mick Krippendorf
Hi, Shaun wrote: > I'm trying to create a dictionary with lists as the value for each > key. I was looking for the most elegant way of doing it... from collections import defaultdict d = defaultdict(list) d["joe"].append("something") d["joe"].append("another") d["jim"].append("slow down, gras

Is pythonic version of scanf() or sscanf() planned?

2009-10-03 Thread ryniek90
Hi I know that in python, we can do the same with regexps or *.split()*, but thats longer and less practical method than *scanf()*. I also found that ( http://code.activestate.com/recipes/502213/ ), but the code doesn't looks so simple for beginners. So, whether it is or has been planned the

Dictionary with Lists

2009-10-03 Thread Shaun
Hi, I'm trying to create a dictionary with lists as the value for each key. I was looking for the most elegant way of doing it... I thought this would work: testDict = {} ... testDict [1] = testDict.get (1, []).append ("Test0") # 1 does not exist, create empty array print testDict testDict [1]

Re: question about the GC implementation

2009-10-03 Thread ryles
On Oct 2, 11:20 am, Francis Moreau wrote: > Hello, > > I'm looking at gcmodule.c and in move_unreachable() function, the code > assumes that if an object has its gc.gc_refs stuff to 0 then it *may* > be unreachable. > > How can an object tagged as unreachable could suddenly become > reachable late

Re: PIL : How to write array to image ???

2009-10-03 Thread Peter Otten
Martin wrote: > Dear group > > I'm trying to use PIL to write an array (a NumPy array to be exact) to > an image. > Peace of cake, but it comes out looking strange. > > I use the below mini code, that I wrote for the purpose. The print of > a looks like expected: > > [[ 200. 200. 200. ...,

Re: Customizing Option Elements

2009-10-03 Thread Laszlo Nagy
I want to create elements within a element in which I could insert html, which, of course, is illegal (don't tell the police ;) so I'm looking at recreating the form elements using my own customized elements, that is, hacking the equivalent from scratch, but how do I proceed? I would like t

Re: PIL : How to write array to image ???

2009-10-03 Thread Robert Kern
Martin wrote: Dear group I'm trying to use PIL to write an array (a NumPy array to be exact) to an image. Peace of cake, but it comes out looking strange. I use the below mini code, that I wrote for the purpose. The print of a looks like expected: [[ 200. 200. 200. ...,0.0.0.] [

Re: Python resident memory retention & Evan Jones' improvements

2009-10-03 Thread Matt Ernst
On Oct 2, 4:47 pm, Andrew MacIntyre wrote: > There are two things you need to be aware of in this situation: > > - not all Python's memory is allocated through Python's specialised >    malloc() - int and float objects in particular (in 2.x at least) are >    allocated directly via a privately man

Re: Q: sort's key and cmp parameters

2009-10-03 Thread Paul Rubin
kj writes: > !!! > > Maybe Haskell is much handier than I give it credit for, but it's > hard for me to imagine that it is as convenient as Python 3, even > without the cmp sort option... Heh, yeah, I was being a bit snarky/grouchy. Haskell has a very steep learning curve and will never be as

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Jack Diederich
It's Xah Lee, he's been trolling this and every other programing language group for over 10 years (preferably all at once). Let it go. On Sat, Oct 3, 2009 at 2:53 AM, Chris Withers wrote: > Xah Lee wrote: >> >> Haskell has a new logo. A fantastic one. Beautiful. For creator, >> context, detail,

PIL : How to write array to image ???

2009-10-03 Thread Martin
Dear group I'm trying to use PIL to write an array (a NumPy array to be exact) to an image. Peace of cake, but it comes out looking strange. I use the below mini code, that I wrote for the purpose. The print of a looks like expected: [[ 200. 200. 200. ...,0.0.0.] [ 200. 200. 200

Re: AJAX Widget Framework

2009-10-03 Thread Mathias Waack
Laszlo Nagy wrote: > I'm looking for an open source, AJAX based widget/windowing framework. > Here is what I need: > > - end user opens up a browser, points it to a URL, logs in > - on the server site, sits my application, creating a new session for > each user that is logged in > - on the server

Re: The Python: Rag October issue available

2009-10-03 Thread Bernie
On Fri, 02 Oct 2009 11:32:41 -0700, steven.oldner wrote: Hi, no -its just put on the website. Unless there's a method you can suggest? Cheers Bernie > On Oct 2, 11:14 am, Bernie wrote: >> The Python: Rag October issue available >> >> The October issue of The Python: Rag is available at

Re: Q: sort's key and cmp parameters

2009-10-03 Thread kj
In <7xtyyhikrl@ruckus.brouhaha.com> Paul Rubin writes: >Python 2.x provides two ways >and you can use whichever one fits the application better. I have >never understood why Python 3.x finds it necessary to break one of >them. Maybe I can migrate to Haskell by

Customizing Option Elements

2009-10-03 Thread Victor Subervi
Hi; I want to create elements within a element in which I could insert html, which, of course, is illegal (don't tell the police ;) so I'm looking at recreating the form elements using my own customized elements, that is, hacking the equivalent from scratch, but how do I proceed? I would like to

Re: Regular expression to structure HTML

2009-10-03 Thread 504cr...@gmail.com
On Oct 2, 11:14 pm, greg wrote: > Brian D wrote: > > This isn't merely a question of knowing when to use the right > > tool. It's a question about how to become a better developer using > > regular expressions. > > It could be said that if you want to learn how to use a > hammer, it's better to pr

Re: setuptools, accessing ressource files

2009-10-03 Thread PJ Eby
On Oct 2, 7:04 am, Patrick Sabin wrote: > I use setuptools to create a package. In this package I included some > images and I checked that they are in the egg-file. The problem is how > can I access the images in the package? > > I tried pkgutil.get_data, but only got an IOError, because the EGG-

Enormous Input and Output Test

2009-10-03 Thread n00m
Hi, py.folk! I need your help to understand how http://www.spoj.pl/problems/INOUTEST/ can be passed in Python. I see two guys who managed to get accepted: http://www.spoj.pl/ranks/INOUTEST/lang=PYTH My code for this is: === import psyco psyco.full() impor

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Nick Keighley
On 3 Oct, 00:33, Xah Lee wrote: > Haskell has a new logo. A fantastic one. Beautiful. For creator, > context, detail, see bottom of: > > • A Lambda Logo Tour >  http://xahlee.org/UnixResource_dir/lambda_logo.html I'm amazed he thinks anyone would donate 3 USD to that site -- http://mail.python

Need feedback on subprocess-using function

2009-10-03 Thread gb345
I'm relatively new to Python, and I'm trying to get the hang of using Python's subprocess module. As an exercise, I wrote the Tac class below, which can prints output to a file "in reverse order", by piping it through the Unix tac utility. (The idea is to delegate the problem of managing the m

Re: Fast decimal arithmetic module released

2009-10-03 Thread Stefan Krah
Mark Dickinson wrote: > On Oct 2, 8:53 pm, Stefan Krah wrote: > > Hi, > > > > today I have released the following packages for fast arbitrary precision > > decimal arithmetic: > > > [...] > > Nice! I'd been wondering how you'd been finding all those decimal.py > bugs. Now I know. :) Thanks!

Re: Calendar yr-mnth-day data to day since data

2009-10-03 Thread Piet van Oostrum
> "skorpi...@gmail.com" (sc) wrote: >sc> Hi all, >sc> I have some calendar data in three arrays corresponding to yr, month, >sc> day that I would like to convert to day since data and be consistent >sc> with changes in leap year. I've included a sample of the data >sc> structures below. Any

Re: Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-03 Thread Piet van Oostrum
> subeen (s) wrote: >s> Hi, >s> I am trying to send compressed data to a server written in django. But >s> it shows error while decompressing the data in the server. After some >s> experiment I found that the server is not receiving the exact data I >s> am sending. >s> data = 'hello, this is

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Tim Rowe
2009/10/3 Xah Lee : > for my criticism or comment on logos, typical response by these people > are showcases of complete ignorance of social function of logos [snip and rearrange] > discussed now and then in these communities often without my > involvement. > “you are a fucking idiot... > moth

Re: unicode text file

2009-10-03 Thread Junaid
On Sep 27, 6:39 pm, "Mark Tolonen" wrote: > "Junaid" wrote in message > > news:0267bef9-9548-4c43-bcdf-b624350c8...@p23g2000vbl.googlegroups.com... > > >I want to do replacements in a utf-8 text file. example > > > f=open("test.txt","r") #this file is uft-8 encoded > > raw = f.read() > > txt = ra

Re: Q: sort's key and cmp parameters

2009-10-03 Thread Paul Rubin
Paul Rubin writes: > c = compare(tree1['left'], tree2['left']) Of course this recursive call crashes if either branch is None. Oh well, I'll stop trying to correct it since I'm sure you get the idea. -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Donn
Great description - wish the Python docs could be as clear. Thanks. \d -- http://mail.python.org/mailman/listinfo/python-list

re.sub do not replace portion of match

2009-10-03 Thread J Wolfe
Hi, Is there a way to flag re.sub not to replace a portion of the string? I have a very long string that I want to add two new line's to rather than one, but keep the value X: string = "testX.\n.today" <-- note X is a value string = re.sub("testX.\n.","testX.\n\n.", stri

The Python: Rag October issue available

2009-10-03 Thread Bernie
The Python: Rag October issue available The October issue of The Python: Rag is available at: http://www.pythonrag.org A monthly, free, community run, Python magazine - issues are in pdf format, intended for anyone interested in Python, without being particularly serious. If you have anythi

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Steven D'Aprano
On Sat, 03 Oct 2009 10:24:13 +0200, Stef Mientki wrote: > I still don't use (because I don't fully understand them) packages, but > by trial and error I found a reasonable good working solution, with the > following specifications I find that fascinating. You haven't used packages because you don

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Robert H
http://blog.plover.com/prog/haskell/logo.html Oops... -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub do not replace portion of match

2009-10-03 Thread Duncan Booth
J Wolfe wrote: > Hi, > > Is there a way to flag re.sub not to replace a portion of the string? > > I have a very long string that I want to add two new line's to rather > than one, but keep the value X: > > string = "testX.\n.today" <-- note X is a value > string = re.sub("test...

Re: Threaded GUI slowing method execution?

2009-10-03 Thread sturlamolden
On 2 Okt, 21:30, Dave Angel wrote: > There could very well be multiprocess support in wxPython.  I'd check > there first, before re-inventing the wheel. I don't think there is. But one can easily make a thread in the subprocess that polls a pipe and calls wx.PostEvent or wx.CallLater when someth

Calendar yr-mnth-day data to day since data

2009-10-03 Thread skorpi...@gmail.com
Hi all, I have some calendar data in three arrays corresponding to yr, month, day that I would like to convert to day since data and be consistent with changes in leap year. I've included a sample of the data structures below. Any suggestions??? Thanks in advance yr mnthday

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Steven D'Aprano
On Fri, 02 Oct 2009 18:14:44 -0700, bukzor wrote: > I would assume that putting scripts into a folder with the aim of re- > using pieces of them would be called a package, A package is a special arrangement of folder + modules. To be a package, there must be a file called __init__.py in the fol

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Stef Mientki
bukzor wrote: I would assume that putting scripts into a folder with the aim of re- using pieces of them would be called a package, but since this is an "anti-pattern" according to Guido, apparently I'm wrong-headed here. (Reference: http://mail.python.org/pipermail/python-3000/2007-April/006793.

Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-03 Thread subeen
Hi, I am trying to send compressed data to a server written in django. But it shows error while decompressing the data in the server. After some experiment I found that the server is not receiving the exact data I am sending. data = 'hello, this is a test message this is another message' data = z

Re: Q: sort's key and cmp parameters

2009-10-03 Thread Paul Rubin
Paul Rubin writes: > Example comparison function: > > def compare(tree1, tree2): > c = cmp(tree1['value'], tree2['value']) > if c != 0: return c > c = cmp(tree1['left'], tree2['left']) > if c != 0: return c > return cmp(tree1['right'], tree

Re: Q: sort's key and cmp parameters

2009-10-03 Thread Paul Rubin
Raymond Hettinger writes: > Can you give an example of a list of trees and a cmp function > that recursively compares them? Example of list of trees (nested dicts). In practice you could get such a list from the simplejson module: list_of_trees = [{'value':1, 'left':{'value':3,'left':None,'r

Re: Opinions, please, on PEP 8 and local, 3rd party imports

2009-10-03 Thread Francesco Bochicchio
On Oct 2, 9:50 pm, Philip Semanchuk wrote: > Hi all, > > PEP 8 says the following: > >     Imports should be grouped in the following order: >     1. standard library imports >     2. related third party imports >     3. local application/library specific