Re: using range() in for loops

2006-04-05 Thread Adam DePrince
On Tue, 2006-04-04 at 21:54 -0400, John Salerno wrote: I'm reading Text Processing in Python right now and I came across a comment that is helping me to see for loops in a new light. I think because I'm used to the C-style for loop where you create a counter within the loop declaration, for

Re: Difference between 'is' and '=='

2006-04-03 Thread Adam DePrince
A good programmer always looks both ways when crossing a one way street. I'm uncertain that a quip about abstracting away the rain would have prompted the same adjective masterful now 10+ years in the future. - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: splitting dictionary definition across two .py files

2006-04-03 Thread Adam DePrince
On Fri, 2006-03-31 at 12:46 -0800, Karthik Gurusamy wrote: Ben Finney wrote: [EMAIL PROTECTED] writes: I'm fairly new to python. I like to define a big dictionary in two files and use it my main file, build.py I want the definition to go into build_cfg.py and build_cfg_static.py.

Re: Best IDE for Python?

2006-04-03 Thread Adam DePrince
On Fri, 2006-03-31 at 09:30 +0200, Fredrik Lundh wrote: Dennis Lee Bieber wrote: I want to know which is the best IDE for python.Please if possible mention the features of the IDE. The best IDE is the one that YOU can be most productive in. What /I/ find useful may not be of

Re: in-place string reversal

2006-03-28 Thread Adam DePrince
( s ) s.reverseme() print s cbA Other users of s between assignment and reversal (like myfancy_structure) might not be happy that is was reversed when they next must use it. Cheers - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: 1.090516455488E9 / 1000000.000 ???

2006-03-28 Thread Adam DePrince
? Print does seem to round at 12 digits. print 1.090516455488E9/100 1090.51645549 Cheers - Adam DePrince I know something with float and //... Anybody? How do I get correct number? -- http://mail.python.org/mailman/listinfo/python-list

Re: freeze.py and GTK apps

2006-03-28 Thread Adam DePrince
On Mon, 2006-03-27 at 16:15 -0800, [EMAIL PROTECTED] wrote: After freezing a PYGTK app, I am unable to run it. It this a common problem, because I could not find any documentation on it at all. I tried freezing this example, which gets by the make as well, but running it results in a

Re: Extending Methods Vs Delegates

2006-03-26 Thread Adam DePrince
On Sun, 2006-03-26 at 07:21 -0800, Alex Martelli wrote: vbgunz [EMAIL PROTECTED] wrote: I am sorry I couldn't reply sooner! Alex, Python in a nutshell is my bible and I take it virtually everywhere! Seriously, I would highly recommend it to anyone with a little to a lot of Python

Re: wired md5 hashing problem

2006-03-26 Thread Adam DePrince
What do you get when you type md5sum backup.tar.bz2? - Adam On Sun, 2006-03-26 at 16:56 +0200, Matthias Güntert wrote: Hello list-members i am in the process of writing a python script to backup my data. Now I would like to implement md5/sha1 hashes. # do md5 fingerprinting

Re: wired md5 hashing problem

2006-03-26 Thread Adam DePrince
On Sun, 2006-03-26 at 16:56 +0200, Matthias Güntert wrote: Hello list-members i am in the process of writing a python script to backup my data. Now I would like to implement md5/sha1 hashes. # do md5 fingerprinting if config.get(global, crc) == md5: m = md5.new()

Re: Bitwise OR?

2006-03-24 Thread Adam DePrince
On Fri, 2006-03-24 at 12:55 +0100, Clemens Hepper wrote: Hello, I've written a little (optimized) method to get a bit-string: def bitstringneg(number, digits=32): optimized for negative numbers result = for a in xrange(digits): if number 1: result += '1' else:

Re: Multiplying all the values in a dictionary

2006-03-24 Thread Adam DePrince
Droppings from other timing tests; starbucks was kicking me out and I was in a hurry. Cheers - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Caching in memory for Apache

2006-03-24 Thread Adam DePrince
database really is the best place for that. Good luck - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Incremental Compression

2006-03-24 Thread Adam DePrince
. Z_FINISH. This is the default action, this is what is killing you. Good luck - Adam DePrince I cannot wait until the end of the stream and then flush, because I need to flush after every packet. Another capability I require is to be able to copy the compression stream. i.e: To be able

Re: New Python logo in high resolution format

