Re: Turning a callback function into a generator

2006-07-03 Thread Alex Martelli
Kirk McDonald <[EMAIL PROTECTED]> wrote: ... > > def func(callback): > > for i in [1, 2, 3, 4, 5]: > > callback(i) ... > Threads are probably a weak point of mine. I have little experience with > them, and so I am inclined to paranoia while using them. What Paranoia is the cor

2006 ICFP Programming Contest registration opens

2006-07-03 Thread Tom 7
Language lovers: Registration is now open for the 9th Annual ICFP Programming Contest! http://icfpcontest.org/ The contest, associated with the International Conference on Functional Programming, will be held on the weekend of July 21-24. The contest task will be released at noon EDT on Frid

Re: Classes and global statements

2006-07-03 Thread Sheldon
Simon Forman skrev: > Sheldon wrote: > > Hi, > > > > I have a series of classes that are all within the same file. Each is > > called at different times by the main script. Now I have discovered > > that I need several variables returned to the main script. Simple, > > right? I thought so and sim

Re: Classes and global statements

2006-07-03 Thread Sheldon
Scott David Daniels skrev: > Sheldon wrote: > > Hi, > > > > I have a series of classes that are all within the same file. Each is > > called at different times by the main script. Now I have discovered > > that I need several variables returned to the main script. Simple, > > right? I thought so

sending binary data over sockets

2006-07-03 Thread thorley
Greetings, since there was no reponse to my previous post about an existing FastCGI server in python, I've taken to writing my own. (which of course I'll share--*if* there's something to share ;) My problem now, is that I need to send certain binary data over a socket. That is, I want to make some

Re: sending binary data over sockets

2006-07-03 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Greetings, since there was no reponse to my previous post about an > existing FastCGI server in python, I've taken to writing my own. (which > of course I'll share--*if* there's something to share ;) > > My problem now, is that I need to send certain binary data over a

Re: sending binary data over sockets

2006-07-03 Thread Diez B. Roggisch
Premature sending syndrome... Diez B. Roggisch schrieb: > [EMAIL PROTECTED] schrieb: >> Greetings, since there was no reponse to my previous post about an >> existing FastCGI server in python, I've taken to writing my own. (which >> of course I'll share--*if* there's something to share ;) >> >> My

Re: sending binary data over sockets

2006-07-03 Thread Sukanta
[EMAIL PROTECTED] wrote: > Greetings, since there was no reponse to my previous post about an > existing FastCGI server in python, I've taken to writing my own. (which > of course I'll share--*if* there's something to share ;) > > My problem now, is that I need to send certain binary data over a >

Re: sending binary data over sockets

2006-07-03 Thread Grant Edwards
On 2006-07-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > My problem now, is that I need to send certain binary data over a > socket. That is, I want to make some bytes, and stuff them in a TCP > packet, send them down the pipe, and then listen for a response. > > socket.send, as best I can te

(Job) SF BAY AREA -- Python Expert

2006-07-03 Thread jscalisi
Taos is a professional IT Consulting Services firm that has been delivering technical excellence to its customers for more than 17 years. We have an immediate openning for a Unix System Administrator with excellent python scripting experience. Please contact [EMAIL PROTECTED] for immediate consid

RE: Dictionary .keys() and .values() should return a set[withPython3000 in mind]

2006-07-03 Thread Delaney, Timothy (Tim)
Paul Rubin wrote: > "Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> writes: >> If you want an independent data set, you have to take a snapshot. >> For the above, that's doing: >> >> k0 = list(d.keys()) > > I don't understand. Why have .keys() at all, if it doesn't get you > an independent da

Re: sending binary data over sockets

2006-07-03 Thread thorley
> Python strings are binary data and can contain > - in oppostion to e.g. C-strings - null-bytes. > > So it is perfectly alright to send "only" strings over a socket. Agreed. I wasn't trying to imply it was 'wrong' just that the receiving application wouldn't interpret strings correctly. -- ht

Re: sending binary data over sockets

2006-07-03 Thread thorley
> It will send the 4 bytes, binary, and not the string as you assumed. If > you want to satisfy yourself, run tcpdump (or ethereal) to observe what > is being sent. Thanks very much for the prompt reply. I'll take your word for it. I actually tried ethereal to verify my hypothesis before posting,

RE: Dictionary .keys() and .values() should return a set [withPython3000 in mind]

