[Tutor] Calling super in __init__

2008-05-19 Thread wcyee
Hi - I wrote a custom exception class as follows: class CustomError(Exception): def __init__(self, msg): super(CustomError, self).__init__(self, msg) But this doesn't work as expected: try: raise CustomError('something bad') except CustomError, err: print err.message err.mes

Re: [Tutor] Calling super in __init__

2008-05-19 Thread Kent Johnson
On Mon, May 19, 2008 at 3:27 AM, wcyee <[EMAIL PROTECTED]> wrote: > Hi - I wrote a custom exception class as follows: > > class CustomError(Exception): > def __init__(self, msg): > super(CustomError, self).__init__(self, msg) Should be super(CustomError, self).__init__(msg) i.e. don'

Re: [Tutor] Calling super in __init__

2008-05-19 Thread Paul McGuire
>> Hi - I wrote a custom exception class as follows: class CustomError(Exception): def __init__(self, msg): super(CustomError, self).__init__(self, msg) But this doesn't work as expected: >> Correct use of super would be: class

[Tutor] Pythoncom Tutorial

2008-05-19 Thread FT
Hi! I noticed that when wanting to learn Pythoncom there is no real good accessible tutorial for it. Does anyone know where a good structured tutorial exists for the Com utilities so I can write my own screen reader program? When trying to understand all the needed variables and such

[Tutor] Python and Plone Boot Camps in Chapel Hill, NC

2008-05-19 Thread Chris Calloway
Triangle (NC) Zope and Python Users Group (TriZPUG) is proud to open registration for our fourth annual ultra-low cost Plone and Python training camps, BootCampArama 2008: http://trizpug.org/boot-camp/2008/ Registration is now open for: PyCamp: Python Boot Camp, August 4 - 8 Plone Boot Camp:

Re: [Tutor] Open a directory in the default file manager

2008-05-19 Thread Tim Michelsen
Hi! > is there any function/module that allows me to open a directory in the > default file manager of a operating system? On Windows you can use os.startfile(). On "pure" Unices there's no such thing as filetype associations However, if you use a desktop environment, you can spawn xdg-open

Re: [Tutor] converting all files in a directory with subprocess

2008-05-19 Thread Tim Michelsen
Hello, just for the records: below is some code that works ### convert all t2t docs in a directory. #!/usr/bin/env python # -*- coding: utf-8 -*- import os import subprocess import fnmatch documentation_directory = './doc/' for file in os.listdir(documentation_directory): if fnmatch.fnmat

Re: [Tutor] Pythoncom Tutorial

2008-05-19 Thread Hansen, Mike
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of FT > Sent: Monday, May 19, 2008 12:04 PM > To: Tutor Python ORG > Subject: [Tutor] Pythoncom Tutorial > > > Hi! > > I noticed that when wanting to learn Pythoncom there is > no real good > ac

[Tutor] env variable

2008-05-19 Thread james collins
just wondering how to set up my env variable? can't import scripts because my IDLE MacPython 2.5, can't find the module scripts. i created the file with textwrangler and stored them in my home folder in a folder i called python, on a macbook pro running mac os 10.5.2 _

[Tutor] timed functions? Timeouts?

2008-05-19 Thread W W
Hi, I'm having trouble finding any information (or if it's possible) on this particular topic. Specifically, there's a feature in javascript that I want to emulate. this is an example I pulled from a webmonkey tutorial -- function writeTime() { // get a date object

[Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread Marilyn Davis
Hi Tutors and Tutees, I've been teaching Python quite a while and a brilliant student asked a question that made me realize a big hole in my understanding. I think it is really magical that, when I define __getitem__ on classic classes, the built-in iterator uses it. But, when I make the same cl

Re: [Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread wesley chun
> I think it is really magical that, when I define __getitem__ on classic > classes, the built-in iterator uses it. > > But, when I make the same class as a new style class, I lose this behavior. > > I didn't realize that something was lost in defining a new style class. > Maybe it's something

Re: [Tutor] Pythoncom Tutorial

2008-05-19 Thread Alan Gauld
"FT" <[EMAIL PROTECTED]> wrote I noticed that when wanting to learn Pythoncom there is no real good accessible tutorial for it. Does anyone know where a good structured tutorial exists for the Com utilities so I can write my own screen reader program? Assuming you mean Pythonwin, the

Re: [Tutor] converting all files in a directory with subprocess

2008-05-19 Thread Alan Gauld
"Tim Michelsen" <[EMAIL PROTECTED]> wrote in below is some code that works ### convert all t2t docs in a directory. for file in os.listdir(documentation_directory): if fnmatch.fnmatch(file, '*.t2t'): You might be able to do this more succinctly using the glob.glob() function... Ju

Re: [Tutor] env variable

2008-05-19 Thread Alan Gauld
"james collins" <[EMAIL PROTECTED]> wrote just wondering how to set up my env variable? can't import scripts because my IDLE MacPython 2.5, can't find the module scripts. You should try setting your PYTHONPATH environment vaqriable in your bash shell. .profile or .login are the two files t

Re: [Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread Kent Johnson
On Mon, May 19, 2008 at 5:21 PM, Marilyn Davis <[EMAIL PROTECTED]> wrote: > Hi Tutors and Tutees, > > I've been teaching Python quite a while and a brilliant student asked a > question that made me realize a big hole in my understanding. > > I think it is really magical that, when I define __getite

Re: [Tutor] timed functions? Timeouts?

2008-05-19 Thread Alan Gauld
"W W" <[EMAIL PROTECTED]> wrote The specific bit I'm looking at is this line the_timeout = setTimeout('writeTime();',500); basically it calls the function again in 500ms, but rather than pausing, I guess it spawns a new thread? I'm not really sure. You might be able to use select() for th

Re: [Tutor] timed functions? Timeouts?

2008-05-19 Thread Kent Johnson
On Mon, May 19, 2008 at 5:28 PM, W W <[EMAIL PROTECTED]> wrote: > Now, when I look at that example and try to translate the timeout to > what I think is going on "behind the scenes" I'm pretty sure it spawns > a thread that does something similar to this: > > 1 import time > 2 > 3 def timer(end

Re: [Tutor] Pythoncom Tutorial

2008-05-19 Thread FT
> Hi! > > I noticed that when wanting to learn Pythoncom there is > no real good > accessible tutorial for it. > Does anyone know where a good structured tutorial exists > for the Com > utilities so I can write my own screen reader program? > Python Programming on Win32 might help. There'

Re: [Tutor] timed functions? Timeouts?

2008-05-19 Thread W W
Those examples are really helpful and I'm pretty sure they'll do what I need, I'll just have to play with them a little more. I do have a question about one of the examples though! Specifically this part: 4 class Operation(threading._Timer): 5 def __init__(self, *args, **kwargs): 6

Re: [Tutor] Calling super in __init__

2008-05-19 Thread wcyee
Kent and Paul, Thanks very much for your help! On Mon, May 19, 2008 at 8:43 AM, Paul McGuire <[EMAIL PROTECTED]> wrote: > >> > Hi - I wrote a custom exception class as follows: > > class CustomError(Exception): >def __init__(self, msg): >super(CustomError