2006-03-24 Thread Adam DePrince
On Fri, 2006-03-24 at 10:49 -0800, Robert Hicks wrote: How about we all get tatoos? : ) ... still trying to scrape the old one off ... Robert -- http://mail.python.org/mailman/listinfo/python-list

PEP for nondeterminism.

2006-03-24 Thread Adam DePrince
language changes, the second calls for a minor (and likely symbolic) change to list comprehension's semantics to better support future parallelism. PEP: XXX Title: Nondeterminism Version: $Revision$ Last-Modified: $Date$ Author: Adam DePrince [EMAIL PROTECTED] Status: Draft Python-Version: 3.0

Re: Multiplying all the values in a dictionary

2006-03-23 Thread adam . deprince
for key in d: d[key] = [x*2 for x in d[key]] Naw, if you are going to use list interpolation go all the way and save yourself all of that ugly indexing into the dict. d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]} d.update( [[key,[x*2 for x in item]] for key,item in d.items()]

Re: Getting a loop to activate a loop above it

2006-03-23 Thread adam . deprince
This is how python is supposed to work. I'm sure not what languages you have used ... it seems that you are expecting some sort rule based system like make, or prolog. Grab a cup of joe, pull up a chair and let me help you out here. Python is an imperative language, you can envision the presence

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Yes, I cede that explicit indexing is faster by quite a bit. There is a somewhat philosophical decision for why I avoided that. I prefer to try to present python with as big of a picture of what I want as possiable. update tells python what I want to do, whereas the for-loop describes how to.

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Wait! It occured to me. Why are we touching the key at all. This is a dictionary with mutable values. [EMAIL PROTECTED] ~]$ python2.4 -mtimeit -s 'd = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}; x = dict(d)' 'for i in x.values(): i[:]=[j*1 for j in i]' 10 loops, best of 3: 2.79

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Excuse me, I mean python2.4 -mtimeit -s 'from numarray import array; d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}; x = dict(d);' 'for i in x.values(): i[0]*=1;i[1]*=1' 100 loops, best of 3: 1.72 usec per loop i[0]*=1, not j[0]*=1 ... --

Re: overlapping sets

2006-03-23 Thread Adam DePrince
luck - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
. But whatever you do, don't beg. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
On Tue, 2005-02-15 at 14:25, Ilias Lazaridis wrote: Adam DePrince wrote: On Tue, 2005-02-15 at 13:29, Ilias Lazaridis wrote: Mike Meyer wrote: Ilias Lazaridis [EMAIL PROTECTED] writes: [...] MinGW compatibility is not [only] my need. It is an community need [at least partially

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Adam DePrince
On Tue, 2005-02-15 at 17:24, Jeff Shannon wrote: Ilias Lazaridis wrote: Adam DePrince wrote: [...] You're on it. You drive a car? You have to treat it right to get what you want, right? Same here. Ask correctly, and you will get your answers. Your interpretation/definition

Re: image fourier transform

2005-02-15 Thread Adam DePrince
', then you do 1D FFTs on all the columns of X'. So, for a 32x32 2D FFT, you'll end up doing 64 1D FFTs. FFTW: http://www.fftw.org/ Python bindings for it: http://pylab.sourceforge.net/ Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterator / Iteratable confusion

2005-02-15 Thread Adam DePrince
the paragraph above with 'a fixed point' substituted for 'minimal'. How is spencerator different than itertools.tee? Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question convert C to python

2005-02-15 Thread Adam DePrince
it as you would such a creature in C ... vTable[0][0] = 1 or whatever you want to do. I've seen this question before. Lot in the archives for the subject 2D array from Dec 7th 2004 - Dec 10th 2004. Steven and I recommended roughly opposite solutions at the time :-) Adam DePrince -- http

Re: Python versus Perl ?

2005-02-08 Thread Adam DePrince
that execution speed is a real issue for your programming task (in order to continue this discussion). Otherwise the debate will go south real quick. Not only most speed be an issue, but the economics must be such that any alternative is better than throwing more hardware at the problem. Adam

Re: bytecode obfuscation

2005-02-06 Thread Adam DePrince
on obscurity: The bad guys are rounding off your pennies as you read this. The worse case if you depend on encryption and open your spec: You get to publish your code, but might get competition. Just my $0.02. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-06 Thread Adam DePrince
of this scheme is dependent on a lot, including the strength of sha, your ability to keep your secret key secret, the correctness of what I'm saying, etc etc etc. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: bytecode obfuscation

2005-02-06 Thread Adam DePrince
On Sun, 2005-02-06 at 08:19, Philippe Fremy wrote: Adam DePrince wrote: No amount of obfuscation is going to help you. Theorically, that's true. Anything obfuscated can be broken, just like the non obfuscated version. However it takes more skills and time to break it. And that's

Re: pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-06 Thread Adam DePrince
as a hedge against malicious data. Can I, as a user of said card, change the data in the pickle? If so, when you load the pickle back into python you need to confirm that it is a sane pickle that you wrote earlier. - Adam Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I convert arithemtic string (like 2+2) to a number?

2005-02-05 Thread Adam DePrince
-rf %(HOME)s%os.environ ) as the expression to evaluate. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing huge Sets() to disk

