Re: capture the output

2006-07-21 Thread ciccio
On 7/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: On 7/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Dear all, I'm executing a program by os.spawnv() function. However the program print out several things. I would to capture this output, but I don't know how. Could you give me

Re: function v. method

2006-07-21 Thread Diez B. Roggisch
Alex Martelli schrieb: > danielx <[EMAIL PROTECTED]> wrote: > >>> ...and source code... >> *shudders* What happened to all the goodness of abstraction? > > Misses an l at the end: http://www.joelonsoftware.com/articles/LeakyAbstract

Re: Depricated String Functions in Python

2006-07-21 Thread Duncan Booth
Sybren Stuvel wrote: > Donn Cave enlightened us with: >> Oh, excellent - the string module is dead, long live the string >> module! I can replace string.join with str.join, and never have to >> defile my code with that ' '.join(x) abomination. > > It's not an abomination. It's a very clear way o

Re: How to use pdb?

2006-07-21 Thread peter
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 -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use pdb?

2006-07-21 Thread R. Bernstein
[EMAIL PROTECTED] writes: > I am trying to figure out how to use the pdb module to debug Python > programs, and I'm having difficulties. I am pretty familiar with GDB > which seems to be similar, If you are pretty familiar with gdb, try http://bashdb.sourceforge.net/pydb. It is a great deal mor

IMAP4 search with special characters

2006-07-21 Thread Luis Corrales
Hi all, I have a problem when searching for text with special characters in e-mails in an IMAP server. I'm using imaplib in python 2.4.3 and I can't get this code working: # first connect and login conn = IMAP4(my_server) conn.login(my_user, my_pass) # now select INBOX conn.select('INBOX') # a

Re: Accessors in Python (getters and setters)

2006-07-21 Thread Diez B. Roggisch
Ed Jensen schrieb: > Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>> Java is not an acronym. That is: it's "Java", not "JAVA". >> Now THAT was an important information RIGHT on topic. > > It was not meant offensively. Ok. >>> Java does not allow access to private members via reflection. >> For

Re: function v. method

2006-07-21 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: >> (snip) >>> >>>Obviously, such things would be omitted from your docs, but users also >>>learn by interacting with Python, which is really one of Python's great >>>virtues. When supporting documents aren't sufficient to learn an api

Re: change default install directory when using bdist_rpm

2006-07-21 Thread J�r�me Le Bougeant
Hi, try : python setup.py bdist_rpm --dist-dir="/home/..." > I'm using : > python setup.py bdist_rpm > > to create an rpm package to distribute my python app on linux. > > When i install the rpm, the files are installed in > /usr/share/python/site-packages/. directory by default. > > How do i

Re: IronPython and scipy/pyExcelerator

2006-07-21 Thread Robin Becker
[EMAIL PROTECTED] wrote: > I'm looking forward to the release IronPython, primarily for its IDE. I > currently use scipy and pyExcelerator to crunch numbers and write them > to Excel: does can these packages be used with IronPython as well? > > Thanks in advance > > Thomas Philips > I don't thin

pyqt scrollview layout

2006-07-21 Thread Felix Steffenhagen
Hello, I have a problem with updating contents in a qscrollview. I've implementented two widgets (PremiseInput and PremiseList). You can find the source code under http://www.informatik.uni-freiburg.de/~steffenh/premiseinput.{html|py} and http://www.informatik.uni-freiburg.de/~steffenh/premiselist

Semantics of propagated exceptions

2006-07-21 Thread Thomas Lotze
Hi, I wonder how to solve the following problem the most pythonic way: 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 disting

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 Ant
> # python 2.5 > >>> a, b = "", 0 > >>> a if False else b > 0 > >>> a if True else b > '' > > Time to tear out that page. Really. Not quite - 2.5 hasn't been released in its final version yet, and many projects I should imagine will take a while to upgrade. -- http://mail.python.org/mailman/lis

Re: pyqt scrollview layout

