Carl Banks a écrit :
(snip)
class A(object):
def __init__(self,*args,**kwargs):
raise TypeError('Type not callable; use factory function
instead')
@classmethod
def _create_object(cls,initial_value):
self = object.__new__(cls) # avoid __init__
self.value = in
On Mon, 10 Aug 2009 16:37:25 +0200, Ulrich Eckhardt wrote:
> ...that is the question!
>
> I have a module which exports a type. It also exports a function that
> returns instances of that type. Now, the reason for my question is that
> while users will directly use instances of the type, they wil
On Aug 10, 7:37 am, Ulrich Eckhardt wrote:
> ...that is the question!
>
> I have a module which exports a type. It also exports a function that
> returns instances of that type. Now, the reason for my question is that
> while users will directly use instances of the type, they will not create
> in
10-08-2009 Ulrich Eckhardt wrote:
So, the type is a part of the public API, but its constructor is not.
Should
I mark the type as private (with a leading underscore) or not?
IMHO you shouldn't (i.e. name should be marked "public") because of
possible usage of e.g. "isinstance(foo, YourType)
...that is the question!
I have a module which exports a type. It also exports a function that
returns instances of that type. Now, the reason for my question is that
while users will directly use instances of the type, they will not create
instances of the type themselves.
So, the type is a part