Re: Has anyone used davlib by Greg Stein?

2006-07-21 Thread Guido Goldstein
Hi! On Tue, 18 Jul 2006 15:06:55 +0200 Joel Hedlund <[EMAIL PROTECTED]> wrote: > Hi! > > I want to PUT files to a authenticated https WebDAV server from within > a python script. Therefore I put "python dav" into google, and the > davlib module by Greg Stein (and Guido?) came up. It seems to be

Re: Python newbie needs constructive suggestions

2006-07-21 Thread Peter Otten
[EMAIL PROTECTED] wrote: > What is the idiomatically appropriate Python way to pass, as a > "function-type parameter", code that is most clearly written with a local > variable? > > For example, map takes a function-type parameter: > > map(lambda x: x+1, [5, 17, 49.5]) > > What if, instead of j

Re: Nested function scope problem

2006-07-21 Thread Josiah Manson
I just did some timings, and found that using a list instead of a string for tok is significantly slower (it takes 1.5x longer). Using a regex is slightly faster for long strings, and slightly slower for short ones. So, regex wins in both berevity and speed! -- http://mail.python.org/mailman/list

Re: Python newbie needs constructive suggestions

2006-07-21 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > b) give up on using an anonymous function and create a named "successor" > function with "def", This is what you have to do. For some reason mr van Rossum has this aversion to anonymous functions, and tries to cripple them as much as

Re: Nested function scope problem

2006-07-21 Thread Josiah Manson
Thank you for your corrections to the previous code. Your regex solution is definitely much cleaner. Referring to your other suggestions, is the advantage of using a list of chars instead of adding to a string just a bow to big-O complexity, or are there other considerations? First I had tried appe

Re: New to threads. How do they work?

2006-07-21 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Grant Edwards wrote: > On 2006-07-21, Lawrence D'Oliveiro <[EMAIL PROTECTED]> > wrote: >> In message <[EMAIL PROTECTED]>, gel >> wrote: >> >>> I am attempting to understand threads to use in a network app which I >>> am writing. >> >> It is written, somewhere in the

Re: Nested function scope problem

2006-07-21 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Justin Azoff wrote: > Simon Forman wrote: >> That third option seems to work fine. > > Well it does, but there are still many things wrong with it > > if len(tok) > 0: > should be written as > if(tok): I prefer the first way. Besides, your way is sub-opt

Linux Kernel Testing--Why Python

2006-07-21 Thread Lawrence D'Oliveiro
Just came across this article from the Ottawa Linux Symposium, which mentions (among other things) Martin Bligh's presentation on the automated testing system used for the Linux kernel: The test system is written in Python, and he d

Re: Nested function scope problem

2006-07-21 Thread Justin Azoff
Simon Forman wrote: > That third option seems to work fine. Well it does, but there are still many things wrong with it if len(tok) > 0: should be written as if(tok): tok = '' tok = toc + c should be written as tok = [] tok.append(c) and later ''.join(toc) anyway, th

Re: random shuffles

