I realize now that it would probably be best to define the problem I'm
having according to the constraints imposed by other requirements, and
not by describing the basic functionality. That way, since there are so
many possible ways to get something like what I want, there will
probably be only
>>bit more insight into the arrangement I'm trying to get:
>>
>>restrict = True
>>
>>
>Why a global value? If it is to affect class instantiation, why not pass it
>or a value to the constructor, e.g., C(True) or C(some_bool)?
>
>
>
For reasons unrelated to this problem, the class that does t
On Mon, 16 Jan 2006 18:55:43 -0800, David Hirschfield <[EMAIL PROTECTED]> wrote:
>Thanks for this, it's a great list of the ways it can be done. Here's a
Actually, your way is yet another ;-)
>bit more insight into the arrangement I'm trying to get:
>
>restrict = True
Why a global value? If it i
Thanks for this, it's a great list of the ways it can be done. Here's a
bit more insight into the arrangement I'm trying to get:
restrict = True
class A(object):
_restrict = ["test"]
def _null(self, *args, **kws):
raise Exception,"not allowed to access"
def test(s
On Sun, 15 Jan 2006 19:23:30 -0800, David Hirschfield <[EMAIL PROTECTED]> wrote:
>I should have explicitly mentioned that I didn't want this particular
>solution, for a number of silly reasons.
>Is there another way to make this work, without needing to place an
>explicit "if allowed" around eac
On Mon, 16 Jan 2006 06:39:48 -0500, Dan Sommers wrote:
> By the principle of least surprise, if dir(some_sobject) contains foo,
> then some_object.foo should *not* raise a NameError.
Good thinking. Yes, it should raise a different exception.
--
Steven.
--
http://mail.python.org/mailman/listin
On Mon, 16 Jan 2006 21:25:50 +1100,
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Sun, 15 Jan 2006 18:41:02 -0800, David Hirschfield wrote:
>> Here's a strange concept that I don't really know how to implement, but
>> I suspect can be implemented via descriptors or metaclasses somehow:
>>
>> I
On Sun, 15 Jan 2006 18:41:02 -0800, David Hirschfield wrote:
> Here's a strange concept that I don't really know how to implement, but
> I suspect can be implemented via descriptors or metaclasses somehow:
>
> I want a class that, when instantiated, only defines certain methods if
> a global in
David Hirschfield <[EMAIL PROTECTED]> wrote:
> Here's a strange concept that I don't really know how to implement, but
> I suspect can be implemented via descriptors or metaclasses somehow:
Yeah, a custom metaclass will do it, easily.
> I want a class that, when instantiated, only defines certai
I should have explicitly mentioned that I didn't want this particular
solution, for a number of silly reasons.
Is there another way to make this work, without needing to place an
explicit "if allowed" around each method definition?
Thanks again,
-David
Dan Sommers wrote:
>On Sun, 15 Jan 2006 1
On Sun, 15 Jan 2006 18:41:02 -0800,
David Hirschfield <[EMAIL PROTECTED]> wrote:
> I want a class that, when instantiated, only defines certain methods
> if a global indicates it is okay to have those methods. So I want
> something like:
> global allow
> allow = ["foo","bar"]
> class A:
> de
Here's a strange concept that I don't really know how to implement, but
I suspect can be implemented via descriptors or metaclasses somehow:
I want a class that, when instantiated, only defines certain methods if
a global indicates it is okay to have those methods. So I want something
like:
gl
12 matches
Mail list logo