Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread Tim Chase
> def chunkify(s, chunksize): > "Yield sequence s in chunks of size chunksize." > for i in range(0, len(s), chunksize): > yield s[i:i+chunksize] > > I wrote this because I need to take a string of a really, really long > length and process 4000 bytes at a time. > > Is there a bett

Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread Fredrik Lundh
Matthew Wilson wrote: > I wrote a function that I suspect may already exist as a python builtin, > but I can't find it: > > def chunkify(s, chunksize): > "Yield sequence s in chunks of size chunksize." > for i in range(0, len(s), chunksize): > yield s[i:i+chunksize] > > I wrote t

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Fredrik Lundh
Larry Hastings wrote: >> Nice idea, though. You might also see how it does on tasks like >> >> s = "" >> for i in range(10): >> s += "a" > > Sure. Here are the results, but with range (1000): ten million? what hardware are you running this on? > Python 2.5 release: 31.0s >

Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread George Sakkis
Matthew Wilson wrote: > I wrote a function that I suspect may already exist as a python builtin, > but I can't find it: > > def chunkify(s, chunksize): > "Yield sequence s in chunks of size chunksize." > for i in range(0, len(s), chunksize): > yield s[i:i+chunksize] > > I wrote thi

Re: Problems with Python 2.5 installer.

2006-09-29 Thread John Machin
Matthew Warren wrote: > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of paw > Sent: 29 September 2006 11:01 > To: python-list@python.org > Subject: Re: Problems with Python 2.5 installer. > > > John Machin wrote: > > paw wrote: > > > I have ran the M

Scoping bugs in an embedded Python interpreter - Wizards please

2006-09-29 Thread morris . slutsky
So every now and then I like to mess around with hobby projects - I often end up trying to write an OpenGL video game. My last attempt aborted due to the difficulty of automating game elements and creating a good level editor - I basically needed a scripting language to control the C modules of th

Hot new programming languages - according to the TIOBE index

2006-09-29 Thread vasudevram
Interesting post by voidspace. Ruby and Python are doing well, according to the latest TIOBE index. Java, C and C++ and 1, 2 and 3 on the list http://jugad.livejournal.com/2006/09/29/ Vasudev Ram http://www.dancingbison.com P.S. Dunno why "hot new" though - not too many of them are new. More

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Matthew Warren <[EMAIL PROTECTED]> wrote: > I have > found that in real usage of other programs within the company that use > lockfiles, it sometimes causes a bit of troubleshooting time when it stops > working due to a stale lockfile.. This especially happens when the program > is ki

Re: "ValueError: Empty module name" on basic import

