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

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: 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 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

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

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:

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

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: 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,

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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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 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 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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: 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: 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: 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: 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

fun programming competition

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

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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: 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

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*

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). *

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

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: 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: Sending hex number as is

2005-03-21 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Basically, I just want to send a hex number from one machine to the > next: 'Hex number' is not completely clear. Do you want to send the number in binary form or in text form. Text form is much easier and more dependable, so shou

Re: Text-to-speech

2005-03-21 Thread Bill Mill
On 21 Mar 2005 12:47:07 -0800, Paul McGuire <[EMAIL PROTECTED]> wrote: > Brian, > > Having reviewed your Cease and Desist petition, I'm afraid I must > dispute some or all of your claims: > > 1. Your citation of prior art has one or more significant defects: > a. In your citation, "brace" is clea

Re: For loop extended syntax

2005-03-21 Thread Jeff Shannon
George Sakkis wrote: 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 in python one day; it is pretty obvious what > it would do for any

Re: wxPython vs. pyQt

2005-03-21 Thread [EMAIL PROTECTED]
since I'm developing in Tkinter, I'm intrigued by your comment that: "It allowed me to do things in hours, which literally took weeks with tkinter, " please elaborate! Cheers S -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-21 Thread George Sakkis
"Michele Simionato" <[EMAIL PROTECTED]> wrote: > FWIW, here is my take on the defaultdict approach: > > def defaultdict(defaultfactory, dictclass=dict): > class defdict(dictclass): > def __getitem__(self, key): > try: > return super(defdict, self).__getitem_

Re: For loop extended syntax

2005-03-21 Thread George Sakkis
"Ron" <[EMAIL PROTECTED]> wrote: > How would this examples work? > > for x=5,y,z in (123),(4,5),(6,7,8,9) > > Would the x default over ride the first value? > Should, the 4 element in the third tuple be dropped without an error? It has already been clarified twice in the thread that the default v

Re: Sending hex number as is

2005-03-21 Thread Grant Edwards
On 2005-03-21, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > msg = "Length is " > n = '\x81' > msg += n > sock.send(msg) > > The problem is n's value is not fixed. For example, > > msg = "Length is " > n = len(somestring) > msg += n # This won't work of course, since n is int > > How do I send t

Re: Text-to-speech

2005-03-21 Thread Paul McGuire
Brian, Having reviewed your Cease and Desist petition, I'm afraid I must dispute some or all of your claims: 1. Your citation of prior art has one or more significant defects: a. In your citation, "brace" is clearly rhymed with "whitespace", not "space". The broad concept of "whitespace" is subs

PIGIP Meeting tonight -- Python Interest Group In Princeton

2005-03-21 Thread [EMAIL PROTECTED]
PIGIP will hold it's March meeting tonight at 7pm at the Lawrenceville Public Library. Anyone in Central New Jersey, USA interested in the Python Programming Language is invited to attend. We will be reviewing the Python tutorial (Chapters 6,7,and 8), and open discussion about Python use will be e

Re: Sending hex number as is

2005-03-21 Thread Irmen de Jong
[EMAIL PROTECTED] wrote: > This question may be ased before, but I couldn't find the answer > searching the archive. > > Basically, I just want to send a hex number from one machine to the > next: > > for example > > msg = "Length is " > n = '\x81' > msg += n > sock.send(msg) > > The problem is

Sending hex number as is

2005-03-21 Thread knguyen
This question may be ased before, but I couldn't find the answer searching the archive. Basically, I just want to send a hex number from one machine to the next: for example msg = "Length is " n = '\x81' msg += n sock.send(msg) The problem is n's value is not fixed. For example, msg = "Length

Re: xmlrpc with Python and large datases

2005-03-21 Thread writeson
Duncan, Thanks for the reply. We are running this on an Apache server on the linux box, and an iPlanet4.1 server on the solaris machines. However, both these servers are strictly 'inside' the firewall. I checked the apache configuration and there is no limitrequestbody parameter in the file at all

Re: Python scope is too complicated

2005-03-21 Thread Terry Reedy
"jfj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def foo(x): > y= (i for i in x) > return y > > From the disassembly it seems that the generator is a code object What is type(foo([1,2,3])) ? > but 'x' is not a cell variable. WTF? As I understand it, the object 'x' b

Re: getting text from WinXP console

2005-03-21 Thread Jeff Shannon
Lucas Raab wrote: Chris Maloof wrote: Does anyone know how I can read the ASCII text from a console window (from another application) in WinXP? It doesn't sound like a major operation, but although I can find the window via pywin32, I haven't been able to do anything with it. I'd really just like

Python 2.4 (Windows) Binaries of SciPy

2005-03-21 Thread Srijit Kumar Bhadra
Hello, I have posted a similar message in SciPy mailing list. I hope it is ok to also post it here. I am looking for Python 2.4 Binaries (Windows)of SciPy. Are there any plans to upload Python 2.4 binaries? Best Regards, /Srijit -- http://mail.python.org/mailman/listinfo/python-list

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

2005-03-21 Thread Paul Rubin
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. --

Re: Save passwords in scripts

2005-03-21 Thread Paul Rubin
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 to > execute it but should n

Re: Please help for Python programming

2005-03-21 Thread Terry Reedy
This is what I see (minus the '> '): > while 1: > user, serviceType, msgType, inOut, date, time, numBytes = > aLog.GetNextMessage("") [etc] Advice: use spaces, not tabs, to indent posted code (some readers discard tabs). Don't use google groups to post code (it deletes initial spaces and won't