2006-07-03 Thread Delaney, Timothy (Tim)
Paul Rubin wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> And a "view" of the dictionary is orders faster than creating a copy >> of it (which is required to keep k0 from changing in your example). >> If you're LUCKY, copying a dictionary is O(n), > > There are ways to do it so you

Re: sending binary data over sockets

2006-07-03 Thread thorley
> Are those not the four octets you wanted to send? Yes. My understanding of struct was broken. Sukanta corrected it for me. thank you -- matthew -- http://mail.python.org/mailman/listinfo/python-list

Re: Out of the box database support

2006-07-03 Thread Alex Biddle
On 7/3/06, Paul McGuire <[EMAIL PROTECTED]> wrote: > "Alex Biddle" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hey, thanks for the reply Jean-Paul. > > > > That's pretty cool knowing that Python 2.5 will have it out of the > > box, however what about basic out-of-the-box funct

Re: sending binary data over sockets

2006-07-03 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Greetings, since there was no reponse to my previous post about an > existing FastCGI server in python, I've taken to writing my own. (which > of course I'll share--*if* there's something to share ;) > > My problem now, is that I need to send certain binary data over a >

Re: Dictionary .keys() and .values() should return a set [withPython3000 in mind]

2006-07-03 Thread Scott David Daniels
Delaney, Timothy (Tim) wrote: > Plus copy-on-write isn't something you want in general - it's *much* > slower since it needs to copy the internal data every time it's > modified. The vast majority of uses of data structures does not involve > concurrent modification. But copy-on-write in the prese

Re: inline metaclasses

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, gangesmaster wrote: > just something i thought looked nice and wanted to share with the rest > of you: > class x(object): > ... def __metaclass__(name, bases, dict): > ... print "hello" > ... return type(name, bases, dict) > ... > hello >>>

starting and stopping a program from inside a python script

2006-07-03 Thread dfaber
Aloha! I want to terminate a process/program from within a python script. For example, if I have a program say foo.sh that starts running, then I can run it from within a python script using os.popen('foo.sh') which starts a program/process say 'bar' At some point later, I want to kill 'bar'. C

RE: Dictionary .keys() and .values() should return a set[withPython3000 in mind]

2006-07-03 Thread Delaney, Timothy (Tim)
Scott David Daniels wrote: > Delaney, Timothy (Tim) wrote: >> Plus copy-on-write isn't something you want in general - it's *much* >> slower since it needs to copy the internal data every time it's >> modified. The vast majority of uses of data structures does not >> involve concurrent modificatio

ascii character - removing chars from string

2006-07-03 Thread bruce
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii chars. i'm assuming python has something like valid_str = strip(invalid_str) where 'strip' removes/strips

Re: ascii character - removing chars from string

2006-07-03 Thread bearophileHUGS
bruce: > valid_str = strip(invalid_str) > where 'strip' removes/strips out the invalid chars... This isn't short but it is fast: import string valid_chars = string.lowercase + string.uppercase + \ string.digits + """|!'\\"£$%&/()=?^*é§_:;>+,.-<\n \t""" all_chars = "".join(map(

Re: ascii character - removing chars from string

2006-07-03 Thread John Machin
On 4/07/2006 9:27 AM, bruce wrote: > hi... > > i'm running into a problem where i'm seeing non-ascii chars in the parsing > i'm doing. in looking through various docs, i can't find functions to > remove/restrict strings to valid ascii chars. > It's possible that you would be better off handling

Re: Controlling Windows Media Player from Python

2006-07-03 Thread Lawrence Oluyede
Jeffrey Barish <[EMAIL PROTECTED]> wrote: > Is there a way to interact with Windows Media Player from Python? I would > like to be able to do things like tell WMP to play a given sound file or to > ask WMP for metadata about a sound file. Take a look at pywinauto, I attended the today talk at EP

Re: ascii character - removing chars from string

2006-07-03 Thread Rune Strand
bruce wrote: > hi... > > i'm running into a problem where i'm seeing non-ascii chars in the parsing > i'm doing. in looking through various docs, i can't find functions to > remove/restrict strings to valid ascii chars. > > i'm assuming python has something like > > valid_str = strip(invalid_str) >

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
bruce wrote: > hi... > > i'm running into a problem where i'm seeing non-ascii chars in the parsing > i'm doing. in looking through various docs, i can't find functions to > remove/restrict strings to valid ascii chars. > > i'm assuming python has something like > > valid_str = strip(invalid_str) >

Re: inline metaclasses

2006-07-03 Thread Alex Martelli
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, gangesmaster > wrote: > > > just something i thought looked nice and wanted to share with the rest > > of you: > > > class x(object): > > ... def __metaclass__(name, bases, dict): > > ... print "he

Re: Threads and time.strptime()

2006-07-03 Thread placid
Maximilian Michel wrote: > Hi all, > > I have an interesting problem: > I have written code, that reads a logfile and parses it for date string > (Thu Jun 29 14:01:23 2006). > Standalone everthing works fine, all is recognized. > > But if I let the same code run in a thread, with the same file as

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
hi... update. i'm getting back html, and i'm getting strings like " foo  " which is valid HTML as the ' ' is a space. i need a way of stripping/removing the ' ' from the string the   needs to be treated as a single char... text = "foo cat  " ie ok_text = strip(text) ok_text = "foo cat" th

Re: sending binary data over sockets

2006-07-03 Thread Simon Forman
Grant Edwards wrote: > On 2006-07-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > My problem now, is that I need to send certain binary data over a > > socket. That is, I want to make some bytes, and stuff them in a TCP > > packet, send them down the pipe, and then listen for a response. ...

Re: Out of the box database support

2006-07-03 Thread BartlebyScrivener
> Thanks for the info. No thanks for the smarmy "pony" comment. Do you really want "smarmy" here? I don't think it works. Don't you mean "flip" or "smart-alecky" or "facetious"? Websters 3rd Unabridged Main Entry:smarmy Function:adjective Inflected Form:-er/-est 1 : SLEEK *smarmy-headed David Wa

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
bruce wrote: > hi... > > update. i'm getting back html, and i'm getting strings like " foo  " > which is valid HTML as the ' ' is a space. &, n, b, s, p, ; Those are all ascii characters. > i need a way of stripping/removing the ' ' from the string > > the   needs to be treated as a single char.

Re: Out of the box database support

2006-07-03 Thread Terry Hancock
BartlebyScrivener wrote: > > Thanks for the info. No thanks for the smarmy "pony" comment. > > Do you really want "smarmy" here? I don't think it works. Don't you > mean "flip" or "smart-alecky" or "facetious"? Hmm. I think the word we're looking for here is "snarky". ;-) Although, I confess to

simple script - Tkinter question.

2006-07-03 Thread jkuo22
Hi everyone, Here is my simple Tkinter script: ## start of entry.py from Tkinter import * root=Tk() e1=Entry(root, width=16) e1.pack() e2=Entry(root, width=16) e2.pack() mainloop() ## end First, it works on win2k. When I run it as 'python entry.py' on linux, both 'e1' and 'e2' appear perfectly e

sqlite3 in Python 2.5b1: my out-of-the-box experience

2006-07-03 Thread John Machin
Apologies in advance if this is a bit bloggy, but I'd like to get comments on whether I've lost the plot (or, more likely, failed to acquire it) before I start reporting bugs etc. From "What's new ...": """ # Create table c.execute('''create table stocks (date timestamp, trans varchar, symbol v

simple script - Tkinter question.

2006-07-03 Thread jkuo22
Hi everyone, Here is my simple Tkinter script: ## start of entry.py from Tkinter import * root=Tk() e1=Entry(root, width=16) e1.pack() e2=Entry(root, width=16) e2.pack() mainloop() ## end First, it works on win2k. When I run it as 'python entry.py' on linux, both 'e1' and 'e2' appear perfectly e

Re: list comprehension

2006-07-03 Thread Terry Hancock
Andy Dingley <[EMAIL PROTECTED]> wrote: > Simon Forman wrote: > > > There's more to it, but that's the basic idea. > > This much I knew, but _why_ and _when_ would I choose to use list > comprehension (for good Python style), rather than using a simple > "traditional" loop ? They are a very co

Re: Out of the box database support

2006-07-03 Thread Alex Martelli
Terry Hancock <[EMAIL PROTECTED]> wrote: ... > Although, I confess to ignorance on what a "snark" is or whether http://www.gutenberg.org/etext/13 Alex -- http://mail.python.org/mailman/listinfo/python-list

a question about "return"

2006-07-03 Thread yaru22
In one of the examples in the book I'm reading, it says: def __init__(self): ... ... ... return It has nothing after "return". I expected it to have some number like 0 or 1. What does it mean to have nothing after return? Why do we even include "return" if we are not putting any

Re: inline metaclasses

2006-07-03 Thread K.S.Sreeram
Marc 'BlackJack' Rintsch wrote: > But why use a metaclass? If the meta class is only applied to *one* > class, can't you do at class level whatever the metaclass is doing!? The very fact that you can put a loop inside __metaclass__ may be reason enough for a one-off metaclass. Here's a contrived

Re: Out of the box database support

2006-07-03 Thread BartlebyScrivener
Alex Martelli wrote: > http://www.gutenberg.org/etext/13 Leave it to the guy who can quote Borges and The Celestial Emporium of Benevolent Knowledge while explaining multiple inheritance. See Cookbook 2nd Ed pg. 234 -- http://mail.python.org/mailman/listinfo/python-list

RE: ascii character - removing chars from string

2006-07-03 Thread bruce
simon... the ' ' is not to be seen/viewed as text/ascii.. it's a representation of a hex 'u\xa0' if i recall... i'm looking to remove or replace the insances with a ' ' (space) -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Simon Forman Sent: Mond

Re: Threads and time.strptime()

2006-07-03 Thread John Machin
On 3/07/2006 6:57 PM, Maximilian Michel wrote: > Hi all, > > I have an interesting problem: > I have written code, that reads a logfile and parses it for date string > (Thu Jun 29 14:01:23 2006). > Standalone everthing works fine, all is recognized. > > But if I let the same code run in a thread,

Re: Tkinter function variable passing

2006-07-03 Thread arvind
please send it to-[EMAIL PROTECTED] Fredrik Lundh wrote: > "arvind" <[EMAIL PROTECTED]> wrote: > > > thanx for replynig. > > but functios are independent > > and the button is inside one of the functions. > > will u please reshape ur code and send it to me? > > where do I send the invoice ?

Re: Out of the box database support

2006-07-03 Thread Alex Martelli
BartlebyScrivener <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > http://www.gutenberg.org/etext/13 > > Leave it to the guy who can quote Borges and The Celestial Emporium of > Benevolent Knowledge while explaining multiple inheritance. > > See Cookbook 2nd Ed pg. 234 ...;-) Alex --

Best Python web-hosting?

2006-07-03 Thread Luis M. Gonzalez
Hi Walter,   I just read your message about "dollar-hosting.org" that you posted a couple months ago, and I wonder how was your experience with this service so far.   How does mod_python work? Are the basic handlers properly configured? (publisher, psp) Is it easy to use?   Is it possible to

Re: sqlite3 in Python 2.5b1: my out-of-the-box experience

2006-07-03 Thread Avizoa
John Machin wrote: > Apologies in advance if this is a bit bloggy, but I'd like to get > comments on whether I've lost the plot (or, more likely, failed to > acquire it) before I start reporting bugs etc. These are not, in fact, bugs. One of SQLite's features is that it does not enforce type, mea

RE: ascii character - removing chars from string update

2006-07-03 Thread bruce
update... here is a sample of the text i'm looking to do hte search/replace for... ACCT 209 - SURVEY OF ACCT PRIN   i'm trying to figure out how to replace the " " with a ''. in html, the ' ' char is not a valid ascii char... in perl, i'd do 's / //' and be done with it

"Next Generation Artificial Intelligence, Artificial Mind - Part One - Basic Architecture and Cognitive Structure"

2006-07-03 Thread tommak
It's a dream of human beings to build machines that can think and behave like human beings. The most important part of of such a machine is an artificial mind that can emulate the cognitive processing of human mind. This book, "Next Generation Artificial Intelligence, Artificial Mind - Part One

Re: a question about "return"

2006-07-03 Thread Grant Edwards
On 2006-07-04, yaru22 <[EMAIL PROTECTED]> wrote: > What does it mean to have nothing after return? It means to return None. > Why do we even include "return" if we are not putting any > value after? If it's the last statement in the function, you don't need it. Some people do it just as a forma

How can I access the 'Entry' string in another function?

2006-07-03 Thread arvind
hi all, i've created the myclass instance and calles the "function second()". i want to access the text entered in 'w' through Entry widget in "function third()" i am getting the 'fuction not having 'w' attribute error. how to overcome it? class myclass: senter='arvind' def __init__(self

Re: a question about "return"

2006-07-03 Thread Tim Roberts
"yaru22" <[EMAIL PROTECTED]> wrote: >In one of the examples in the book I'm reading, it says: > >def __init__(self): >... >... >... >return > >It has nothing after "return". I expected it to have some number like 0 >or 1. > >What does it mean to have nothing after return? It means

Re: Can I do it using python?? about xterm and telnet

2006-07-03 Thread Marc Schoechlin
valpa schrieb: > Can I do it automatically by python? After that, there have 20 xterm > consoles opened and telneted to their corresponding servers. Then I > could start to type command in these xterms. Is there a framework/module to automate ssh-sessions/scp-filetransfers with python-programmi

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
bruce wrote: > simon... > > the ' ' is not to be seen/viewed as text/ascii.. it's a representation > of a hex 'u\xa0' if i recall... Did you not see this part of the post that you're replying to? > 'nbsp': '\xa0', My point was not that '\xa0' is an ascii character... It was that your initial re

Re: Controlling Windows Media Player from Python

2006-07-03 Thread Roger Upole
"Jeffrey Barish" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a way to interact with Windows Media Player from Python? I would > like to be able to do things like tell WMP to play a given sound file or to > ask WMP for metadata about a sound file. > -- > Jeffrey Barish

How to specify default directory for saving files in IDLE

2006-07-03 Thread JohnJohnUSA
I am using Python IDLE 2.4.3 on Windows XP. I use File->New Window to create a new program. In the Save As dialog, it always takes me to the python program directory (where python is installed). Since this is not where I want to save my source file, I have to select the directory I want. Is there

converting file formats to txt

2006-07-03 Thread Gaurav Agarwal
Hi All, Am looking for a python script that can convert fileformats to txt format. Am unable to find anything in python. Currently the InfoCon projects looks pretty good to use, but it is return in java. Thanks and Regards, Gaurav Agarwal -- http://mail.python.org/mailman/listinfo/python-list

converting file formats to txt

2006-07-03 Thread Gaurav Agarwal
Hi All, Am looking for a python script that can convert fileformats to txt format. Am unable to find anything in python. Currently the InfoCon projects looks pretty good to use, but it is return in java. Thanks and Regards, Gaurav Agarwal -- http://mail.python.org/mailman/listinfo/python-list

my newsgroup base database. (test)

2006-07-03 Thread Netkiller
#!/usr/bin/python # -*- coding: utf-8 -*- """ Project: Network News Transport Protocol Server Program Description: 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子 Reference: NNTP协议: http://www.mibsoftware.com/userkt/0099.htm 正则表达式: http://wiki.woodpecker.org.cn/moin/RegExpInPython#head-235876538484

Re: How can I access the 'Entry' string in another function?

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, arvind wrote: > i've created the myclass instance and calles the "function second()". > i want to access the text entered in 'w' through Entry widget in > "function third()" > i am getting the 'fuction not having 'w' attribute error. > how to overcome it? Make `w` an attri

Re: my newsgroup base database. (test)

2006-07-03 Thread Netkiller
Netkiller 写道: > #!/usr/bin/python > # -*- coding: utf-8 -*- > """ > Project: Network News Transport Protocol Server Program > Description: > 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子 import sys,re import MySQLdb class NewsDB: conn = None cursor = None def connect(self): try:

RE: ascii character - removing chars from string update

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bruce wrote: > here is a sample of the text i'm looking to do hte search/replace for... > > bgcolor="#ff" > ACCT 209 - SURVEY OF ACCT PRIN   > > i'm trying to figure out how to replace the " " with a ''. in html, the > ' ' char is not a valid

Re: my newsgroup base database. (test)

2006-07-03 Thread Netkiller
Netkiller 写道: > Netkiller 写道: > > > #!/usr/bin/python > > # -*- coding: utf-8 -*- > > """ > > Project: Network News Transport Protocol Server Program > > Description: > > 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子 > > Database SQL Script follow: -- phpMyAdmin SQL Dump -- version 2.7.0-rc1 -- http://www.ph

Re: simple script - Tkinter question.

2006-07-03 Thread Eric Brunel
On Tue, 04 Jul 2006 05:02:39 +0200, jkuo22 <[EMAIL PROTECTED]> wrote: > Hi everyone, > > Here is my simple Tkinter script: > > ## start of entry.py > from Tkinter import * > root=Tk() > e1=Entry(root, width=16) > e1.pack() > e2=Entry(root, width=16) > e2.pack() > mainloop() > ## end > > First, it

Re: converting file formats to txt

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gaurav Agarwal wrote: > Am looking for a python script that can convert fileformats to txt > format. Am unable to find anything in python. Currently the InfoCon > projects looks pretty good to use, but it is return in java. What do you mean by 'fileformats'? A script that

<    1   2