Re: [Tutor] MySQL Connection Function (Solution)

2005-06-23 Thread Don Parris
On Wed, 22 Jun 2005 15:06:22 -0400 Python <[EMAIL PROTECTED]> wrote: > On Wed, 2005-06-22 at 14:20 -0400, Don Parris wrote: > > On Tue, 21 Jun 2005 19:13:43 -0400 > > Python <[EMAIL PROTECTED]> wrote: > > > > Here's my solution, using the code Lloyd provided in a previous post: The script that

Re: [Tutor] Cookies and authorization - urllib2 vs urllib

2005-06-23 Thread Kent Johnson
D. Hartley wrote: > P.S. Kent - thank you for the helpful tutorials on authentication, > they really cleared up the process a great deal. The only problem is: > > When I create an opener to process the cookies, it looks like this: > > opener = > urllib2.build_opener(urllib2.HTTPCookieProcessor(

Re: [Tutor] Interesting problem

2005-06-23 Thread Kent Johnson
Smith, Jeff wrote: > That's what I was looking for. Although I couldn't get the below to > work, I went with a different mod of the original you gave: > > def get_props_as_dict(self): > d = dict() > for entry in dir(self.__class__): > if isinstance(getattr(self.__c

Re: [Tutor] Lists in List question

2005-06-23 Thread Danny Yoo
On Thu, 23 Jun 2005, Phillip Hart wrote: > I've been using lists within lists for several functions, but have been > unable, in loop form, to extract data from them or, in loop for, apply data > to them. [cut] Hi Phillip, Can you try checking for indentation? Your code came out indented all o

[Tutor] Lists in List question

2005-06-23 Thread Phillip Hart
Hello, I've been using lists within lists for several functions, but have been unable, in loop form, to extract data from them or, in loop for, apply data to them. Basically, when extracting data, it only runs 1 loop. Likewise, when initially assigning the data, it only runs 1 loop. In the f

Re: [Tutor] strip an email

2005-06-23 Thread Reed L. O'Brien
nephish wrote: > Does anyone know how to strip everything off of an email? > i have a little app that i am working on to read an email message and > write the > body of a message to a log file. > each email this address gets is only about three to five lines long. > but i cannot seem to get just t

[Tutor] Cookies and authorization - urllib2 vs urllib

2005-06-23 Thread D. Hartley
>From Christian: > Try subclassing urllib.FancyURLopener and overriding the > prompt_user_passwd() method. That should get you what you need :-) Well, I used urllib.FancyURLopener, and can open and look at the url, like this: import urllib opener2 = urllib.FancyURLopener({}) f = opener2.open("

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
That's what I was looking for. Although I couldn't get the below to work, I went with a different mod of the original you gave: def get_props_as_dict(self): d = dict() for entry in dir(self.__class__): if isinstance(getattr(self.__class__, entry), property):

Re: [Tutor] Interesting problem

2005-06-23 Thread Alan G
> Consider a class with a lt of properties. I would like a member > function which generates a dictionary where the keys are the property > names and the values are the property values? Use the force... :-) Since Python uses dictionaries to store all those things already there must be a suitable

Re: [Tutor] Interesting problem

2005-06-23 Thread Kent Johnson
Smith, Jeff wrote: > Here would be the usage: > > myinst = MyClass() > print myinst.getprops_as_dict() > > would print > > {'var1': 1, 'var2': 2, 'var3': 3} > > Needless to say I want the instance values which might be different for > each instance. I know that I could code it brute force, but

Re: [Tutor] Cookies and authorization

2005-06-23 Thread Christian Wyglendowski
> -Original Message- > > Christian, > > > Try subclassing urllib.FancyURLopener and overriding the > > prompt_user_passwd() method. That should get you what you need :-) > > Well, I used urllib.FancyURLopener, and can open and look at > the url, like this: > > import urllib > open

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
Here would be the usage: myinst = MyClass() print myinst.getprops_as_dict() would print {'var1': 1, 'var2': 2, 'var3': 3} Needless to say I want the instance values which might be different for each instance. I know that I could code it brute force, but I want to be able to add properties with

Re: [Tutor] Interesting problem

2005-06-23 Thread Kent Johnson
Smith, Jeff wrote: > I can see I wasn't clear :-) > > Here's the basic framework of what I'm looking for. Needless to say, > this is just an example and not the real problem which is quite > complicated and includes multiple classes. > > What I'm looking for is the actual implementation of get_p

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
I can see I wasn't clear :-) Here's the basic framework of what I'm looking for. Needless to say, this is just an example and not the real problem which is quite complicated and includes multiple classes. What I'm looking for is the actual implementation of get_props_as_dict which I've written h

Re: [Tutor] Interesting problem

2005-06-23 Thread Kent Johnson
Smith, Jeff wrote: > Consider a class with a lt of properties. I would like a member > function which generates a dictionary where the keys are the property > names and the values are the property values? > > Is this clear? No, actually :-) Do you want the properties of the class (which are typ

Re: [Tutor] Interesting problem

2005-06-23 Thread Christian Wyglendowski
> -Original Message- > > Consider a class with a lt of properties. I would like a member > function which generates a dictionary where the keys are the property > names and the values are the property values? > > Is this clear? I think so :-) > How might I go about this? I think yo

Re: [Tutor] Cookies and authorization

2005-06-23 Thread Kent Johnson
D. Hartley wrote: > My problem is, when I plug this url into my sample code above, I get > an error ("HTTP Error 401: Authorization Required"), because normally > when you go to this url it makes you enter in a username and a > password. > > (Also, there is lots of documentation on the cookie mo

Re: [Tutor] Interesting problem

2005-06-23 Thread Jeremy Jones
Smith, Jeff wrote: >Consider a class with a lt of properties. I would like a member >function which generates a dictionary where the keys are the property >names and the values are the property values? > >Is this clear? > >How might I go about this? > >Jeff >__

Re: [Tutor] Cookies and authorization

2005-06-23 Thread Christian Wyglendowski
> -Original Message- > > Hello, everyone! Hi, > My problem is, when I plug this url into my sample code above, I get > an error ("HTTP Error 401: Authorization Required"), because normally > when you go to this url it makes you enter in a username and a > password. Does anyone know

[Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
Consider a class with a lt of properties. I would like a member function which generates a dictionary where the keys are the property names and the values are the property values? Is this clear? How might I go about this? Jeff ___ Tutor maillist - T

[Tutor] Cookies and authorization

2005-06-23 Thread D. Hartley
Hello, everyone! I am trying to go to a website, collect any and all cookies I receive by going to that website, and then look at the cookies/print them. So I did the following, from the cookie examples in the documentation: import cookielib, urllib2 myjar = cookielib.CookieJar() opener = urllib

Re: [Tutor] database app

2005-06-23 Thread Christian Wyglendowski
> -Original Message- > > Hey there, Hi, > i have used the cgi module and dig it. > heres the deal, > my employer wants me to build a dynamic website that will > access a > database and display customer > information on web. ok, easy enough. Looks like some others have

[Tutor] getting an image out of a postgre database

2005-06-23 Thread Mike Hansen
Well, I've managed to get an image into a postgre database, but now I'm having trouble getting it out. #! /usr/bin/env python from pyPgSQL import PgSQL def main(): connectdb = PgSQL.connect('server:port:database:username:password') cur = connectdb.cursor() sqlStatement = """SELEC

Re: [Tutor] samples

2005-06-23 Thread Andrei
D. Hartley gmail.com> writes: > code, but it's made up of 46 different .py files, none of which seem > to be the "main" game (lots of little modules, like an input box, a > high score list, etc). It's a lot harder for someone new to > programming to read. Identify the main file (the one that y

Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?

2005-06-23 Thread Kent Johnson
Ron Phillips wrote: > I believe I've tried every setting known to man, in every script in > every little scrap of documentation available. XMLRPC requests using > SimpleXMLRPCRequestHandler -- no problem. But try to run them as a CGI > script, and I get system lock ups and that's all. No error c

Re: [Tutor] Class vs. Static Methods

2005-06-23 Thread Kent Johnson
Alan G wrote: >>This is a neat trick. But can't this also be done with a static > > method > >>that accesses a static data attribute the same way? > > > I don't think so because the static mehod can only see > the attributes of Shape not of Line. Well, it can *see* Point._count and Line._coun

Re: [Tutor] samples

2005-06-23 Thread Alan G
> What I *am* looking for, if you have it or know of anyone who does, is > *simple* source code files (preferrably the entire game's code is in > one .py file), Thats unlikely to happen because its very bad practice and Python tries to make it easy NOT to do that. Breaking code into modules makes

Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?

2005-06-23 Thread Shuying Wang
I'm not sure what you're trying to do. But I run cgi scripts and make xmlrpc requests with xmlrpclib with a connection with xmlrpclib.Server(server_uri), though I'm only doing this client side. I'm not running the server as cgi. On 6/23/05, Ron Phillips <[EMAIL PROTECTED]> wrote: > > I believe I

Re: [Tutor] Changing what you've already printed

2005-06-23 Thread Alan G
> > Curses comes as standard on linux... > > > > More seriously, I seem to recall that on the contrary, the > Windows Python distribution does not include the curses module That's correct. > have to use msvcrt[?] instead). I wonder why, because I'm pretty sure > I saw (C) curses-based applic

Re: [Tutor] Class vs. Static Methods

2005-06-23 Thread Alan G
> This is a neat trick. But can't this also be done with a static method > that accesses a static data attribute the same way? I don't think so because the static mehod can only see the attributes of Shape not of Line. It doesn't have access to the cls value in Kent's code below... > >> @classm