In article <21e704ee-648b-423d-8682-11cb310a3...@googlegroups.com>, Rick Johnson <rantingrickjohn...@gmail.com> wrote:
> On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj...@gmail.com wrote: > > When I get match result: > > py>pattern='abcd' > > py>prog = re.compile(pattern) > > py>string='abcd' > > py>result = prog.match(string) > > py>result > > <_sre.SRE_Match object at 0x6ffffeda5e0> > > py>result.group(0) > > 'abcd' > > > > It looks like 'result' is different from a simple > > 'counter' variable. I do not yet find the definition of > > 'result' object. What do you call 'result' object? Where > > can I find it (what topic would be in a tutorial)? Thanks, > > One of the most powerful features of Python,,, for the > noob,,, be documentation strings. I guess I must still be a noob, because I still find them pretty useful! More generically, Python supports "introspection", which means you can ask an object to tell you things about itself. Let's say you've got an object, foo. Here's some useful things you can do to learn more about it: * As Rick points out, you can do help(foo). This is probably the place to start. * You can print dict(foo), which just prints out the attributes the object has. This is really handy when you vaguely remember that a class has some operation, but can't remember the exact name. For example, I use two different database packages, and can never remember which has sort() and which has order_by(). * You can print foo itself, to find out its value, but this can get tricky, since sometimes objects print themselves in confusing ways. Printing repr(foo) will usually get you more detail. * You can print type(foo), to find out exactly what it is (useful when even printing repr() doesn't explain what's going on). -- https://mail.python.org/mailman/listinfo/python-list