Re: Generate a new object each time a name is imported

2009-08-02 Thread alex23
On Aug 3, 4:07 am, Terry Reedy wrote: > Peter Otten wrote: > > Steven D'Aprano wrote: [...] Fantastic question, answer & explanation, guys. Well done. -- http://mail.python.org/mailman/listinfo/python-list

Re: Skipping a superclass

2009-08-02 Thread Miles Kaufmann
On Aug 2, 2009, at 5:36 AM, Steven D'Aprano wrote: I have a series of subclasses like this: class A(object): def method(self, *args): print "Lots of work gets done here in the base class" class B(A): def method(self, *args): print "A little bit of work gets done in B"

Registation is open for the 9th PyWeek game programming challenge!

2009-08-02 Thread Richard Jones
The ninth PyWeek challenge will run between: Sunday 30th August to Sunday 6th September (00:00UTC to 00:00UTC) The PyWeek challenge invites entrants to write a game in one week from scratch either as an individual or in a team. Entries must be developed in Python, during the challenge, and must

Re: Python docs disappointing

2009-08-02 Thread Christian Heimes
Mohan Parthasarathy schrieb: I am a newbie and about a month old with Python. There is a wealth of material about Python and I am really enjoying learning Python. One thing that could have helped Python documentation is that instead of the very "raw" doc string, it could have used something like

Re: Seeding the rand() Generator

2009-08-02 Thread Carl Banks
On Aug 2, 2:18 pm, Fred Atkinson wrote: > On Sun, 02 Aug 2009 08:53:50 -0700, Scott David Daniels > > wrote: > >Fred Atkinson wrote: > >>        How does one seed the rand() generator when retrieving random > >> recordings in MySQL?   > > >It is not entirely clear what you are asking.  If you are

Re: Python docs disappointing

2009-08-02 Thread Chris Rebert
> On Fri, Jul 31, 2009 at 1:10 PM, kj wrote: >> I'm pretty new to Python, and I like a lot overall, but I find the >> documentation for Python rather poor, overall. >> >> I'm sure that Python experts don't have this problem: they have >> internalized some good ways to access the documentation, are

Re: Python docs disappointing

2009-08-02 Thread Mohan Parthasarathy
I am a newbie and about a month old with Python. There is a wealth of material about Python and I am really enjoying learning Python. One thing that could have helped Python documentation is that instead of the very "raw" doc string, it could have used something like PythonDoc (java doc style) so

Re: Building / making an application

2009-08-02 Thread Peter Chant
Diez B. Roggisch wrote: > You should consider using setuptools. Then you get an egg that people > can install, and you can define "console_scripts"-entry-points which > will be installed into /usr/local/bin or similar locations. Interesting, I think I need to have a play with that. The cross pl

Re: Is python buffer overflow proof?

2009-08-02 Thread Marcus Wanner
On 8/2/2009 10:43 AM, Christian Heimes wrote: Marcus Wanner wrote: I believe that python is buffer overflow proof. In fact, I think that even ctypes is overflow proof... No, ctypes isn't buffer overflow proof. ctypes can break and crash a Python interpreter easily. Christian I see. I thoug

RE Question

2009-08-02 Thread Victor Subervi
Hi; How do I search and replace something like this: aLine = re.sub('[<]?[p]?[>]?[<]?[b]?[>]?', '', aLine) where RE *only* looks for the possibility of "" at the beginning of the string; that is, not the individual components as I have it coded above, but the entire 3-character block? TIA, Victor -

Re: Python docs disappointing

2009-08-02 Thread kj
In <09bf4f17-40a5-4bad-81d3-1950545b7...@g6g2000vbr.googlegroups.com> Carl Banks writes: Thanks. Your remarks at least confirm that my impression was not simply due to my noob ignorance: the keyboard-accessible docs are indeed as poor as they look. kynn -- http://mail.python.org/mailman/list

Get Cliet IP Address

2009-08-02 Thread Fred Atkinson
What is the function to obtain the client browser's IP address? Fred -- http://mail.python.org/mailman/listinfo/python-list

Re: Processes not exiting

2009-08-02 Thread Piet van Oostrum
> MRAB (M) wrote: >M> I wonder whether one of the workers is raising an exception, perhaps due >M> to lack of memory, when there are large number of jobs to process. But that wouldn't prevent the join. And you would probably get an exception traceback printed. I wonder if something fishy is

Re: Predefined Variables

