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...

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 applications

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 it

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._count, it just

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

Re: [Tutor] samples

2005-06-23 Thread Andrei
D. Hartley denise.hartley at 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

[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 = SELECT

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 pointed

[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 =

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 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 modules,

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 you could

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

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

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

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 opener2 =

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 I want to

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 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):

[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 =

[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

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 on

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