Re: missing? dictionary methods

2005-03-21 Thread Terry Reedy
"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 if the second file contains a key that > was not in the first fi

Re: generating audio signals

2005-03-21 Thread Cappy2112
>>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() import wave wave.open("filename","b") wave.Wave_read.getparams() -- http:

Re: spaces in re.compile()

2005-03-21 Thread rbt
Jeff Epler wrote: Maybe you want r'\b'. From 'pydoc sre': \b Matches the empty string, but only at the start or end of a word. import re r = re.compile( r'\btest\b' ) print r.findall("testy") print r.findall(" testy ") print r.findall(" test ") print r.findall("test") That works great. T

Re: getting text from WinXP console

2005-03-21 Thread Cappy2112
Are you the one who is launching the Nethack program, or is it already running, and you ar e trying to capture the text after Nethack is launched ? If you are launching it you can try using one of the python popen() calls to redirect the screen output to your python program. I havne't doen this

Re: getting text from WinXP console

2005-03-21 Thread Cappy2112
If you re-direct the output to a file, then you won't see it on the console at all, unless the program writes to stderr separately. -- http://mail.python.org/mailman/listinfo/python-list

Re: Save passwords in scripts

2005-03-21 Thread Esben Pedersen
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 execute it but should not be able to read out

Re: Getting directory size

2005-03-21 Thread P
francisl wrote: How can we get a full directory size (sum of all his data)? like when we type `du -sh mydir` Because os.path.getsize('mydir') only give the size of the directory physical representation on the disk. Have a look at: http://www.pixelbeat.org/scripts/dutop Pádraig. -- http://mail.pyth

Re: [ann] fdups 0.15

2005-03-21 Thread P
Patrick Useldinger wrote: I am happy to announce version 0.15 of fdups. Cool. For reference have a look at: http://www.pixelbeat.org/fslint/ Pádraig. -- http://mail.python.org/mailman/listinfo/python-list

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

2005-03-21 Thread Leif K-Brooks
Claudio Grondi wrote: Is there an already available script/tool able to extract records and generate proper HTML code out of the data stored in the Wikipedia SQL data base? They're not in Python, but there are a couple of tools available here: . By the way: has someone suc

Re: exec src in {}, {} strangeness

2005-03-21 Thread Stefan Seefeld
Bernhard Herzog wrote: Stefan Seefeld <[EMAIL PROTECTED]> writes: Is there anything wrong with 'exec source in a, b' where a and b are distinc originally empty dictionaries ? Again, my test code was class Foo: pass class Bar: foo = Foo and it appears as if 'Foo' was added to 'a', but when evalua

Re: exec src in {}, {} strangeness

2005-03-21 Thread Bernhard Herzog
Stefan Seefeld <[EMAIL PROTECTED]> writes: > Is there anything wrong with 'exec source in a, b' where > a and b are distinc originally empty dictionaries ? Again, > my test code was > > class Foo: pass > class Bar: >foo = Foo > > and it appears as if 'Foo' was added to 'a', but when evaluating

Re: Getting directory size

2005-03-21 Thread Graham Fawcett
Peter Hansen wrote: > francisl wrote: > > How can we get a full directory size (sum of all his data)? > > like when we type `du -sh mydir` > > > > Because os.path.getsize('mydir') only give the size of the directory > > physical representation on the disk. > > os.popen('du -sh mydir') would be one

Re: getting text from WinXP console

2005-03-21 Thread Lucas Raab
Jeff Schwab wrote: Lucas Raab wrote: Chris Maloof wrote: Hello, Does anyone know how I can read the ASCII text from a console window (from another application) in WinXP? It doesn't sound like a major operation, but although I can find the window via pywin32, I haven't been able to do anything with

Re: remove strings from source

2005-03-21 Thread qwweeeit
I am in debt with you of an answer on " my" solution in removing literal strings... I apologize not to have followed your suggestions but I am just learning Python, and your approach was too difficult for me! I've already developed the cross reference tool, and for that I identified two types of li

Re: Save passwords in scripts

2005-03-21 Thread Florian Lindner
Peter Hansen wrote: > Florian Lindner wrote: >> 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 execute it but sh

Re: exec src in {}, {} strangeness

2005-03-21 Thread Stefan Seefeld
Peter Hansen wrote: Stefan Seefeld wrote: Indeed, using 'globals()' and 'locals()' works. However, both report the same underlaying object, which is a bit confusing. (Under what circumstances does 'locals()' return not the same object as 'globals()' ?) When you aren't at the interactive prompt...

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

2005-03-21 Thread Scott David Daniels
Tim Churches wrote: ... My first attempt (which does not scan properly): A Dutch mathematician most prophetic, Did invent a language, name herpetic. With design quite intelligent, And syntax mostly elegant, Big ideas could be made non-hypothetic. To improve the scan: A mathematician, propheti

Re: Python becoming less Lisp-like

2005-03-21 Thread Jeff Shannon
Antoon Pardon wrote: Op 2005-03-18, Jeff Shannon schreef <[EMAIL PROTECTED]>: I find it odd that you start by saying you still find them very consistent and here state there is a slight inconsistency. I said that the way that binding a name on a class instance always creates an instance attribute

  1   2   >