Re: How to recognise "generator functions" ?

2006-07-19 Thread Georg Brandl
imho wrote: > Hi all. > > Is there a way to know if a function object is actually a "generator > function" or not ? e.g.: > > def f(): > pass > > def g(): > yield None > > f.__class__ is the same as g.__class__ , i.e. "function" type. > But i "know" that the second, when invoked, r

Re: sysadmin -> python programmer

2006-07-19 Thread Martin P. Hellwig
Dan Stromberg wrote: > I've been a sysadmin for about 13 years, but I'm realizing that my > favorite part of being a sysadmin are those moments where there's a reason > to write some code - preferably in python. > > What might one do to make the transition from sysadmin to python > programmer, asi

Re: How to recognise "generator functions" ?

2006-07-19 Thread imho
Georg Brandl ha scritto: f.func_code.co_flags > 67 g.func_code.co_flags > 99 > > => 32 (CO_GENERATOR in compiler.consts) is the flag that indicates a > generator code object. > > Georg What a fast reply! Thank You very much! :-) -- http://mail.python.org/mailman/listinfo/python-list

threading._start_new_thread executes twice?

2006-07-19 Thread Hari Sekhon
I'm got a script which has a function with a while 1: loop that seems to execute the line it's doing twice instead of just once on each pass when called in a thread...#Script Startimport threading,time,cherrypy def func():    while 1:    print time.ctime()    time.sleep(30)threading._start_

python compile code object -- reverse how to