2006-07-21 Thread Jeremy Sanders
Felix Steffenhagen wrote: > I have a problem with updating contents in a qscrollview. > I've implementented two widgets (PremiseInput and PremiseList). > You can find the source code under > http://www.informatik.uni-freiburg.de/~steffenh/premiseinput.{html|py} and > http://www.informatik.uni-frei

Re: Semantics of propagated exceptions

2006-07-21 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Thomas Lotze 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 > distinguish whether

Re: New to threads. How do they work?

2006-07-21 Thread Lawrence D'Oliveiro
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 hack, to be avoided wherever possible. Use processes in preference to thr

Re: Semantics of propagated exceptions

2006-07-21 Thread Steve Holden
Thomas Lotze wrote: > Hi, > > I wonder how to solve the following problem the most pythonic way: > > 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

Re: Semantics of propagated exceptions

2006-07-21 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Thomas Lotze wrote: > I wonder how to solve the following problem the most pythonic way: > > 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 fun

Python proficiency test

2006-07-21 Thread Kent Johnson
I recently helped create an on-line Python proficiency test. The publisher of the test is looking for beta testers to try the test and give feedback. If you are interested, here is an announcement from the publisher: > Brainbench is currently beta testing a new series of test questions > for

Re: function v. method

2006-07-21 Thread Antoon Pardon
On 2006-07-21, fuzzylollipop <[EMAIL PROTECTED]> wrote: > > danielx wrote: >> Bruno Desthuilliers wrote: >> > danielx wrote: >> > > At first I was going to post the following: >> > > >> > > >> > > >> > (snip) >> > > >> > > >> > > >> > > but then I tried this: >> > > >> > > >> > res = Foo.__di

random shuffles

2006-07-21 Thread Boris Borcic
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 confortable with the intuition... can an

Ireland PyPy sprint 21th-27th August 2006

2006-07-21 Thread Michael Hudson
The next PyPy sprint will happen in the nice city of Limerick in Ireland from 21st till 27th August. (Most people intend to arrive 20th August). The main focus of the sprint will be on JIT compiler works, various optimization works, porting extension modules, infrastructure works like a buil

Re: random shuffles

2006-07-21 Thread Peter Otten
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 > con

Re: Coding style

2006-07-21 Thread Antoon Pardon
On 2006-07-20, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On 20 Jul 2006 08:50:44 GMT, Antoon Pardon <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> >> Suppose I have the following kind of code: >> >> while True: >> try: >> if len(result) > 0: >> foo() >>

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
Ant wrote: > >> # python 2.5 >> >>> a, b = "", 0 >> >>> a if False else b >> 0 >> >>> a if True else b >> '' >> >> Time to tear out that page. Really. > > Not quite - 2.5 hasn't been released in its final version yet, and many > projects I should imagine will take a while to upgrade. Ok, use i

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 Bruno Desthuilliers
Peter Otten wrote: > Ant wrote: > > >>># python 2.5 >>> >>a, b = "", 0 >>a if False else b >>> >>>0 >>> >>a if True else b >>> >>>'' >>> >>>Time to tear out that page. Really. >> >>Not quite - 2.5 hasn't been released in its final version yet, and many >>projects I should imagine will

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

2006-07-21 Thread Antoon Pardon
On 2006-07-20, Paul Boddie <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: >> Paul Boddie <[EMAIL PROTECTED]> wrote: >> > >> > Well, range is a function in the current implementation, although its >> > usage is similar to that one would get if it were a class, particularly >> > a subclass of list

Re: random shuffles

2006-07-21 Thread Dustan
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: function v. method

2006-07-21 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-21, fuzzylollipop <[EMAIL PROTECTED]> wrote: > >>danielx wrote: >> (snip) >> >> >>if you prefix with a single underscore, that tells the user, DON'T MESS >>WITH ME FROM OUTSIDE! I AM AN IMPLEMENTATION DETAIL! > > > Personnaly I don't like this convention. To b

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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)

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

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

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

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

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

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

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

  1   2   >