Re: How can I use python for file processing

2007-08-25 Thread Marc 'BlackJack' Rintsch
On Sun, 26 Aug 2007 06:05:11 +, [EMAIL PROTECTED] wrote: > I am trying to use python for file processing. > Suppose I have a file like this: > I want to build a Hashmap between the line "begin_QOS_statistics" and > "end_QOS_statistics" > and for each line I want to put the first text as the ke

Re: Any python Module for generating DocBook?

2007-08-25 Thread Roman Yakovenko
On 8/25/07, Tommy Nordgren <[EMAIL PROTECTED]> wrote: > Do anyone on this list know of a Python module for generating DocBook > programlisting elements for programming language source code > merked with special comments. > I want to write a programming book, and want to mark significant > lines in

How can I use python for file processing

2007-08-25 Thread [EMAIL PROTECTED]
Hi, I am trying to use python for file processing. Suppose I have a file like this: I want to build a Hashmap between the line "begin_QOS_statistics" and "end_QOS_statistics" and for each line I want to put the first text as the key of the hash table and the second text as the value. Received R

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread Alex Martelli
tooru honda <[EMAIL PROTECTED]> wrote: ... > def rand2(): > while True: > randata = urandom(2*1024) > for i in xrange(0, 2*1024, 2): > yield int(hexlify(randata[i:i+2]),16)# integer > in [0,65535] another equivalent pos

Re: Need a better understanding on how MRO works?

2007-08-25 Thread Alex Martelli
Steven W. Orr <[EMAIL PROTECTED]> wrote: ... > Thanks Alex. I am humbled, though I was before I started. > I really don't have a lot of understanding of what you're saying so I'll > probably have to study this for about a year or so. > > * (I need to look up what dictproxy is.) I don't have any

ActiveRecord for Python/MySQL

2007-08-25 Thread Devraj
Hi everyone, My application uses MySQL as a backend and am using the MySQL/Python bindings. Are there any libraries that provide a database abstraction layer like Activerecords for Python?' Any resources/links will be appreciated. Thanks for your time. -- http://mail.python.org/mailman/listinf

Re: accessing keys in dict