2005-01-10 Thread Adam DePrince
are tring to do; perhaps there is a better way, perhaps the problem is unsolvable and there is a heuristic that will satisfy your needs. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Download .jpg from web

2005-01-06 Thread Adam DePrince
many cameras, so there are many threads simultaneously reading and dropping them in a central Queue for saving later. I appreciate it! -Dave WebImage = urllib.urlopen(http://ip-address/jpg/image.jpg).read() QueuePacket = [] QueuePacket.append(WebImage) Adam DePrince -- http

Re: what is lambda used for in real code?

2005-01-04 Thread Adam DePrince
On Fri, 2004-12-31 at 17:36, Steven Bethard wrote: Adam DePrince wrote: Lets not forget the real reason for lambda ... the elegance of orthogonality. Why treat functions differently than any other object? We can operate on every other class without having to involve the namespace

Re: what is lambda used for in real code?

2005-01-04 Thread Adam DePrince
On Fri, 2004-12-31 at 22:09, Terry Reedy wrote: Adam DePrince [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In sort, we must preserve the ability to create an anonymous function simply because we can do so for every other object type, and functions are not special enough

Re: what is lambda used for in real code?

2005-01-04 Thread Adam DePrince
On Sat, 2005-01-01 at 11:42, Steve Holden wrote: Adam DePrince wrote: [...] In sort, we must preserve the ability to create an anonymous function simply because we can do so for every other object type, and functions are not special enough to permit this special case. And you'd

Re: what is lambda used for in real code?

2004-12-31 Thread Adam DePrince
type, and functions are not special enough to permit this special case. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: spacing of code in Google Groups

2004-12-31 Thread Adam DePrince
a look at http://python.org/community/lists.html The news group and this list are mirrors of each other. Of course, the benefit this provides depends on which mail client you use. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Writev

2004-12-21 Thread Adam DePrince
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote: On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince [EMAIL PROTECTED] wrote: [snip] Of course, to take advantage of this requires that writev be exposed. I have an implementation of writev. This implementation is reasonably smart

Re: Writev

2004-12-20 Thread Adam DePrince
On Mon, 2004-12-20 at 02:18, Steven Bethard wrote: Adam DePrince wrote: file.writelines( seq ) and map( file.write, seq ) are the same; the former is syntactic sugar for the later. Well, that's not exactly true. For one thing, map(file.write, seq) returns a list of Nones, while

Writev

2004-12-19 Thread Adam DePrince
iteration.next()'s, you can set an optional parameter to a smaller value. I'm not sure where to take this as a next step. It seems too small a change for a PEP. Any ideas? You can download the patch from http://deprince.net/software/writev/index.html Adam DePrince -- http://mail.python.org

Re: Writev

2004-12-19 Thread Adam DePrince
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote: On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince [EMAIL PROTECTED] wrote: [snip] [snip] to free the memory, of course. The support of iterators is a cool idea, but I'm not sure it is actually useful. Consider the case where not all

Re: Writev

2004-12-19 Thread Adam DePrince
On Mon, 2004-12-20 at 00:30, Steven Bethard wrote: Adam DePrince wrote: Many other programmers have faced a similar issue; cStringIO, ''.join([mydata]), map( file.write, [mydata]) are but some attempts at making this process more efficient by jamming the components to be written

Re: BASIC vs Python

2004-12-17 Thread Adam DePrince
. And if you were in the wannabe category, you got yourself a PET 20 and told it what to do in BASIC. (mumbles into beard and drools quietly in the corner). Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Create linear spaced vector?

2004-12-17 Thread Adam DePrince
, 1.7002, 1.8, 1.8999, 2.0] Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: BASIC vs Python

2004-12-16 Thread Adam DePrince
.) But you are forced to memorize the same list of curse words over and over again in order. This is the BASIC way of learning to program. Don't do it, unless your goal is simply to embarrass and insult programmers. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: os.walk bug?

