# How to get number of args a user-made class' \_\_init\_\_ needs?

**URL:** <https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347>\
**Category:** Newbie\
**Tags:** python\
**Created:** [February 1, 2021, 10:40am UTC](https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347 "2021-02-01T10:40:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrli](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@mrli](https://root-forum.cern.ch/u/mrli)\
**Post date:** [February 1, 2021, 10:40am UTC](https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347/1 "2021-02-01T10:40:54Z")

</div>

Hello all,  
I’m trying to write a Python script to load classes made by RooClassFactory::makePdf(). I use gROOT.LoadMacro() to load class successfully, now I want to get information about what parameters the class need. I’ve browsed all functions of RooAbsPdf and its parent classes and found nothing (maybe I missed something…)

I’ve also tried Python’s way as

```auto
MyClass. __init__. __code__.co_argcount

```

and it didn’t work.

So, is there any way to know what parameters the user-made RooAbsPdf need?

* * *

_ROOT Version:_ 6.22  
_Platform:_ Ubuntu20.04

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [February 1, 2021, 11:50am UTC](https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347/2 "2021-02-01T11:50:36Z")

</div>

@etejedor could please take a look? Thanks!

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [February 1, 2021, 12:21pm UTC](https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347/3 "2021-02-01T12:21:11Z")

</div>

Hi,

`MyClass` is a C++ class, right?

You can try with:

```python
c = ROOT.TClass.GetClass("MyClass")
methods = c.GetListOfMethods()

```

`methods` is a list of `TMethod` instances. You need to find in that list the constructor you are looking for and obtain the number of parameters.

See:  
[https://root.cern.ch/doc/master/classTClass.html#a5648dadc9ffaf897181fcc6309e7c9d3](https://root.cern.ch/doc/master/classTClass.html#a5648dadc9ffaf897181fcc6309e7c9d3)

and:  
[https://root.cern.ch/doc/master/classTMethod.html](https://root.cern.ch/doc/master/classTMethod.html)

---

<div class="post-metadata">

**Author:** ![mrli](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@mrli](https://root-forum.cern.ch/u/mrli)\
**Post date:** [February 1, 2021, 1:17pm UTC](https://root-forum.cern.ch/t/how-to-get-number-of-args-a-user-made-class-init-needs/43347/5 "2021-02-01T13:17:41Z")

</div>

Thanks a lot!  
That’s quite complicated for me, as your advide I tried command below and figure it out! ( as one line)

```auto
TClass.GetClass(‘MyClass’).GetListOfMethods().FindObject(‘MyClass’).GetListOfMethodArgs().GetEntries()
# That’s quite complicated

```