2007-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2007 19:05:07 +, Dustan wrote: > Never assume. A better approach would be to experiment: I assume that you would not like it if I poked you in the eye with a sharp stick, but perhaps I better experiment... *wink* More seriously, if you wish to compare dict.keys() and dict.it

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread tooru honda
By incorporating Alex's code, I got another performance boost of 20%. It is mostly due to Alex's more efficient implementation of block random than my own version. -tooru honda Below is the code I have now: from binascii import hexlify from os import urandom class rcRandomC(random.SystemRan

Python error on Mac

2007-08-25 Thread Clover
When trying to do some things on my Mac (starting Lyx, compiling Latex via TextMate) I get this error: python: execv: /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python: No such file or directory I (and people on Lyx and TextMate lists) are at a compl

Re: Need a better understanding on how MRO works?

2007-08-25 Thread Steven W. Orr
On Saturday, Aug 25th 2007 at 17:19 -0700, quoth Alex Martelli: =>Steven W. Orr <[EMAIL PROTECTED]> wrote: => ... =>> name = 'C1' =>> nclass = new.classobj(name,(D1,),globals()) =>> globals()[name] = nclass => =>Here, you're creating a VERY anomalous class C1 whose __dict__ is =>g

Re: Joining Big Files

2007-08-25 Thread Paul McGuire
On Aug 25, 8:15 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Aug 25, 4:57 am, mosscliffe <[EMAIL PROTECTED]> wrote: > > > I have 4 text files each approx 50mb. > > 50mb? Really? Did you actually try this and find out it was a > problem? > > Try this: > import time > > start = time.clock() > o

Re: simple spider in python

2007-08-25 Thread samushack
On Aug 23, 4:49 pm, [EMAIL PROTECTED] wrote: > well, i think that they deserve people moving toward yahoo's API... > check this out:http://pysearch.sourceforge.net/ > it's basically the same thing as pygoogle BUT working with google's > competitor. it seems like internet has its own built-in antibo

Re: Joining Big Files

2007-08-25 Thread Paul McGuire
On Aug 25, 4:57 am, mosscliffe <[EMAIL PROTECTED]> wrote: > I have 4 text files each approx 50mb. > 50mb? Really? Did you actually try this and find out it was a problem? Try this: import time start = time.clock() outname = "temp.dat" outfile = file(outname,"w") for inname in ['file1.dat', 'fi

Re: beginner, idiomatic python

2007-08-25 Thread Paul McGuire
On Aug 23, 11:50 pm, "bambam" <[EMAIL PROTECTED]> wrote: > Thank you, so generallizing: > > (1) Python re-evaluates the loop range on every loop, and > (2) Python does short-circuit evaluation of conditions, in predictable > order. > > Sorry about the bad question. > A beginner would do well to wo

Re: Need a better understanding on how MRO works?

2007-08-25 Thread Alex Martelli
Steven W. Orr <[EMAIL PROTECTED]> wrote: ... > name = 'C1' > nclass = new.classobj(name,(D1,),globals()) > globals()[name] = nclass Here, you're creating a VERY anomalous class C1 whose __dict__ is globals(), i.e. the dict of this module object; > name = 'C2' > nclass

Re: Joining Big Files

2007-08-25 Thread beginner
On Aug 25, 4:57 am, mosscliffe <[EMAIL PROTECTED]> wrote: > I have 4 text files each approx 50mb. > > I need to join these into one large text file. > > I only need to do this very occasionally, as the problem has occurred > because of upload limitations. > > Bearing in mind filesize and memory use

Need a better understanding on how MRO works?

2007-08-25 Thread Steven W. Orr
Given the following code: (I hope it's as simple as possible) :-) #! /usr/bin/python import new class BASE: def __init__( self ): print 'Hello from BASE init' def m1( self ): print 'M1 Base: Self = ', self def m1replace( self ): print 'm1replace:Self = ', self cla

Re: Filemaker interactions

2007-08-25 Thread M.-A. Lemburg
On 2007-08-01 23:41, Ian Witham wrote: > Hello, > > I'm hoping someone here can put me on the right track with some broad > concepts here. > > What I am hoping to achieve is a simple HTML page to be served over > our company LAN, into which the users (Real Estate Agents) can enter a > property ad

Any python Module for generating DocBook?

2007-08-25 Thread Tommy Nordgren
Do anyone on this list know of a Python module for generating DocBook programlisting elements for programming language source code merked with special comments. I want to write a programming book, and want to mark significant lines in the source code for reference. My DocBook processing software

Re: pyodbc on linux

2007-08-25 Thread M.-A. Lemburg
On 2007-07-21 22:54, Sean Davis wrote: > I have read a couple of blogs suggesting that pyodbc is buildable > under linux. I am running suse 10.2 on a 64-bit intel machine with > unixODBC installed. Upon building, I get a slew of pretty horrid > looking errors that make me wonder if this is suppos

Re: question

2007-08-25 Thread MRAB
On Aug 24, 7:20 pm, [EMAIL PROTECTED] wrote: > Still trying to learn Python and was hoping some of you might be able to give > me some advice > on my code > below. It works but I'm wondering if there's more efficient ways of doing > this than the way > I've done it. > > The first step is I have

GOZERBOT 0.7.1 released

2007-08-25 Thread bthate
GOZERBOT 0.7.1 released - This release fixes the following bugs: * the udp encryption was fixed * a newline injection bug in the RSS plugin was discovered at CCC camp and fixed. credits for finding this bug go to Astro- - version 0.7.1 can be downloaded at http://gozerbot.org.

Re: accessing keys in dict

2007-08-25 Thread Dustan
On Aug 25, 7:41 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>, > > james_027 wrote: > > is there any difference between .. > > > for key in a_dict: > > > from > > > for key in a_dict.keys(): > > I'm assuming the former is equivalent to >

Re: How to find parent function/class of generators?

2007-08-25 Thread Terry Reedy
"J. A. Aczel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hello all. I think I should explain my problem in detail, so everyone | understands what I'm trying to do and why. There may be a better | approach to the whole problem then I am using. | | I am working on a game, with mo

Debugging a curses application in python

2007-08-25 Thread [EMAIL PROTECTED]
Hello all, I'm trying to debug a python application which uses the curses module under Linux. I'm having trouble, since I can't get any debugger to work. Is there a way to separate the output of an application from the debugger. In gdb, the tty command would allow me to specify a separate tty to w

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread Alex Martelli
tooru honda <[EMAIL PROTECTED]> wrote: > At the end, I think it is worthwhile to implement my own shuffle and > random methods based on os.urandom. Not only does the resulting code > gets rid of the minuscule bias, but the program also runs much faster. > > When using random.SystemRandom.shuffl

Re: Regular expression use

2007-08-25 Thread anno4000
John W. Krahn <[EMAIL PROTECTED]> wrote in comp.lang.perl.misc: > Nick Maclaren wrote: > > In article <[EMAIL PROTECTED]>, > > Mirco Wahab <[EMAIL PROTECTED]> writes: > > |> > > |> Using complex regular expressions is like tank destruction > > |> with contact charges glued on them. Only a few peo

Re: curses library

2007-08-25 Thread Ben Finney
Ghirai <[EMAIL PROTECTED]> writes: > Are there any wrappers around curses/ncurses? Python has its own 'curses' module in the standard library of course. http://docs.python.org/lib/module-curses> That's if you want to work directly with the curses functionality, which is rather low-level. >

Re: curses library

2007-08-25 Thread Laurent Pointal
Ghirai wrote: > Hello list, > > I need to write a console application. > > Are there any wrappers around curses/ncurses? > Or any other similar libraries? > > Thanks. I have some links here: http://www.limsi.fr/Individu/pointal/python.html#liens-graph-curses A+ Laurent. -- http://mail.pyth

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread Dan Bishop
On Aug 24, 2:38 am, tooru honda <[EMAIL PROTECTED]> wrote: > Hi, > > I have read the source code of the built-in random module, random.py. > After also reading Wiki article on Knuth Shuffle algorithm, I wonder if > the shuffle method implemented in random.py produces results with modulo > bias. > >

Re: Using Regular Expresions to change .htm to .php in files

2007-08-25 Thread Tobiah
[EMAIL PROTECTED] wrote: > Hi, > > I have a bunch of files that have changed from standard htm files to > php files but all the links inside the site are now broken because > they point to the .htm files while they are now .php files. > > Does anyone have an idea about how to do a simple script t

Re: pure python gaussian blur

2007-08-25 Thread Gerdus van Zyl
Ok, now answering my own question :-) Gaussian blurs can be optimized by seperating the equation and applying in two passes. I also implemented a version using State Vector Machines from www- personal.engin.umd.umich.edu/~jwvm/ece581/21_GBlur.pdf but it does not produce correct results. Most probab

Re: Threading problem when many sockets open

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Philip Zigoris wrote: > ... and the server > would go into a state where the master thread repeatedly polled the > socket and printed an error. Is that because it cannot create a new socket to accept the connection on? -- http://mail.python.org/mailman/listinfo/py

Re: make images with python

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Boris Borcic wrote: > Lawrence Oluyede wrote: > >> stefano <[EMAIL PROTECTED]> wrote: >>> I need make some images using python but i'm lost :P >> >> >> > > If you want to do antialiased drawings into images, > you might r

Re: accessing keys in dict

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, james_027 wrote: > is there any difference between .. > > for key in a_dict: > > from > > for key in a_dict.keys(): I'm assuming the former is equivalent to for key in a_dict.iterkeys() : -- http://mail.python.org/mailman/listinfo/python-list

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread tooru honda
At the end, I think it is worthwhile to implement my own shuffle and random methods based on os.urandom. Not only does the resulting code gets rid of the minuscule bias, but the program also runs much faster. When using random.SystemRandom.shuffle, posix.open and posix.close from calling os.ur

Re: curses library

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ghirai wrote: > I need to write a console application. Why not just use VT100 escape sequences directly? Terminal emulators don't support anything else. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression use

2007-08-25 Thread John W. Krahn
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Mirco Wahab <[EMAIL PROTECTED]> writes: > |> > |> Using complex regular expressions is like tank destruction > |> with contact charges glued on them. Only a few people > |> will even survive the first "usage", but survivors will > |> then e

Re: Co-developers wanted: document markup language

2007-08-25 Thread Torsten Bronger
Hallöchen! Jeremy Sanders writes: > Torsten Bronger wrote: > >> I don't know exactly what you mean but the answer is probably no. >> For example, I want the author to state the title, keywords, etc >> of his document, however, he should not state that he wants the >> title printed centred and 4cm

Re: Joining Big Files

2007-08-25 Thread Marc 'BlackJack' Rintsch
On Sat, 25 Aug 2007 02:57:24 -0700, mosscliffe wrote: > I have 4 text files each approx 50mb. > > I need to join these into one large text file. > > I only need to do this very occasionally, as the problem has occurred > because of upload limitations. > > Bearing in mind filesize and memory use

Re: beginner, idiomatic python

2007-08-25 Thread Scott David Daniels
bambam wrote: >> The reason that lists don't have set-like methods is because >> lists aren't sets -- lists can contain duplicate elements and they are ordered. I'd have used sets if I was sure you meant [1,2,3] to mean the same thing as [3,1,2] and no duplicates. > Interesting point -- if that's

Re: Regular expression use

2007-08-25 Thread Josef Moellers
Nick Maclaren wrote: > For reasons that I won't explain, as they are too complicated > and not terribly relevant, I am interested in discovering what > people actually use regular expressions for. Not the subject > domain, but the construction of the regular expressions. > > I know about computer

Joining Big Files

2007-08-25 Thread mosscliffe
I have 4 text files each approx 50mb. I need to join these into one large text file. I only need to do this very occasionally, as the problem has occurred because of upload limitations. Bearing in mind filesize and memory useage, would I be better reading every line in every file and writing eac

Re: Co-developers wanted: document markup language

2007-08-25 Thread Jeremy Sanders
Torsten Bronger wrote: > I don't know exactly what you mean but the answer is probably no. > For example, I want the author to state the title, keywords, etc of > his document, however, he should not state that he wants the title > printed centred and 4cm from the top of the page. > > The latter

How to find parent function/class of generators?

2007-08-25 Thread J. A. Aczel
Hello all. I think I should explain my problem in detail, so everyone understands what I'm trying to do and why. There may be a better approach to the whole problem then I am using. I am working on a game, with most of my AI code & such divided up into generator functions (really coroutines that d

Re: Running daemon with zdaemon ... example help?

2007-08-25 Thread asrenzo
Hi, This could also be a good starting point: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 Regards, Laurent Genie T a écrit : > Hi all, > > I'm looking at zdaemon to run my python scripts as a daemon but it > seems to have few example that guide me how to follow. It would be