Re: Sorting dict keys

2007-07-20 Thread Alex Popescu
Miles <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On 7/20/07, Alex Popescu <[EMAIL PROTECTED]> wrote: >> If you just want to iterate over your dict in an ordered manner than >> all you have to do is: >> >> for k in my_dict.keys().sort(): >> # rest of the code > > I think you meant s

Re: Pythonic way for missing dict keys

2007-07-20 Thread Steven D'Aprano
On Fri, 20 Jul 2007 19:08:57 +, Alex Popescu wrote: > I am wondering what is the most pythonic way of dealing with missing > keys and default values. [snip three versions] Others have already mentioned the collections.defaultdict type, however it seems people have forgotten about the setdef

Re: Sorting dict keys

2007-07-20 Thread Steven D'Aprano
On Fri, 20 Jul 2007 15:27:51 -0700, montyphyton wrote: b = a.keys() b.sort() > [1, 2, 3] > > Works fine, but I would really like it if I could somehow do it in one > line. Why? Is the Enter key on your keyboard broken? Is there a global shortage of newline characters that I haven't be

converting 64-bit fixed-point to float

2007-07-20 Thread John Fisher
Hi Group, troubles with converting signed 32.32, little-endian, 2's complement back to floating point. I have been trying to brew it myself. I am running Python 2.5 on a Mac. Here is the C-code I have been trying to leverage: double FPuint8ArrayToFPDouble(uint8 *buffer, int startIndex) { uin

RE: code packaging

2007-07-20 Thread Ryan Ginstrom
> On Behalf Of Paul Rubin > I'm wondering how other projects go about this. I develop an automated build system from the very beginning. Running the build script: * Creates the API documentation (epydoc) * Creates the help files (extracting some information from the source) * Builds a windows exec

◙►FREE Satellite TV on your PC◄◙

2007-07-20 Thread Dan C
Watch Free Satellite TV on your PC or Laptop Instantly Turn your Computer into a Super TV • Watch all your favorite shows on your Computer & TV! • Channels you can’t get any other place in the U.S.A! • Watch from anywhere in the world! • Save 1000's of $$$ over many years on cable and satellite

Re: converting 64-bit fixed-point to float

2007-07-20 Thread Michael Tobis
It appears to be correct for positive numbers. if conval >= 2**16: conval -= 2**32 would appear to patch things up. It's not very pretty, though. You could at least start with input1 = [c_ushort(item) for item in input] instead of your first 9 lines. mt -- http://mail.python.org/mailman/

Python in Nashville

2007-07-20 Thread Patrick Altman
Anyone on this group writing Python code in Nashville, TN? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way for missing dict keys

2007-07-20 Thread Rustom Mody
Can someone who knows about python internals throw some light on why >>> x in dic is cheaper than >>> dic.has_key(x) ?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way for missing dict keys

2007-07-20 Thread Carsten Haese
On Sat, 21 Jul 2007 09:22:32 +0530, Rustom Mody wrote > Can someone who knows about python internals throw some light on why > >>> x in dic > is cheaper than > >>> dic.has_key(x) > > ?? I won't claim to know Python internals, but compiling and disassembling the expressions in question reveals the

Re: NTLM APS python version 0.98

2007-07-20 Thread Jay Loden
pycraze wrote: > Hi , > > I am working on NTLM (Windows NT Lan Manager )APS > (Authentication Proxy Server ) , to port to C language . the 'wget' utility supports NTLM authentication as of version 1.1.0 or so, you might try just looking at the C source code to wget if you're looking to imp

Permutations with generators

2007-07-20 Thread Pablo Torres
Hey guys! For the last couple of days, I've been fighting a war against generators and they've beaten the crap out of me several times. What I want to do is implement one that yields every possible permutation of a given sequence (I had lists in mind, but I could swear that this would work on strin

Re: Permutations with generators

2007-07-20 Thread Pablo Torres
Just a quick P.S: This WOULD NOT work with strings, because of seq.insert() In very other aspect, I'm still lost. -- http://mail.python.org/mailman/listinfo/python-list

Spam filter?

2007-07-20 Thread Danyelle Gragsone
So, Can mailing lists have its mail filtered? I get more spam via mailing lists than I do in my own inbox. I am not just singling this mailing list. I see it a lot now. Danyelle -- http://mail.python.org/mailman/listinfo/python-list

Re: Permutations with generators

2007-07-20 Thread Dan Bishop
On Jul 21, 12:42 am, Pablo Torres <[EMAIL PROTECTED]> wrote: > Hey guys! > For the last couple of days, I've been fighting a war against > generators and they've beaten the crap out of me several times. What I > want to do is implement one that yields every possible permutation of > a given sequenc

Re: Permutations with generators

2007-07-20 Thread Paul Rubin
Pablo Torres <[EMAIL PROTECTED]> writes: > def perm(seq): > "Reshuffles the elements of seq in every possible way" > if len(seq) == 1: > yield seq > else: > for p in perm(seq[1:]): > for i in range(len(seq)): >

Re: Permutations with generators

2007-07-20 Thread Pablo Torres
> > list.insert returns None. Thus, except in the one-element case, your > generator is yielding None all the time. > Oh god...silly me. Thank you guys for the help :) P.S I'm dead stubborn, so here's what I did to fix my code: def perm(seq): "Reshuffles the elements of seq in every pos

Re: Pickled objects over the network

2007-07-20 Thread Hendrik van Rooyen
"Steve Holden" <[EMAIL PROTECTED]> wrote: > Hmm, I suspect I detect the sounds of the square wheel being reinvented. Very helpful, thank you, Steve - Now how about pointing out in which direction the round wheels are kept, and what their monikers are? - Hendrik -- http://mail.python.org/mailma

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-20 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > > Come on, this is real-time embedded software, > Since when did we restrict ourselves to such an environment? I was under the > impression that this thread is about the merits and capabilities of static > type-checking? One branch of the discussion

Re: exec and CodeObjects

2007-07-20 Thread Gabriel Genellina
En Fri, 20 Jul 2007 12:48:05 -0300, Prepscius, Colin (IT) <[EMAIL PROTECTED]> escribió: > Does anybody know how to pass parameters to 'exec > somefunction.func_code'? > def f1(): > print 'this is f1' > def f2(p): > print 'this is f2, p =', str(p) > exec f1.func_code > THIS RESULTS IN: "

<    1   2