Re: why the different output in Eclipse and Python Shell?

2012-07-31 Thread Terry Reedy
On 8/1/2012 12:45 AM, levi nie wrote: my code in Eclipse: dict.fromkeys(['China','America']) In Eclipse, I presume this prints nothing, as is normal for an editor. print "dict is",dict output: dict is This is red herring. The shell does the same with that line. It is not relevant to you

why the different output in Eclipse and Python Shell?

2012-07-31 Thread levi nie
my code in Eclipse: dict.fromkeys(['China','America']) print "dict is",dict output: dict is my code in Python Shell: dict.fromkeys(['China','America']) output:{'America': None, 'China': None} Output in Python Shell is what i wanna,but why not in Eclipse? -- http://mail.python.org/mailman/li

Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.

2012-07-31 Thread Pedro Kroger
On Aug 1, 2012, at 12:19 AM, Peter Billam wrote: > I'll check it out. It probably fits into a whole software > ecosystem that you're putting together … yes, I use it for my book, Music for Geeks and Nerds and for teaching. > It's a crowded area, e.g. my midi stuff is at: > http://www.pjb.com.

Re: missing python-config and building python on Windows

2012-07-31 Thread Mark Hammond
On 1/08/2012 10:48 AM, Damon Register wrote: I am attempting to build gtk and glade using mingw/msys. It seems that some of the packages require python. I installed 2.7.3 using the installer from python.org. That worked for some of the packages but now I am trying to do one that needs python-c

Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.

2012-07-31 Thread Peter Billam
On 2012-07-30, Pedro Kroger wrote: > Pyknon is a simple music library for Python hackers. With Pyknon > you can generate Midi files quickly and reason about musical > proprieties. It works with Python 2.7 and 3.2. > ... a basic example to create 4 notes and save into a MIDI file: > from pykn

missing python-config and building python on Windows

2012-07-31 Thread Damon Register
I am attempting to build gtk and glade using mingw/msys. It seems that some of the packages require python. I installed 2.7.3 using the installer from python.org. That worked for some of the packages but now I am trying to do one that needs python-config which I don't find in the installation d

Re: Linux shell to python

2012-07-31 Thread Barry Scott
On 30 Jul 2012, at 23:56, Dan Stromberg wrote: > > On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott wrote: > lspci gets all its information from the files in /sys/bus/pci/devices. > > You can use os.listdir() to list all the files in the folder and then open > the files you want to get the data

Re: NameError vs AttributeError

2012-07-31 Thread Terry Reedy
On 7/31/2012 4:49 PM, Chris Kaynor wrote: On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy mailto:tjre...@udel.edu>> wrote: Another example: KeyError and IndexError are both subscript errors, but there is no SubscriptError superclass, even though both work thru the same mechanism -- __ge

Re: Why 'Flat is better than nested'

2012-07-31 Thread Terry Reedy
On 7/31/2012 5:49 PM, Ian Kelly wrote: On Tue, Jul 31, 2012 at 3:28 PM, Ifthikhan Nazeem wrote: as many as (about) 2*N - log2(N) parent child relationships I would like to know how did you come up with the above formula? Forgive my ignorance. By non-rigorous experimentation, which did not qu

Re: Is Python a commercial proposition ?

2012-07-31 Thread David
On 01/08/2012, lipska the kat wrote: > On 31/07/12 14:52, David wrote: >> >> [1] as in beer >> [2] for research purposes > > There's one (as in 1 above) in the pump for you. Great, more beer => better research => \o/\o/\o/ But, "pump" sounds a bit extreme .. I usually sip contentedly from a glass

Re: simplified Python parsing question

2012-07-31 Thread Chris Angelico
On Tue, Jul 31, 2012 at 11:54 AM, Steven D'Aprano wrote: > Google Docs is, in my opinion, a nasty piece of rubbish > that doesn't run on any of my browsers. As far as I'm concerned, I'd > rather download a Word doc, because at least I can open that in > OpenOffice or Abiword and read it. Something

Re: Why 'Flat is better than nested'

2012-07-31 Thread Ian Kelly
On Tue, Jul 31, 2012 at 3:28 PM, Ifthikhan Nazeem wrote: > as many as (about) 2*N - log2(N) parent child relationships > > I would like to know how did you come up with the above formula? Forgive my > ignorance. I come up with 2N - 2 myself. If there are N leaf nodes and N - 1 non-leaf nodes, th