2006-09-29 Thread alain MONTMORY
Thank for your response :-) I have tried (it's my first try ..)  : ./TestOfficiel TestPythonFoo multiply 3 2 and i get : [EMAIL PROTECTED] swigCallPython]$ ./TestOfficiel TestPythonFoo multiply 3 2 ImportError: No module named TestPythonFoo Failed to load "TestPythonFoo" Then i tried what y

Re: Scoping bugs in an embedded Python interpreter - Wizards please

2006-09-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > But I'm suffering from serious scoping bugs. I hope someone here > can help me with them. > > First of all, if I type in something like; > > def f(x): > if x==1: > return x > else: > return x * f(x-1) > > and then go > print f(5) >

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Fredrik Lundh
Tim Williams wrote: > def check_lock(): > import os, sys > try: > os.remove({filename}) > except: > if "Permission denied" in sys.exc_info()[1]: > print 'This program is already running' > sys.exit() > f_lock = open({filename},'w') have you

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Larry Hastings
Fredrik Lundh wrote: > > Sure. Here are the results, but with range (1000): > ten million? what hardware are you running this on? Athlon 64 x2 4400+ (aka 2.2GHz), 3GB of RAM, Windows XP. > what's in "s" when that loop is done? It's equivalent to " 'a' * 1000 ". (I shan't post it here

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > > def check_lock(): > > import os, sys > > try: > > os.remove({filename}) > > except: > > if "Permission denied" in sys.exc_info()[1]: > > print 'This program is already running'

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread William Heymann
On Friday 29 September 2006 08:34, Larry Hastings wrote: > It would still blow up if you ran > s = "" > for i in range(1000): > s = "a" + s This is a pretty small change but I would suggest xrange instead of range. That way you don't allocate that large list just to throw all the ite

retry in exception

2006-09-29 Thread Antoine De Groote
Hi, I hope I don't upset anybody by comparing Python to Ruby (again). Is there something like Ruby's retry keyword in Python? I couldn't find any thing... Regards, antoine -- http://mail.python.org/mailman/listinfo/python-list

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Fredrik Lundh
Larry Hastings wrote: >> what's in "s" when that loop is done? > > It's equivalent to " 'a' * 1000 ". (I shan't post it here.) but what *is* it ? an ordinary PyString object with a flattened buffer, or something else ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Talking to marketing people about Python

2006-09-29 Thread Magnus Lycka
Roy Smith wrote: > I'm working on a product which for a long time has had a Perl binding for > our remote access API. A while ago, I wrote a Python binding on my own, > chatted it up a bit internally, and recently had a (large) customer enquire > about getting access to it. > > I asked for per

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Larry Hastings
William Heymann wrote: > This is a pretty small change but I would suggest xrange instead of range. Good point! Since I was calling range() during the benchmark, it was timed too. Switching to xrange() will mean less overhead. I re-ran this benchmark (again): s = "" for i in range(10):

the actual C code - Re: Scoping bugs in an embedded Python interpreter - Wizards please

2006-09-29 Thread morris . slutsky
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > But I'm suffering from serious scoping bugs. I hope someone here > > can help me with them. > > > > First of all, if I type in something like; > > > > def f(x): > > if x==1: > > return x > > else: > > return

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Larry Hastings
Fredrik Lundh wrote: > >> what's in "s" when that loop is done? > > It's equivalent to " 'a' * 1000 ". (I shan't post it here.) > but what *is* it ? an ordinary PyString object with a flattened buffer, > or something else ? At the exact moment that the loop is done, it's a PyStringConcatenat

Re: windev vs python SOS

2006-09-29 Thread aaaWindev
Hi, Bruno Desthuilliers a écrit : > I've never met a programmer that "loved" Windev. I have met some here (I'm the guy with a mustache-just kidding but actually I was there). http://www.pcsoft.fr/pcsoft/tdftech/2006/images/Paris/07-IMG_5853.jpg WinDev is widely used in France and that's a thing

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Fredrik Lundh
Larry Hastings wrote: > > At the exact moment that the loop is done, it's a > PyStringConcatenationObject * which points to a deep one-sided tree of > more PyStringConcatenationObject * objects. Its ob_sval is NULL, which > means that the first time someone asks for its value (via the macro > PyS

Re: retry in exception

2006-09-29 Thread Sybren Stuvel
Antoine De Groote enlightened us with: > I hope I don't upset anybody by comparing Python to Ruby (again). Is > there something like Ruby's retry keyword in Python? Please don't assume that everybody knows Ruby through and through... Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Sybren Stuvel
Tim Williams enlightened us with: > def check_lock(): > import os, sys > try: > os.remove({filename}) > except: > if "Permission denied" in sys.exc_info()[1]: > print 'This program is already running' > sys.exit() > f_lock = open({filename},'w

Re: windev vs python SOS

2006-09-29 Thread John Henry
Why are they all look so gloomy? I don't see a single smile on their faces. :=) [EMAIL PROTECTED] wrote: > Hi, > > Bruno Desthuilliers a écrit : > > I've never met a programmer that "loved" Windev. > > I have met some here (I'm the guy with a mustache-just kidding but > actually I was there). >

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Checking for a lock, and later acquiring the lock, seems non-atomic to > me. It's easier to simply create a lock directory. If it fails, the > dir already exists and someone else holds the lock. If it succeeds, > the lock is immediately yours,

Re: screen capture

2006-09-29 Thread titan516
Craig W wrote: > > I need to take a screen shot of the computer screen. > > I am trying to use PIL and I saw there is ImageGrab...however it only > works on Windows. Is there a platform-independent ability to work > around this? > > thanks > > -- > http://mail.python.org/mailman/listinfo/p

Re: $1 MILLION REWARD for a simple paper in PHYSICS -- CONTROLLED DEMOLITION HOAX of 9/11

2006-09-29 Thread lucasea
Oh, good, just what we needed--sort of a Nobel Prize for whackos. AP should be a shoo-in. Eric Lucas <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Copy and paste from the site on 911 http://reopen911.org/ $1 Million Challenge Details This is void where prohibited by law: inclu

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Paul Rubin
"Tim Williams" <[EMAIL PROTECTED]> writes: > My reply was in response to a post that mentioned a known problem with > this, what happens when the previously running program doesn't exit > gracefully, and leaves the directory in place ?? Don't use the presence or absence of a file as a lock. Have

Re: screen capture

2006-09-29 Thread Fredrik Lundh
titan516 wrote: >> I am trying to use PIL and I saw there is ImageGrab...however it only >> works on Windows. Is there a platform-independent ability to work >> around this? > Maybe you can try http://www.acasystems.com ACA capture PRO , it , i > think,can fix your problem well.. "System re

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29 Sep 2006 09:47:12 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Tim Williams" <[EMAIL PROTECTED]> writes: > > My reply was in response to a post that mentioned a known problem with > > this, what happens when the previously running program doesn't exit > > gracefully, and leav

Re: Leave the putdowns in the Perl community, the Python world does not need them

2006-09-29 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > Steve makes a good point. Fredrik is one of the most important > contributors of Python code, tools, etc and as far as I am concerned, > that is so important that it gives him the right to be cranky from tiem > to time. Since February last year I've had the opportunity t

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Paul Rubin
"Tim Williams" <[EMAIL PROTECTED]> writes: > That's the same kind of principle as my posted snippet, it doesn't > rely on the file's presence or absence as such. It only cares when > the file exists *and* is held open by another process.When the > process exits, the lock ends without needing

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Fredrik Lundh
Paul Rubin wrote: > Don't use the presence or absence of a file as a lock. Have the file > there all the time, and have the app open it and use fcntl to get an > exclusive kernel lock on the file descriptor. doesn't work on all file systems, though... -- http://mail.python.org/mailman/listin

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Fredrik Lundh
Tim Williams wrote: > So that I know my mistake, which bit fails (the text from > sys.exc_info()[1]?? ) , or is it all complete rubbish - and not > do-able - on a *nix system ? opening a file for writing doesn't lock it on Unix. if you want locking, you need other mechanisms, and I'm not sure

Re: wxPython and threading issue

2006-09-29 Thread [EMAIL PROTECTED]
Patrick Smith wrote: > > Well, the problem is that you can't simply kill a thread--it shares > > memory with other threads that it could be leaving in an inconsistent > > state. Imagine that it was, say, holding a lock when it was forceably > > killed. Now any other thread that tries to acquire t

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29 Sep 2006 10:04:15 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Tim Williams" <[EMAIL PROTECTED]> writes: > > That's the same kind of principle as my posted snippet, it doesn't > > rely on the file's presence or absence as such. It only cares when > > the file exists *and* is

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Fredrik Lundh
Paul Rubin wrote: >> That's the same kind of principle as my posted snippet, it doesn't >> rely on the file's presence or absence as such. It only cares when >> the file exists *and* is held open by another process.When the >> process exits, the lock ends without needing to clean up. >> >>

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > > So that I know my mistake, which bit fails (the text from > > sys.exc_info()[1]?? ) , or is it all complete rubbish - and not > > do-able - on a *nix system ? > > opening a file for writing doesn't lock it on Unix.

Re: windev vs python SOS

2006-09-29 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi, > > Bruno Desthuilliers a écrit : >> I've never met a programmer that "loved" Windev. > > I have met some here (I'm the guy with a mustache-just kidding but > actually I was there). > > http://www.pcsoft.fr/pcsoft/tdftech/2006/images/Paris/07-IMG_5853.jpg > > WinD

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Paul Rubin
Fredrik Lundh <[EMAIL PROTECTED]> writes: > opening a file for writing doesn't lock it on Unix. if you want > locking, you need other mechanisms, and I'm not sure any of them > work properly on all configurations, under all circumstances. Hmm. What about trying to listen on a PF_UNIX socket asso

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Larry Hastings
Fredrik Lundh wrote: > so what does the benchmark look like if you actually do this ? Okay, timing this: x = "" for i in range(10): x += "a" t = x[1] # forces the concat object to render The result: Python 2.5 release: 30.0s Python 2.5 locally built: 30.2s Python 2.5 concat: 4

another distutils question

2006-09-29 Thread Eric S. Johansson
is there anyway I can, in a setup.py file, set and internal equivalent to the '--install-scripts' commandline option? script installation directory but I don't want on the command line where things can go horribly wrong if the user forgets. I would like to create a new default setting for th

creating a small test server on my local computer

2006-09-29 Thread John Salerno
Ok, this is completely unnecessary so I don't intend to get into stuff that's beyond my skill, but I'm wondering how simple it would be to use Python to create a server that runs on my computer so I can test my webpages (because otherwise I have to keep sending them to our IT person so he can u

Re: Talking to marketing people about Python

2006-09-29 Thread John Salerno
Magnus Lycka wrote: > In other words, Python has to a significant taken over the role Perl > had. This seems relevant to that thought (although it's not working right now): http://suttree.com/2006/09/02/php-is-the-new-classic/ -- http://mail.python.org/mailman/listinfo/python-list

Passing Arguments

2006-09-29 Thread theemails
New to Python ... this should be an easy question to answer. INPUT import sys print 'The command line arguments are:' for i in sys.argv: print i print '\nThe PYTHONPATH is', sys.path OUTPUT The command line arguments are: C:\Python25\using_sys.py The PYTHONPATH is ['C:\\Python25\\Lib\\idl

Re: Passing Arguments

2006-09-29 Thread Tim Chase
> It works fine when I 'Run Module'...but when I type in interactive mode > in the Python Shell python using_sys.py test1 test2 test3 > > I get the following error: > SyntaxError: invalid syntax By using proper syntax... :*) To pass parameters, you do it when *starting* python[*]. Thus,

Mark Lutz Python interview

2006-09-29 Thread Mark Lutz
Python author and trainer Mark Lutz will be interviewed on the radio show Tech Talk this Sunday, October 1st, at 6PM Eastern time. He'll be answering questions about Python, his books, and his Python training services. For more details about the show, see Tech Talk's website at http://techtalk.im

Re: Can recursive descent parser handle Python grammar?

2006-09-29 Thread [EMAIL PROTECTED]
Ben Sizer wrote: > [EMAIL PROTECTED] wrote: > > I'm a compiler newbie and was curious if Python's language/grammar > > can be handled by a recursive descent parser. > > I believe a recursive descent parser can handle any grammar; it just > depends on how pure you want it to be. > > -- > Ben Size

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Klaas
metaperl wrote: > Actually right after posting this I came up with a great usage. I use > meld3 for my Python based dynamic HTML generation. Whenever I plan to > loop over a tree section I use a for loop, but if there is no data to > iterate over, then I simply remove that section from the tree or

How to query a function and get a list of expected parameters?

2006-09-29 Thread Matthew Wilson
I'm writing a function that accepts a function as an argument, and I want to know to all the parameters that this function expects. How can I find this out in my program, not by reading the source? For example, I would want to know for the function below that I have to pass in two things: def f(

Re: retry in exception

2006-09-29 Thread MonkeeSage
Sybren Stuvel wrote: > Antoine De Groote enlightened us with: > > I hope I don't upset anybody by comparing Python to Ruby (again). Is > > there something like Ruby's retry keyword in Python? > > Please don't assume that everybody knows Ruby through and through... In ruby, the equivalent to try...

Automatic methods in new-style classes

2006-09-29 Thread bertgoos
Hey, I have the following code that has to send every command it receives to a list of backends. Instead of: class MultiBackend(object): """Renders to multiple backends""" def __init__(self, backends): self.backends = backends def flush(self): for b in self.backends:

Re: creating a small test server on my local computer

2006-09-29 Thread Irmen de Jong
John Salerno wrote: > Ok, this is completely unnecessary so I don't intend to get into stuff > that's beyond my skill, but I'm wondering how simple it would be to use > Python to create a server that runs on my computer so I can test my > webpages (because otherwise I have to keep sending them t

Re: Leave the putdowns in the Perl community, the Python world does not need them

2006-09-29 Thread Istvan Albert
metaperl wrote: > I was shocked to see the personal insults hurled in this thread: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/d0758cb9545cad4b Ahhh, no need to overreact, that's just the usual Friday night steel cage match: Fredrik vs "Poster Who is Convinced That The

Re: another distutils question

2006-09-29 Thread Robert Kern
Eric S. Johansson wrote: > is there anyway I can, in a setup.py file, set and internal equivalent > to the '--install-scripts' commandline option? Please don't. Hard-coding that interferes with the user's decision of where things should go. Only the user should be making that decision, not the

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-29 Thread Carl Friedrich Bolz
Larry Hastings wrote: [snip] > The core concept: adding two strings together no longer returns a pure > "string" object. Instead, it returns a "string concatenation" object > which holds references to the two strings but does not actually > concatenate > them... yet. The strings are concatenated

Re: There's another Timbot on the loose!

2006-09-29 Thread Carl Friedrich Bolz
Paul Rubin wrote: > http://web.cecs.pdx.edu/~mpj/timbot/index.html How said it's another one? Maybe our timbot grew a body. -- http://mail.python.org/mailman/listinfo/python-list

Re: XSLT speed comparisons

2006-09-29 Thread Jordan
If your using python 2.4.3 or essentially any of the 2.3, 2.4 series, i'd test out PyScripter as an IDE, it's one of the best that I've used. Unfortunately, they have yet to fully accomedate 2.5 code (you can still write 2.5 code with almost no problems, but you won't be able to use a 2.5 interact

Re: XSLT speed comparisons

2006-09-29 Thread Jordan
If your using python 2.4.3 or essentially any of the 2.3, 2.4 series, i'd test out PyScripter as an IDE, it's one of the best that I've used. Unfortunately, they have yet to fully accomedate 2.5 code (you can still write 2.5 code with almost no problems, but you won't be able to use a 2.5 interact

Re: retry in exception

2006-09-29 Thread Diez B. Roggisch
MonkeeSage schrieb: > Sybren Stuvel wrote: >> Antoine De Groote enlightened us with: >>> I hope I don't upset anybody by comparing Python to Ruby (again). Is >>> there something like Ruby's retry keyword in Python? >> Please don't assume that everybody knows Ruby through and through... > > In ruby

Re: Can recursive descent parser handle Python grammar?

2006-09-29 Thread Antoon Pardon
On 2006-09-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm a compiler newbie and was curious if Python's language/grammar > can be handled by a recursive descent parser. IIUC the python grammer is LL(1) and the development team is commited to keeping it LL(1). LL(1) languages can be handle

Re: How to query a function and get a list of expected parameters?

2006-09-29 Thread Nick Vatamaniuc
Matt, In [26]: inspect.getargspec(f) Out[26]: (['x1', 'x2'], None, None, None) For more see the inspect module. -Nick Vatamaniuc Matthew Wilson wrote: > I'm writing a function that accepts a function as an argument, and I > want to know to all the parameters that this function expects. How c

PEP proposal : Getting rid of the extension version/compiler dependency

2006-09-29 Thread Steve Menard
It's been observed a couple times recently ... distributing and compiling extensions is a pain, especially on windows, when the main supported compilers are not freely availble .. nor even commercially availble anymore. What we need is a way to break out of this dependency. A way for python ext

Re: creating a small test server on my local computer

2006-09-29 Thread John Salerno
Irmen de Jong wrote: > John Salerno wrote: >> Ok, this is completely unnecessary so I don't intend to get into stuff >> that's beyond my skill, but I'm wondering how simple it would be to >> use Python to create a server that runs on my computer so I can test >> my webpages (because otherwise I

Re: retry in exception

2006-09-29 Thread Fredrik Lundh
MonkeeSage wrote: > I don't think python has any equivalent (could be wrong). a trivial combination of while and try/except/else does the trick: n = 0 while 1: try: # do something print n n = n + 1 # make sure it fails a couple of times if n < 10:

Re: retry in exception

2006-09-29 Thread Tim Chase
> In ruby, the equivalent to try...except is begin...rescue. In the > rescue section you can ask it to retry the begin section. So, for > example: > > b=0 > begin > puts 1/b > rescue > b=1 > retry # <- this little guy > end Well, it's all a matter of how you look at it. I personally pref

Re: How to query a function and get a list of expected parameters?

2006-09-29 Thread George Sakkis
Matthew Wilson wrote: > I'm writing a function that accepts a function as an argument, and I > want to know to all the parameters that this function expects. How can > I find this out in my program, not by reading the source? > > For example, I would want to know for the function below that I hav

Sockets in python

2006-09-29 Thread OneMustFall
Reciently i wrote a simple client (in twisted) using Reconnecting Factory. That client logins to my socket server.. and that`s it. Interesting thing is that it is seems that twisted client, sends some ping on a TCP level without sending any data to the socket directl

Re: creating a small test server on my local computer

2006-09-29 Thread Tim Chase
>> Why do you need to use Python for the server? > > Well, perhaps I don't know what I'm talking about. I'm on an XP machine > and I just needed a way to test my web pages, and I thought Python could > be used to create a server to do this. But I know nothing about network > programming... Wel

Re: retry in exception

2006-09-29 Thread MonkeeSage
Everyone wrote: > [cool stuff] Ps. I've only used retry a handful of times in about 3 or 4 years of using ruby; I wasn't advocating it or criticizing python, just trying to explain the OPs request. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: another distutils question

2006-09-29 Thread Eric S. Johansson
Robert Kern wrote: > Eric S. Johansson wrote: >> is there anyway I can, in a setup.py file, set and internal equivalent >> to the '--install-scripts' commandline option? > > Please don't. Hard-coding that interferes with the user's decision of where > things should go. Only the user should be m

Re: creating a small test server on my local computer

2006-09-29 Thread Mirco Wahab
Thus spoke John Salerno (on 2006-09-29 21:13): > Irmen de Jong wrote: >> John Salerno wrote: >>> Ok, this is completely unnecessary so I don't intend to get into stuff >>> that's beyond my skill, but I'm wondering how simple it would be to >>> use Python to create a server that runs on my compute

Re: another distutils question

2006-09-29 Thread Robert Kern
Eric S. Johansson wrote: > Robert Kern wrote: >> Eric S. Johansson wrote: >>> is there anyway I can, in a setup.py file, set and internal equivalent >>> to the '--install-scripts' commandline option? >> Please don't. Hard-coding that interferes with the user's decision of where >> things should

Re: another distutils question

2006-09-29 Thread Eric S. Johansson
Robert Kern wrote: > > Okay, if it's just for internal use, then I certainly have no objection. Use > a > setup.cfg file: > >http://docs.python.org/inst/config-syntax.html > > Specifically, use something like the following section: > > [install] > install_scripts=/path/to/scripts/director

storing variable names in a list before they are used?

2006-09-29 Thread John Salerno
If I want to have a list like this: [(first_name, 'First Name:'), (last_name, 'Last Name:').] where the first part of each tuple is a variable name and the second part is a label for the user to see, such as a form like this: First Name: Last Name: (the variables would s

Re: windev vs python SOS

2006-09-29 Thread jmdeschamps
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > > Bruno Desthuilliers a écrit : > >> I've never met a programmer that "loved" Windev. > > > > I have met some here (I'm the guy with a mustache-just kidding but > > actually I was there). > > > > http://www.pcsoft.fr/pcsoft/tdftec

Addendum (was: creating a small test server on my local computer)

2006-09-29 Thread Mirco Wahab
Thus spoke Mirco Wahab (on 2006-09-29 21:32): > Thus spoke John Salerno (on 2006-09-29 21:13): >> Irmen de Jong wrote: >>> John Salerno wrote: Ok, this is completely unnecessary so I don't intend to get into stuff >>> Why do you need to use Python for the server? >> Well, perhaps I don't know

Re: another distutils question

2006-09-29 Thread Robert Kern
Eric S. Johansson wrote: > Now I get to puzzle out how to install the CGI plus images plus > stylesheets plus plus plus mess. Probably a bit outside of the scope of > distutils even if the CGI programs are Python. ;-) I recommend installing the data inside the package itself. In 2.4, use the

Re: ctypes.c_void_p(-1) might not be C return (void *) -1

2006-09-29 Thread Thomas Heller
[EMAIL PROTECTED] schrieb: >> I've started a wiki page where I already added an entry about the above >> question. >> Do you think the entry would have answered your question? >> http://starship.python.net/crew/theller/moin.cgi/CodeSnippets > > As concise as I now can imagine, yes thank you. > >

Re: storing variable names in a list before they are used?

2006-09-29 Thread Farshid Lashkari
Hi John John Salerno wrote: > how would I go about putting these variable names in a list? I know I > can't leave them as above, but if I put them in as a string, then how do > I later "transform" them into an actual variable for assign, such as: > > first_name = widget.get_text() > > Is there

Re: storing variable names in a list before they are used?

2006-09-29 Thread jmdeschamps
John Salerno wrote: > If I want to have a list like this: > > [(first_name, 'First Name:'), (last_name, 'Last Name:').] > > where the first part of each tuple is a variable name and the second > part is a label for the user to see, such as a form like this: > > First Name: > Last Name

Re: iterator question

2006-09-29 Thread Travis Oliphant
Neal Becker wrote: > Any suggestions for transforming the sequence: > > [1, 2, 3, 4...] > Where 1,2,3.. are it the ith item in an arbitrary sequence > > into a succession of tuples: > > [(1, 2), (3, 4)...] > > In other words, given a seq and an integer that specifies the size of tuple > to retu

Re: another distutils question

2006-09-29 Thread Eric S. Johansson
Robert Kern wrote: > Eric S. Johansson wrote: > >> Now I get to puzzle out how to install the CGI plus images plus >> stylesheets plus plus plus mess. Probably a bit outside of the scope of >> distutils even if the CGI programs are Python. ;-) > > I recommend installing the data inside the pa

Re: Mark Lutz Python interview

2006-09-29 Thread Fuzzyman
Mark Lutz wrote: > Python author and trainer Mark Lutz will be interviewed > on the radio show Tech Talk this Sunday, October 1st, > at 6PM Eastern time. He'll be answering questions about > Python, his books, and his Python training services. > Does he always talk in the third person ? ;-) Fuz

Re: another distutils question

2006-09-29 Thread Eric S. Johansson
Eric S. Johansson wrote: > So what I have seen so far says that to be able to take data from a > series of directories scatter it to other directories may be out of > scope. It's okay. If I have to write a wrapper, it won't be the first > time. do'h. http://docs.python.org/dist/node13.html

Re: storing variable names in a list before they are used?

2006-09-29 Thread Ant
John Salerno wrote: > If I want to have a list like this: > > [(first_name, 'First Name:'), (last_name, 'Last Name:').] > > where the first part of each tuple is a variable name and the second ... > can't leave them as above, but if I put them in as a string, then how do > I later "transform"

Re: Automatic methods in new-style classes

2006-09-29 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Hey, I have the following code that has to send every command it > receives to a list of backends. Instead of: > > class MultiBackend(object): > """Renders to multiple backends""" > > def __init__(self, backends): > self.backends = backends > > def

Re: storing variable names in a list before they are used?

2006-09-29 Thread MonkeeSage
John Salerno wrote: > If I want to have a list like this: > > [(first_name, 'First Name:'), (last_name, 'Last Name:').] Do you need the data to be ordered? If not, just use a dictionary: d = {'First Name:': '', 'Last Name:': ''} d['First Name:'] = 'Bob' d['Last Name:'] = 'Smith' print "Hi, I

Re: analyzing removable media

2006-09-29 Thread Jay
Dennis is absolutely right. The reason you won't find a method in the standard libraries for doing this task specifically is because python aims to by cross-platform. If it were to support a method that worked in the way you describe specifically for Windows, that would essentially break python's

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Johan Steyn
On 29 Sep 2006 11:26:10 -0700, Klaas <[EMAIL PROTECTED]> wrote: else: does not trigger when there is no data on which to iterate, butwhen the loop terminated normally (ie., wasn't break-ed out).  It is meaningless without break.  The else clause *is* executed when there is no data on which to itera

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Klaas
Klaas wrote: > else: does not trigger when there is no data on which to iterate, but > when the loop terminated normally (ie., wasn't break-ed out). It is > meaningless without break. Sorry, this was worded confusingly. "else: triggers when the loop terminates normally, not simply in the case t

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Mike Klaas
On 9/29/06, Johan Steyn <[EMAIL PROTECTED]> wrote: > On 29 Sep 2006 11:26:10 -0700, Klaas <[EMAIL PROTECTED]> wrote: > > > else: does not trigger when there is no data on which to iterate, but > > when the loop terminated normally (ie., wasn't break-ed out). It is > > meaningless without break. >

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread BJörn Lindqvist
On 9/29/06, Johan Steyn <[EMAIL PROTECTED]> wrote: > I agree that it is meaningless without a break statement, but I still find > it useful when I want to determine whether I looped over the whole list or > not. For example, if I want to see whether or not a list contains an odd > number: > > for

Re: Automatic methods in new-style classes

2006-09-29 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Hey, I want to send commands to a list of backends: How about something like: class Forwards(object): to_forward = set(['flush', 'read', 'write', 'close']) def __init__(self, backends): self.backends = backends def forwarder(self, methodname)

Re: Automatic methods in new-style classes

2006-09-29 Thread Scott David Daniels
Scott David Daniels wrote: > > class Forwards(object): > > to_forward = set(['flush', 'read', 'write', 'close']) > > def __init__(self, backends): > self.backends = backends > > def forwarder(self, methodname): > def method(*args, **kwargs): > for b in se

Re: creating a small test server on my local computer

2006-09-29 Thread Roger Upole
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Irmen de Jong wrote: >> John Salerno wrote: >>> Ok, this is completely unnecessary so I don't intend to get into stuff >>> that's beyond my skill, but I'm wondering how simple >>> it would be to use Python to create a se

Re: Automatic methods in new-style classes

2006-09-29 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: > Hey, I have the following code that has to send every command it > receives to a list of backends. > I would like to write each method like: > > flush = multimethod() Here's one way, using a metaclass: class multimethod(object): def transform(self, attr):

Re: creating a small test server on my local computer

2006-09-29 Thread Paul Boddie
Tim Chase wrote: > > Well, you could investigate WebStack: [...] > The documentation is a bit terse, and lacking in some areas, but > a little debugging output goes a long way toward diagnosing > problems with your code. Suggestions for improvement are very welcome! And I do value the expertise

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Matthew Woodcraft
[EMAIL PROTECTED] wrote: > And so on. For every use of the for/else clause there exists a better > alternative. Which sums up my opinion about the construct -- if you > are using it, there's something wrong with your code. How do you transform this? height = 0 for block in stack: if block.is_

<    1   2   3   >