[Tutor] raw_input into range() function
Hello, I am trying to do the exercises in Michael Dawson's "Absolute Beginner" book. In chapter four ("for Loops, Strings, and Tuples") one of the challenges is: "Write a program that counts for the user. Let the user enter the starting number, the ending number, and the amount by which to count." The code I have come up with so far is further below; basically my problem is that I don't know how to feed the range() function with the user-input numbers it expects. Your help is highly appreciated! Guba # Counting Program # 2007-04-18 # Welcoming the player print "Hello, let me do some counting for you!" # Telling the player what to do & assigning that info to variables. start_num = int(raw_input("Please give me a starting number. ")) end_num = int(raw_input("Please give me an ending number. ")) interval = int(raw_input("By which amount am I to count? ")) start_num == 0 end_num == 1 interval == 2 print "Counting:" for i in range(0, 1, 2): print i raw_input("\n\nHit Enter to exit.") ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] which function replaced fork() in Python2.5?
which function replaced fork() in Python2.5? ShivThe idiot box is no longer passé; it's making news and how! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] raw_input into range() function
Guba wrote: > The code I have come up with so far is further below; basically my > problem is that I don't know how to feed the range() function with the > user-input numbers it expects. > # Telling the player what to do & assigning that info to variables. > start_num = int(raw_input("Please give me a starting number. ")) > end_num = int(raw_input("Please give me an ending number. ")) > interval = int(raw_input("By which amount am I to count? ")) > > start_num == 0 > end_num == 1 > interval == 2 > > print "Counting:" > for i in range(0, 1, 2): > print i Just use the variable names instead of the numbers: for i in range(start_num, end_num, interval): Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which function replaced fork() in Python2.5?
shiv k wrote: > > > which function replaced fork() in Python2.5? os.fork() hasn't moved, why do you think it was replaced? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
Rikard Bosnjakovic wrote: > On 4/17/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > >> I really wish this list would start mungin' some headers already. > > I second that. > > Not using a reply-to-tag is braindead. Please don't start this thread again. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
On 4/18/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Please don't start this thread again. We didn't start it, rather it just never ends. -- - Rikard - http://bos.hack.org/cv/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Mixing generator expressions with list definitions
I would like to be able to do something along the lines of: >>> my_list = [1, 2, x for x in range(3,6), 6] However this doesn't work. Is there any way of achieving this kind of thing? I tried: >>> my_list = [1, 2, *(x for x in range(3,6)), 6] which also doesn't work. I wrote a quick function that allows me to use the generator expression as long as it is the last argument: >>> def listify(*args): ... return [arg for arg in args] ... >>> my_list = listify(1,2, *(x for x in range(3,6))) but obviously this limits me to using it only at the end of a list. Any clues on this greatly appreciated. Thanks Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Mixing generator expressions with list definitions
Ed Singleton wrote: > I would like to be able to do something along the lines of: > my_list = [1, 2, x for x in range(3,6), 6] > > However this doesn't work. Is there any way of achieving this kind of thing? my_list = [1, 2] + range(3,6) + [6] or, to build it in steps, my_list = [1, 2] my_list.extent(range(3, 6)) my_list.append(6) By the way I can't think of any reason to write "x for x in range(3, 6)" instead of just "range(3, 6)". range() returns a list which can be used almost anywhere the generator expression can be. If you need an explicit iterator use iter(range(3, 6)). > I wrote a quick function that allows me to use the generator > expression as long as it is the last argument: > def listify(*args): > ... return [arg for arg in args] or return list(args) Kent > ... my_list = listify(1,2, *(x for x in range(3,6))) > > but obviously this limits me to using it only at the end of a list. > > Any clues on this greatly appreciated. > > Thanks > > Ed > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Mixing generator expressions with list definitions
Kent Johnson wrote: > my_list.extent(range(3, 6)) should be my_list.extend(range(3, 6)) Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Questions of Maths
Hi, I am working on an implementation of an L-system in Python. I hate using turtle module since it uses Tk and as my IDE also uses Tk I have to close my editor before I can test the program. So I am implementing the graphics using PIL. Now to the problem. Say you have a line AB with co-ords (x1,y1) and (x2,y2). Say you also have a point C with co-ords (x3,y3). Question: how to determine whether point C is to the left or to the right of the line AB? Any suggestions would be welcome. Ta, AH ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Mixing generator expressions with list definitions
On 4/18/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Singleton wrote: > > I would like to be able to do something along the lines of: > > > my_list = [1, 2, x for x in range(3,6), 6] > > > > However this doesn't work. Is there any way of achieving this kind of > > thing? > > my_list = [1, 2] + range(3,6) + [6] I thought I'd got past the point where there were stupidly simple answers to my questions ;) Oh well. Thanks yet again, Kent. > or, to build it in steps, > my_list = [1, 2] > my_list.extent(range(3, 6)) > my_list.append(6) Yeah, that's how I had ben doing it. I don't really like it for some reason, though I'm not clear why I don't like it. I think maybe because it's quite verbose so it's a bit difficult for me to read it afterwards, and makes typos more likely ;) > By the way I can't think of any reason to write "x for x in range(3, 6)" > instead of just "range(3, 6)". range() returns a list which can be used > almost anywhere the generator expression can be. If you need an explicit > iterator use iter(range(3, 6)). Sorry, I oversimplfied my example. I'm actually doing: widgets = [(organisation_widget,(),{'organisation':organisation})] widgets.extend([(event_widget,(),{'event':event}) for event in organisation.events]) widgets.append((event_form,(),{'values':values})) so that later on I can just iterate through the widgets like so: for (widget, args, kwargs) in widgets: widget.display(*args, **kwargs) Ed ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Questions of Maths
On 4/18/07, Abu Ismail <[EMAIL PROTECTED]> wrote: > Hi, > > I am working on an implementation of an L-system in Python. I hate > using turtle module since it uses Tk and as my IDE also uses Tk I have > to close my editor before I can test the program. So I am implementing > the graphics using PIL. > > Now to the problem. > > Say you have a line AB with co-ords (x1,y1) and (x2,y2). Say you also > have a point C with co-ords (x3,y3). > > Question: how to determine whether point C is to the left or to the > right of the line AB? > 1. Write an equation for the line AB in the form x = Wy + Z (as opposed to y = mx + b, which is the usual form). 2. Substitute the value for y3 in that equation - it will give you the value of x on that line (call it X3). 3. Compare x3 with X3. A quick derivation gave me (please verify) x = [(x2-x1) y + x1 y2 - x2 y1]/(y2-y1) where the multiplication signs are implicit. Good luck! André > Any suggestions would be welcome. > > Ta, > AH > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
I never talk to mailboxes, nor to other inanimate objects; I was talking to you. Rikard Bosnjakovic wrote: > On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: > >> IF my memory serves well, argument 0 in that list is the name of the >> program itself, as well as the path to it if any was provided. > > Stop replying to my mailbox. > > -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
use a replyto header, or swap around things so the FROM is the list address, not the submitter, or kill me, or give me food, or something. Luke Paireepinart wrote: > Rikard Bosnjakovic wrote: >> On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: >> >> >>> IF my memory serves well, argument 0 in that list is the name of the >>> program itself, as well as the path to it if any was provided. >>> >> Stop replying to my mailbox. >> > I really wish this list would start mungin' some headers already. > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
On 4/18/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: > I never talk to mailboxes, nor to other inanimate objects; I was talking > to you. I'm not interested in listening to your ifs about your memory. -- - Rikard - http://bos.hack.org/cv/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which function replaced fork() in Python2.5?
shiv k wrote: > > > > MR Kent its there in ubuntu but if we see the same in windows xp there > is no fork() instead there are spawn family. fork() is not supported under Windows. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
As long as the PROBLEM lives, the THREAD will rise from the dead over and over. Kill the problem, you kill the thread. Kent Johnson wrote: > Rikard Bosnjakovic wrote: >> On 4/17/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: >> >>> I really wish this list would start mungin' some headers already. >> I second that. >> >> Not using a reply-to-tag is braindead. > > Please don't start this thread again. > > Kent > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sys.argv?
My memory is fine, as is my grip on reality as well as courtesy to my fellow pythonistas. Good day to you sir. Rikard Bosnjakovic wrote: > On 4/18/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: > >> I never talk to mailboxes, nor to other inanimate objects; I was talking >> to you. > > I'm not interested in listening to your ifs about your memory. > -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] screen scraping web-based email
Hello. I've been playing with Python for a while, and even have some small scripts in my employ, but I have a bit of a problem and I'm not sure how to proceed. I'm starting graduate school (econ!) in the Fall; the school I'll be attending uses Lotus for email and allows neither forwarding nor POP/IMAP access. This is - for many, many reasons - *quite* unacceptable to me. I'd like to write a daemon that logs into the text-based web client every so often, scrapes for new email, and uses smtplib to send that email to another email address. But I really don't know how I'd go about logging in and staying logged in without a browser. Hints are appreciated. Am I wrong-headed about this? Any other options available to me? (I know I could do it with a torturous combination of applescript and python ... but I'd like to avoid that, plus I'd like something remotely portable.) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] screen scraping web-based email
James Cunningham wrote: > I'd like to write a daemon that logs into the text-based web client > every so often, scrapes for new email, and uses smtplib to send that > email to another email address. But I really don't know how I'd go > about logging in and staying logged in without a browser. > > Hints are appreciated. Am I wrong-headed about this? Any other options > available to me? This might be a starting point: http://pywebmail.sourceforge.net/ Otherwise mechanize and Beautiful Soup will give you some high-level tools to get started with: http://wwwsearch.sourceforge.net/mechanize/ http://www.crummy.com/software/BeautifulSoup/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] screen scraping web-based email
On Wed, 18 Apr 2007 12:15:26 -0400, Kent Johnson wrote: > James Cunningham wrote: > >> I'd like to write a daemon that logs into the text-based web client >> every so often, scrapes for new email, and uses smtplib to send that >> email to another email address. But I really don't know how I'd go >> about logging in and staying logged in without a browser. >> >> Hints are appreciated. Am I wrong-headed about this? Any other options >> available to me? > > This might be a starting point: > http://pywebmail.sourceforge.net/ > > Otherwise mechanize and Beautiful Soup will give you some high-level > tools to get started with: > http://wwwsearch.sourceforge.net/mechanize/ > http://www.crummy.com/software/BeautifulSoup/ > > Kent pywebmail sounds great, and mechanize is actually just what I was looking for. Thanks a lot, especially for the quick response! Best, James ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] raw_input into range() function
Guba wrote: > Hello, > > I am trying to do the exercises in Michael Dawson's "Absolute Beginner" > book. In chapter four ("for Loops, Strings, and Tuples") one of the > challenges is: "Write a program that counts for the user. Let the user > enter the starting number, the ending number, and the amount by which to > count." > > The code I have come up with so far is further below; basically my > problem is that I don't know how to feed the range() function with the > user-input numbers it expects. > > Your help is highly appreciated! > > Guba > > > # Counting Program > # 2007-04-18 > > # Welcoming the player > print "Hello, let me do some counting for you!" > > # Telling the player what to do & assigning that info to variables. > start_num = int(raw_input("Please give me a starting number. ")) > end_num = int(raw_input("Please give me an ending number. ")) > interval = int(raw_input("By which amount am I to count? ")) So far so good, if the user enters integers for all 3 inputs. All you need now is: print "Counting:" for i in range(start_num, end_num, interval): print i > > start_num == 0 > end_num == 1 > interval == 2 These are expressions that compare a variable to a constant. They contribute nothing to the program. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] raw_input into range() function
On 4/18/07, Guba <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to do the exercises in Michael Dawson's "Absolute Beginner" > book. In chapter four ("for Loops, Strings, and Tuples") one of the > challenges is: "Write a program that counts for the user. Let the user > enter the starting number, the ending number, and the amount by which to > count." > > The code I have come up with so far is further below; basically my > problem is that I don't know how to feed the range() function with the > user-input numbers it expects. > > Your help is highly appreciated! > > Guba > > > # Counting Program > # 2007-04-18 > > # Welcoming the player > print "Hello, let me do some counting for you!" > > # Telling the player what to do & assigning that info to variables. > start_num = int(raw_input("Please give me a starting number. ")) > end_num = int(raw_input("Please give me an ending number. ")) > interval = int(raw_input("By which amount am I to count? ")) > > start_num == 0 > end_num == 1 > interval == 2 > > print "Counting:" > for i in range(0, 1, 2): > print i > > > raw_input("\n\nHit Enter to exit.") Your attempt to read input is never used, and your variable assignments are not correct. You are using the test operator '==' instead of the assignment operator '='. The lines: """ start_num == 0 end_num == 1 interval == 2 """ do something you aren't trying to do here. Those lines are testing to see if start_num equals zero, and then ignoring what the test result is. They don't actually *do* anything. Your code should look like this: print "Hello, let me do some counting for you!" start_num = int(raw_input("Please give me a starting number. ")) end_num = int(raw_input("Please give me an ending number. ")) interval = int(raw_input("By which amount am I to count? ")) print "Counting:" for i in range(start_num, end_num, interval): print i ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which function replaced fork() in Python2.5?
"shiv k" <[EMAIL PROTECTED]> wrote > which function replaced fork() in Python2.5? Try the subprocess module. I think it can do a similar job even on Windows... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Questions of Maths
"Abu Ismail" <[EMAIL PROTECTED]> wrote > I am working on an implementation of an L-system in Python. I hate > using turtle module since it uses Tk and as my IDE also uses Tk I > have > to close my editor before I can test the program. Why so? Don''t you have a multi-tasking OS? If so just run a command line window alongside your editor and run the code in that! > Say you have a line AB with co-ords (x1,y1) and (x2,y2). Say you > also > have a point C with co-ords (x3,y3). > > Question: how to determine whether point C is to the left or to the > right of the line AB? Derive the equation of the line. Use it to determine the y coordinate for x3 If y3 is greater than the calculated y then your point is above the line. HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] screen scraping web-based email
"James Cunningham" <[EMAIL PROTECTED]> wrote > I'd like to write a daemon that logs into the text-based web client > every so often, scrapes for new email, and uses smtplib to send that > email to another email address. Kent has pointed you at useful add-on modules. Using the standard library consider the urllib2 library (way better than urllib) and I believe the email module rather than the smtlib is the current preferred route. But I'd still recommend Beautiful Soup for parsing the HTML the HTMLParser module can be used but its less reliable and more work. PS. I'm currently writing a tutorial topic on this very subject and I'm trying to use the standard libs for the first time (since I want my tutor to be based on the standard library) and it's proving to be a "learning opportunity"! -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Multiple lines with the command line
"Kharbush, Alex [ITCSV]" <[EMAIL PROTECTED]> wrote > I need multiple entries with the os.system(cmd)line > MY PROBLEM is that i need to enter multiple lines of > input into unix. os.system() takes only one argument How about uysing popen instead? Or the new Popen class in the subprocess module... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Questions of Maths
Hi Abu, > Question: how to determine whether point C is to the left or to the > right of the line AB? When the line given by A(Xa,Ya) and B(Xb, Yb), the area of the A-B-C triangle can be calculated with the value of next determinant / 2 | Xa, Ya, 1 | | Xb, Yb, 1 | | Xc, Yc, 1 | / 2 So: Area = ( Xa(Yb-Yc) - Xb(Ya-Yc) + Xc(Ya-Yb) ) / 2 Area > 0 | the points are clockwise (C is on the left) Area < 0 | the points are counterclockwise (C is on the right) Area = 0 | the points are on the same line It can be written in a python function ### def TriArea(a, b, c): #Area = (Xa(Yb-Yc) - Xb(Ya-Yc) + Xc(Ya-Yb)) /2 return ( a[0] * (b[1]-c[1]) - b[0] * (a[1]-c[1]) + c[0] * (a[1]-b[1]) )/2 ### # to test it. print TriArea((0,0), (10,0), (2,2)) print TriArea((0,0), (10,0), (2,-2)) print TriArea((0,0), (10,0), (2,0)) ### The biggest advantage of this calculation is that, it never goes to zero division exception. Best regards, Janos ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] screen scraping web-based email
> I'm starting graduate school (econ!) in the Fall; the school I'll be > attending uses Lotus for email You can drive the fat client via COM if you install the Win32 extensions for python. > (I know I could do it with a torturous combination of applescript and Except judging by this, you're on a MAC... so maybe not. Still, working WITH the app (using its APIs) is bound to better than working AGAINST it (screen scraping). Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to program to python the right way?
Hello everyone, I have pretty much finished hacking on my Thesis and I have come to the conclusion, I really do not know how to use Python to it "full" extent. Some of the things I have really messed up in my implementation are serialization (specifically sub-classes), classes, and instantiating them the "correct" way, and there are some things I have not tried, but I would like to like contained execution and thread management. Are there any books (with examples) out there that show some of these techniques and explain the gotchas that come with the package. Thanks in advance. Adam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Seeking python projects
Writing your own programs is a good idea. However, this is primarily a good idea with small programs. For example, when learning Python, I wrote a set of backup scripts for my computer; I still use them and they've served me well. If you want to write 'complete applications,' you're probably better off helping with a project that has already started. This is important for a few reasons. First, you'll learn about Python packaging and documentation standards, and possibly things like unit tests as well. These are things that often escape new programmers, but are very important for large-scale projects. Second, you'll be far more likely to make a contribution this way. If you decide to implement your own py(insert App Name here), you'll probably never get done. Scratch that, you'll almost certainly never get done (I speak from experience). Find a open-source Python project that needs someone (Sourceforge actually has a 'job listings' page) and help them out instead. You'll learn a lot of practical things and quickly become a better programmer, as opposed to simply reimplementing the same mistakes over and over as I did :-) Asrar Kadri wrote: > Hi folks, > > I want to practice Python programming by developing complete applications. > > Where can I get such problems, which can improve my Python programming > skills. > > Thanks in anticipation. > > Regards, > > Asrar > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which function replaced fork() in Python2.5?
* Alan Gauld <[EMAIL PROTECTED]> [070418 21:28]: > > "shiv k" <[EMAIL PROTECTED]> wrote > > > which function replaced fork() in Python2.5? Replaced? >>> sys.version, os.fork ('2.5 (release25-maint, Dec 9 2006, 14:35:53) \n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)]', ) Andreas ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Builtin "property" decorator hiding exceptions
Hi, The sample script below throws the exception "AttributeError: input" rather than the expected exception "AttributeError: non_existent_attribute". Please help me write a decorator or descriptor of my own that fixes the issue. class Sample(object): def __init__(self): self.arguments = {} def __getattr__(self, name): ret_val = self.arguments.get(name, None) if ret_val != None: return ret_val raise AttributeError, name @property def input(self): self.non_existent_attribute sample = Sample() sample.input Regards, Jacob Abraham __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Builtin "property" decorator hiding exceptions
I know, this might sound stupid, but property is not a decorator. :) Andreas * Jacob Abraham <[EMAIL PROTECTED]> [070419 08:25]: > Hi, > >The sample script below throws the exception "AttributeError: input" > rather than the expected exception "AttributeError: non_existent_attribute". > >Please help me write a decorator or descriptor of my own that fixes the > issue. > > class Sample(object): > def __init__(self): > self.arguments = {} > > def __getattr__(self, name): > ret_val = self.arguments.get(name, None) > if ret_val != None: return ret_val > raise AttributeError, name > > @property > def input(self): > self.non_existent_attribute > > > sample = Sample() > sample.input > > > Regards, > Jacob Abraham > > > > __ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] screen scraping web-based email
"R. Alan Monroe" <[EMAIL PROTECTED]> wrote > You can drive the fat client via COM if you install the Win32 > extensions for python. > >> (I know I could do it with a torturous combination of applescript >> and > > Except judging by this, you're on a MAC... so maybe not. Still, > working WITH the app (using its APIs) is bound to better than > working > AGAINST it (screen scraping). Good point Alan. The OP can use Python to drive applescript in a similar way to Windows users driving COM. The MacPython package includes functions to interface to applescript. There are examples of doing this in the book MacOS Hacks by O'Reilly (albeit from Perl, but the Python interface is, I believe, very similar) So that might be an alternative route. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor