Re: subexpressions (OT: math)

2007-06-02 Thread Hendrik van Rooyen
"Steve Howell" wrote: > > --- Steven D'Aprano > <[EMAIL PROTECTED]> wrote: > > Angles are real numbers (in the maths sense), so > > sqrt(pi/4) radians is > > just as reasonable an angle as pi/4 radians. Both > > are irrational numbers > > (that is, can't be written exactly as the ratio of >

Re: How to control the creation of an instance?

2007-06-02 Thread Steven D'Aprano
On Sat, 02 Jun 2007 23:25:49 -0700, 7stud wrote: > Oops. This line: > >> temp = object.__new__(Sample, args, kwds) > > should be: > > temp = object.__new__(cls, args, kwds) > > although it would seem that cls is always going to be Sample, so I'm > not sure what practical difference that makes

Re: How to control the creation of an instance?

2007-06-02 Thread 7stud
On Jun 3, 12:17 am, 7stud <[EMAIL PROTECTED]> wrote: > On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > suppose i have a free_object list[Sample1, Smaple2]. when create a > > new object sample(*args, **kwds), if free_object_list isn't empty, just > > pop one from free_o

Re: How to control the creation of an instance?

2007-06-02 Thread 7stud
On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote: > Hi, > > suppose i have a free_object list[Sample1, Smaple2]. when create a > new object sample(*args, **kwds), if free_object_list isn't empty, just > pop one from free_object_list instead of creating a new instance. > > any way to do this

Re: Help with win32 com_error exception

2007-06-02 Thread kaens
Richard, you posted it four times. Not twice. On 6/2/07, Andrew Holme <[EMAIL PROTECTED]> wrote: > > "Richard Gordon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Sorry if this is sent twice, but I didn't see it get posted the first > > time. > > > > I've got a fatal bug using

Re: How to control the creation of an instance?

2007-06-02 Thread 7stud
I just noticed that in your code you used pop(0). It's not efficient to pop an element off the front of a list because after doing so, every other element in the list has to be moved over to the left one position. If you pop() an element off the end of the list, then the first element in the list

Re: How to control the creation of an instance?

2007-06-02 Thread 7stud
On Jun 2, 10:31 pm, lialie <[EMAIL PROTECTED]> wrote: > Hi, > > suppose i have a free_object list[Sample1, Smaple2]. when create a > new object sample(*args, **kwds), if free_object_list isn't empty, just > pop one from free_object_list instead of creating a new instance. > > any way to do this

Re: int vs long

2007-06-02 Thread kaens
On 02 Jun 2007 20:18:02 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Dan Bishop <[EMAIL PROTECTED]> writes: > > Note that recent versions of Python automatically promote the results > > of integer arithmetic to long if necessary, so the distinction is less > > relevant than it used t

Re: Need help! win32 com_error 'Exception occurred'

2007-06-02 Thread Tim Roberts
"Richard Gordon" <[EMAIL PROTECTED]> wrote: > >I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 >using MS SAPI 5.1 and Hammond's win32 module. The test program is > import pyTTS > tts = pyTTS.Create() > tts.Speak('Hello world.') >... > com_error: (-2147352567, 'Exceptio

How to control the creation of an instance?

2007-06-02 Thread lialie
Hi, suppose i have a free_object list[Sample1, Smaple2]. when create a new object sample(*args, **kwds), if free_object_list isn't empty, just pop one from free_object_list instead of creating a new instance. any way to do this? I do some work as follows: class Sample(object): used_object =

Re: Is PEP-8 a Code or More of a Guideline?

2007-06-02 Thread Ben Finney
"Joe Riopel" <[EMAIL PROTECTED]> writes: > Using camel case instead of the under_score means less typing. I am lazy. Using camelCase instead of lower_case means harder reading. I am lazy. Remember: a program is read by humans much more often than it is written. -- \ "If you saw two guys

Re: Is PEP-8 a Code or More of a Guideline?

2007-06-02 Thread Ben Finney
Carl Banks <[EMAIL PROTECTED]> writes: > Identifiers should just allow spaces. > > first element.get item(selected value) > > This is not a joke. It would be a hideous pain to read though. My decades of schooling have carved channels in my brain that recognise the space as a *separator* for lexic

