from calendar import* doesn't import everything

Kiuhnm kiuhnm03.4t.yahoo.it
Tue Apr 24 19:42:02 EDT 2012


On 4/25/2012 1:18, Rotwang wrote:
> Sorry if this is a stupid question, but what is up with this:
> 
>  >>> from calendar import*
>  >>> Calendar
> 
> Traceback (most recent call last):
> File "<pyshell#9>", line 1, in <module>
> Calendar
> NameError: name 'Calendar' is not defined
>  >>> from calendar import Calendar
>  >>> Calendar
> <class 'calendar.Calendar'>
> 
> ?

calendar.py defines __all__ this way:

__all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
           "firstweekday", "isleap", "leapdays", "weekday", "monthrange",
           "monthcalendar", "prmonth", "month", "prcal", "calendar",
           "timegm", "month_name", "month_abbr", "day_name", "day_abbr"]

Only those names are imported with '*'.

Kiuhnm



More information about the Python-list mailing list