2006-07-21 Thread bryanjugglercryptographer
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. You would be mistaken (except

Re: Nested function scope problem

2006-07-21 Thread Simon Forman
Gerhard Fiedler wrote: > On 2006-07-21 21:05:22, Josiah Manson wrote: > > > I found that I was repeating the same couple of lines over and over in > > a function and decided to split those lines into a nested function > > after copying one too many minor changes all over. The only problem is > > th

Re: Language Design: list_for scope?

2006-07-21 Thread Carl Banks
guthrie wrote: > I'm pretty new to Python, and trying to parse the grammar. > > Q: What is the scope of the testlist in a list_for? > > For example; > Instead of; > for x in [ x in dict if dict[x]=="thing" ]: > in this: > for x in dict and dict[x]=="thing": > x is undefined. In the abo

Re: Python newbie needs constructive suggestions

2006-07-21 Thread Justin Azoff
[EMAIL PROTECTED] wrote: > What is the idiomatically appropriate Python way to pass, as a "function-type > parameter", code that is most clearly written with a local variable? > > For example, map takes a function-type parameter: > >map(lambda x: x+1, [5, 17, 49.5]) > > What if, instead of jus

Re: Python newbie needs constructive suggestions

2006-07-21 Thread faulkner
optional arguments. map(lambda x, one=1: x + one, ...) it is entirely possible, however, to implement let in python. def let(**kw): sys._getframe(2).f_locals.update(kw) def begin(*a): return a[-1] map(lambda x: begin(let(one=1), x+one), range(10)) i really should warn you, though, that

Re: How to use pdb?

2006-07-21 Thread tron . thomas
R. Bernstein wrote: > Perhaps what you are looking for is: > python /usr/lib/python2.4/pdb.py Myprogram.py I tried this and it did not work. pdb did not load the file so it could be debugged. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use pdb?

2006-07-21 Thread tron . thomas
peter wrote: > I haven't tried to use pdb myself, but this looks fairly helpful ... > > http://www.ferg.org/papers/debugging_in_python.html > > good luck > > Peter That link was indeed helpful. I was finally able to debug the program -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested function scope problem

2006-07-21 Thread Gerhard Fiedler
On 2006-07-21 21:05:22, Josiah Manson wrote: > I found that I was repeating the same couple of lines over and over in > a function and decided to split those lines into a nested function > after copying one too many minor changes all over. The only problem is > that my little helper function doesn

Ann: Crunchy Frog 0.6

2006-07-21 Thread André
Crunchy Frog (version 0.6) has been released. Crunchy Frog is an application that transforms an html-based Python tutorial into an interactive session within a browser window. The interactive embedded objects include: * a Python interpreter; * a simple code editor, whose input can be executed by

Re: regular expression - matches

2006-07-21 Thread John Machin
On 22/07/2006 9:25 AM, John Machin wrote: Apologies if this appears twice ... post to the newsgroup hasn't shown up; trying the mailing-list. > On 22/07/2006 2:18 AM, Simon Forman wrote: >> John Salerno wrote: >>> Simon Forman wrote: >>> Python's re.match() matches from the start of the str

Nested function scope problem

2006-07-21 Thread Josiah Manson
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only problem is that my little helper function doesn't work! It claims that a variable doesn't exist. If I

Re: How to recognise "generator functions" ?

2006-07-21 Thread John J. Lee
imho <[EMAIL PROTECTED]> writes: > Georg Brandl ha scritto: > > f.func_code.co_flags > > 67 > g.func_code.co_flags > > 99 > > => 32 (CO_GENERATOR in compiler.consts) is the flag that indicates a > > generator code object. > > Georg > > What a fast reply! > Thank You very much! :-) Geo

Python newbie needs constructive suggestions

2006-07-21 Thread davew-python
What is the idiomatically appropriate Python way to pass, as a "function-type parameter", code that is most clearly written with a local variable? For example, map takes a function-type parameter: map(lambda x: x+1, [5, 17, 49.5]) What if, instead of just having x+1, I want an expression tha

Re: Application Generators

2006-07-21 Thread Steve Hannah
I know that this is an older thread, but I came across it on Nabble.com. Just wanted add some updated info on Walter's observations about Dataface (http://fas.sfu.ca/dataface) . It is much further along in development now and it does support authentication now. Just wanted to follow this up in

Re: Isn't there a better way?

2006-07-21 Thread John J. Lee
Peter Otten <[EMAIL PROTECTED]> writes: [...] > Not sure if this is better, but you can use OptionParser to set attributes > on arbitrary objects, including your Processor instance: [...] I'd guess it's not worth the mental overhead required when you discover the next argument no longer fits this

Re: How to automate user input at the command prompt?