Re: Why 'Flat is better than nested'

2012-07-31 Thread Ifthikhan Nazeem
*as many as (about) 2*N - log2(N) parent child relationships* * * I would like to know how did you come up with the above formula? Forgive my ignorance. -- Thanks and Best Regards, Iftikhan Nazeem *Skype* : iftecan2000 On Tue, Jul 31, 2012 at 11:04 PM, Terry Reedy wrote: > >>> import this > >

Why 'Flat is better than nested'

2012-07-31 Thread Terry Reedy
>>> import this prints 'The Zen of Python', a poem by Tim Peters that consists of python proverbs such as "Flat is better than nested." (Others things being equal) why? Because it is a restatement of the principle of parsimony, of not multiplying entities without necessity. Suppose we have a

Re: NameError vs AttributeError

2012-07-31 Thread Chris Kaynor
On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote: > Another example: KeyError and IndexError are both subscript errors, but > there is no SubscriptError superclass, even though both work thru the same > mechanism -- __getitem__. The reason is that there is no need for one. In > 'x[y]', x is us

Re: NameError vs AttributeError

2012-07-31 Thread Terry Reedy
On 7/31/2012 6:36 AM, Ulrich Eckhardt wrote: Hi! Using Python 2.7, I stumbled across the fact that 'self.xy' raises an AttributeError if self doesn't have an 'xy' as attribute, but 'xy' will instead raise a NameError. To some extent, these two are very similar, namely that the name 'xy' couldn't

Re: Linux shell to python

2012-07-31 Thread 88888 Dihedral
Mark Lawrence於 2012年7月31日星期二UTC+8下午3時15分32秒寫道: > On 31/07/2012 02:20, Dennis Lee Bieber wrote: > > > On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg > > > declaimed the following in gmane.comp.python.general: > > > > > > > > >> Sigh, and I'm also not keen on multi-line list comprehensions,

Re: Is Python a commercial proposition ?

2012-07-31 Thread lipska the kat
On 31/07/12 14:52, David wrote: On 30/07/2012, lipska the kat wrote: On 30/07/12 14:06, Roy Smith wrote: These days, I'm working on a fairly large web application (songza.com). "We are very sorry to say that due to licensing constraints we cannot allow access to Songza for listeners located

Re: docx/lxml

2012-07-31 Thread Cyrille Leroux
On Tuesday, July 31, 2012 5:13:12 PM UTC+2, Stefan Behnel wrote: > Cyrille Leroux, 31.07.2012 17:01: > > > I'm giving pip a try : > > > > > > > > > 1/ Linux (debian lenny) > > > - (as root) sh setuptools-0.6c11-py2.7.egg (ok) > > > - (as root) cd pip-1.1 ; python setup.py install (ok) > >

Re: Pass data to a subprocess

2012-07-31 Thread andrea crotti
2012/7/31 Laszlo Nagy : >> I think I got it now, if I already just mix the start before another add, >> inside the Process.run it won't see the new data that has been added after >> the start. So this way is perfectly safe only until the process is launched, >> if it's running I need to use some mu

Re: docx/lxml

2012-07-31 Thread Stefan Behnel
Cyrille Leroux, 31.07.2012 17:01: > I'm giving pip a try : > > > 1/ Linux (debian lenny) > - (as root) sh setuptools-0.6c11-py2.7.egg (ok) > - (as root) cd pip-1.1 ; python setup.py install (ok) > - pip : ImportError : No module named pkg_resources > - damn, I guess it's going to be a pain, again

Re: Search and replace text in XML file?

2012-07-31 Thread Paul Rudin
Terry Reedy writes: > ... a proper text-editor* > * ... Notepad++ is one such on Windows. Surely emacs is the only such on any platform? :) -- http://mail.python.org/mailman/listinfo/python-list

Re: docx/lxml