Multiple inheritence for exceptions?

2007-06-02 Thread Steven D'Aprano
Useful or a bad idea? I have a module that defines a number of exceptions which inherit from various built-ins like KeyError, ValueError etc. I'm considering defining an abstract module exception like MyModuleError, and having all my real exceptions inherit from it as well, but I don't recall seei

Re: pythonwin closes unexpectedlyI

2007-06-02 Thread John Machin
On Jun 3, 10:50 am, leegold <[EMAIL PROTECTED]> wrote: > Hi, > > I run a script in PythonWin and obviously some sort of an error occurs > in the script and PythonWin closes. No warning, no error message just > closes. I definitely know the line of code that causes the problem and > will cite the c

Re: int vs long

2007-06-02 Thread Paul Rubin
Dan Bishop <[EMAIL PROTECTED]> writes: > Note that recent versions of Python automatically promote the results > of integer arithmetic to long if necessary, so the distinction is less > relevant than it used to be. Note however that even in recent versions, there are still parts of Python that get

Re: monitoring the filesystem for changes

2007-06-02 Thread momobear
> i have designed a desktop search utility in python and a file system > monitoring using readdirectorychangesw from win32api but for eg. it > has a high cpu utilization (using a 2GHz processor). I don't think so. I just build a service to monitor a directory changes using readdirectorychangesw, t

Re: int vs long

2007-06-02 Thread Dan Bishop
On Jun 2, 9:30 pm, jay <[EMAIL PROTECTED]> wrote: > I was reading in a book that the 'int' type can store whole numbers > up to 32 bits. I'm not exactly sure what that means, but got me > wondering, what's the largest number you can store as an 'int' before > you need to switch over to 'long'? sy

Re: Trouble killing a process on windows

2007-06-02 Thread Thomas Nelson
On Jun 2, 11:43 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Thomas Nelson wrote: > > from subprocess import Popen > > from time import sleep > > import win32api > > war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) > > sleep(30) > > print "slept for 30" > > print win32api.Termin

int vs long

2007-06-02 Thread jay
I was reading in a book that the 'int' type can store whole numbers up to 32 bits. I'm not exactly sure what that means, but got me wondering, what's the largest number you can store as an 'int' before you need to switch over to 'long'? Thanks for looking at my question. Jay -- http://mai

Re: Python rocks

2007-06-02 Thread Josiah Carlson
Mark Carter wrote: > Josiah Carlson wrote: >> What kind of scoping did you desire? > > Well, I had in mind so that if you defined a function, but wanted to > access a global var, that you didn't have to use the global keyword. Not > much of a biggie, I guess. You already get read access to glo

Re: Python 2.3 ODBC Datetime limitations

2007-06-02 Thread John Machin
On Jun 3, 4:47 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > YuePing Lu wrote: > >> Hello, > > >> Has any of you ever used Python odbc to retrieve data from a relational DB? > > >> I encountered a problem where it can't handle datetime _earlier than > >> _*1969*, and _later th

Re: Python 2.5.1 broken os.stat module

2007-06-02 Thread Joe Salmeri
> It's not clear whether it's an error, however, localtime() does > something different from what dir does. Hi Martin, First off thank you for spending your time to investigate this bug with me. Thanks for pointing out the issue with Windows XP caching the access timestamps, I was not aware of

Re: subexpressions (OT: math)

2007-06-02 Thread Steven D'Aprano
On Sat, 02 Jun 2007 08:29:59 -0700, Steve Howell wrote: > > --- Steven D'Aprano > <[EMAIL PROTECTED]> wrote: > >> On Sat, 02 Jun 2007 05:54:51 -0700, Steve Howell >> wrote: >> >> >> >> >>def f(x): y = x*x; return sin(y)+cos(y); >> >> >> > >> > Although I know valid trigonometry is not th

Re: can this be implemented?

2007-06-02 Thread greenflame
On Jun 2, 5:05 pm, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Jun 2, 6:54 pm, greenflame <[EMAIL PROTECTED]> wrote: > > > First I should start with some introductory comments. > > > When I first learned about programming, I started with BASIC, QBASIC > > to be more accurate. While I was at that st

