Re: dynamically modify help text

2010-06-27 Thread Red Forks
Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais wrote: > Hello, > > I know that the help text for an object will give a description of every > method based on the doc string.  Is there a way to add something to this > text, spec

Interesting things of 'getattr' and 'setattr'

2009-12-15 Thread Red Forks
I don't know it is a feature, or implement detail: >>> class C(object): pass ... >>> c = C() >>> setattr(c, ' ', 3) >>> getattr(c, ' ') 3 >>> setattr(c, 'with blank', 4) >>> getattr(c, 'with blank') 4 getattr / setattr seems treat any string as attribute name. -- http://mail.python.org/mailman/l

Re: Custom namespaces

2009-08-01 Thread Red Forks
On Sun, Aug 2, 2009 at 9:06 AM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > I was playing around with a custom mapping type, and I wanted to use it > as a namespace, so I tried to use it as my module __dict__: > > >>> import __main__ > >>> __main__.__dict__ = MyNamespace() > T

Re: string.Template issue

2009-08-01 Thread Red Forks
On Thu, Jul 30, 2009 at 4:17 PM, Javier Collado wrote: > Hello, > > In the string.Template documentation > (http://docs.python.org/library/string.html) it's explained that if a > custom regular expression for pattern substitution is needed, it's > possible to override idpattern class attribute (wh

Re: PYTHONPATH and multiple python versions

2009-06-05 Thread Red Forks
maybe a shell script to switch PYTHONPATH, like: start-python-2.5 start-python-2.4 ... On Fri, Jun 5, 2009 at 4:56 PM, David Cournapeau wrote: > Hi, > > As I don't have admin privileges on my main dev machine, I install a > good deal of python modules somewhere in my $HOME, using PYTHONPATH to >

Re: multi-core software

2009-06-05 Thread Red Forks
Single - thread programming is great! clean, safe!!! I'm trying schedual task to several work process (not thread). On Fri, Jun 5, 2009 at 4:49 AM, MRAB wrote: > Kaz Kylheku wrote: > >> ["Followup-To:" header set to comp.lang.lisp.] >> On 2009-06-04, Roedy Green wrote: >> >>> On Thu, 4 Jun 2009

Re: defaultdict's bug or feature?

2009-05-22 Thread Red Forks
gravating if you don't. > I misunderstand you last email, thanks. > > On Fri, 22 May 2009 09:53:04 +0100, Red Forks wrote: > > Yes, you maybe right. When use defaultdict, should not rely get() method >> anymore, d[] is just enough. >> > > Almost. You should re

Re: defaultdict's bug or feature?

2009-05-22 Thread Red Forks
t, using 'onload' function to load the value by the key. When no value correspond to a key, a KeyError will raised. So I need a *safer* version 'get()' method. On Fri, May 22, 2009 at 12:35 PM, Rhodri James wrote: > Please don't top-post, it makes the thread of argumen

Re: defaultdict's bug or feature?

2009-05-21 Thread Red Forks
9 at 7:46 AM, Rhodri James wrote: > On Thu, 21 May 2009 13:07:50 +0100, Red Forks wrote: > > from collections import defaultdict >> >> d = defaultdict(set) >> assert isinstance(d['a'], set) >> assert isinstance(d.get('b'), set) >> >>

defaultdict's bug or feature?

2009-05-21 Thread Red Forks
from collections import defaultdict d = defaultdict(set) assert isinstance(d['a'], set) assert isinstance(d.get('b'), set) d['a'] is ok, and a new set object is insert to d, but d.get('b') won't. It's a bug, or just a feature? I think dict.get() method is just a *safe* version of dict[key], may