[BangPypers] Finding methods in a python script
Chirayu Patel
chirayu at chirayu.org
Thu Mar 13 10:29:55 CET 2008
Heshan,
You will find http://docs.python.org/lib/inspect-types.html helpful.
"A.__dict__["foo"].func_code.co_varnames" will give you arguments of foo.
CP
On 3/13/08, Heshan Suriyaarachchi <heshan.suri at gmail.com> wrote:
>
> Hi
> I am talking about a scenario like this
>
> class A:
> def foo(var1,var2):
> return 'Hello'
> def echo():
> return 'testing'
>
>
> class B:
> def bar(car):
> val = car
> return car
>
> What I need is to find out the classes and the methods of each class with
> their parameters.
> i.e. class A
> foo(var,var)
> echo()
>
> when using dir() it does not show the methods and the method parameters .
>
> Regards
> Heshan Suriyaarachchi
>
> On Thu, Mar 13, 2008 at 12:23 PM, Pradeep Kishore Gowda <
> pradeep at btbytes.com> wrote:
>
> > You mean something like this: http://dpaste.com/39212/
> >
> > On 3/13/08, Akash <akashmahajan at gmail.com> wrote:
> > > On Thu, Mar 13, 2008 at 11:39 AM, Heshan Suriyaarachchi
> > > <heshan.suri at gmail.com> wrote:
> > > > Hi ,
> > > > I am having a python script which is having a class and some
> > methods. I
> > > > need to know whether there is a way to find out which methods are
> > there in
> > > > this script from another python script. Is there something like
> > reflection
> > > > in python which could help me in this process. If someone can
> > direct me to a
> > > > code sample doing this I will be grateful.
> > >
> > >
> > > How about creating an object of that class and using dir() on that?
> > > _______________________________________________
> > > BangPypers mailing list
> > > BangPypers at python.org
> > > http://mail.python.org/mailman/listinfo/bangpypers
> > >
> >
> >
> > --
> > Home - http://btbytes.com
> > Heart - http://sampada.net
> > Yummy! - http://konkanirecipes.com
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080313/f0742c61/attachment.htm
More information about the BangPypers
mailing list