[Tutor] How can I have type "function" in my script?
wprins at gmail.com
Tue May 8 21:11:01 CEST 2012
On 8 May 2012 19:31, xancorreu <xancorreu at gmail.com> wrote:
> A much pain for me. I think there should be a type.function avaliable in
> python, like str, int, etc. exists. I think as python is O-O language and
> have (or at least the page says that) higher-order function, I should could
Just define 'function' as being the type of (a) function. Any function
will do. This will fix your problem eg:
function = type(main)
a = Tag("descripció", str, "primera tasca")
b = Tag("unmes", function, lambda x: x+1)
I used "main" but you can use whatever you like.
It sounds to me however as though your type system may be (at least
partially) independent of the real (python) type of whatever you're
storing. If so, I'd actualy suggest you explicitly define your own type
system and tag your objects accordingly. (E.g. create your own variant of
the 'types' module and use those types as appropriate.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor