MonkeeSage
11/29/2007 11:18:00 PM
On Nov 29, 5:10 pm, Todd Benson <caduce...@gmail.com> wrote:
> On Nov 29, 2007 4:45 PM, MonkeeSage <MonkeeS...@gmail.com> wrote:
>
>
>
> > On Nov 29, 7:30 am, Robert Klemme <shortcut...@googlemail.com> wrote:
> > > 2007/11/29, MonkeeSage <MonkeeS...@gmail.com>:
>
> > > > People often want to look at an object's attributes when debugging.
> > > > [1] Python has a handy dir() function that lists the attributes of an
> > > > object. And I use it tons. I often use obj.methods.sort in ruby for
> > > > the same purpose.
>
> > > You can view the attributes quite conveniently with pp (you'll see
> > > instance variables nicely nested and indented as a tree).
>
> > > Kind regards
>
> > > robert
>
> > > --
> > > use.inject do |as, often| as.you_can - without end
>
> > Example please?
>
> > Regards,
> > Jordan
>
> irb> require 'pp'
> => true
> irb> class C; def initialize; @var = 1; end; end
> => nil
> irb> pp( C.new )
> #<C:0x2d8d3c4 @var=1>
> => nil
>
> Todd
Thanks. I'm aware of that, but it doesn't show methods, class
variables, and so on, and many times it just gives you a to_s (e.g.,
pp([1,2,3])). I was of the impression that Robert was talking about
viewing *all* of the object's attributes with pp.
Regards,
Jordan