Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18067
| References | <4efa3f05$0$6546$426a74cc@news.free.fr> |
|---|---|
| Date | 2011-12-27 17:29 -0500 |
| Subject | Re: Type object returned by the re.compile function |
| From | Jerry Hill <malaclypse2@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4158.1325024967.27778.python-list@python.org> (permalink) |
On Tue, Dec 27, 2011 at 4:56 PM, candide <candide@free.invalid> wrote:
>>>> import re
>>>> reo = re.compile('')
>>>> reo.__class__
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: __class__
>>>>
I'm not going to comment on what type is returned from the various
functions in the re module, mostly because all I have installed
locally is 2.6, and I'm not sure if anything has changed in 2.7 or
3.2.
Instead, I will recommend a different tool for your toolbox. Take a
look at the type() builtin function (
http://docs.python.org/library/functions.html#type ). Particularly,
instead of inspecting reo.__class__ in your example above, you can
print out type(reo).
At a guess, those objects are missing the __class__ attribute,
possibly because they are old style classes.
--
Jerry
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Type object returned by the re.compile function candide <candide@free.invalid> - 2011-12-27 22:56 +0100 Re: Type object returned by the re.compile function Jerry Hill <malaclypse2@gmail.com> - 2011-12-27 17:29 -0500 Re: Type object returned by the re.compile function Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 15:31 -0700
csiph-web