From: ThoML Date: 2008-07-03T02:02:03+09:00 Subject: Re: nested methods good or bad design > Y get it, it's as if each method defines a namespace, can > youdosomething like a()::b() from ouside a? I'd say no. You'd probably have to ask this on a python list for more details. I don't think this would make much sense though: --> def a(x, y): ... def b(z): ... return z * y ... return x * b(4) ... --> a(2, 3) 24 What should a::b(10) return if this were possible? BTW I personally like nested functions/methods. This was/is one thing I miss in ruby. Anyway, I think though the OP asked for something different. The problem with that would be that the proposed code IMHO is that the definition of a method for all objects of that class would depend on the value of an instance variable of one specific object. Ara's solution or instance methods would solve this. If I'm not mistaken, another approach could be: class A def a(x) if x == 0 def self.b 10 end else def self.b 20 end end self end end o1 = A.new.a(0) o2 = A.new.a(1) p o2.b, o1.b => [20, 10]