[Tutor] working with new classes

2005-03-08 Thread C Smith
Hello, After learning about the new class behavior, I am trying to implement a circular type list where, for example, you can compare the nth value to the "(n+1)th" value without worrying about going past the end of the list. (An old approach might be to create a function that converts a given

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Kent Johnson
Shidai Liu wrote: Hi all, I'll sum up a question as following: def int5(): '''return 5''' return 5 class my_int(int): def __init__(self): self.id = int5() int.__init__(self, self.id) # FIXME: this line doesn't work the above code act like this: I = my_int() I 0 I want i

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Max Noel
On Mar 9, 2005, at 01:13, Shitiz Bansal wrote: Whats worse, I had found that the rule is different for different versions of windows.Just proves what we all know...Windows Suxx. The Windows OS sucks! And blows! At the same time! (name the reference, get a cookie ;) ) -- Max maxnoel_fr at yahoo dot

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread R. Alan Monroe
> I have a script that converts data relating to my work. > It works great on my Linux system but some of my colleagues run windows. > I am attempting to convert the file paths to windows but am having no luck. > I need to access 'memo.txt' in 'my documents' on windows & am struggling. > I have

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Danny Yoo
[Windows bashing cut] Python's support for Windows stuff is actually quite good, thanks to the work of Mark Hammond: http://starship.python.net/crew/mhammond/ A lot of us here do use Windows for COM programming. Let's get back to talking about Python programming and let's help Dave with hi

Re: [Tutor] regular expression question

2005-03-08 Thread Mike Hall
Sorry, my last reply crossed this one (and yes, I forgot again to CC the list). I'm experimenting now with your use of the "or" operator( "|") between two expressions, thanks. On Mar 8, 2005, at 6:42 PM, Danny Yoo wrote: On Tue, 8 Mar 2005, Mike Hall wrote: Yes, my existing regex is using a lo

Re: [Tutor] regular expression question

2005-03-08 Thread Danny Yoo
> > Regular expressions are a little evil at times; here's what I think you're > thinking of: > > ### > >>> import re > >>> pattern = re.compile(r"""dog(?!cat) > ...| (?<=dogcat)""", re.VERBOSE) > >>> pattern.match('dogman').start() > 0 > >>> pattern.search('dogcatcher').start

Re: [Tutor] regular expression question

2005-03-08 Thread Mike Hall
This will match the position in front of "dog": (?<=dog) This will match the position in front of "cat": (?<=cat) This will not match in front of "dog" if "dog" is followed by "cat": (?<=dog)\b (?!cat) Now my question is how to get this: (?<=cat) ...but ONLY if "cat" is following "dog." If "dog" do

Re: [Tutor] regular expression question

2005-03-08 Thread Danny Yoo
On Tue, 8 Mar 2005, Mike Hall wrote: > Yes, my existing regex is using a look behind assertion: > > (?<=dog) > > ...it's also checking the existence of "Cat": > > (?!Cat) > > ...what I'm stuck on is how to essentially use a lookbehind on "Cat", > but only if it exists. Hi Mike, [Note: Please

Re: [Tutor] regular expression question

2005-03-08 Thread Sean Perry
Mike Hall wrote: First, thanks for the response. Using your re: my_re = re.compile(r'(dog)(cat)?') ...I seem to simply be matching the pattern "Dog". Example: >>> str1 = "The dog chased the car" >>> str2 = "The dog cat parade was under way" >>> x1 = re.compile(r'(dog)(cat)?') >>> rep1 = x1.su

Re: [Tutor] regular expression question

2005-03-08 Thread Mike Hall
First, thanks for the response. Using your re: my_re = re.compile(r'(dog)(cat)?') ...I seem to simply be matching the pattern "Dog". Example: >>> str1 = "The dog chased the car" >>> str2 = "The dog cat parade was under way" >>> x1 = re.compile(r'(dog)(cat)?') >>> rep1 = x1.sub("REPLACE", str1) >>>

Re: [Tutor] regular expression question

2005-03-08 Thread Danny Yoo
On Tue, 8 Mar 2005, Mike Hall wrote: > I'd like to get a match for a position in a string preceded by a > specified word (let's call it "Dog"), unless that spot in the string > (after "Dog") is directly followed by a specific word(let's say "Cat"), > in which case I want my match to occur direct

Re: [Tutor] regular expression question

2005-03-08 Thread Sean Perry
Mike Hall wrote: I'd like to get a match for a position in a string preceded by a specified word (let's call it "Dog"), unless that spot in the string (after "Dog") is directly followed by a specific word(let's say "Cat"), in which case I want my match to occur directly after "Cat", and not "Dog

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Shidai Liu
On Tue, 8 Mar 2005 17:15:00 -0800 (PST), Terry Carroll <[EMAIL PROTECTED]> wrote: > On Tue, 8 Mar 2005, Shidai Liu wrote: > > > I'll sum up a question as following: > > > > def int5(): > > '''return 5''' > > return 5 > > > > class my_int(int): > > def __init__(self): > > self.

[Tutor] regular expression question

2005-03-08 Thread Mike Hall
I'd like to get a match for a position in a string preceded by a specified word (let's call it "Dog"), unless that spot in the string (after "Dog") is directly followed by a specific word(let's say "Cat"), in which case I want my match to occur directly after "Cat", and not "Dog." I can easily get

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Terry Carroll
On Tue, 8 Mar 2005, Dave S wrote: > IOError: [Errno 2] No such file or directory: 'c:\\my documents\\memo.txt' My two thoughts. 1) is there actually a directory named "my documents" at the root? I don't know about Win2000, but for Win XP, the "my documents" directory is actually C:\Documen

RE: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Shitiz Bansal
I faced the same problem once.Dont remember the solution, but it is definitely the slashes which are causing the problem.I couldnt find a specific rule in whole of microsoft documentation, so i assume it has to be hit and try.Try a mix of backslashes n forward slashes till u get there. Whats worse,

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Terry Carroll
On Tue, 8 Mar 2005, Shidai Liu wrote: > I'll sum up a question as following: > > def int5(): > '''return 5''' > return 5 > > class my_int(int): > def __init__(self): > self.id = int5() > int.__init__(self, self.id) # FIXME: this line doesn't work > > the above code

RE: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread John Purser
I agree with a previous poster, check your path. I think either the path doesn't exist or you don't have permission to get to it. John -Original Message- From: Dave S [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 14:50 To: [EMAIL PROTECTED] Cc: 'Python Tutor' Subject: Re: [Tu

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Dave S
John Purser wrote: Try c:\\my documents\\memo.txt John Unfortunately thats a no go ... palm.py palm memo.txt to oocalc data.csv convertor, written by lentil ;) [EMAIL PROTECTED] - enter "palm software" in the title or it will be junked 09-03-2005 v1.02w Coded for Windows 07-03-2005 v1.02 Cod

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread jfouhy
Quoting Dave S <[EMAIL PROTECTED]>: > I need to access 'memo.txt' in 'my documents' on windows & am > struggling. > I have tried just about every combination of \ and / and \\ and // but > to no avail. > I need something like ... > > C:\My Documents\memo.txt > > Can anyone advise me ? I've nev

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Max Noel
On Mar 8, 2005, at 22:26, John Purser wrote: Try c:\\my documents\\memo.txt John Or even better, c:/My Documents/memo.txt In most programming languages, you can use the slash as a path separator under Windows as well. It'll save you a lot of trouble. -- Max maxnoel_fr at yahoo dot fr -- ICQ

RE: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Eric Culpepper
Try something like this (change the username to the user you're logged in as, or Administrator if that's how you're logged in): c:\\documents and settingsmy documents\\memo.txt -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Dave S Sent: Tuesday, Marc

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread jfouhy
Quoting Max Noel <[EMAIL PROTECTED]>: > I'm not absolutely confident with inheritance in Python (nearly all of > my serious OO work has been in Java), but shouldn't the call to the > superclass's constructor be the very first statement of the subclass's > constructor? No ... Or, well, ma

RE: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread John Purser
Try c:\\my documents\\memo.txt John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave S Sent: Tuesday, March 08, 2005 14:24 To: Python Tutor Subject: [Tutor] Acessing files in Windows 2000 I have a script that converts data relating to my work. It w

[Tutor] Acessing files in Windows 2000

2005-03-08 Thread Dave S
I have a script that converts data relating to my work. It works great on my Linux system but some of my colleagues run windows. I am attempting to convert the file paths to windows but am having no luck. I need to access 'memo.txt' in 'my documents' on windows & am struggling. I have tried just

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Max Noel
On Mar 8, 2005, at 22:10, Shidai Liu wrote: Hi all, I'll sum up a question as following: def int5(): '''return 5''' return 5 class my_int(int): def __init__(self): self.id = int5() int.__init__(self, self.id) # FIXME: this line doesn't work I'm not absolutely confident

[Tutor] HELP: subclass of int

2005-03-08 Thread Shidai Liu
Hi all, I'll sum up a question as following: def int5(): '''return 5''' return 5 class my_int(int): def __init__(self): self.id = int5() int.__init__(self, self.id) # FIXME: this line doesn't work the above code act like this: >>> I = my_int() >>> I 0 I want it to

[Tutor] Using signal handlers

2005-03-08 Thread Michael Lange
Hello tutors, I experience problems with signal handlers, and the explanatzions in the docs don't seem to help me much. The code I try to handle basically comes down to this (it's supposed to run on linux only, btw): from Tkinter import * import tkSnack root = Tk() tkSnack.initializeSnack(roo

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Kent Johnson
Paul Tremblay wrote: So I just make a file called /etc/router_passwords and include something like WRT54G username password Then parse the file, and supply the info to the password handler? This is easy to do, and I guess it is secure. No, it's not secure at all. In either case (password in the

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Paul Tremblay
On Tue, Mar 08, 2005 at 01:42:40PM -0500, Kent Johnson wrote: > Date: Tue, 08 Mar 2005 13:42:40 -0500 > From: Kent Johnson <[EMAIL PROTECTED]> > User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) > Cc: python tutor > Subject: Re: [Tutor] getting a webpage via python > > Paul Tremblay wrote:

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Kent Johnson
Paul Tremblay wrote: This is giving me 401 error, authorization required. Here's what I have: auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password('realm', '127.0.0.1', 'myname', 'password') opener = urllib2.build_opener(auth_handler) # ...and install it globally so it can be use

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Paul Tremblay
On Tue, Mar 08, 2005 at 11:50:12AM -0500, Kent Johnson wrote: > > Paul Tremblay wrote: > > You can use urllib2 to do this. It is a little work to set it up to use > Basic authentication. Here is an example (slightly modified from the > urllib2 example page): > > import urllib2 > > # Create an

[Tutor] Re: [Pysqlite-users] Querying 2 databases together

2005-03-08 Thread Liam Clarke
Ack - wrong list. On Wed, 9 Mar 2005 06:52:57 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote: > Care to post the SQL of what you're trying to do? > > > On Tue, 8 Mar 2005 17:01:07 +0100, Pierre-Yves Delens > <[EMAIL PROTECTED]> wrote: > > bonjour, > > > > Iread through SqLite syntax (Attach), and

[Tutor] Re: [Pysqlite-users] Querying 2 databases together

2005-03-08 Thread Liam Clarke
Care to post the SQL of what you're trying to do? On Tue, 8 Mar 2005 17:01:07 +0100, Pierre-Yves Delens <[EMAIL PROTECTED]> wrote: > bonjour, > > Iread through SqLite syntax (Attach), and found some old posts on PySqLite, > but.. > > I didn't manage to join a table from a 2d database file in my

Re: [Tutor] Paradox database files

2005-03-08 Thread Victor Bouffier
That did the trick. Thanks Ewald. FYI, I used the '--nodeps' directive once I realized there were really no major issues. I still needed to keep the added symlink since the px libraries couldn't find the libbz2.so.1.0 file. Thanks again to all. That was great help. Victor Ewald Ertl wrote: Hi Vi

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Kent Johnson
Paul Tremblay wrote: Is there a simple way to get a web page with python? I have done no network programming with python before. My router (a Linksys 54G model) stores the IP/MAC addresss in a web page. There is no way for me to access them except through the web. Righ now, I am using this code

Re: [Tutor] getting a webpage via python

2005-03-08 Thread Ewald Ertl
Hi Paul! As mentioned earlier by Kent in this group under the subject: Subject: Re: [Tutor] Downloading from http Mark Kels wrote: > On Sat, 12 Feb 2005 09:25:10 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > >>urllib or urllib2 or maybe httplib maybe? >> >>urlopen( url[, data]) > I

RE: [Tutor] getting a webpage via python

2005-03-08 Thread Eric Culpepper
You could use the builtin modules like urllib2, httplib, or you could use John Lee's spifftastic module "mechanize". I use mechanize a lot for automating downloading files from various partner websites my company has relations with. http://docs.python.org/lib/module-httplib.html http://docs.pyt

Re: [Tutor] Paradox database files

2005-03-08 Thread Ewald Ertl
Hi Victor on Tue, 08 Mar 2005 10:06:50 -0600 Victor Bouffier <[EMAIL PROTECTED]> wrote : - Victor Bouffier > Hi all, Victor Bouffier > I know this is OT from Python, but does anybody know how to fix my

[Tutor] getting a webpage via python

2005-03-08 Thread Paul Tremblay
Is there a simple way to get a web page with python? I have done no network programming with python before. My router (a Linksys 54G model) stores the IP/MAC addresss in a web page. There is no way for me to access them except through the web. Righ now, I am using this code: command = 'lynx -r

Re: [Tutor] Paradox database files

2005-03-08 Thread Victor Bouffier
Hi all, I know this is OT from Python, but does anybody know how to fix my library issues. I get some awkward dependencies issues from these pylib libraries. # rpm -Uvh pxlib-0.4.3-1.i386.rpm error: Failed dependencies: libbz2.so.1.0 is needed by pxlib-0.4.3-1.i386 but when I look into my