RE: c[:]()

2007-06-02 Thread Steven D'Aprano
On Sat, 02 Jun 2007 11:25:04 -0700, Warren Stringer wrote: > Since `a()` translates to `a() for a in b` then the error would be the exact > same `TypeError: 'str' object is not callable` Not in any language called Python I know of. Supposedly 28 years programming experience, and you can't even s

Re: Python rocks

2007-06-02 Thread Alex Martelli
Josiah Carlson <[EMAIL PROTECTED]> wrote: > > pitfall of Python is knowing whether an operation is destructive or not. > > If it returns None, it probably changes the content of an object. A reasonable heuristic, but with lots of exceptions, alas: somedict.get(somekey) will often return None

Re: Python rocks

2007-06-02 Thread Alex Martelli
Mark Carter <[EMAIL PROTECTED]> wrote: > I picked Chicken Scheme for OS X. Things started well, and even the web ... > that; but I found that it ultimately depended on gmp, which turned out a > pain to compile. Yes, GMP is a pain to compile (especially on Mac OS X), but I believe that the Univ

Re: Jinja 1.1 Released

2007-06-02 Thread Ben Finney
Armin Ronacher <[EMAIL PROTECTED]> writes: > Jinja 1.1 Released > == > > Jinja 1.1 codenname sinka is out! And with more changes then ever. > Here a small summary of the new features and improvements: This gives the reader no information about what Jinja actually is. It's far pref

pythonwin closes unexpectedlyI

2007-06-02 Thread leegold
Hi, I run a script in PythonWin and obviously some sort of an error occurs in the script and PythonWin closes. No warning, no error message just closes. I definitely know the line of code that causes the problem and will cite the code below. Note: I'm using ArcGIS 9.1 (Python 2.1 is bundled wit

Re: __getslice__ depreciation

2007-06-02 Thread Michael Hoffman
[EMAIL PROTECTED] wrote: > On Jun 1, 7:50 pm, [EMAIL PROTECTED] wrote: >> If __getslice__ is depreciated (since version 2.0) why are neither >> __setslice__ or __delslice__ >> depreciated?http://docs.python.org/ref/sequence-methods.html > > Sorry disregard that, I should have RTFA A request to h

Re: can this be implemented?

2007-06-02 Thread Dan Bishop
On Jun 2, 6:54 pm, greenflame <[EMAIL PROTECTED]> wrote: > First I should start with some introductory comments. > > When I first learned about programming, I started with BASIC, QBASIC > to be more accurate. While I was at that stage, I learned about the > INPUT command. I used it abundantly. > >

can this be implemented?

2007-06-02 Thread greenflame
First I should start with some introductory comments. When I first learned about programming, I started with BASIC, QBASIC to be more accurate. While I was at that stage, I learned about the INPUT command. I used it abundantly. Ok so now for the actual issue. I would like to implement something

Re: Python Pop Quiz

2007-06-02 Thread reed
On Jun 1, 10:33 pm, [EMAIL PROTECTED] wrote: > 1. Do you like Python? 0 > 2. Do you think Python is good? 0 > 3. Do you think Python is real good? 0 > 4. What is your favorite version of Python? 2.4+ > 5. Because of Python, do you think it will be easier to take over the > world? If so, when? I

Re: Trouble killing a process on windows

2007-06-02 Thread reed
On Jun 2, 12:27 pm, Thomas Nelson <[EMAIL PROTECTED]> wrote: > Hi, I'd like to start a program, run it for a while, then terminate > it. I can do this on linux, but I'm new to working with windows. > Here's my script: > > from subprocess import Popen > from time import sleep > import win32api > wa

Re: SMTPlib Sender Refused?

2007-06-02 Thread reed
On Jun 2, 1:20 pm, erikcw <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to send an email message with python, and I'm getting this > error: > > Traceback (most recent call last): > File "wa.py", line 430, in ? > main() > File "wa.py", line 425, in main > smtp.sendmail(fromaddr, to, ms

Re: Error message if there is a space in the source directory

2007-06-02 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I am trying to learn Python. I am working on a simple backup program > (code listed below). When using a source directory (the files to be > backed up) without spaces in the title, my program works fine [see > line 5]. If I try to access a directory with a space in the