2006-07-21 Thread M�ta-MCI
Hi! I had try with pipes & subprocess. Unfortunaly, when dos-commandline show a text who question for Yes/No, this text is not available in subprocess/pipe ; => and block! And then, I can't send "Y" to the stdin... I test with: MD TOTO RD TOTO/S (I know, RD TOTO/S/Q run Ok, but I

Re: An optparse question

2006-07-21 Thread John J. Lee
"T" <[EMAIL PROTECTED]> writes: [...] > What I would like to do is insert some string *before* the "usage = " > string, which is right after the command I type at the command prompt. > So I would like to make it look like this: > > % myprog.py -h > THIS IS NEWLY INSERTED STRING *

Re: How to automate user input at the command prompt?

2006-07-21 Thread Roger Upole
If you have the Pywin32 extensions installed, you can use the win32console module to send keystrokes directly to a command prompt via WriteConsoleInput. Roger <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I'm working on a scirpt to be used on a windows machine and I need

Re: How to automate user input at the command prompt?

2006-07-21 Thread Gerhard Fiedler
On 2006-07-21 19:39:52, [EMAIL PROTECTED] wrote: > Cameron Laird wrote: >> I suspect there are easier approaches--but probably won't have time >> before Monday to explain. For now, I counsel the original poster >> not to be discouraged. > > Although I have not find the solution I need yet, thank

Re: How to automate user input at the command prompt?

2006-07-21 Thread gert365
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > >In that case, the OP can probably use cygwin's version of python. > >pexpect definitely works there. > . > . > . > I suspec

Re: How to automate user input at the command prompt?

2006-07-21 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >In that case, the OP can probably use cygwin's version of python. >pexpect definitely works there. . . . I suspect there are easier approaches--but

Re: Track keyboard and mouse usage

2006-07-21 Thread [EMAIL PROTECTED]
Hello dfaber, I had the same problem not long ago. I tried to use the Xlib since its obvious the X server has all the events but I couldn't have the mouse events if my app was out of focus. If you have a way to do that I'm really interested. Anyway I found this to be a good introduction to Xlib:

OT Re: getaddrinfo not found on SCO OpenServer 5.0.5

2006-07-21 Thread David Reed
On Jul 21, 2006, at 4:20 PM, Steve M wrote: > In case you haven't heard Microsoft is suing SCO for stealing his > Internet concepts and letters and numbers, so you should probably just > ditch OpenServer and get Debian like all the smart people have done. > > I guess the quality of SCO software h

Re: An optparse question

2006-07-21 Thread dan . gass
> Nope. That only *nearly* does what T wants. The usage message will > still be printed immediately *after* the 'usage: ' string. > > >>> parser = OptionParser(usage=usage) > >>> parser.print_help() > usage: THIS IS NEWLY INSERTED STRING > usage: lopts.py [options] input

Re: An optparse question

2006-07-21 Thread Steve Holden
T wrote: > fuzzylollipop wrote: > >>you can make the usage line anything you want. >> >>... >>usage = 'This is a line before the usage line\nusage %prog [options] >>input_file' >>parser = OptionsParser(usage=usage) >>parser.print_help() >>... >> > > > No, that affects the string printed only *af

Re: random shuffles

2006-07-21 Thread Raymond Hettinger
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > confo

Re: Coding style

2006-07-21 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > > (snip) >>Other than in PHP, Python has clear rules when an object of a builtin type >>is considered false (i.e. when it's empty). So why not take advantage of >>this? > > Because the clearest rule of all is

Re: regular expression - matches

2006-07-21 Thread Simon Forman
John Salerno wrote: > Thanks guys! A pleasure. : ) -- http://mail.python.org/mailman/listinfo/python-list

Re: An optparse question

2006-07-21 Thread Simon Forman
[EMAIL PROTECTED] wrote: > > No, that affects the string printed only *after* the "usage = " string. > > What I would like to do is insert some string *before* the "usage = " > > string, which is right after the command I type at the command prompt. > > So I would like to make it look like this: >

