Re: Wikipedia - conversion of in SQL database stored data to HTML

2005-03-21 Thread Claudio Grondi
redirects (if not just down) to http://en.wikipedia.org/wiki/Wikipedia:Database_download#Static_HTML_tree_dumps_for_mirroring_or_CD_distribution I see from this page only one tool (not a couple) which is available to download and use: http://www.tommasoconforti.com/ th

Re: PyGTK and pyexe

2005-03-21 Thread Viktor
I succeeded :))) And the winner is: from distutils.core import setup import py2exe opts = { "py2exe": { "includes": ["pango", "atk", "gobject", "gtk","gtk.glade"], "dll_excludes": ["

Re: PyGTK and pyexe

2005-03-21 Thread Tom Cocagne
I remember removing the locales and all of the documentation. Beyond that I can't remember. If your app falls under the common case of running on machines with ample disk space, I wouldn't worry too much about the size. WinZip does a pretty good job of shrinking my distribution file to a managabl

Python 2.4 | 7.3 The for statement

2005-03-21 Thread brainsucker
Hi My name is Juan Carlos Rodrigo, and I love Python. It is the most impressive and usefull language that I have ever seen. I am studing, at http://www.uoc.edu, an Information Technology Postgraduate. And I have programmed some REXX applications in my past Jobs (So I love python, no more ENDS). *

Set literals

2005-03-21 Thread George Sakkis
How about overloading curly braces for set literals, as in >>> aSet = {1,2,3} - It is the standard mathematic set notation. - There is no ambiguity or backwards compatibility problem. - Sets and dicts are in many respects similar data structures, so why not share the same delimiter ? *ducks*

Re: Set literals

2005-03-21 Thread George Sakkis
> - There is no ambiguity or backwards compatibility problem. ...at least if it wasn't for the empty set.. hmm... -- http://mail.python.org/mailman/listinfo/python-list

RE: Set literals

2005-03-21 Thread Delaney, Timothy C (Timothy)
George Sakkis wrote: > How about overloading curly braces for set literals, as in > aSet = {1,2,3} > > - It is the standard mathematic set notation. > - There is no ambiguity or backwards compatibility problem. > - Sets and dicts are in many respects similar data structures, so why > not sh

Re: Pre-PEP: Dictionary accumulator methods

2005-03-21 Thread Evan Simpson
Raymond Hettinger wrote: I would like to get everyone's thoughts on two new dictionary methods: def count(self, value, qty=1): def appendlist(self, key, *values): -1.0 When I need these, I just use subtype recipes. They seem way too special-purpose for the base dict type. class C

C pointers/Python

2005-03-21 Thread [EMAIL PROTECTED]
Hello, I am trying to convert some C code into python. Here's the C code... typedef enum { CODE1 = 0x1, CODE2 = 0x2 } CODE testit(unsigned char *buffer, unsigned long length, CODE code) { unsigned long data switch (code) { case CODE1: while(len--) {

Re: Set literals

2005-03-21 Thread simon
+1 from me. The other possible meaning for {1,2,3} would be {1:None,2:None,3:None}, but that is usually meant to be a set anyway (done with a dict). So what is this: {1:2, 3, 4 } (apart from "nearly useless") ? hmmm, thinking a bit more about this, it seems you can build a set from a dict's keys

Re: Set literals

2005-03-21 Thread George Sakkis
"Delaney, Timothy C (Timothy)" <[EMAIL PROTECTED]> wrote: > > How about overloading curly braces for set literals, as in > > > aSet = {1,2,3} > > > > - It is the standard mathematic set notation. > > - There is no ambiguity or backwards compatibility problem. > > - Sets and dicts are in many

Re: Building Time Based Bins

2005-03-21 Thread MCD
Thanks Alessandro... I'll have to try that as well. I have a modified working version of John's code (thanks John!). I'm able to output the bins by 5min intervals, sum one of the fields, and get the high and low of each field. So far I'm really happy with how it works. Thank you to everybody. The

Re: Python limericks (was Re: Text-to-speech)

2005-03-21 Thread Peter Hansen
Paul Rubin wrote: Scott David Daniels <[EMAIL PROTECTED]> writes: A mathematician, prophetic, invented a language, herpetic. decidedly brilliant, syntacticly elegant, syntactically elegant, with features intelligent Made ideas far less hypothetic. Made writing new code copasetic. W

Re: Text-to-speech

2005-03-21 Thread Peter Hansen
Bill Mill wrote: T'were two coders in c.l.p Who liked to argue legally About copyright All day and night, Just to prove their inanity Nit-picking: Bill, you missed an "s" in that last word... -- http://mail.python.org/mailman/listinfo/python-list

Re: Set literals

2005-03-21 Thread George Sakkis
[EMAIL PROTECTED]> wrote: > +1 from me. > > The other possible meaning for {1,2,3} would be {1:None,2:None,3:None}, > but that is usually meant to be a set anyway (done with a dict). > > So what is this: {1:2, 3, 4 } (apart from "nearly useless") ? Syntax error; you'll have to decide whether you

Re: getting text from WinXP console

2005-03-21 Thread Peter Hansen
Jeff Shannon wrote: Unless I'm seriously mistaken, the only way that this will be possible is if there's a Win32 API call that will give the correct information. This might be possible to find in the MSDN documentation, if it exists, but I suspect that it probably doesn't. Just thinking: in NT,

Re: getting text from WinXP console

2005-03-21 Thread Ron
On Mon, 21 Mar 2005 12:06:03 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: >Actually, there's probably a second way -- capture the window image as >a bitmap, and then run OCR software on it. There's also OCR aware clipboard software that can cut a selected area from the screen, convert the grap

Re: Building Time Based Bins

2005-03-21 Thread Michael Spencer
MCD wrote: Thanks Alessandro... I'll have to try that as well. I have a modified working version of John's code (thanks John!). I'm able to output the bins by 5min intervals, sum one of the fields, and get the high and low of each field. So far I'm really happy with how it works. Thank you to every

Re: generating audio signals

2005-03-21 Thread Bengt Richter
On 21 Mar 2005 11:12:38 -0800, "Cappy2112" <[EMAIL PROTECTED]> wrote: >>>Maybe make yourself a little utility first that will show you the >specs for any .wav file (i.e., >>>sampling frequency, bytes per sample, channels, etc.) > >You can do this with one function call - wave.Wave_read.getparams()

Re: Save passwords in scripts

2005-03-21 Thread Florian Lindner
Esben Pedersen wrote: > Florian Lindner wrote: >> Hello, >> I've a scripts that allows limited manipulation of a database to users. >> This script of course needs to save a password for the database >> connection. The users, on the other hand need read permission on the >> script in order to execu

Re: Save passwords in scripts

2005-03-21 Thread Florian Lindner
Paul Rubin wrote: > Florian Lindner <[EMAIL PROTECTED]> writes: >> I've a scripts that allows limited manipulation of a database to users. >> This script of course needs to save a password for the database >> connection. The users, on the other hand need read permission on the >> script in order t

Re: simultaneous copy to multiple media

2005-03-21 Thread Bengt Richter
On Mon, 21 Mar 2005 17:53:34 +0100, Jacek Trzmiel <[EMAIL PROTECTED]> wrote: > >> > This is small tool I've wrote, that does use large memory buffers with >> > asynchronous I/O to copy file. > >Claudio Grondi wrote: >> Thank you! >> This (with a drawback of blocking the entire system) does it! >>

Re: C pointers/Python

2005-03-21 Thread Stephen Thorne
On 21 Mar 2005 15:52:44 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to convert some C code into python. > Here's the C code... > > typedef enum { > CODE1 = 0x1, > CODE2 = 0x2 > } CODE > testit(unsigned char *buffer, >unsigned long length, >CODE cod

fun programming competition

2005-03-21 Thread integer
http://dinsights.com/POTM/KEYSTROKES/details.php -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple account program

2005-03-21 Thread Igorati
Question then, do I do an import pickle pickle.dump ((withdrawl), file ('account.pickle', 'w')) pickle.dump ((deposit), file ('account.pickle', 'w')) Am I on the right track? -- http://mail.python.org/mailman/listinfo/python-list

Re: C pointers/Python

2005-03-21 Thread integer
you never deal directly with pointers in python. in your case, you need to pass a mutable object as your 'buffer' argument and perform operations on it such that 'buffer==data'. (for example, you could use a list here.) def testit( buffer ): for i in range( len ): buffer[A+i]=data[B+i] for

Re: Please help for Python programming

2005-03-21 Thread yy0127
Actually, this script will open a text file which is seperated by tabs. The PRINT code is for my testing. My problem is bytemsg will be omitted some records. For example, my text file have 53 records about username. After byteDict = users1[user1], it remains 50 records in the output file. I woul

Re: exec src in {}, {} strangeness

2005-03-21 Thread Greg Ewing
Stefan Seefeld wrote: Bernhard Herzog wrote: When "foo = Foo" is executed, Foo is first looked up in that new locals dictionary. That fails, so it's also looked up in the globals dictionary a. That fails as well because Foo was bound in b. The final lookup in the builtins also fails, and thus yo

Re: missing? dictionary methods

2005-03-21 Thread Chris Rebert (cybercobra)
Antoon Pardon wrote: > Well at least I find them missing. > > For the moment I frequently come across the following cases. > > 1) Two files, each with key-value pairs for the same dictionary. > However it is an error if the second file contains a key that > was not in the first file. > > In treati

Re: For loop extended syntax

2005-03-21 Thread Terry Reedy
"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > A generalization of the 'for .. in' syntax that would handle > extra arguments the same way as functions would be: > > for (x,y,z=0,*rest) in (1,2,3), (3,4), (5,6,7,8): > print x, y, z, rest > > I'd love to see this

sorting a dictionary?

2005-03-21 Thread Anthony Liu
I have a dictionary which contains some words and their frequency in a short novel. It looks like this: mydict = {'the':358, 'they':29, 'went':7, 'said':65} Is there an easy to sort this dictionary and get a list like the following (in decreasing order)? the 358 said 65 they 29 went 7 Tha

Re: getting text from WinXP console

2005-03-21 Thread Jeff Shannon
Peter Hansen wrote: Jeff Shannon wrote: Unless I'm seriously mistaken, the only way that this will be possible is if there's a Win32 API call that will give the correct information. This might be possible to find in the MSDN documentation, if it exists, but I suspect that it probably doesn't. J

Re: Pre-PEP: Dictionary accumulator methods

2005-03-21 Thread Greg Ewing
Michele Simionato wrote: def defaultdict(defaultfactory, dictclass=dict): class defdict(dictclass): def __getitem__(self, key): try: return super(defdict, self).__getitem__(key) except KeyError: return self.setdefault(key, defaultf

Re: For loop extended syntax

2005-03-21 Thread Greg Ewing
Jeff Shannon wrote: Function arguments are *not* (in general) a case of tuple unpacking, on the other hand, so the parallels between function arguments and for loop control-variable tuples are not so straightforward as is being claimed. It seems to me the parallel is close enough that no confusio

Re: sorting a dictionary?

2005-03-21 Thread M.E.Farmer
This comes up so often on this list that there are many examples and recipes. You are looking for a dictionary sort by value. search strategy: Python sorting dictionary 44,000+ hits on google. First entry: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52306 hth, M.E.Farmer -- http://

Re: missing? dictionary methods

2005-03-21 Thread Greg Ewing
George Sakkis wrote: As for naming, I would suggest reset() instead of set(), to emphasize that the key must be there. make() is ok; other candidates could be add() or put(). How about 'new' and 'old'? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand

Re: Building Time Based Bins

2005-03-21 Thread MCD
Hi Michael, thanks for responding. I actually don't use a method to get each bin... the bin outputs are nested in the loop. Here's my code: data_file = open('G:\file.txt') DUMMY = bintm = DUMMY for line in data_file: fields = line.strip().split() if not line: continue ilist = [int

Re: For loop extended syntax

2005-03-21 Thread Ron
On Mon, 21 Mar 2005 15:56:26 -0500, "George Sakkis" <[EMAIL PROTECTED]> wrote: >It has already been clarified twice in the thread that the default values >would be allowed *only in >the end*, exactly as default function arguments. Was just asking if there should be other special general cases.

Re: inline comparison

2005-03-21 Thread sam
Diez B. Roggisch wrote: If you really need that sort of dependent matching, there are better ways to accomplish that in python: for m, name in [self.macro_parser, self.a_parser, self.b_parser, ...]: mo = m.match(data) if mo: break Hi, this method looks more elegant. However I got th

Re: sorting a dictionary?

2005-03-21 Thread Scott David Daniels
Anthony Liu wrote: mydict = {'the':358, 'they':29, 'went':7, 'said':65} Is there an easy to sort this dictionary and get a list like the following (in decreasing order)? Yes. def sortkey((word, frequency)): return -frequency, word for word_freq in sorted(mydict.items(), key=sortkey)

Re: inline comparison

2005-03-21 Thread Steve Holden
sam wrote: Diez B. Roggisch wrote: If you really need that sort of dependent matching, there are better ways to accomplish that in python: for m, name in [self.macro_parser, self.a_parser, self.b_parser, ...]: mo = m.match(data) if mo: break Hi, this method looks more elegant. How

Re: sorting a dictionary?

2005-03-21 Thread Anthony Liu
--- Scott David Daniels <[EMAIL PROTECTED]> wrote: > Anthony Liu wrote: > > mydict = {'the':358, 'they':29, 'went':7, > 'said':65} > > Is there an easy to sort this dictionary and get a > > list like the following (in decreasing order)? > Yes. > > def sortkey((word, frequency)): > r

Re: Python scope is too complicated

2005-03-21 Thread Greg Ewing
jfj wrote: def foo(x): y= (i for i in x) return y From the disassembly it seems that the generator is a code object but 'x' is not a cell variable. WTF? That's because x is not assigned to anywhere in the body of foo. The bytecode compiler optimizes away the creation of a cell in this ca

Re: C pointers/Python

2005-03-21 Thread Stephen Thorne
On 21 Mar 2005 17:16:18 -0800, integer <[EMAIL PROTECTED]> wrote: > you never deal directly with pointers in python. > in your case, you need to pass a mutable object as your 'buffer' > argument and perform operations on it such that 'buffer==data'. (for > example, you could use a list here.) > def

Re: C pointers/Python

2005-03-21 Thread Marcin Mika
agreed. you might say i was trying to translate his C code "word for word", rather than properly "pythonizing" the entire chunk of code as a whole. -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple account program

2005-03-21 Thread Greg Ewing
Igorati wrote: pickle.dump ((withdrawl), file ('account.pickle', 'w')) ^ Is this banking done with an American accent? :-) pickle.dump ((deposit), file ('account.pickle', 'w')) Am I on the right track? The file you create in the second statement is going to overwrite the fir

Re: C pointers/Python

2005-03-21 Thread [EMAIL PROTECTED]
Can i do something like this? if code == CODE1: data = 0x0 While True: len = len - 1 if len == -1: break buffer = data Do i need to initialze the buffer? -Thanks, Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Python limericks (was Re: Text-to-speech)

2005-03-21 Thread Bengt Richter
On Mon, 21 Mar 2005 15:39:45 +1100, Tim Churches <[EMAIL PROTECTED]> wrote: >Steve Holden wrote: >> Tim Churches wrote: >>> There once was a language called Python... >>> >>> (which is pretty close to having three anapaestic left feet) >>> >>> or more promisingly, rhyme-wise, but metrically rather

Re: getting text from WinXP console

2005-03-21 Thread Chris Maloof
Thanks for the interesting suggestions! On 21 Mar 2005 10:47:52 -0800, "Cappy2112" <[EMAIL PROTECTED]> wrote: >If you are launching it you can try using one of the python popen() >calls to redirect the screen output to your python program. Aha. This sounds perfect, and I don't know why it doesn

Re: Pre-PEP: Dictionary accumulator methods

2005-03-21 Thread Roose
I agree -- I find myself NEEDING sets more and more. I use them with this idiom quite often. Once they become more widely available (i.e. Python 2.3 is installed everywhere), I will use them almost as much as lists I bet. So any solution IMO needs to at least encompass sets. But preferably some

Re: sorting a dictionary?

2005-03-21 Thread George Sakkis
"Anthony Liu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > --- Scott David Daniels <[EMAIL PROTECTED]> wrote: > > Anthony Liu wrote: > > > mydict = {'the':358, 'they':29, 'went':7, > > 'said':65} > > > Is there an easy to sort this dictionary and get a > > > list like the followi

Re: sorting a dictionary?

2005-03-21 Thread Scott David Daniels
Anthony Liu wrote: --- Scott David Daniels <[EMAIL PROTECTED]> wrote: def sortkey((word, frequency)): return -frequency, word for word_freq in sorted(mydict.items(), key=sortkey): print '%-6s %s' % word_freq Thank you scott, but 'sorted' itself is not a python library functi

Re: Building Time Based Bins

2005-03-21 Thread Michael Spencer
MCD wrote: Hi Michael, thanks for responding. I actually don't use a method to get each bin... That's because you picked the wrong suggestion ;-) No, seriously, you can do it easily with this approach: the bin outputs are nested in the loop. Here's my code: data_file = open('G:\file.txt') DUMM

Re: C pointers/Python

2005-03-21 Thread Marcin Mika
> Can i do something like this? > > if code == CODE1: > data = 0x0 > While True: > len = len - 1 > if len == -1: > break > buffer = data certainly not! there are many things wrong with that. first of all, as was pointed out already: this is highly u

Re: For loop extended syntax

2005-03-21 Thread Kay Schluehr
Terry Reedy wrote: > Jeff covered the obvious objection that this is a change from assignment > sematics to function call semantics. > Slightly less obvious is that this > will slow down everyone's for loops for the benefit of the very few who > would want to do such a thing. If the action of (x,

Anonymus functions revisited

2005-03-21 Thread Kay Schluehr
Since George Sakkis proposed a new way of doing list comprehensions http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/ac5023ad18b2835f/d3ff1b81fa70c8a7#d3ff1b81fa70c8a7 letting tuples-like objects (x,y,z=0) acting as functions on other tuples I wonder why this would not be a

Anonymus functions revisited

2005-03-21 Thread Kay Schluehr
Since George Sakkis proposed a new way of doing list comprehensions http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/ac5023ad18b2835f/d3ff1b81fa70c8a7#d3ff1b81fa70c8a7 letting tuples-like objects (x,y,z=0) acting as functions on other tuples I wonder why this would not be a

Re: Simple account program

2005-03-21 Thread Chris Rebert (cybercobra)
You probably want: import pickle pickle.dump(myAccount, file("account.pickle", "w")) To reload your account: import pickle myAccount = pickle.load(file("account.pickle")) -- http://mail.python.org/mailman/listinfo/python-list

Begniner Question

2005-03-21 Thread Glen
#!/usr/local/bin/python import sys print "1.\tDo Something" print "2.\tDo Something" print "3.\tDo Something" print "4.\tDo Something" print "5.\tDo Something" print "6.\tExit" choice=raw_input("Please Enter Choice: ") if int(choice)==1: print "Here" else: pass if int(choice)==2: else:

Embeding Py: failed to instantiate a class

2005-03-21 Thread Brano Zarnovican
Hi ! I need to import a module and create an instance of a class from that module (in C). import mod o = mod.klass() (mod.klass is a subclass of tuple) When I receive a class object from the module.. module = PyImport_ImportModule("mod") cls = PyObject_GetAttrString(module, "klass") ..it fail

Re: Begniner Question

2005-03-21 Thread Mikael Olofsson
"Glen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] if int(choice)==2: else: pass File "./Code.py", line 20 else: ^ IndentationError: expeted an indented block What am I doing wrong? As the error trace informs you, Python expexts an indented block. You need to put something

RE: Begniner Question

2005-03-21 Thread Vishnu
>if int(choice)==2: >else: > pass if int(choice)==2: print "Here" # <== There should be some statement present after the # if condition. Likewise place this statement in # all other if conditions else: pass HTH, Vishnu -Original Message--

Re: Begniner Question

2005-03-21 Thread Robert Kern
Glen wrote: #!/usr/local/bin/python import sys print "1.\tDo Something" print "2.\tDo Something" print "3.\tDo Something" print "4.\tDo Something" print "5.\tDo Something" print "6.\tExit" choice=raw_input("Please Enter Choice: ") if int(choice)==1: print "Here" else: pass if int(choice)==2:

Re: missing? dictionary methods

2005-03-21 Thread Antoon Pardon
Op 2005-03-21, Terry Reedy schreef <[EMAIL PROTECTED]>: > > "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> For the moment I frequently come across the following cases. >> >> 1) Two files, each with key-value pairs for the same dictionary. >> However it is an error

<    1   2