Re: PythonCard or Dabo?

2007-06-02 Thread Ed Leafe
On Jun 2, 2007, at 7:22 AM, SPE - Stani's Python Editor wrote: > Another alternative are GUI designers such as wxGlade or XRCed, both > of which ship with SPE (http://pythonide.stani.be). Dabo is especially > usefull (but not limited to) developping database applications as it > is an open source

Re: Help with win32 com_error exception

2007-06-02 Thread Andrew Holme
"Richard Gordon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sorry if this is sent twice, but I didn't see it get posted the first > time. > > I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 > using MS SAPI 5.1 and Hammond's win32 module. The test progr

Re: Python rocks

2007-06-02 Thread Mark Carter
Josiah Carlson wrote: > Mark Carter wrote: >> Not that I'm particularly knowledgeable about language design issues, >> but maybe closures and slightly different scoping rules would be nice. > > Python has had closures for years. I just looked up http://www.secnetix.de/~olli/Python/lambda_functio

Re: Python rocks

2007-06-02 Thread Aahz
In article <[EMAIL PROTECTED]>, George Sakkis <[EMAIL PROTECTED]> wrote: > >I had probably stumbled on many/most of the common pitfalls usually >mentioned (e.g. http://www.ferg.org/projects/python_gotchas.html, >http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but >picked them up

Re: Non-blocking subprocess call

2007-06-02 Thread Kevin Walzer
Josiah Carlson wrote: > > If you are talking about non-blocking reading and writing from the > subprocess, there isn't natively. But there is a cookbook entry: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > - Josiah Any idea why this feature was removed from the lan

Re: iterblocks cookbook example

2007-06-02 Thread Raymond Hettinger
On Jun 2, 10:19 am, Steve Howell <[EMAIL PROTECTED]> wrote: > George Sakkis produced the following cookbook recipe, > which addresses a common problem that comes up on this > mailing list: ISTM, this is a common mailing list problem because it is fun to solve, not because people actually need it o

RE: Help with win32 com_error exception

2007-06-02 Thread David Stockwell
Hi Rich, I've seen errors like this before. first off it will help you better if you represent your error in hex. Doing so yields this 80020009 <==> -2147352567 0x 0x80020009 Anyways, its probably the result of something not being either registered/installed correctly (

Re: Non-blocking subprocess call

2007-06-02 Thread Josiah Carlson
Kevin Walzer wrote: > I'm currently using os.popen in an application of mine, which calls for > non-blocking data, in this fashion: > > self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' % > (self.passtext, self.packagename), 'r', os.O_NONBLOCK) > > What is the equivalent/comp

Re: Python rocks

2007-06-02 Thread Josiah Carlson
Mark Carter wrote: > Not that I'm particularly knowledgeable about language design issues, > but maybe closures and slightly different scoping rules would be nice. Python has had closures for years. What kind of scoping did you desire? > A > pitfall of Python is knowing whether an operation is

Help with win32 com_error exception

2007-06-02 Thread Richard Gordon
Sorry if this is sent twice, but I didn't see it get posted the first time. I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting de

Re: Detecting an active exception

2007-06-02 Thread Steve Holden
Duncan Booth wrote: > "NeBlackCat (lists)" <[EMAIL PROTECTED]> wrote: > >> Depending on what you read, sys.exc_info() is supposed to return >> (None,None,None) when there is no active exception, but it seems that >> it returns info about the last exception when there isn't one >> currently active

Re: Using PIL to find separator pages

2007-06-02 Thread Steve Holden
Steve Holden wrote: > Larry Bates wrote: [...] >> I think I've come up with something that will work. I use PIL >> Image.getcolors() to get colors and take the top 10 colors of my >> background page. I then calculate the average of the R, G, B >> components. That becomes my reference. Then I re

** VIDEO SPEECH OF PAKISTANIAN CHIEF JUSTICE REQUESTED ***

2007-06-02 Thread thermate
The nexus between 911 truth movement and its success is closely related to the democratic victory in Pakistan. The Pakistanian Military Dictator, a foolish patsy of Bush-Neocon- Crime Syndicate, provided critical validation to the 911 LIE by implicitly buckling under the false conspiracy theory.

