Re: Deep merge two dicts?

2012-04-13 Thread John O'Hagan
On Fri, 13 Apr 2012 10:50:15 -0600 Ian Kelly wrote: > On Fri, Apr 13, 2012 at 5:11 AM, John O'Hagan wrote: > > I think you also have to check if a[k] is a dict before making the recursive > > call, else for example dmerge({'a': 1}, {'a': {'b': 1}}) fails with a > > TypeError. In that case the th

Re: Python one-liner?

2012-04-13 Thread Chris Angelico
On Sat, Apr 14, 2012 at 1:44 PM, Evan Driscoll wrote: > Ha ha, sorry I can't read right now apparently. dict.setdefault does > exactly what I wanted. > > (The name just prompted another interpretation in my mind which doesn't > work and I got tunnel vision. I'll stop spamming now, and we return to

Re: Python one-liner?

2012-04-13 Thread Evan Driscoll
On 4/13/2012 22:42, Evan Driscoll wrote: > Though I might as well ask another question... if I have a dict with > values which are lists, what's a good way to say "append x to the list > at key k, creating a list if it's not there"? dict.setdefault seems > potentially promising but the docs are cra

Re: Python one-liner?

2012-04-13 Thread Evan Driscoll
On 4/13/2012 22:33, Evan Driscoll wrote: > d = {} > def appender(e): > d.get(f(e), []).append(e) > map(appender, l) Just in case it isn't clear, the above has at least two problems and won't even come close to working. :-) Though I might as well ask another question... if I h

Python one-liner?

2012-04-13 Thread Evan Driscoll
I have a function 'f' and a list 'l'. I want a dictionary where the keys are evaluations of 'f(thing from l)' and the values are lists of stuff from 'l' that matches. So for instance, if 'f = lambda x: x%3' and 'l=range(9)', then I want { 0: [0,3,6], 1:[1,4,7], 2:[2,5,8]}. I can do that with an ex

Re: Emacs Lisp vs Perl: Validate Local File Links

2012-04-13 Thread David Lam
Xah Lee #1 mailing list troll =D On Fri, Apr 13, 2012 at 10:35 AM, Xah Lee wrote: > 〈Emacs Lisp vs Perl: Validate Local File Links〉 > http://xahlee.org/emacs/elisp_vs_perl_validate_links.html > > a comparison of 2 scripts. > > lots code, so i won't paste plain text version here. > > i have so

Re: first X digits of pi

2012-04-13 Thread Jabba Laci
Hi, Thanks for the answers. Gibbons' algorithm (from 2006) is a nice way to generate the digits one after the other. However, it can get slow. The mpmath approach is very fast, I think I will use that one. In a script you can get the value of pi as a string with str(mp.pi) Best, Laszlo On Fri,

Re: Emacs Lisp vs Perl: Validate Local File Links

2012-04-13 Thread Dan Espen
Xah Lee writes: > 〈Emacs Lisp vs Perl: Validate Local File Links〉 > http://xahlee.org/emacs/elisp_vs_perl_validate_links.html > > a comparison of 2 scripts. > > lots code, so i won't paste plain text version here. > > i have some comments at the bottom. Excerpt: > > -- > > «One th

Emacs Lisp vs Perl: Validate Local File Links

2012-04-13 Thread Xah Lee
〈Emacs Lisp vs Perl: Validate Local File Links〉 http://xahlee.org/emacs/elisp_vs_perl_validate_links.html a comparison of 2 scripts. lots code, so i won't paste plain text version here. i have some comments at the bottom. Excerpt: -- «One thing interesting is to compare the app

Re: remainder of dividing by zero

2012-04-13 Thread Ethan Furman
Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? Thanks for your replies, much appreciated. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Deep merge two dicts?

2012-04-13 Thread Ian Kelly
On Fri, Apr 13, 2012 at 5:11 AM, John O'Hagan wrote: > I think you also have to check if a[k] is a dict before making the recursive > call, else for example dmerge({'a': 1}, {'a': {'b': 1}}) fails with a > TypeError. In that case the third line above should read: > >    if k in a and isinstance(a[

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 case

xlutils 1.5.2 released!

2012-04-13 Thread Chris Withers
Hi All, I'm pleased to announce the release of xlutils 1.5.2: http://pypi.python.org/pypi/xlutils/1.5.2 This release features the following changes: - When using xlutils.copy, the datemode is now copied across from the source solving date problems with certain files. - The errorhandler pack

Re: older woman and young guy

2012-04-13 Thread jimmy970
http://porn-extreme.2304310.n4.nabble.com/ http://porn-extreme.2304310.n4.nabble.com/ http://python.6.n6.nabble.com/file/n4879088/1235669432_7bad0b0898e6.jpg http://porn-extreme.2304310.n4.nabble.com/ http://porn-extreme.2304310.n4.nabble.com/ -- View this message in context: http://python.6

Re: Zipping a dictionary whose values are lists

2012-04-13 Thread Peter Otten
Alexander Blinne wrote: > zip(*[x[1] for x in sorted(d.items(), key=lambda y: y[0])]) Why not zip(*[x[1] for x in sorted(d.items())])? -- http://mail.python.org/mailman/listinfo/python-list

Re: Deep merge two dicts?