2009-08-02 Thread Fred Atkinson
On Sun, 02 Aug 2009 08:11:22 -0700, Scott David Daniels wrote: >Piet van Oostrum wrote: >>> Scott David Daniels (SDD) wrote: >>> SDD> Stephen Cuppett (should have written in this order): > "Fred Atkinson" wrote ... >> Is there a pre-defined variable that returns the GET line...

Re: Seeding the rand() Generator

2009-08-02 Thread Fred Atkinson
On Sun, 02 Aug 2009 08:53:50 -0700, Scott David Daniels wrote: >Fred Atkinson wrote: >> How does one seed the rand() generator when retrieving random >> recordings in MySQL? > >It is not entirely clear what you are asking. If you are talking about >MySQL's random number generator, you are

Re: Help with Regex for domain names

2009-08-02 Thread Aahz
In article , MRAB wrote: >Nobody wrote: >> On Thu, 30 Jul 2009 10:29:09 -0700, rurpy wrote: >> regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)') >>> You might also want to consider that some country >>> codes such as "co" for Columbia might match more than >>> you want, for example: >>> >>>

Re: Building / making an application

2009-08-02 Thread Diez B. Roggisch
Peter Chant schrieb: Krishnakant wrote: Have you considered creating a deb or rpm package for your application? Most of the documentation for deb or rpm will talk about make files. But even a distutil based python package (with a setup.py) can be made into a deb package. Then the your requirem

Re: Building / making an application

2009-08-02 Thread Peter Chant
Krishnakant wrote: > Have you considered creating a deb or rpm package for your application? > Most of the documentation for deb or rpm will talk about make files. > But even a distutil based python package (with a setup.py) can be made > into a deb package. > Then the your requirement will be sa

Re: Building / making an application

2009-08-02 Thread Krishnakant
On Sun, 2009-08-02 at 20:21 +0100, Peter Chant wrote: > What is a good way to do this? There are instructions on making modules at: > > http://docs.python.org/distutils/setupscript.html > > however, what do you do if you don't want a module? I'm thinking of where > I'd like to split the code in

Re: socket policy flash help