Re: Python Pop Quiz

2007-06-02 Thread k47867
> 1. Do you like Python? > Yes, or I wouldn't still be subscribed to the python-list. > 2. Do you think Python is good? s Yes. Well it is a good Language. I can code in python at-least twice as fast as I could in C or C++. > > 3. Do you think Python is real good? > Yeah, if you meant 'very' instead

Strange behavior in Windows

2007-06-02 Thread Jakob Svavar Bjarnason
Greetings. I have been trying to switch to Python from other languages such as Perl and now I have a newbie question. I have been trying to run a setup script to install a python library. To do that I need to run "c:> python setup.py install" but the strange thing is is that when it runs the

Need help! win32 com_error 'Exception occurred'

2007-06-02 Thread Richard Gordon
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting debug trace is: PythonWin 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32

Please help! win32 com_error 'Exception occurred'

2007-06-02 Thread Richard Gordon
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting debug trace is: PythonWin 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32

com_error 'Exception occurred'

2007-06-02 Thread Richard Gordon
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting debug trace is: PythonWin 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32

RE: c[:]()

2007-06-02 Thread Warren Stringer
Oops, forgot to cut and paste the point, to this: > > - there is no Python error for "you > > cannot do this with this object, but you can do it with other objects > > of the same type". > > Yes there is: > > # > def yo(): print "yo" > def no(): print blah > yo() > no()

Re: Python 2.3 ODBC Datetime limitations

2007-06-02 Thread Tim Golden
Steve Holden wrote: > YuePing Lu wrote: >> Hello, >> >> Has any of you ever used Python odbc to retrieve data from a relational DB? >> >> I encountered a problem where it can't handle datetime _earlier than >> _*1969*, and _later than _*2040*. It just returned some garbage strings >> when I call

Re: Error message if there is a space in the source directory

2007-06-02 Thread Mark Peters
> When using a source like this on line 5: > > source = [r'C:\test\test 2\\'] > > which has a space in the title, the program will not work. Try wrapping that argument in double quotes when you build the command -- http://mail.python.org/mailman/listinfo/python-list

Re: Using PIL to find separator pages

2007-06-02 Thread Steve Holden
Larry Bates wrote: > Steve Holden wrote: >> Larry Bates wrote: >>> Steve Holden wrote: Larry Bates wrote: > I have a project that I wanted to solicit some advice > on from this group. I have millions of pages of scanned > documents with each page in and individual .JPG file. >

RE: c[:]()

2007-06-02 Thread Warren Stringer
Andre Engels wrote: > > I am not insisting on anything. I use ``c[:]()`` as shorthand way of > saying > > "c() for c in d where d is a container" > > > > Having c() support containers seems obvious to me. It jibes with duck > > typing. Perhaps the title of this thread should have been: "Why don't >

Non-blocking subprocess call

2007-06-02 Thread Kevin Walzer
I'm currently using os.popen in an application of mine, which calls for non-blocking data, in this fashion: self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' % (self.passtext, self.packagename), 'r', os.O_NONBLOCK) What is the equivalent/comparable call in the new subprocess

Error message if there is a space in the source directory

2007-06-02 Thread lukefrancomusic
I am trying to learn Python. I am working on a simple backup program (code listed below). When using a source directory (the files to be backed up) without spaces in the title, my program works fine [see line 5]. If I try to access a directory with a space in the name the program fails with this er

Re: Python rocks

2007-06-02 Thread George Sakkis
On Jun 2, 12:31 pm, Steve Howell <[EMAIL PROTECTED]> wrote: > --- Mark Carter <[EMAIL PROTECTED]> wrote: > > > Well, I know I'm preaching to the converted - but > > Python rocks. > > [...] > > A few questions from the choir: > > As a recent newcomer to the language, did you > encounter any traps or

Re: Python rocks

2007-06-02 Thread Mark Carter
Steve Howell wrote: > --- Mark Carter <[EMAIL PROTECTED]> wrote: > >> Well, I know I'm preaching to the converted - but >> Python rocks. >> [...] > > A few questions from the choir: > > As a recent newcomer to the language, did you > encounter any traps or pitfalls while you were > learning? Al

