Re: Building a web questionnaire, can it be done in Python ?

2008-12-19 Thread Steve Bergman
The most popular choice for web apps, and the one I use myself, would be Django. You might post your question in the Django group: http://groups-beta.google.com/group/django-users The only thing that I see that could be a problem would be the legacy database. But that depends very much upon

How to make this unpickling/sorting demo faster?

2008-04-17 Thread Steve Bergman
I'm involved in a discussion thread in which it has been stated that: Anything written in a language that is 20x slower (Perl, Python, PHP) than C/C++ should be instantly rejected by users on those grounds alone. I've challenged someone to beat the snippet of code below in C, C++, or

Re: Python module for reading FilePro files?

2008-04-17 Thread Steve Bergman
Thanks. Yes, there is a php-filepro extension that I could hook up with using the command line interpreter. That may well be what I end up doing. Or maybe port the php extension to python. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this unpickling/sorting demo faster?

2008-04-17 Thread Steve Bergman
THe above is applied slavishly by those who value machine time over peoples time. Do you want to work with them? I understand where you are coming from. But in writing the code snippet I learned something about pickling/unpickling, which I knew *about* but had never actually used before. And

Re: How to make this unpickling/sorting demo faster?

2008-04-17 Thread Steve Bergman
Thanks for the help. Yes, I see now that gdbm is really superfluous. Not having used pickel before, I started from the example in Python in a Nutshell which uses anydbm. Using a regular file saves some time. By far, the biggest improvement has come from using marshall rather than cPickel.

Re: How to make this unpickling/sorting demo faster?

2008-04-17 Thread Steve Bergman
On Apr 17, 7:37 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Therefore the likelihood of a C or asm program being 20x faster including disk i/o is dim.  But realistically, counting just CPU time, you might get a 20x speedup with assembler if you're really determined, using x86 SSE (128-bit

Python module for reading FilePro files?

2008-04-16 Thread Steve Bergman
Does anyone know of a Python package or module to read data files from the venerable old Filepro crossplatform database/IDE? -- http://mail.python.org/mailman/listinfo/python-list

Re: Fuzzy string comparison