2006-07-19 Thread leo
Hi, following is the python scripts: import marshal script = """ print 'hello' """ code = compile(script, "

Re: using names before they're defined

2006-07-19 Thread jordan . nick
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > I have a problem. I'm writing a simulation program with a number of > > mechanical components represented as objects. When I create instances > > of objects, I need to reference (link) each object to the objects > > upstream and downstream of it,

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael Spencer
Michael J. Fromberger wrote: ... > > Of course, I could just bypass super, and explicitly invoke them as: > > C.__init__(self, ...) > D.__init__(self, ...) > > ... but that seems to me to defeat the purpose of having super in the > first place. As others have pointed out, super, is designe

Re: sysadmin -> python programmer

2006-07-19 Thread fumanchu
Dan Stromberg wrote: > I've been a sysadmin for about 13 years, but I'm realizing that my > favorite part of being a sysadmin are those moments where there's a reason > to write some code - preferably in python. > > What might one do to make the transition from sysadmin to python > programmer, asid

restricted environment

2006-07-19 Thread Gabriele *darkbard* Farina
Hi, I saw the rexec module is deprecated. I need to develop a python application able to run custom python code based on a configuration file that tells the path of the script that have to be executed. Those scripts can be runned simultaneously trought threading module, but the MUST not have any w

wxPython: wxStaticBitmap and large images

2006-07-19 Thread Roger Miller
I have a WxPython app that displays images that are typically around 600x600 pixels. I use a wxStaticBitmap, which appears to work fine on Windows XP. However the documentation states that a StaticBitmap "... is meant for display of the small icons in the dialog boxes and is not meant to be a gener

Re: restricted environment

2006-07-19 Thread Paul Rubin
"Gabriele *darkbard* Farina" <[EMAIL PROTECTED]> writes: > There is a way to reach this point without using rexec? Not without a totally separate interpreter. If rexec were so easy to fix, they'd fix it. > There is a way to start a python interpreter from python to run the > scripts? Of course

Re: python compile code object -- reverse how to

2006-07-19 Thread leo
Hi, all, i mean to convert 'c\000\000\000\000\001\000\000\000s\017\000\000\00 > 0\177\000\000\177\002\000d\000\000GHd\001\000S(\00 > 2\000\000\000s\005\000\000\000helloN(\000\000\000\ > 000(\000\000\000\000s\010\000\000\000

Re: restricted environment

2006-07-19 Thread Gabriele *darkbard* Farina
Using a separate interpreter could be a solution, but restarting any time the interpreter give me too much overhead and the application will work as slow as a CGI app even if it runs using FastCGI. Can't I put the interpreter to the starting state any time it finishes a script execution without re

Re: restricted environment

2006-07-19 Thread Paul Rubin
"Gabriele *darkbard* Farina" <[EMAIL PROTECTED]> writes: > Using a separate interpreter could be a solution, but restarting any > time the interpreter give me too much overhead and the application will > work as slow as a CGI app even if it runs using FastCGI. How many users are you talking about?

Re: question about what lamda does

2006-07-19 Thread danielx
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What would i use a lamda for that i > could not or would not use a def for ? Is there a notable difference ? > I only ask because i see it in code sample

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, Michael Spencer <[EMAIL PROTECTED]> wrote: > As others have pointed out, super, is designed to do something different from > what you want. See > http://www.python.org/download/releases/2.2.3/descrintro/#cooperation for > GvR's > explanation of super's inten

dual python / bootstrap RPM woes

2006-07-19 Thread zman818
Greetings. In an effort to get python2.4 on my Centos 3.7, I installed the python bootstrap rpm. This installed 2.4 alongside 2.2 and updated yum to 2.4.0. Oddly, it didn't create a symlink 'python' for either 2.2 or 2.4. I also get a series of troubling dependency errors when I run yum updat

Re: restricted environment

2006-07-19 Thread faulkner
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496746 When you think of modifying the interpreter, think of the compiler module. Gabriele *darkbard* Farina wrote: > Hi, > > I saw the rexec module is deprecated. I need to develop a python > application able to run custom python code based

Re: function v. method

2006-07-19 Thread danielx
Bruno Desthuilliers wrote: > danielx wrote: > > At first I was going to post the following: > > > > > > > (snip) > > > > > > > > but then I tried this: > > > > > res = Foo.__dict__['func'] > res is dan > > > > True > > > > And it all started to make sense. The surprising thing turned out

Re: function v. method

2006-07-19 Thread danielx
Leif K-Brooks wrote: > danielx wrote: > > This is still a little bit of magic, which gets me thinking again about > > the stuff I self-censored. Since the dot syntax does something special > > and unexpected in my case, why not use some more dot-magic to implement > > privates? Privates don't have

Re: function v. method

2006-07-19 Thread danielx
Duncan Booth wrote: > danielx wrote: > > Foo.func = dan# <-- Appearantly, something magical happens here, > because... > Foo.func > > > f = Foo.func > f is dan # <-- things begins to look suprising here. > > False > ismethod(f) > > True > > > > Imagine my

New to threads. How do they work?

2006-07-19 Thread gel
Hi all I am attempting to understand threads to use in a network app which I am writing. The part that I am going to use threads on is run on the clients/workstations. I will monitor all starting and ending processes. Below is what I have been doing. It looks like only the first thread is starti

Ann: PyPgExplorer-0.8

2006-07-19 Thread jerry . levan
PyPgExplorer is a pure python application that allows the user to browse and modify Postgresql Databases. Features include: o A Scripts menu that makes access to your favorite SQL scripts only a click away. o On unix and Mac systems, if psql is detected in a standard location, then access to

Re: how to know if socket is still connected

2006-07-19 Thread bryanjugglercryptographer
Grant Edwards wrote: > If the server has closed the connection, then a recv() on the > socket will return an empty string "", after returning all the data the remote side had sent, of course. > and a send() on the > socket will raise an exception. Send() might, and in many cases should, raise a

Tkinter focus_set use with grid

2006-07-19 Thread Stan Cook
A newbie to Tkinter here. . . . . . I'm trying to set the focus on an Entry textbox with focus_set. I am using the grid manager. I created the same interface before using the pack() method and the focus_set worked, but now it says "AttributeError: 'NoneType' object has no attribute 'focus_s

Re: Accessors in Python (getters and setters)

2006-07-19 Thread danielx
Bruno Desthuilliers wrote: > ZeD wrote: > > Bruno Desthuilliers wrote: > > > > > >>>I decided to change the name of an attribute. Problem is I've used the > >>>attribute in several places spanning thousands of lines of code. If I > >>>had encapsulated the attribute via an accessor, I wouldn't need

Re: Tkinter focus_set use with grid

2006-07-19 Thread John McMonagle
On Thu, 2006-07-20 at 02:53 +, Stan Cook wrote: > A newbie to Tkinter here. . . . . . > > I'm trying to set the focus on an Entry textbox with > focus_set. I am using the grid manager. I created the same > interface before using the pack() method and the focus_set > worked, but now it sa

Re: using names before they're defined

2006-07-19 Thread Paul McGuire
[EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a number of > mechanical components represented as objects. Have you looked at SimPy? This may simplify much of your data structure anguish (probably only need forward refs, without the back refs), plus it will do

Re: Using super()

2006-07-19 Thread Michele Simionato
Carl Banks ha scritto: > Pupeno wrote: > > I see, thank you. > > > > class MyConfig(ConfigParser, object): > > def add_section(self, section) > > super(MyConfig, self).add_section(section) > > > > seems to work and as expected. Is there anything wrong with it ? > > Wow. > > I highly r

questions to anyone who uses wxPython

2006-07-19 Thread damacy
hello. i'm using wxPython as my GUI package and whenever my program executes a long process which takes at least 2 or 3 seconds, the user interface gets corrupted while executing the progrocess during the period. i have tried the following lines of code... frame = mainwindow(None, -1, 'my program

Re: Partial classes

2006-07-19 Thread Michele Simionato
Sanjay ha scritto: > Thanks for the code showing how to implement partial classes. Infact, I > was searching for this code pattern. I will have a study on metaclass > and then try it. > > Thanks > Sanjay Anyway, I would suggest you NOT to use this code in production. Yes, Python can imitate Ruby

Re: Coding style

2006-07-19 Thread Patrick Maupin
Terry Reedy wrote: > > > Carl Banks wrote: > >> def process_values(lst): > >> if not lst: > >> return > >> do_expensive_initialization_step() > >> for item in lst: > >> do_something_with(item) > >> do_expensive_finalization_step() > > Give

Re: Accessors in Python (getters and setters)

2006-07-19 Thread mystilleef
Bruno Desthuilliers wrote: > mystilleef wrote: > > Bruno Desthuilliers wrote: > > > >>mystilleef wrote: > (snip) > > > >Of course using setters for the sake of just using them is pointless. > > Indeed. > > > > >The reason to use them is if pre-conditions or post

Weekly Python Patch/Bug Summary

2006-07-19 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 398 open ( +5) / 3334 closed (+19) / 3732 total (+24) Bugs: 904 open ( -4) / 6011 closed (+36) / 6915 total (+32) RFE : 222 open ( -1) / 231 closed ( +2) / 453 total ( +1) New / Reopened Patches __ Fix for #

Re: Using super()

2006-07-19 Thread Michele Simionato
Michele Simionato ha scritto: > I believe the new style system was designed to allows this sort of > mixing and > that there are no issues at all. Thinking a bit more, there are no issues at all if you know what a new style class is and if you do not expect it to work as an old-style one ;) For th

Re: Partial classes

2006-07-19 Thread Sanjay
> Anyway, I would suggest you NOT to use this code in production. Yes, > Python > can imitate Ruby, but using this kind of classes would confuse > everybody and > make your code extremely unpythonic. As always, consider changing your > mindset, > when you switch language. For you problem, you could

Re: Accessors in Python (getters and setters)

2006-07-19 Thread mystilleef
Steve Holden wrote: > mystilleef wrote, making me somewhat tired of his/her repeated inability > to get what's being said [sigh]: > > Bruno Desthuilliers wrote: > >>mystilleef wrote: > >>>Bruno Desthuilliers wrote: > mystilleef wrote: > >Gerhard Fiedler wrote: > >>On 2006-07-15 06:55:1

Re: Coding style

2006-07-19 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Bob Greschke >> wrote: >> >>> I'd go even one step further. Turn it into English (or your favorite >>> non-computer language): >>> >>> 1. While list, pop. >>> >>> 2. While the le

Re: Partial classes

2006-07-19 Thread Stefan Behnel
Kay Schluehr wrote: > What about letting your teammates editing certain data-structures in > different files ( physical modules ) but using them in a uniform way > and enable a single access point. If you have partial classes there is > no reason why your team has to share a large file where they h

Re: questions to anyone who uses wxPython

2006-07-19 Thread Frank Millman
damacy wrote: > hello. i'm using wxPython as my GUI package and whenever my program > executes a long process which takes at least 2 or 3 seconds, the user > interface gets corrupted while executing the progrocess during the > period. > > i have tried the following lines of code... > > frame = mai

Re: restricted environment

2006-07-19 Thread K.S.Sreeram
Gabriele *darkbard* Farina wrote: > The first attempt to reach my goal was to override the __import__ > function to limit it working on modules that can be used and on custom > import directories that can be accessed. Then I executed the scripts > using exec. There is any security problem related t

Depricated String Functions in Python

2006-07-19 Thread Anoop
Hi All Can any one help me out with the various depricated string functions that is followed in Python. For example how will be string.lower depricated. As far as string.lower('PYTHON') is concerned it is depricated as 'PYTHON'.lower(). Both of them would return an output : >>> python Thanks fo

Re: Depricated String Functions in Python

2006-07-19 Thread Stefan Behnel
Anoop wrote: > Can any one help me out with the various depricated string functions > that is followed in Python. > > For example how will be string.lower depricated. > > As far as string.lower('PYTHON') is concerned it is depricated as > 'PYTHON'.lower(). Both of them would return an output : >>

Re: Weird MemoryError issue

2006-07-19 Thread jedi200581
John Machin wrote: > On 20/07/2006 6:05 AM, John Machin wrote: > > On 20/07/2006 1:58 AM, [EMAIL PROTECTED] wrote: > >> def is_prime n: > > > > Syntax error. Should be: > >def is_prime n: > > Whoops! Take 2: > > Should be: > > def is_prime(n): Sorry for that, I was not able to cut-paste the c

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
Dave, Python properties allow you to get rid of methods like c.getAttr(), c.setAttr(v), c.delAttr() and replace them with simple constructs like c.attr, c.attr=v and del c.attr. If you have been using Java or C++ you know that as soon as you code your class you have to start filling in the get()

Re: New to threads. How do they work?

2006-07-19 Thread gel
Dennis Lee Bieber wrote: > On 19 Jul 2006 19:08:12 -0700, "gel" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > import thread > > > Step one... Skip the thread module and use threading module instead. > > > def create(): > > > > pythoncom.CoInitialize() > >

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, mystilleef wrote: > > Bruno Desthuilliers wrote: >> mystilleef wrote: >> > Bruno Desthuilliers wrote: >> > >> > Because you don't want third parties illegimately tampering with an >> > object's internal data and thus crashing your system? >> >> Let's try again... >> >> poi

<    1   2   3