Automating a telnet session with an echo to stdout

2007-06-02 Thread Samuel
Hi, I am trying to automate a telnet session (currently using Python's telnetlib) and would like to echo any response of the remote host to stdout, as soon as it arrives on telnetlib's open TCP socket. Currently I print the return value of the read_some() method (or other read* methods) to the

Re: PythonCard or Dabo?

2007-06-02 Thread Terry Reedy
"Bill Maxwell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On 19 Mar 2007 10:40:03 -0700, [EMAIL PROTECTED] wrote: | | ... | >You might want to submit this to the wxpython news-group. | ... | | What is the name of this newsgroup? I can't seem to locate it on my | news server.

SMTPlib Sender Refused?

2007-06-02 Thread erikcw
Hi, I'm trying to send an email message with python, and I'm getting this error: Traceback (most recent call last): File "wa.py", line 430, in ? main() File "wa.py", line 425, in main smtp.sendmail(fromaddr, to, msg.encode('utf-8')) File "/usr/local/lib/python2.4/smtplib.py", line 6

iterblocks cookbook example

2007-06-02 Thread Steve Howell
George Sakkis produced the following cookbook recipe, which addresses a common problem that comes up on this mailing list: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521877 I would propose adding something like this to the cookbook example above. def iterblocks2(lst, start_delim):

Re: Delete a file from a CGI

2007-06-02 Thread Matias Surdi
Steve Holden escribió: > Matias Surdi wrote: >> Thanks for your reply. >> >> This is the code that creates the file: >> lock_file = open(".lock","w") >> lock_file.write("test") >> lock_file.close() >> #Change permissions so that CGI can write lock file >> os.chmod(".lock",stat.S_IMODE(stat.S_IRWX

Re: Python 2.3 ODBC Datetime limitations

2007-06-02 Thread Steve Holden
YuePing Lu wrote: > Hello, > > Has any of you ever used Python odbc to retrieve data from a relational DB? > > I encountered a problem where it can't handle datetime _earlier than > _*1969*, and _later than _*2040*. It just returned some garbage strings > when I call str(my_date_object). > > W

[Fwd: Re: Trouble killing a process on windows]

2007-06-02 Thread Tim Golden
Tim Golden wrote: > Thomas Nelson wrote: [... re problem Terminating process ...] >> File "C:\Python24\warcraft\runwar3.py", line 7, in ? >> print win32api.TerminateProcess(int(war3game._handle),-1) >> error: (5, 'TerminateProcess', 'Access is denied.') >> >> I'm logged in as adminstrator.

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Wildemar Wildenburger
Steven Bethard wrote: > Wildemar Wildenburger wrote: > > class Observable(object): > >> ... def __init__(self, func, instance=None, observers=None): >> ... self.func = func >> ... self.instance = instance >> ... self.observers = observers or [] >>

Re: Trouble killing a process on windows

2007-06-02 Thread Tim Golden
Thomas Nelson wrote: > from subprocess import Popen > from time import sleep > import win32api > war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) > sleep(30) > print "slept for 30" > print win32api.TerminateProcess(int(war3game._handle),-1) > #print > ctypes.windll.kernel32.Te

Re: Python rocks

2007-06-02 Thread Steve Howell
--- Mark Carter <[EMAIL PROTECTED]> wrote: > Well, I know I'm preaching to the converted - but > Python rocks. > [...] A few questions from the choir: As a recent newcomer to the language, did you encounter any traps or pitfalls while you were learning? Also, could you single out anything in p

Trouble killing a process on windows

2007-06-02 Thread Thomas Nelson
Hi, I'd like to start a program, run it for a while, then terminate it. I can do this on linux, but I'm new to working with windows. Here's my script: from subprocess import Popen from time import sleep import win32api war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) sleep(30

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Steven Bethard
Wildemar Wildenburger wrote: class Observable(object): > ... def __init__(self, func, instance=None, observers=None): > ... self.func = func > ... self.instance = instance > ... self.observers = observers or [] Unless you also changed code in __get__, this means yo

Re: file reading by record separator (not line by line)

