[Tutor] How can I have type "function" in my script?

Dave Angel d at davea.name
Mon May 7 21:16:57 CEST 2012

On 05/07/2012 03:11 PM, Joel Goldstick wrote:
> On Mon, May 7, 2012 at 3:07 PM, Dave Angel <d at davea.name> wrote:
>> On 05/07/2012 02:24 PM, xancorreu wrote:
>>> Hi,
>>> I have this script:
>>> from types import *
>> Bad idea.  Once you do that, you can silently overwrite globals in your
>> own module with stuff that the current version of types happens to have
>> in it.  Besides, it then becomes very hard to read your program and
>> figure out which names you really did want to import.
>> If you're just getting one or two names, such as in your case, better
>> just do
>>    import types
>>> class Tag:
> can a class be defined this way in python 3.x?  I thought it needs a
> parent class as a parameter?

That's legal in 3.x   The difference between 2.x and 3.x is that if you
omit the base class in 2.x, it generates an old-style class, while in
3.x it always uses new-style classes.



More information about the Tutor mailing list