using array as execute parameter in dbapi

2006-07-21 Thread gglegrp112
Is it possible to send an array as a parameter for an execute method in dbapi2 module? I'm using adodbapi and try to perfrom the following SQL query: select * from item where storeid in ('01', '02') When I use direct string formating it works: a=('01','02') cur.execute('select * from

Re: An optparse question

2006-07-21 Thread Simon Forman
T wrote: > fuzzylollipop wrote: > > > > you can make the usage line anything you want. > > > > ... > > usage = 'This is a line before the usage line\nusage %prog [options] > > input_file' > > parser = OptionsParser(usage=usage) > > parser.print_help() > > ... > > > > No, that affects the string pri

Re: How to automate user input at the command prompt?

2006-07-21 Thread [EMAIL PROTECTED]
In that case, the OP can probably use cygwin's version of python. pexpect definitely works there. Mike Kent wrote: > [EMAIL PROTECTED] wrote: > > You may want to look at pexpect: > > > > http://pexpect.sourceforge.net/ > > > > But I am not sure about its support on windows. > > To the best of my

Re: An optparse question

2006-07-21 Thread dan . gass
> No, that affects the string printed only *after* the "usage = " string. > What I would like to do is insert some string *before* the "usage = " > string, which is right after the command I type at the command prompt. > So I would like to make it look like this: The example was fine (except for

Re: getaddrinfo not found on SCO OpenServer 5.0.5

2006-07-21 Thread Steve M
In case you haven't heard Microsoft is suing SCO for stealing his Internet concepts and letters and numbers, so you should probably just ditch OpenServer and get Debian like all the smart people have done. I guess the quality of SCO software has declined over the last forty or fifty years and they

Re: An optparse question

2006-07-21 Thread T
fuzzylollipop wrote: > > you can make the usage line anything you want. > > ... > usage = 'This is a line before the usage line\nusage %prog [options] > input_file' > parser = OptionsParser(usage=usage) > parser.print_help() > ... > No, that affects the string printed only *after* the "usage = " s

Re: Note on PEP 299

2006-07-21 Thread bearophileHUGS
Faulkner: > http://home.comcast.net/~faulkner612/programming/python/mainer.py It's a bit of magic, I'll test it more, but it seems to work binding the main() with Psyco too. I have changed it a little (removed argv passed to the main and the import of type, etc). I don't know if/when I'll use it,

Re: How to automate user input at the command prompt?

2006-07-21 Thread Mike Kent
[EMAIL PROTECTED] wrote: > You may want to look at pexpect: > > http://pexpect.sourceforge.net/ > > But I am not sure about its support on windows. To the best of my recent investigation, and an email exchange with the author of pexpect, it is NOT supported under Windows. -- http://mail.python.

Re: what's wrong with this if statement?

2006-07-21 Thread John Salerno
Philippe Martin wrote: > Check the type of self.time: unicode - you need to convert it to int > first ... plus your timer will need to be shutdown when you're done. Ah, of course! Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to automate user input at the command prompt?

2006-07-21 Thread [EMAIL PROTECTED]
You may want to look at pexpect: http://pexpect.sourceforge.net/ But I am not sure about its support on windows. [EMAIL PROTECTED] wrote: > I'm working on a scirpt to be used on a windows machine and I need to > automate a user's input on the command prompt. For example I'm using > os.system('

Re: An optparse question

2006-07-21 Thread fuzzylollipop
T wrote: > I have a short program using optparse.OptionParser that prints out help > message with -h flag: > > % myprog.py -h > usage: myprog.py [options] input_file > > options: > -h, --help show this help message and exit > -v, --verboseprint program's version number and

Re: what's wrong with this if statement?

2006-07-21 Thread Philippe Martin
John Salerno wrote: > Here's the full code, but you can probably safely ignore most of it, > especially the wxPython stuff: > > --- > > import wx > > > class MyFrame(wx.Frame): > > def __init__(self): > wx.Frame.__init__(self, parent=None, id=wx.I

An optparse question

2006-07-21 Thread T
I have a short program using optparse.OptionParser that prints out help message with -h flag: % myprog.py -h usage: myprog.py [options] input_file options: -h, --help show this help message and exit -v, --verboseprint program's version number and exit -o FILE

Re: function v. method

2006-07-21 Thread fuzzylollipop
Antoon Pardon wrote: > Suppose I am writing my own module, I use an underscore, to > mark variables which are an implementation detail for my > module. > > Now I need to import an other module in my module and need access > to an implementation variable from that module. So now I have > variables

what's wrong with this if statement?

2006-07-21 Thread John Salerno
Here's the full code, but you can probably safely ignore most of it, especially the wxPython stuff: --- import wx class MyFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, parent=None, id=wx.ID_ANY) panel = wx.Panel(self)

On Computing and Its People

2006-07-21 Thread Xah Lee
Hi all, in the past years, i have written few hundreds of essays and tutorials on computing. Now, i've but a index page to this collection: http://xahlee.org/Periodic_dosage_dir/skami_prosa.html many of these, originated from online forum. The writing style is enticing and the content astute. al

Re: How to automate user input at the command prompt?

2006-07-21 Thread M�ta-MCI
Hi! Same problem. I had search, long time, with popenX, with subprocess. I don't have, actually, any solution... Suggestion: the first which finds prevents the others... @+ Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

How to automate user input at the command prompt?

2006-07-21 Thread gert365
I'm working on a scirpt to be used on a windows machine and I need to automate a user's input on the command prompt. For example I'm using os.system('mycommand') to excute the commands I want. However some of these command will prompt for a confirmation of yes or no from user. Is there anything

PyGTK Classes Problems

2006-07-21 Thread Tom Grove
I can't seem to get a function to continue after I call another gtk window class. Basically I need to grab a date from a calendar in one windows and insert that value into an entry box on the calling window. Calling Window: import winCal def getDate(self, widget): cimsCal.winCal.dateSelect

Re: Isn't there a better way?

2006-07-21 Thread Bruno Desthuilliers
T wrote: > I am using an optparse to get command line options, and then pass them > to an instance of another class: > > > > # Class that uses optparse.OptionParser > foo = Parse_Option() > > # Class that does the real work > bar = Processor() > > bar.index = foo.options.index > bar.output =

Re: using names before they're defined

2006-07-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi > > (snip) > def get_class_by_name(name): return globals()[name] >>> >>Q&D way to retrieve the class object (Python's classes are themselves >>objects) known by it's name (as a string). > > > ok, so it actually returns the class object itself. > One thing

Re: random shuffles

2006-07-21 Thread Paul Rubin
Boris Borcic <[EMAIL PROTECTED]> writes: > To be more convincing... assume the algorithm is optimal and calls That assumption is not even slightly realistic. Real-world sorting algorithms almost never do a precisely minimal amount of comparison. -- http://mail.python.org/mailman/listinfo/python-

Re: Language Design: list_for scope?

2006-07-21 Thread guthrie
Larry Bates wrote: > First things first: > > Don't name a variable "dict" because if you do it shadows > the built in dict function (same goes for list, str, ...). > This WILL bite you later, so start now by not naming > variables by any built in names. -- Thanks, got it! > > Now to your quest

Re: Isn't there a better way?

2006-07-21 Thread T
T wrote: > > I don't know what both classes do [snip] > > foo basically gets values for verbose (a True or False) and index (an > integer) from command line options, using > optparse.OptionParser.add_option() and > optparse.OptionParser.parse_args() > > I would like bar to access the values of ver

Re: function v. method

2006-07-21 Thread Gerhard Fiedler
On 2006-07-20 18:10:21, danielx wrote: >>> When supporting documents aren't sufficient to learn an api (I'm sure >>> this never happens, so just humor me), you can always turn to >>> interactive Python. >> >> ...and source code... > > *shudders* What happened to all the goodness of abstraction?

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like that. Sorting assumes an order >> relation on the items

Re: Coding style

2006-07-21 Thread Gerhard Fiedler
On 2006-07-21 09:00:43, Antoon Pardon wrote: > So we have code with certain shudder characteristics. And instead > of trying to help the OP with his problem, some people react > to the shudder and come with all sort of comments that might be > true if the code as shown was production code, but whi

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like that. Sorting assumes an order >> relation on the items

Re: Language Design: list_for scope?

2006-07-21 Thread Paddy
guthrie wrote: > I'm pretty new to Python, and trying to parse the grammar. > > Q: What is the scope of the testlist in a list_for? > > For example; > Instead of; > for x in [ x in dict if dict[x]=="thing" ]: > in this: > for x in dict and dict[x]=="thing": > x is undefined. > > And wh

Re: Language Design: list_for scope?

2006-07-21 Thread Larry Bates
First things first: Don't name a variable "dict" because if you do it shadows the built in dict function (same goes for list, str, ...). This WILL bite you later, so start now by not naming variables by any built in names. Now to your question: for x in : requires be an iterable (e.g. list, tup

Re: Semantics of propagated exceptions

2006-07-21 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, Thomas Lotze <[EMAIL PROTECTED]> wrote: > Suppose you have a function f which, as part of its protocol, raises some > standard exception E under certain, well-defined circumstances. Suppose > further that f calls other functions which may also raise E. How to best

Re: random shuffles

2006-07-21 Thread Boris Borcic
Thanks for these details. BB Tim Peters wrote: > [ Boris Borcic] >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> >> pick a random shuffle of x with uniform distribution ? > > Say len(x) == N. With Python's current sort, the conjecture is true > if and only if N <= 2. > >> Intuitively,

Re: random shuffles

2006-07-21 Thread Boris Borcic
Paul Rubin wrote: > Boris Borcic <[EMAIL PROTECTED]> writes: >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> pick a random shuffle of x with uniform distribution ? > > You really can't assume anything like that. Sorting assumes an order > relation on the items being sorted, which means

Language Design: list_for scope?

2006-07-21 Thread guthrie
I'm pretty new to Python, and trying to parse the grammar. Q: What is the scope of the testlist in a list_for? For example; Instead of; for x in [ x in dict if dict[x]=="thing" ]: in this: for x in dict and dict[x]=="thing": x is undefined. And why doesn't this work: for x in

Re: regular expression - matches

2006-07-21 Thread John Salerno
Simon Forman wrote: > John Salerno wrote: >> Simon Forman wrote: >> >>> Python's re.match() matches from the start of the string, so if you >>> want to ensure that the whole string matches completely you'll probably >>> want to end your re pattern with the "$" character (depending on what >>> the r

Re: regular expression - matches

2006-07-21 Thread Simon Forman
John Salerno wrote: > Simon Forman wrote: > > > Python's re.match() matches from the start of the string, so if you > > want to ensure that the whole string matches completely you'll probably > > want to end your re pattern with the "$" character (depending on what > > the rest of your pattern matc

Re: regular expression - matches

2006-07-21 Thread Steve Holden
John Salerno wrote: > Simon Forman wrote: > > >>Python's re.match() matches from the start of the string, so if you >>want to ensure that the whole string matches completely you'll probably >>want to end your re pattern with the "$" character (depending on what >>the rest of your pattern matches.

Re: Isn't there a better way?

2006-07-21 Thread Peter Otten
T wrote: > I am using an optparse to get command line options, and then pass them > to an instance of another class: > # Class that uses optparse.OptionParser > foo = Parse_Option() > > # Class that does the real work > bar = Processor() > bar.index = foo.options.index > bar.output = foo.opt

Re: using names before they're defined

2006-07-21 Thread davehowey
Hi > Also, I gave the example using Python code as 'config' format, but any > structured enough text format could do, ie JSON, XML, or even ini-like: > > # schema.ini > objects = turbine1, frobnicator2 > > [turbine1] > class=Turbine > upstream=frobnicator2 > downstream= > yes, I like the idea of

Re: regular expression - matches

2006-07-21 Thread John Salerno
Simon Forman wrote: > Python's re.match() matches from the start of the string, so if you > want to ensure that the whole string matches completely you'll probably > want to end your re pattern with the "$" character (depending on what > the rest of your pattern matches.) Is that necessary? I was

Re: Isn't there a better way?

2006-07-21 Thread Steve Holden
T wrote: > I am using an optparse to get command line options, and then pass them > to an instance of another class: > > > > # Class that uses optparse.OptionParser > foo = Parse_Option() > > # Class that does the real work > bar = Processor() > > bar.index = foo.options.index > bar.output =

Re: Isn't there a better way?

2006-07-21 Thread T
> I don't know what both classes do [snip] foo basically gets values for verbose (a True or False) and index (an integer) from command line options, using optparse.OptionParser.add_option() and optparse.OptionParser.parse_args() I would like bar to access the values of verbose and index. Is ther

Re: range() is not the best way to check range?

2006-07-21 Thread Steve Holden
Paul Boddie wrote: [...] > Regardless of whether myslice inherits from object or not, there's no > persuading the interpreter that it is a genuine slice, and remember > that we can't subclass slice (for some reason unknown). So, it would > appear that the interpreter really wants instances from som

Re: New to threads. How do they work?

2006-07-21 Thread Grant Edwards
On 2006-07-21, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, gel > wrote: > >> I am attempting to understand threads to use in a network app which I >> am writing. > > It is written, somewhere in the philosophy of *nix programming, that threads > are a performance

Re: random shuffles

2006-07-21 Thread Paul Rubin
Boris Borcic <[EMAIL PROTECTED]> writes: > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > pick a random shuffle of x with uniform distribution ? You really can't assume anything like that. Sorting assumes an order relation on the items being sorted, which means if a < b and b < c, then a <

Re: regular expression - matches

2006-07-21 Thread James Oakley
On Friday 21 July 2006 10:57 am, abcd wrote: > yea i saw thatguess I was trusting that my regex was accurate :) > ...b/c i was getting a Matcher when I shouldnt have, but i found that > it must be the regex. http://kodos.sourceforge.net/ Makes regex generation and debugging much easier. --

Re: Isn't there a better way?

2006-07-21 Thread rony steelandt
Le Fri, 21 Jul 2006 07:51:15 -0700, T a écrit : > > I am using an optparse to get command line options, and then pass them > to an instance of another class: > > > > # Class that uses optparse.OptionParser > foo = Parse_Option() > > # Class that does the real work > bar = Processor() > > bar

Re: Note on PEP 299

2006-07-21 Thread faulkner
http://home.comcast.net/~faulkner612/programming/python/mainer.py turns if __name__ == '__main__': sys.exit(main(sys.argv)) into import mainer [EMAIL PROTECTED] wrote: > I don't like much the syntax of: > if __name__ == '__main__': > > Some time ago I have read this PEP: > http://www.python.org/de

Re: Accessors in Python (getters and setters)

2006-07-21 Thread Ed Jensen
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Which puts us to the next question: the sealing itself doesn't do > anything to restrict the code, the SecurityManager does. Which AFAIK is > something hooked into the VM. Now, I'm not on sure grounds here on how > to altere its behaviour, but I'd sa

Isn't there a better way?

2006-07-21 Thread T
I am using an optparse to get command line options, and then pass them to an instance of another class: # Class that uses optparse.OptionParser foo = Parse_Option() # Class that does the real work bar = Processor() bar.index = foo.options.index bar.output = foo.options.output bar.run() Th

Re: regular expression - matches

2006-07-21 Thread Simon Forman
abcd wrote: > how can i determine if a given character sequence matches my regex, > completely? > > in java for example I can do, > Pattern.compile(regex).matcher(input).matches() > > this returns True/False whether or not input matches the regex > completely. > > is there a matches in python? Yes

Re: regular expression - matches

2006-07-21 Thread abcd
yea i saw thatguess I was trusting that my regex was accurate :) ...b/c i was getting a Matcher when I shouldnt have, but i found that it must be the regex. -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser: what read('non-existent-filename') returns in 2.3.x?

2006-07-21 Thread Chris Lambacher
On Thu, Jul 20, 2006 at 02:01:08PM -0700, Danil Dotsenko wrote: > Chris Lambacher wrote: > > On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote: > >> Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's > >> SuperKaramba widget. > >> (http://www.kde-look.org/content/show.p

Re: regular expression - matches

2006-07-21 Thread Tim Chase
abcd wrote: > how can i determine if a given character sequence matches my regex, > completely? > > in java for example I can do, > Pattern.compile(regex).matcher(input).matches() > > this returns True/False whether or not input matches the regex > completely. > > is there a matches in python?

regular expression - matches

2006-07-21 Thread abcd
how can i determine if a given character sequence matches my regex, completely? in java for example I can do, Pattern.compile(regex).matcher(input).matches() this returns True/False whether or not input matches the regex completely. is there a matches in python? -- http://mail.python.org/mailm

Re: range() is not the best way to check range?

2006-07-21 Thread Paul Boddie
Antoon Pardon wrote: > [Subclasses of list or slice for ranges] > Except that if you write your own class from scratch, you can't use > it as a slice. For a language that is supposed to be about duck typing > I find it strange that if I make my own class with a start, stop and > step attribute, t

Re: random shuffles

2006-07-21 Thread Tim Peters
[ Boris Borcic] > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? Say len(x) == N. With Python's current sort, the conjecture is true if and only if N <= 2. > Intuitively, assuming list.sort() does a minimal number of comparisons to

getaddrinfo not found on SCO OpenServer 5.0.5

2006-07-21 Thread edcdave
I'm trying to get MoinMoin 1.5.4 running with Python 2.3.4 (installed from an SCO Skunkworks binary). Python 2.3.4 (#1, Aug 27 2004, 18:22:39) [GCC 2.95.3 20030528 (SCO/p5)] on sco_sv3 One of the MoinMoin modules attempts to import cgi and triggers this traceback: Traceback (most recent call last

Re: question about what lamda does

2006-07-21 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: >>(snip) >> >> >>>Python's lambda really can't be as powerful as Lisp's because Python >>>does not have expressions that do case analysis (this is not lambda's >>>fault, of course ;). The reason is that you really want to put each >>>c

Re: Checking File permissions

2006-07-21 Thread Tal Einat
Anoop wrote: > Hi All > > Please tell me how to check the existence of a file and the read > permission to the file using python script > > Thanks for ur inputs > > Anoop os.access(path, mode) does just this, check it out. Cross-platform-ness isn't a problem, the docs say it is available for Win

Re: Since there was talk of if-then-else not being allowed in lambda expressions, the following is from "Dive into Python"

2006-07-21 Thread Peter Otten
Bruno Desthuilliers wrote: > But isn't allowed in a lambda !-) Then tear out that lambada page, too, I was tempted to say, but I will desist. For now... Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: random shuffles

2006-07-21 Thread Iain King
Dustan wrote: > Boris Borcic wrote: > > does > > > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > > > pick a random shuffle of x with uniform distribution ? > > > > Intuitively, assuming list.sort() does a minimal number of comparisons to > > achieve the sort, I'd say the answer is yes.

  1   2   >