TP wrote:
> Hi everybody,
>
> I try to make a "link" (or shortcut, if you want) so that len(b_instance)
> computes in fact len(a) (see the code below). I could write a method
> __len__ to b, but I wonder if it is possible to make it with a
> setattr/getattr trick, as I do below.
>
> Thanks in ad
Hi everybody,
I try to make a "link" (or shortcut, if you want) so that len(b_instance)
computes in fact len(a) (see the code below). I could write a method
__len__ to b, but I wonder if it is possible to make it with a
setattr/getattr trick, as I do below.
Thanks in advance,
Julien
###
bruno at modulix wrote:
> Gerard Flanagan wrote:
> > The functions were kind of related
> > and meaningless outside the module they were declared -
>
> FWIW (and from the snippet I saw), these functions are useless even in
> the module !-)
>
ok, ok... :-)
> Unless you want to dynamically choose t
Gerard Flanagan wrote:
> bruno at modulix wrote:
> [...]
>
>>I don't know this HtmlElement class, nor where it comes from.
>>'to_string()' (or is it toString() ?) is javaish. The pythonic idiom for
>>this is implementing the __str__() method and calling str(obj) on the
>>obj (which will call obj._
bruno at modulix wrote:
[...]
>
> I don't know this HtmlElement class, nor where it comes from.
> 'to_string()' (or is it toString() ?) is javaish. The pythonic idiom for
> this is implementing the __str__() method and calling str(obj) on the
> obj (which will call obj.__str__()). Hence my (bad) gu
Gerard Flanagan wrote:
> bruno at modulix wrote:
>
(snip french)
>
> I was trying to implement the factory pattern.
> The recipe above uses 'apply' which is deprecated according to the
> docs, and I suppose I was curious how to do the same sort of thing
> without 'apply'.
def fun(*args, **kwargs
bruno at modulix wrote:
(snip)
> Je ne vois pas très bien à quoi sert cette classe (à moins bien sûr
> qu'il y ait d'autre code). Pour ce que je vois là, pourquoi ne pas
> appeler directement les classes HtmlPage, HtmlElement et HtmlLiteral ?
>
oops, sorry, forgot to remove this before posting :(
Gerard Flanagan wrote:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/86900
>
> mais il utilise 'apply', qui est...blah
>
> I was trying to implement the factory pattern.
> The recipe above uses 'apply' which is deprecated according to the
> docs, and I suppose I was curious how to
Fredrik Lundh wrote:
> Gerard Flanagan wrote:
>
> > I have the following code:
> >
> > builder.py #
> > class HtmlBuilder(object):
> >
> > @staticmethod
> > def page(title=''):
> > return HtmlPage(title)
> >
> > @staticmethod
> > def element(tag, text=None, **at
bruno at modulix wrote:
> Gerard Flanagan wrote:
> > Hello
> >
> > I have the following code:
> >
> > builder.py #
> > class HtmlBuilder(object):
> >
> > @staticmethod
> > def page(title=''):
> > return HtmlPage(title)
> >
> > @staticmethod
> > def element(tag,
Gerard Flanagan wrote:
> I have the following code:
>
> builder.py #
> class HtmlBuilder(object):
>
> @staticmethod
> def page(title=''):
> return HtmlPage(title)
>
> @staticmethod
> def element(tag, text=None, **attribs):
> return HtmlElement(tag, text
Gerard Flanagan wrote:
> Hello
>
> I have the following code:
>
> builder.py #
> class HtmlBuilder(object):
>
> @staticmethod
> def page(title=''):
> return HtmlPage(title)
>
> @staticmethod
> def element(tag, text=None, **attribs):
> return HtmlElem
Hello
I have the following code:
builder.py #
class HtmlBuilder(object):
@staticmethod
def page(title=''):
return HtmlPage(title)
@staticmethod
def element(tag, text=None, **attribs):
return HtmlElement(tag, text, **attribs)
@staticmethod
de
13 matches
Mail list logo