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
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
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
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__
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
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
> 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
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
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
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
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
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
[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
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
[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
15 matches
Mail list logo