2009-08-02 Thread Piet van Oostrum
> NighterNet (N) wrote: >N> Here the full code. >N> flashpolicy.xml >N> [[[ >N> >N> >N> >N> >N> ]]] >N> flashpolicytest_server3x.py >N> [[[ >N> #!/usr/local/bin/python >N> ''' >N> Still under testing... >N> python version 3.x.x >N> ''' >N> import socket >N> import threading >N> impor

Building / making an application

2009-08-02 Thread Peter Chant
What is a good way to do this? There are instructions on making modules at: http://docs.python.org/distutils/setupscript.html however, what do you do if you don't want a module? I'm thinking of where I'd like to split the code into several files and have a build / setup script put it together a

Re: cgi script

2009-08-02 Thread Piet van Oostrum
> golu (g) wrote: >g> Hi, >g> i started learning cgi few days ago in python and everything went >g> fine until i started getting the follwing error >g> " >g> The server encountered an internal error and was unable to complete >g> your request. Either the server is overloaded or there was an

Re: Get Cliet IP Address

2009-08-02 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA>What is the function to obtain the client browser's IP >FA> address? You mean in a web server? The following should work (and was posted by me not long ago): from os import getenv ip = (getenv("HTTP_CLIENT_IP") or getenv("HTTP_X_FORWARDED_FOR")

Re: Processes not exiting

2009-08-02 Thread MRAB
ma3mju wrote: On 2 Aug, 15:48, ma3mju wrote: On 31 July, 11:34, MRAB wrote: ma3mju wrote: Hi all, I'm having trouble with multiprocessing I'm using it to speed up some simulations, I find for large queues when the process reaches the poison pill it does not exit whereas for smaller queues

Re: How to read webpage

2009-08-02 Thread catafest
Maybe your python2.5 not working good!? But, I use python 2.6 , and i use this for your problem: import urllib html = urllib.urlopen("http://www.rediff.com/";).read() print html If you want use authenticate then... You make working urllib2 and use this >>>auth = urllib2.Request(auth_uri, authreq_d

Re: Generate a new object each time a name is imported

2009-08-02 Thread Terry Reedy
Peter Otten wrote: Steven D'Aprano wrote: I'm looking for a way to hide the generation of objects from the caller, so I could do something like this: from Module import factory() as a # a == "Object #1" from Module import factory() as b # b == "Object #2" except of course that syntax is il

Re: Processes not exiting

2009-08-02 Thread ma3mju
On 2 Aug, 15:48, ma3mju wrote: > On 31 July, 11:34, MRAB wrote: > > > > > ma3mju wrote: > > > Hi all, > > > > I'm having trouble with multiprocessing I'm using it to speed up some > > > simulations, I find for large queues when the process reaches the > > > poison pill it does not exit whereas fo

Re: Seeding the rand() Generator

2009-08-02 Thread Scott David Daniels
Fred Atkinson wrote: How does one seed the rand() generator when retrieving random recordings in MySQL? It is not entirely clear what you are asking. If you are talking about MySQL's random number generator, you are talking in the wrong newsgroup. If you are talking about Python's, d

Re: Is python buffer overflow proof?

2009-08-02 Thread Steven D'Aprano
On Sun, 02 Aug 2009 13:50:14 +, Jizzai wrote: > Is a _pure_ python program buffer overflow proof? It's supposed to be. > For example in C++ you can declare a char[9] to hold user input. If the > user inputs 10+ chars a buffer overflow occurs. > > In python, I cannot seem to find a way to de

Re: Predefined Variables

2009-08-02 Thread Scott David Daniels
Piet van Oostrum wrote: Scott David Daniels (SDD) wrote: SDD> Stephen Cuppett (should have written in this order): "Fred Atkinson" wrote ... Is there a pre-defined variable that returns the GET line... os.environment('QUERY_STRING') SDD> Maybe you mean: SDD> os.environ['USER'] Let's t

Re: Processes not exiting

2009-08-02 Thread ma3mju
On 31 July, 11:34, MRAB wrote: > ma3mju wrote: > > Hi all, > > > I'm having trouble with multiprocessing I'm using it to speed up some > > simulations, I find for large queues when the process reaches the > > poison pill it does not exit whereas for smaller queues it works > > without any problems

Re: Processes not exiting

2009-08-02 Thread ma3mju
On 31 July, 11:27, Piet van Oostrum wrote: > > ma3mju (m) wrote: > >m> Hi all, > >m> I'm having trouble with multiprocessing I'm using it to speed up some > >m> simulations, I find for large queues when the process reaches the > >m> poison pill it does not exit whereas for smaller queues it w

Re: Is python buffer overflow proof?

2009-08-02 Thread Christian Heimes
Marcus Wanner wrote: I believe that python is buffer overflow proof. In fact, I think that even ctypes is overflow proof... No, ctypes isn't buffer overflow proof. ctypes can break and crash a Python interpreter easily. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Seeding the rand() Generator

2009-08-02 Thread Marcus Wanner
On 8/2/2009 9:42 AM, Fred Atkinson wrote: How does one seed the rand() generator when retrieving random recordings in MySQL? Regards, Fred something like: import random, time random.seed(time.time()) #not actual record access code: sqlite3.recordaccessfuction(recordid =

Re: Is python buffer overflow proof?

2009-08-02 Thread Marcus Wanner
On 8/2/2009 9:50 AM, Jizzai wrote: Is a _pure_ python program buffer overflow proof? For example in C++ you can declare a char[9] to hold user input. If the user inputs 10+ chars a buffer overflow occurs. In python, I cannot seem to find a way to define/restrict a string length. This is probabl

"PAK WEB" "PAK WEB TV" "PAK WEBSITES" "PAK WEB DIRECTORY" "PAK WEB HOSTING" "PAK WEB HOST" "PAK WEB HOSTING" "PAK WEB" "PAK WEB" "PAK WEB" "PAK WEB" "PAK WEB" "PAK WEB" "PAK WEB" on www.pak-web-page

2009-08-02 Thread Kamal Kamal
"PAK WEB" www.pak-web-pages.blogspot.com "PAK WEB TV" www.pak-web-pages.blogspot.com "PAK WEBSITES" www.pak-web-pages.blogspot.com "PAK WEB DIRECTORY" www.pak-web-pages.blogspot.com "PAK WEB HOSTING" www.pak-web-pages.blogspot.com "PAK WEB HOST" www.pak-web-pages.blogspot.com "PAK

Is python buffer overflow proof?

2009-08-02 Thread Jizzai
Is a _pure_ python program buffer overflow proof? For example in C++ you can declare a char[9] to hold user input. If the user inputs 10+ chars a buffer overflow occurs. In python, I cannot seem to find a way to define/restrict a string length. This is probably by design and raises the topic in

IFL 2009: Call for Papers and Participation

2009-08-02 Thread IFL 2009
Call for Papers and ParticipationIFL 2009Seton Hall UniversitySOUTH ORANGE, NJ, USAhttp://tltc.shu.edu/blogs/projects/IFL2009/Register at: http://tltc.shu.edu/blogs/projects/IFL2009/registration.html* NEW *Registration and talk submission extended to August 23, 2009! ***The 21st

Re: Colour of output text

2009-08-02 Thread Albert van der Horst
In article , Jean-Michel Pichavant wrote: >Nobody wrote: >> On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote: >> >> > I would like to learn a way of changing the colour of a particular > part of the output text. I've tried the following > On Unix operating systems t

Re: A Bug By Any Other Name ...

2009-08-02 Thread Albert van der Horst
In article , J. Cliff Dyer wrote: >On Fri, 2009-07-17 at 20:53 +, Albert van der Horst wrote: >> Because unlike in algol 68 in python whitespace is relevant, >> we could get by with requiring whitespace: >> x= -q # okay >> a> 8 ** -2

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Christian Heimes
Michael M Mason wrote: I'm running Python 3.1 on Vista and I can't figure out how to add my own directory to sys.path. The docs suggest that I can either add it to the PYTHONPATH environment variable or to the PythonPath key in the registry. However, PYTHONPATH doesn't exist, and updating t

Re: Skipping a superclass

2009-08-02 Thread Chris Rebert
On Sun, Aug 2, 2009 at 5:36 AM, Steven D'Aprano wrote: > I have a series of subclasses like this: > > class A(object): >    def method(self, *args): >        print "Lots of work gets done here in the base class" > > class B(A): >    def method(self, *args): >        print "A little bit of work gets

Seeding the rand() Generator

2009-08-02 Thread Fred Atkinson
How does one seed the rand() generator when retrieving random recordings in MySQL? Regards, Fred -- http://mail.python.org/mailman/listinfo/python-list

Skipping a superclass

2009-08-02 Thread Steven D'Aprano
I have a series of subclasses like this: class A(object): def method(self, *args): print "Lots of work gets done here in the base class" class B(A): def method(self, *args): print "A little bit of work gets done in B" super(B, self).method(*args) class C(B): d

Re: Generate a new object each time a name is imported

2009-08-02 Thread Peter Otten
wrote: KNode cannot parse your From-string correctly. Strange. > Peter Otten <__pete...@web.de> writes: >> >>> import sys >> >>> sys.modules["yadda"] = A() > > OMG wow. I bow to you. But I'm not sure whether that's bowing in > awe or in terror. I don't know who invented it, but it's an o

Re: Help understanding the decisions *behind* python?

2009-08-02 Thread Marcus Wanner
On 8/1/2009 9:31 PM, sturlamolden wrote: - Python and C programmers use lists and arrays similarly. I'm guessing that's because of the brackets... Marcus -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate a new object each time a name is imported

2009-08-02 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > >>> import sys > >>> sys.modules["yadda"] = A() OMG wow. I bow to you. But I'm not sure whether that's bowing in awe or in terror. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Mark Lawrence
Michael M Mason wrote: "Mark Lawrence" wrote in message news:mailman.4130.1249203322.8015.python-l...@python.org... Be careful, I'm screwed things up on several occasions by placing a file on PYTHONPATH that overrides a file in the standard library, test.py being my favourite! Thanks. Sure

Re: Generate a new object each time a name is imported

2009-08-02 Thread Steven D'Aprano
On Sun, 02 Aug 2009 12:33:03 +0200, Peter Otten wrote: > How about [snip] import sys sys.modules["yadda"] = A() Perfect! That's exactly the sort of thing I'm looking for. Thanks for everyone who answered. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate a new object each time a name is imported

2009-08-02 Thread Peter Otten
Steven D'Aprano wrote: > I would like to generate a new object each time I import a name from a > module, rather than getting the same object each time. For example, > currently I might do something like this: > > # Module > count = 0 > def factory(): > # Generate a unique object each time th

Re: Help understanding the decisions *behind* python?

2009-08-02 Thread Dave Angel
sturlamolden wrote: On 20 Jul, 18:27, Phillip B Oldham wrote: We're not looking to start any arguments or religious wars and we're not asking that python be changed into something its not. We'd simply like to understand the decision behind the lists and tuple structures. We feel that in n

Re: Newbie Question regarding __init__()

2009-08-02 Thread Dave Angel
Simon wrote: Okay I will fix my code and include "self" and see what happens. I know I tried that before and got another error which I suspect was another newbie error. The idea behind the init_Pre is that I can put custom code here to customize the __init__ instead of creating a new subclass.

Re: Run pyc file without specifying python path ?

2009-08-02 Thread Dave Angel
Barak, Ron wrote: Hi Dave, It seems like I don't understand your solution. I use the (appatched) soapAPI.py as the wrapper to parsing.pyc. However, if I do (for instance): $ python -u parsing.pyc -U aaa The last line of the output is (as expected): return_code: 12 ; params: {'username': 'aaa'

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason
"Mark Lawrence" wrote in message news:mailman.4130.1249203322.8015.python-l...@python.org... Be careful, I'm screwed things up on several occasions by placing a file on PYTHONPATH that overrides a file in the standard library, test.py being my favourite! Thanks. Sure enough, I've already got

Re: Generate a new object each time a name is imported

2009-08-02 Thread Hrvoje Niksic
Steven D'Aprano writes: > I'm looking for a way to hide the generation of objects from the caller, > so I could do something like this: > > from Module import factory() as a # a == "Object #1" > from Module import factory() as b # b == "Object #2" > > except of course that syntax is illegal.

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Mark Lawrence
Michael M Mason wrote: "Dave Angel" wrote in message news:mailman.4120.1249172970.8015.python-l...@python.org... Michael M Mason wrote: I'm running Python 3.1 on Vista and I can't figure out how to add my own directory to sys.path. Thanks to Jon, Piet, David and Dave for the responses.

RE: Run pyc file without specifying python path ?

2009-08-02 Thread Barak, Ron
> -Original Message- > From: Dave Angel [mailto:da...@dejaviewphoto.com] > Sent: Thursday, July 30, 2009 20:08 > To: Barak, Ron > Cc: 'python-list@python.org' > Subject: Re: Run pyc file without specifying python path ? > > Barak, Ron wrote: > > Hi Dave, > > > > On second thoughts, I may

Re: Generate a new object each time a name is imported

2009-08-02 Thread Jonathan Gardner
On Aug 2, 12:35 am, Steven D'Aprano wrote: > > I'm looking for a way to hide the generation of objects from the caller, > so I could do something like this: > > from Module import factory() as a  # a == "Object #1" > from Module import factory() as b  # b == "Object #2" > Explicit is better than

Generate a new object each time a name is imported

2009-08-02 Thread Steven D'Aprano
I would like to generate a new object each time I import a name from a module, rather than getting the same object each time. For example, currently I might do something like this: # Module count = 0 def factory(): # Generate a unique object each time this is called global count coun

Re: Custom namespaces

2009-08-02 Thread Chris Rebert
On Sun, Aug 2, 2009 at 12:18 AM, Steven D'Aprano wrote: > On Sat, 01 Aug 2009 21:46:35 -0700, Chris Rebert wrote: > >>> Is there any way to install a custom type as a namespace? >> >> For classes/objects, yes, using metaclasses. See the __prepare__() >> method in PEP 3115: http://www.python.org/dev

Re: Custom namespaces

2009-08-02 Thread Steven D'Aprano
On Sat, 01 Aug 2009 21:46:35 -0700, Chris Rebert wrote: >> Is there any way to install a custom type as a namespace? > > For classes/objects, yes, using metaclasses. See the __prepare__() > method in PEP 3115: http://www.python.org/dev/peps/pep-3115/ Looks good, but that's Python 3 only, yes? A

Re: cgi script

2009-08-02 Thread Carl Banks
On Aug 1, 11:11 pm, golu wrote: > Hi, > i started learning cgi few days ago in python and everything went > fine  until i started getting the follwing error > " > The server encountered an internal error and was unable to complete > your request. Either the server is overloaded or there was an err

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason
"Dave Angel" wrote in message news:mailman.4120.1249172970.8015.python-l...@python.org... Michael M Mason wrote: I'm running Python 3.1 on Vista and I can't figure out how to add my own directory to sys.path. Thanks to Jon, Piet, David and Dave for the responses. sys.path gets its values

Re: Get Cliet IP Address

2009-08-02 Thread eliasf
"Fred Atkinson" wrote: What is the function to obtain the client browser's IP address? Do you mean the external public IP to the Internet? When I wanted to log the dynamic IP that my ADSL connection gets, I used whatismyip.com like this: import urllib2 QUERY_URL = 'http://www.whatismy