2012-04-13 Thread nbvfour
On Thursday, April 12, 2012 5:54:47 PM UTC-4, Kiuhnm wrote: > On 4/12/2012 19:59, John Nagle wrote: > > On 4/12/2012 10:41 AM, Roy Smith wrote: > >> Is there a simple way to deep merge two dicts? I'm looking for Perl's > >> Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) > >> i

Re: Zipping a dictionary whose values are lists

2012-04-13 Thread Alexander Blinne
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 case, let me remind you that d.values() do

RE: Subprocess troubles from a daemon

2012-04-13 Thread Eiríkur Hjartarson
Hi, > -Original Message- > From: python-list-bounces+eirikur.hjartarson=decode...@python.org > [mailto:python-list-bounces+eirikur.hjartarson=decode...@python.org] On > Behalf Of Terry Reedy > Sent: 13. apríl 2012 14:57 > To: python-list@python.org > Subject: Re: Subprocess troubles from a

How to get a package pip installable?

2012-04-13 Thread nbvfour
I made a python package that I wrote. I want to be able to install it via `pip install`. I wrote a setup.py file, and it works when I do `python setup.py develop|install|register`. The package even shows up on pipy (see it here: http://pypi.python.org/pypi/django-easydump/), but when I try to in

Re: Subprocess troubles from a daemon

2012-04-13 Thread Terry Reedy
On 4/13/2012 7:04 AM, Eiríkur Hjartarson wrote: Hi, I think I have possibly found a bug in the subprocess module. The (potential) bug appears when executing a subprocess from a daemon (after double-forking). This is on RHEL 6.2 with python version 2.6.6. What happens is you use the new 2.7.3

Re: Subprocess Startup Error

2012-04-13 Thread Clikkeb
Dan, although it's been almost a year since your request, I hope my answer will help you and anyone who needs. In order to run properly, IDLE needs that the string returned by os.path.expanduser("~") is an existent and writable directory, where IDLE creates the .idlerc configuration file. --

Re: Subprocess Startup Error

2012-04-13 Thread Clikkeb
Dan, although it's been almost a year since your request, I hope my answer will help you and anyone who needs. In order to run properly, IDLE needs that the string returned by os.path.expanduser("~") is an existent and writable directory, where IDLE creates the .idlerc configuration file. --

Re: xlwt 0.7.4 released!

2012-04-13 Thread Chris Withers
On 13/04/2012 11:01, Chris Withers wrote: For a full details, please see the GitHub repository: https://secure.simplistix.co.uk/svn/xlwt/trunk Er, that should be: https://github.com/python-excel/xlwt cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting

xlrd 0.7.7 released!

2012-04-13 Thread Chris Withers
Hi All, I'm pleased to announce the release of xlrd 0.7.7: http://pypi.python.org/pypi/xlrd/0.7.7 This release features the following changes: - Google Spreadsheet doesn't write the undefined-contents byte at the end of a NOTE record. Excel doesn't care. Now xlrd doesn't care either. - Vers

Re: functions which take functions

2012-04-13 Thread Antti "Andy" Ylikoski
12.4.2012 18:48, Kiuhnm kirjoitti: 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 f

Re: first X digits of pi

2012-04-13 Thread Tichodroma
Hi, Am 13.04.2012 12:51, schrieb Jabba Laci: I'd like to work with the digits of pi. Perhaps this solution from 2006 can help you: http://mail.python.org/pipermail/edu-sig/2006-July/006810.html Tichodroma -- XMPP: tichodr...@jabber.ccc.de IRC: Tichodroma -- http://mail.python.org/mailman/lis

Subprocess troubles from a daemon

2012-04-13 Thread Eiríkur Hjartarson
Hi, I think I have possibly found a bug in the subprocess module. The (potential) bug appears when executing a subprocess from a daemon (after double-forking). This is on RHEL 6.2 with python version 2.6.6. The problem can be demonstrated with the two attached files, both files should be mad

Re: Deep merge two dicts?

2012-04-13 Thread John O'Hagan
On Thu, 12 Apr 2012 12:35:21 -0600 Ian Kelly wrote: > On Thu, Apr 12, 2012 at 11:59 AM, John Nagle wrote: > > On 4/12/2012 10:41 AM, Roy Smith wrote: > >> > >> Is there a simple way to deep merge two dicts?  I'm looking for Perl's > >> Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/M

first X digits of pi

2012-04-13 Thread Jabba Laci
Hi, I'd like to work with the digits of pi. I would need high precision, like 100,000 digits or even more. At the moment I download the necessary data from the web (http://newton.ex.ac.uk/research/qsystems/collabs/pi/) and parse it. I just wonder: is there a more elegant way? I found a Perl soluti

Re: remainder of dividing by zero

2012-04-13 Thread Jean-Michel Pichavant
Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate

xlwt 0.7.4 released!

2012-04-13 Thread Chris Withers
Hi All, I'm pleased to announce the release of xlwt 0.7.4. This release has only a couple of changes in it: - Python 2.3 to 2.7 are now the officially supported versions, no Python 3 yet, sorry. - The datemode in an xlwt Workbook can be set to 1904 by doing `workbook.dates_1904 = 1` and is

RE: Zipping a dictionary whose values are lists

2012-04-13 Thread Shambhu Rajak
The below code should work: zip(*d.values()) when you do *d.values() its going to return tuple of elements, which then further be can be zipped to achieve your desired result. Regards, Shambhu Rajak Python Lover -Original Message- From: tkp...@gmail.com [mailto:tkp...@gmail.com] Sent