2004-12-16 Thread Adam DePrince
,templates}' Does this help? - Adam Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I convert characters into integers?

2004-12-15 Thread Adam DePrince
in terms of maping here. Don't say ... for ... Think ... message = map( ord, message ) or message = [chr( (ord( x ) + 3 )%256) for x in message] Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-15 Thread Adam DePrince
. And to properly stand upon those shoulders, we must match the theoretical models used. That means we need more, not fewer, immutable counterparts to most of our datatypes. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: lies about OOP

2004-12-15 Thread Adam DePrince
that is a good thing. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-15 Thread Adam DePrince
, inmutable counterparts to most of our datatypes. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie questions

2004-12-13 Thread Adam DePrince
répondre en français. - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: how do I peek into the next line?

2004-12-13 Thread Adam DePrince
= f.readline() print line, line = f.readline() print line, line = f.readline() print line, f.unreadline( line ) line = f.readline() print line, line = f.readline() print line, Running this prints: a b c c d Hope this helps. Adam DePrince

Re: lies about OOP

2004-12-13 Thread Adam DePrince
, Python for that matter. Practice casting problems as classes in Python and submit them here for praise and criticism. Lastly, Perl is an OOPl in its own right ... like Python and quite unlike Java, it doesn't jam its OOP-ness down your throat. Adam DePrince -- http://mail.python.org/mailman

Re: Deadlock detection

2004-12-10 Thread Adam DePrince
. Largely this problem is intractable, even with simplifications, but it is done which is why safety critical programs are (well, should be) small and their languages not very expressive (as in finite state machine, and not in the but my computer is a FSM sense.) Adam DePrince -- http

Re: newbie questions

2004-12-10 Thread Adam DePrince
(): ... a[:] = [] ... b() a [1, 2] c() a [0, 2] d() a [] Now forgive me ... what you really want to do is follow Erik's advice. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: sources for DOS-16bit

2004-12-10 Thread Adam DePrince
cycles per array reference was a big thing back then ... Anyhow, sorry about babbling on about this non-python related nonsense and good luck. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: 2D array

2004-12-08 Thread Adam DePrince
might want to consider using a dictionary where the key is a tuple representing the coordinates. a = {} a[(0,0)] = 0 a[(0,1)] = 1 a[(1,0)] = 2 a[(1,1)] = 3 a[(2,0)] = 4 a[(2,1)] = 5 a[(3,0)] = 6 a[(3,1)] = 7 a[(4,0)] = 8 a[(4,1)] = 9 a.get( (3,0), None ) 6 print a.get( (5,0), None ) None Adam

Re: Sorting in huge files

2004-12-08 Thread Adam DePrince
to do on 10^8 elements with repeats in the keys? I guess I should just try and see for myself. Repeats in the keys don't matter. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive list comprehension

2004-12-08 Thread Adam DePrince
On Wed, 2004-12-08 at 15:02, Steven Bethard wrote: Adam DePrince wrote: def flatten( i ): try: i = i.__iter__() while 1: j = flatten( i.next() ) try: while 1: yield j.next() except

Re: 2D array

2004-12-08 Thread Adam DePrince
On Wed, 2004-12-08 at 15:06, Steven Bethard wrote: Adam DePrince wrote: If your data is sparse you might want to consider using a dictionary where the key is a tuple representing the coordinates. a = {} a[(0,0)] = 0 a[(0,1)] = 1 [snip] print a.get( (5,0), None ) Good point

Re: Newbie alert !

2004-12-03 Thread Adam DePrince
callbacks ... - Adam Using Python 2.3, IDLE and Win2k. Thanks for your time Jean Montambeault Adam DePrince Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: distinction between float int

2004-12-03 Thread Adam DePrince
operator returns true if its two parameters internally have the same pointer value and are the same object. Floating point values are not interned, so 1.1 is 1.1 is false. Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: efficient intersection of lists with rounding

2004-12-02 Thread Adam DePrince
deal clearer. from sets import Set set_a = Set( [(i,round(j)) for i,j in a] ) set_b = Set( [(i,round(j)) for i,j in b] ) set_a.intersection( set_b ) Set([(123, 2.0), (123, 1.0), (123, 8.0)]) Or you could say ... set_a, set_b = [[Set((i,round(j))) for i,j in s] for s in (a,b )] Adam

Re: PySQLLite Speed

2004-12-02 Thread Adam DePrince
://promotions.yahoo.com/new_mail Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list