2007-06-02 Thread Steve Howell
--- Steve Howell <[EMAIL PROTECTED]> wrote: > > Can I suggest a minor optimization? > > Instead of this... > > def get_predicate(arg): > return arg if callable(arg) else ( >arg.__eq__ if hasattr(arg,'__eq__') > else >lambda item: item == arg) > Neve

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Wildemar Wildenburger
Peter Otten wrote: class Descriptor(object): > ... def __get__(*args): return object() > ... > class SomeActor(object): > ... meth = Descriptor() > ... > SomeActor.meth is SomeActor.meth > False > Of course ... Man, this lang

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Steven Bethard
David Wahler wrote: > On Jun 2, 12:27 am, Steven Bethard <[EMAIL PROTECTED]> wrote: >> I think you want to define __get__ on your Observable class so that it >> can do the right thing when the method is bound to the instance: [snip] > Is this desired behavior? > a = SomeActor() b = SomeA

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Peter Otten
Wildemar Wildenburger wrote: > Thanks for the thorough explanation. But you did mock me with that > "SomeActor.meth is SomeActor.meth"-line, right? ;) Acually, no: >>> class Descriptor(object): ... def __get__(*args): return object() ... >>> class SomeActor(object): ... meth = Descriptor

Re: file reading by record separator (not line by line)

2007-06-02 Thread Steve Howell
--- George Sakkis <[EMAIL PROTECTED]> wrote: > > It seems > > like it would be fairly straightforward to do a > quick > > prototype implementation of this. I'm off to work > > soon, so I can't do it today, but maybe Sunday. > > I'm afraid I beat you to it :) > http://aspn.activestate.com/ASPN/

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Wildemar Wildenburger
David Wahler wrote: > > Here's my attempt at an implementation that works as a decorator. It > stores the observers in a dictionary attribute of the instance, using > the method name as a key. For example: > > > [snip: another nice aproach] > Anyway, these are just my initial thoughts -- I don't

Re: subexpressions (fourier example)

2007-06-02 Thread Steve Howell
--- Steve Howell <[EMAIL PROTECTED]> wrote: > > --- Stef Mientki <[EMAIL PROTECTED]> > wrote: > > Maybe he meant > >sin(x)^2 + cos(x)^2 > > which is well known demodulation technique if you > > create two signals 90 degrees out of phase. > > > A more realistic subexpression where you migh

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Wildemar Wildenburger
Peter Otten wrote: > Then you have modified the code posted by Steven Bethard. > > Oops. Indeed I did. I changed this >>> class Observable(object): ... def __init__(self, func, instance=None, observers=None): ... if observers is None: ... observers = [] ... self.

Re: subexpressions

2007-06-02 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> wrote: > Maybe he meant >sin(x)^2 + cos(x)^2 > which is well known demodulation technique if you > create two signals 90 degrees out of phase. > There's a shorter way to phrase that expression, of course. :) 1

Re: subexpressions (OT: math)

2007-06-02 Thread Steve Howell
--- Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 02 Jun 2007 05:54:51 -0700, Steve Howell > wrote: > > >> > >>def f(x): y = x*x; return sin(y)+cos(y); > >> > > > > Although I know valid trigonometry is not the > point of > > this exercise, I'm still trying to figure out why > > an

monitoring the filesystem for changes

