Re: Does python have the static function member like C++

2007-04-11 Thread goodwolf
On Apr 11, 10:15 am, Bruno Desthuilliers wrote: > goodwolf a écrit : > > > > > On Apr 11, 9:09 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > >> goodwolf a écrit : > >> (snip) > > >>> 1. In this case you will prefer a classmethod

Re: Does python have the static function member like C++

2007-04-11 Thread goodwolf
On Apr 11, 9:09 am, Bruno Desthuilliers wrote: > goodwolf a écrit : > (snip) > > > 1. In this case you will prefer a classmethod instead a staticmethod. > > 2. If counter is the number of instances of class AAA then you will > > incrase counter inside __init__ meth

Re: Does python have the static function member like C++

2007-04-10 Thread goodwolf
On Apr 11, 5:19 am, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > > > I define the class like this: > > class AAA: > > counter = 0 > > def __init__(self): > > pass > > def counter_increase(): > > AAA.counter += 1

Re: class attrdict

2007-03-04 Thread goodwolf
class Namespace(object): def __init__(self, __ns=None, **kwargs): if __ns is None:#if no dictionary is given self.__dict__ = kwargs #then use kwargs without copying or creating new dict else: assert len(kwargs) == 0 self.__dict__

Re: class attrdict

2007-03-04 Thread goodwolf
On Mar 4, 1:03 pm, "goodwolf" <[EMAIL PROTECTED]> wrote: > On Mar 3, 4:25 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > > > > > Hallvard B Furuseth <[EMAIL PROTECTED]> wrote: > > > > Does this class need anything more? > > > Is there an

Re: class attrdict

2007-03-04 Thread goodwolf
On Mar 3, 4:25 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Hallvard B Furuseth <[EMAIL PROTECTED]> wrote: > > > Does this class need anything more? > > Is there any risk of a lookup loop? > > Seems to work... > > > class attrdict(dict): > > """Dict where d['foo'] also can be accessed as d.fo

Re: Solved: Question about idiomatic use of _ and private stuff.

2007-02-23 Thread goodwolf
> If you say > > from foo import _fooa, _foob, > > then the import will fail because the _ is used only by the import to > decide that you shouldn't see _fooa or _foob. ??? Read Python manuals, please. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about idiomatic use of _ and private stuff.

2007-02-23 Thread goodwolf
On Feb 23, 5:12 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I understand that two leading underscores in a class attribute make the > attribute private. But I often see things that are coded up with one > underscore. Unless I'm missing something, there's a idiom going on here. > > Why do peopl

Re: Getting a class name

2007-02-18 Thread goodwolf
On Feb 18, 9:17 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 18 Feb 2007 04:20:33 -0300, goodwolf <[EMAIL PROTECTED]> > escribió: > > > I suppose that you wont get class name into its code (or before > > definition end) but not into a me

Re: Getting a class name

2007-02-17 Thread goodwolf
I suppose that you wont get class name into its code (or before definition end) but not into a method definition. import sys def getCodeName(deap=0): return sys._getframe(deap+1).f_code.co_name class MyClass (object): name = getCodeName() + '!' -- http://mail.python.org/mailman/list

Re: Help Required for Choosing Programming Language

2007-02-17 Thread goodwolf
In your situation consider C# too. If you like python then try IronPython for .NET. I think that C++ is not ideal for you. P.S.: VB6 is NOT a real OOP language. -- http://mail.python.org/mailman/listinfo/python-list

Re: output to console and to multiple files

2007-02-14 Thread goodwolf
like this? class Writers (object): def __init__(self, *writers): self.writers = writers def write(self, string): for w in self.writers: w.write(string) def flush(self): for w in self.writers: w.flush(): import sys logfile = open('log

Re: arguments of a function/metaclass

2007-01-16 Thread goodwolf
[EMAIL PROTECTED] je napisao/la: > Hello, > > > I have a member function with many (20) named arguments > > def __init__(self,a=1,b=2): > self.a=a > self.b=b > > I would like to get rid of the many redundant lines like self.a=a and > set the members automatically. > The list of default arg

Re: arguments of a function/metaclass

2007-01-16 Thread goodwolf
Gabriel Genellina je napisao/la: > "goodwolf" <[EMAIL PROTECTED]> escribió en el mensaje > news:[EMAIL PROTECTED] > > A simply solution: > > > > def __init__(self, a=1, b=2, c=3, ..): > >for key, val in locals().items(): > >if

Re: arguments of a function/metaclass

2007-01-16 Thread goodwolf
[EMAIL PROTECTED] je napisao/la: > Hello, > > > I have a member function with many (20) named arguments > > def __init__(self,a=1,b=2): > self.a=a > self.b=b > > I would like to get rid of the many redundant lines like self.a=a and > set the members automatically. > The list of default arg