# Does ruby have a similar functions to the Python dir and hel

**URL:** <https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883>\
**Category:** Ruby\
**Created:** [March 23, 2007, 2:50pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883 "2007-03-23T14:50:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 23, 2007, 2:50pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/1 "2007-03-23T14:50:49Z")

</div>

In python during runtime, or in the python shell you can type:

dir()

or

dir(\<some\_object\>)

and get a list of variables, methods etc that exist for that object.

Also there is help(\<some\_object\>), or help(\<some\_object.aMethod\>).

does ruby have similar functions. I know that you can use ri…but  
is there a function to call while in the ruby shell?

thanks

---

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 23, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/2 "2007-03-23T14:54:50Z")

</div>

Ruby can tell you the methods: obj.methods (there’s also  
#public\_methods, #instance\_methods, #private\_methods, etc.). Ruby can  
tell you the instance variables (#instance\_variables).

Ruby can’t tell you the documentation; there’s no docstring like there  
is in Python. There are some enhancements to irb available that give  
an ri command from within irb.

-austin

---

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 23, 2007, 3:27pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/3 "2007-03-23T15:27:54Z")

</div>

def dir(object)  
object.methods.sort  
end

That should give you the same effect; as for the help method, ri is  
your only option AFAIK.

–Jeremy

On 3/23/07, py [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Also there is help(\<some\_object\>), or help(\<some\_object.aMethod\>).
> 
> does ruby have similar functions. I know that you can use ri…but  
> is there a function to call while in the ruby shell?
> 
> thanks

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My free Ruby e-book:  
[http://www.humblelittlerubybook.com/book/](http://www.humblelittlerubybook.com/book/)

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)

---

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 23, 2007, 5:52pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/4 "2007-03-23T17:52:50Z")

</div>

There is also the IHelp project : [http://fhtr.org/projects/ihelp/](http://fhtr.org/projects/ihelp/)

---

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 23, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/5 "2007-03-23T17:40:47Z")

</div>

Le vendredi 23 mars 2007 14:54, Austin Z. a écrit :

> Ruby can tell you the methods: obj.methods (there’s also  
> #public\_methods, #instance\_methods, #private\_methods, etc.). Ruby can  
> tell you the instance variables (#instance\_variables).
> 
> Ruby can’t tell you the documentation; there’s no docstring like there  
> is in Python. There are some enhancements to irb available that give  
> an ri command from within irb.
> 
> -austin

Actually, irb can give you documentation. For example :

irb(main):001:0\> help Array

It works like ri.

---

<div class="post-metadata">

**Author:** ![pypypy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5daacb/32.png) [@pypypy](https://www.ruby-forum.com/u/pypypy)\
**Post date:** [March 24, 2007, 9:55am UTC](https://www.ruby-forum.com/t/does-ruby-have-a-similar-functions-to-the-python-dir-and-hel/89883/6 "2007-03-24T09:55:33Z")

</div>

Austin Z. wrote:

> Ruby can tell you the methods: obj.methods (there’s also  
> #public\_methods, #instance\_methods, #private\_methods, etc.). Ruby can  
> tell you the instance variables (#instance\_variables).

you can also use local\_variables to get a list of… local variables!

Daniel