2007-06-02 Thread rohit
hello, i have designed a desktop search utility in python and a file system monitoring using readdirectorychangesw from win32api but for eg. it has a high cpu utilization (using a 2GHz processor). a solution ntfs change journal proposed here works only for ntfs partitions is there another low (proc

Re: speeding things up with C++

2007-06-02 Thread Jorgen Grahn
On Thu, 31 May 2007 12:25:17 -0500, Chris Mellon <[EMAIL PROTECTED]> wrote: > On 31 May 2007 03:45:32 -0700, bullockbefriending bard > <[EMAIL PROTECTED]> wrote: >> Thanks this is good news. I think my C/C++ background is sufficient to >> manage to figure things out if I RTFM carefully. >> >> Basic

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread David Wahler
On Jun 2, 3:00 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Then you have modified the code posted by Steven Bethard. > > > I don't see how your behaviour should come about ... a new observer-list > > is created for every decorated method, so there is no problem. > > Yes, but that list is shared a

Re: subexpressions

2007-06-02 Thread Stef Mientki
Steve Howell wrote: >>def f(x): y = x*x; return sin(y)+cos(y); >> > > Although I know valid trigonometry is not the point of > this exercise, I'm still trying to figure out why > anybody would ever take the square of an angle. > What's the square root of pi/4 radians? Maybe he meant sin(x)

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Peter Otten
Wildemar Wildenburger wrote: > David Wahler wrote: >> Is this desired behavior? >> >> > a = SomeActor() > b = SomeActor() > a.meth.observers is b.meth.observers > >> True >> > No it's not, but I get > a = SomeActor() b = SomeActor() a.meth.observers i

Re: subexpressions

2007-06-02 Thread Steven D'Aprano
On Sat, 02 Jun 2007 05:54:51 -0700, Steve Howell wrote: >> >>def f(x): y = x*x; return sin(y)+cos(y); >> > > Although I know valid trigonometry is not the point of > this exercise, I'm still trying to figure out why > anybody would ever take the square of an angle. > What's the square root

Python rocks

2007-06-02 Thread Mark Carter
Well, I know I'm preaching to the converted - but Python rocks. I've been enchanted by the siren calls of Scheme, Lisp and Forth, but in the end, I find Python much easier. I even tried a little bit of Tcl. To give a bit of context ... I have recently switched from Windows to OS X and Linux. I

Re: c[:]()

2007-06-02 Thread Bruce Coram
I am a relative newbie to Python and certainly to this mailing list. I have watched this thread with interest. After the first few exchanges I thought it would prove interesting and it has. Warren Stringer is one of two things: A joker having some fun at your expense. An intellectually prete

Re: file reading by record separator (not line by line)

2007-06-02 Thread George Sakkis
On Jun 1, 7:00 am, Steve Howell <[EMAIL PROTECTED]> wrote: > --- Tijs <[EMAIL PROTECTED]> wrote: > > > Yes, or a single one that takes a wide range of > > construction possibilities, > > like strings, lambdas or regexes in various keyword > > parameters. > > > BlockReader(f, start='>') > > BlockRea

Re: Observer-Pattern by (simple) decorator

2007-06-02 Thread Wildemar Wildenburger
David Wahler wrote: > Is this desired behavior? > > a = SomeActor() b = SomeActor() a.meth.observers is b.meth.observers > True > No it's not, but I get >>> a = SomeActor() >>> b = SomeActor() >>> a.meth.observers is b.meth.observers False I don't see how your

Re: subexpressions

2007-06-02 Thread Steve Howell
> >def f(x): y = x*x; return sin(y)+cos(y); > Although I know valid trigonometry is not the point of this exercise, I'm still trying to figure out why anybody would ever take the square of an angle. What's the square root of pi/4 radians?

Re: Python Pop Quiz

2007-06-02 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Roy Smith > wrote: > > > In article <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] wrote: > >> 7. How many Z80 assembly language programmers does it take to equal > >> one Python guru? > >

Re: Creating a distro of python... What would you include in it?

2007-06-02 Thread SPE - Stani's Python Editor
On May 30, 7:47 pm, yuce <[EMAIL PROTECTED]> wrote: > re: BJörn, I think selecting a GPL license will increase the number of > usable packages, since using Python license with GPL is perfectly fine > as long as the whole software is licensed under GPL [I am not really > sure it is a must to license

Re: Python Pop Quiz

2007-06-02 Thread Dustan
On Jun 1, 9:33 pm, [EMAIL PROTECTED] wrote: > 1. Do you like Python? yes > 2. Do you think Python is good? yes > 3. Do you think Python is real good? yes > 4. What is your favorite version of Python? The most recent one. > 5. Because of Python, do you think it will be easier to take over th

Re: Python Pop Quiz

2007-06-02 Thread Michael Bentley
On Jun 1, 2007, at 9:33 PM, [EMAIL PROTECTED] wrote: > 1. Do you like Python? It's pretty good. > 2. Do you think Python is good? It's pretty good. > 3. Do you think Python is real good? It's pretty good. > 4. What is your favorite version of Python? The one I have. > 5. Because of Python,

  1   2   >