2006-12-27 Thread Steve Bergman
Thanks, all. Yes, Levenshtein seems to be the magic word I was looking for. (It's blazingly fast, too.) I suspect that if I strip out all the punctuation, etc. from both the itemnumber and description columns, as suggested, and concatenate them, pairing the record with its closest match in the

Fuzzy string comparison

2006-12-26 Thread Steve Bergman
. Thanks, Steve Bergman -- http://mail.python.org/mailman/listinfo/python-list

About the 79 character line recommendation

2006-12-05 Thread Steve Bergman
I'm on this general topic, the guide mentions a pet peeve about inserting more than one space to line up the = in assignment statements. To me, lining them up, even if it requires quite a few extra spaces, helps readability quite a bit. Comments? Thanks, Steve Bergman -- http://mail.python.org

Re: About the 79 character line recommendation

2006-12-05 Thread Steve Bergman
Thanks for the responses. The point about 132 columns is good. Pretty much any printer will handle that today, though I reserve the right to change my mind about the utility of 17cpi print after I'm 50. Hopefully, all printers will be at least 1200dpi by then. ;-) --- Yes, I dislike \ for

Re: why would anyone use python when java is there?

2006-11-30 Thread Steve Bergman
Bruce Eckel states the case pretty well in this interview: http://www.artima.com/intv/aboutme.html Bruce is the author of Thinking In Java and other excellent books, but has migrated from the Java camp. (I'm excited to see him getting at least a bit involved in TurboGears. He has a lot to offer

Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
Just wanted to report a delightful little surprise while experimenting with psyco. The program below performs astonoshingly well with psyco. It finds all the prime numbers 10,000,000 Processor is AMD64 4000+ running 32 bit. Non psyco'd python version takes 94 seconds. psyco'd version takes

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
Will McGugan wrote: Some trivial optimizations. Give this a whirl. I retimed and got 9.7 average for 3 runs on my version. Yours got it down to 9.2. 5% improvement. Not bad. (Inserting '2' at the beginning doesn't seem to impact performance much.;-) ) BTW, strictly speaking, shouldn't I

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
[EMAIL PROTECTED] wrote: BTW, can this code be made any more efficient? I'm not sure, but the following code takes around 6 seconds on my 1.2Ghz iBook. How does it run on your machine? Hmm. Come to think of it, my algorithm isn't the sieve. Anyway, this is indeed fast as long as you

Why are slice indices the way they are in python?

2006-11-29 Thread Steve Bergman
A couple of off the wall questions. It seems to me that there is usually a solid *reason* for things in Python and I'm wondering about the rationale for the way slicing works: my_string[2:5] gets you the 3rd through the 3rd through the 5th character of the string because indexing starts at 0

Re: scanning for numerals / letters

2006-04-18 Thread Steve Bergman
Something like this should work: == for c in form.get('date'): if c in string.letters: print ERROR: You have to enter a date with numbers. == You have to import the string module. 'letters' is one of the attributes defined in that module. Other attributes

Re: Starting value with raw_input

2006-04-18 Thread Steve Bergman
Kinda ugly, and I lifted it from an old post, but this should work: import readline readline.set_startup_hook(lambda: readline.insert_text('supercalifragilisticexpialidocious')) try: new_value = raw_input() finally: readline.set_startup_hook(None) --

Re: piping question

2006-04-17 Thread Steve Bergman
Have you tried running python with '-u'? That turns off most buffering within python at least. I'm not familiar with newspost, so I've no idea what to do about any output buffering it might be doing. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help for a complete newbie

2006-04-15 Thread Steve Bergman
You can also access this group through Google Groups: http://groups.google.com/group/comp.lang.python which has nice search features. I found O'Reilly's Learning Python to be helpful in combination with O'Reilly's Python in a Nutshell. Learning python is a nice introduction to Python but is

Re: Should I learn Python instead?

2006-04-15 Thread Steve Bergman
There is also TurboGears, which (IMO) is greatness in the making. Though unfortunately, the documentation is still catching up to the greatness. I'm using it and loving it, though. http://www.turbogears.org DJango is great for content management. TurboGears is (IMO) a more generalized

Re: Help for a complete newbie

2006-04-14 Thread Steve Bergman
The indentation is wrong. Python cares about indentation. print print This \autotp\ program will create raw bitmap test pattern images. print print Please read the information below thoroughly: print print 1. Graphic files MUST be TIFF images. print 2. Images MUST have been ripped though

Re: HELP PLEASE: What is wrong with this?

2006-04-14 Thread Steve Bergman
Welcome to Python! :-) You may find this mailing list useful: http://mail.python.org/mailman/listinfo/tutor -- http://mail.python.org/mailman/listinfo/python-list

Sorting a list of objects by multiple attributes

2006-04-10 Thread Steve Bergman
Hi, I am trying to come up with a clean and simple way to sort a list of objects (in this case SQLObject instances) by multiple attributes. e.g. a Person object may have an age, a lastName, and a firstName. I'd like to be able to arbitrarily sort by any combination of those in any order. I

Re: Which SQL module to use?

2005-10-04 Thread Steve Bergman
to get your results as a dictionary. -Steve Bergman -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributing programs

2005-10-02 Thread Steve Bergman
Leif K-Brooks wrote: But remember that Python bytecode can be easily decompiled with a publicly-available program. I hope it is not considered too antisocial to bring it up here, but there is always PyObfuscate: http://www.lysator.liu.se/~astrand/projects/pyobfuscate/ -Steve Bergman

Re: Distributing programs

2005-10-02 Thread Steve Bergman
Wouter van Ooijen (www.voti.nl) wrote: Yes, and you must also include a blank sheet, signed by you in blood. I thought you only had to do that if you were submitting a patch to MySQL, Qt, OpenOffice, or OpenSolaris. ;-) -Steve Bergman -- http://mail.python.org/mailman/listinfo/python-list

Re: Most direct way to strip unoprintable characters out of a string?

2005-09-25 Thread Steve Bergman
Fredrik Lundh wrote: (sanitizing HTML data by running filters over encoded 8-bit data is hardly ever the right thing to do...) I'm very much open to suggestions as to the right way to do this. I'm working on this primarily as a learning project and security is my motivation for wanting

Most direct way to strip unoprintable characters out of a string?

2005-09-24 Thread Steve Bergman
is OK. But it seems like there should be more straightforward way that I just haven't figured out. Is there? Thanks, Steve Bergman -- http://mail.python.org/mailman/listinfo/python-list

Re: Most direct way to strip unoprintable characters out of a string?

2005-09-24 Thread Steve Bergman
George Sakkis wrote: If by straightforward you mean one-liner, there is: ''.join(c for c in input_string if c not in string.printable) If you care about performance though, string.translate is faster; as always, the best way to decide on a performance issue is to profile the alternatives on

Re: Intermediate to expert book

2005-09-21 Thread Steve Bergman
I'm waiting for the release of the next edition of Programming Python from O'Reilly. It's due out in December. The current edition is rather oldish. From 2001, I believe. Steve -- http://mail.python.org/mailman/listinfo/python-list

Pygresql classic vs DB-API interface

2005-09-19 Thread Steve Bergman
elegant way of which I am unaware? I still like the portability of pgdb though. So, does anyone have any recommendations? Perhaps a module that does for inserts and updates kind of what dtuple does for selects? Thank you for any guidance. Steve Bergman -- http://mail.python.org/mailman/listinfo