2012-07-31 Thread Cyrille Leroux
On Tuesday, July 31, 2012 4:00:25 PM UTC+2, Pedro Kroger wrote: > On Jul 31, 2012, at 10:36 AM, Cyrille Leroux wrote: > > > > > - Do you know any *easy to use*, *easy to deploy* package to generate ".doc > > like" documents ? > > > - Do you have any suggestion to do it differently (maybe with

Re: Pass data to a subprocess

2012-07-31 Thread Laszlo Nagy
> I think I got it now, if I already just mix the start before another add, inside the Process.run it won't see the new data that has been added after the start. So this way is perfectly safe only until the process is launched, if it's running I need to use some multiprocess-aware data structur

Re: Pass data to a subprocess

2012-07-31 Thread andrea crotti
> > > def procs(): > mp = MyProcess() > # with the join we are actually waiting for the end of the running time > mp.add([1,2,3]) > mp.start() > mp.add([2,3,4]) > mp.join() > print(mp) > I think I got it now, if I already just mix the start before another add, inside th

Firefox 3.6 [OT] (was: Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.)

2012-07-31 Thread Andrew Berg
On 7/30/2012 9:25 PM, Steven D'Aprano wrote: > I don't. But in my experience, the risk of security breaches is *much* > less than the chance that the new version will break functionality, > introduce bugs, have a worse user interface, and generally be a step > backwards rather than forward. 4.0

Re: docx/lxml

2012-07-31 Thread Pedro Kroger
On Jul 31, 2012, at 10:36 AM, cyrille.ler...@gmail.com wrote: > - Do you know any *easy to use*, *easy to deploy* package to generate ".doc > like" documents ? > - Do you have any suggestion to do it differently (maybe with native packages > ?) > > - As a python newby, I don't understand why y

Re: Is Python a commercial proposition ?

2012-07-31 Thread David
On 30/07/2012, lipska the kat wrote: > On 30/07/12 14:06, Roy Smith wrote: >> >> These days, I'm working on a fairly large web application (songza.com). > > "We are very sorry to say that due to licensing constraints we cannot > allow access to Songza for listeners located outside of the United St

docx/lxml

2012-07-31 Thread cyrille . leroux
Hello, I'm trying to use the docx package to generate documents containing some text and tables. I don't want to install any module since I just want my coworkers to copy a directory and run a script, without installing tons of softwares (Just python2.7 which is already installed). First, I d

Re: profiling and optimizing

2012-07-31 Thread Peter Otten
Rita wrote: > I recently inherented a large python process and everything is lovely. As > a learning experience I would like to optimize the code so I ran it thru > the profiler > > python -m cProfile myscript.py > > It seems majority of the time is taking in the deep copy but that seems to > co

Re: argparse limitations

2012-07-31 Thread Benoist Laurent
> The standard way, however, is to have a parser that takes the first > non-option argument as a subcommand name and parses the remaining arguments > according to that subcommand. Your command line users are more likely to be > able to understand how to use the program if it works that way. I'l

Re: argparse limitations

2012-07-31 Thread Oscar Benjamin
On 31 July 2012 13:51, Benoist Laurent wrote: > > Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit : > > > > On 31 July 2012 12:03, Benoist Laurent wrote: > >> Finally. >> >> The code I proposed doesn't work in this case: if you add any positional >> argument to one of the subparsers, then the

Re: py2c - an open source Python to C/C++ is looking for developers

2012-07-31 Thread Stefan Behnel
Stefan Behnel, 31.07.2012 07:23: > From a look at the source code, it seems hard to bring it together with > anything. It looks very monolithic. Hmm, sorry, I mixed it up with "2c.py", which is yet another of those Python-to-C compilers with an all too similar name. https://code.google.com/p/2c-p

Re: argparse limitations

2012-07-31 Thread Benoist Laurent
Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit : > > > On 31 July 2012 12:03, Benoist Laurent wrote: > Finally. > > The code I proposed doesn't work in this case: if you add any positional > argument to one of the subparsers, then the parsing doesn't work anymore. > The reason seems to be

Re: profiling and optimizing

2012-07-31 Thread Oscar Benjamin
On 31 July 2012 13:13, Rita wrote: > hello, > > I recently inherented a large python process and everything is lovely. As > a learning experience I would like to optimize the code so I ran it thru > the profiler > > python -m cProfile myscript.py > > It seems majority of the time is taking in the

Re: profiling and optimizing

2012-07-31 Thread Stefan Behnel
Rita, 31.07.2012 14:13: > I recently inherented a large python process and everything is lovely. As a > learning experience I would like to optimize the code so I ran it thru the > profiler > > python -m cProfile myscript.py > > It seems majority of the time is taking in the deep copy but that se

Re: profiling and optimizing

2012-07-31 Thread Chris Angelico
On Tue, Jul 31, 2012 at 10:13 PM, Rita wrote: > It seems majority of the time is taking in the deep copy but that seems to > come from a function (or functions) in the code. Is there a way to optimize > that? Why is the program deep-copying things? Rather than making deepcopy faster, consider doi

Re: Is Python a commercial proposition ?

2012-07-31 Thread Roy Smith
In article <50177b4d$0$29867$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Do they consider that perhaps there are alternatives to threads? There's basically two reasons people use threads. First is because it's a convenient way to multiplex short-lived tasks on a single proce

Re: OT: accessibility (was "Re: simplified Python parsing question")

2012-07-31 Thread Eric S. Johansson
On 7/30/2012 10:54 PM, Tim Chase wrote: On 07/30/12 21:11, Eric S. Johansson wrote: the ability for multiple people to work on the same document at the same time is really important. Can't do that with Word or Libre office. revision tracking in traditional word processors are unpleasant to work

Re: argparse limitations

2012-07-31 Thread Oscar Benjamin
On 31 July 2012 12:03, Benoist Laurent wrote: > Finally. > > The code I proposed doesn't work in this case: if you add any positional > argument to one of the subparsers, then the parsing doesn't work anymore. > The reason seems to be that argparse thinks the last argument of the first > parser i

NameError vs AttributeError

2012-07-31 Thread Ulrich Eckhardt
Hi! Using Python 2.7, I stumbled across the fact that 'self.xy' raises an AttributeError if self doesn't have an 'xy' as attribute, but 'xy' will instead raise a NameError. To some extent, these two are very similar, namely that the name 'xy' couldn't be resolved in a certain context, but the

Re: Linux shell to python

2012-07-31 Thread Alister
On Tue, 31 Jul 2012 08:15:32 +0100, Mark Lawrence wrote: > On 31/07/2012 02:20, Dennis Lee Bieber wrote: >> On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg >> declaimed the following in gmane.comp.python.general: >> >> >>> Sigh, and I'm also not keen on multi-line list comprehensions, >>> speci

Re: argparse limitations

2012-07-31 Thread Benoist Laurent
Finally. The code I proposed doesn't work in this case: if you add any positional argument to one of the subparsers, then the parsing doesn't work anymore. The reason seems to be that argparse thinks the last argument of the first parser is the last but one argument. Hence, if a subparser takes

Re: argparse limitations

2012-07-31 Thread Benoist Laurent
Really sorry about that. So, for the community, below is the full code for a tool that behaves like a Unix standard tool. It takes in argument the files to process and a command. """Just to setup a command-line parser that acts just like a unix standard tool.""" import argparse import sys def

Re: argparse limitations

2012-07-31 Thread Oscar Benjamin
On Jul 31, 2012 10:32 AM, "Benoist Laurent" wrote: > > Well sorry about that but it seems I was wrong. > It was Friday evening and I guess I've not been careful. > > Actually when you specify nargs="?", the doc says "One argument will be consumed from the command line if possible, and produced as

Re: argparse limitations

2012-07-31 Thread Benoist Laurent
Well sorry about that but it seems I was wrong. It was Friday evening and I guess I've not been careful. Actually when you specify nargs="?", the doc says "One argument will be consumed from the command line if possible, and produced as a single item". So you can't pass several arguments to the

Re: Linux shell to python

2012-07-31 Thread Chris Angelico
On Tue, Jul 31, 2012 at 5:15 PM, Mark Lawrence wrote: > On 31/07/2012 02:20, Dennis Lee Bieber wrote: >> >> should be pecked to death by a dead parrot. >> > > Any particular species? I'm sure that, if you're in Norway, you could find an appropriate bird. But for those of us for whom that's not an

Re: Linux shell to python

2012-07-31 Thread Mark Lawrence
On 31/07/2012 02:20, Dennis Lee Bieber wrote: On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg declaimed the following in gmane.comp.python.general: Sigh, and I'm also not keen on multi-line list comprehensions, specifically because I think they tend to make less readable code. It also beco