Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39019

Re: Calendar module question

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '16,': 0.03; 'attribute': 0.05; 'result,': 0.05; 'exception.': 0.07; 'subject:question': 0.08; 'python': 0.09; '__future__': 0.09; 'ide': 0.09; 'imports': 0.09; 'interpreter,': 0.09; 'pep': 0.09; 'subject:module': 0.09; 'cc:addr:python-list': 0.10; '328': 0.16; 'calendar': 0.16; 'modules,': 0.16; 'wing': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'pfxlen:0': 0.17; 'module': 0.19; 'sort': 0.21; 'import': 0.21; '2.x': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'absolute': 0.23; 'thus': 0.24; 'script': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; '(most': 0.27; 'module.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'piece': 0.29; 'searches': 0.29; 'included': 0.29; 'skip:& 10': 0.29; 'this.': 0.29; 'skip:& 30': 0.30; 'code': 0.31; 'problem.': 0.32; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'print': 0.32; 'traceback': 0.33; 'weeks': 0.33; 'skip:& 20': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'problem,': 0.35; 'there': 0.35; 'except': 0.36; 'thank': 0.36; 'bad': 0.37; 'resolve': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'instead': 0.39; 'skip:" 10': 0.40; 'your': 0.60; 'leading': 0.61; 'different': 0.63; 'due': 0.66; '8bit%:24': 0.84; 'sender:addr:chris': 0.84; 'to:addr:bigpond.com': 0.84; 'url:rebertia': 0.84; 'phil': 0.91; 'adventures': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ZOFBcfotMxyaue4H8KmWcWuDq4lZZJSxwDwymrVLgJk=; b=dbNOSOz87lgwieD7Tiur9Nb0rNutzeGS4PFwiPLTlytTj0iIKkBcgMBWU0+9Gp48cv 1WR/W0/+nQ/NxAfQgWnlGdwmiBC1AdkCvg1j2JiGePQlrK1e0QmnZfv+aagPbWMdfbfj H2gjS83qaSjWcqHQZE7Lzz29hg5ppJgT0pcd8=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=ZOFBcfotMxyaue4H8KmWcWuDq4lZZJSxwDwymrVLgJk=; b=EU0DY8G4NsEQEHD5h6NPvDMg/WM3HaqDlzmdZ8pKoi6Ysu5fw3M6yt971pL6569Ys8 u6adte+OFL38EXN7RfENpH0mElKD1hUGMWGkMYKeNC0dm2qYzQc0UpqyP2oGUx/6kv1F BREqYV8c9BokYKCt442woGI37KjsrOB1cpNlfzcz9AupBZtYtMvSRM3M9BdGMCNZb95H af05jgFa9YdhP/RjCg3d44CMVr5qCPxfWcrHC0Wv3Gl7mxNCn94ajlt/inF5u31f7iEs cMPboez+PuuO7mhrp0JNUr+dJrV8Tjlg2Jg1m2uL+m11mfRInKJrJFDNGyCltf+mOGsi X4UA==
MIME-Version 1.0
X-Received by 10.50.56.139 with SMTP id a11mr5373734igq.86.1361090365911; Sun, 17 Feb 2013 00:39:25 -0800 (PST)
Sender chris@rebertia.com
In-Reply-To <51208B03.2070404@bigpond.com>
References <51208B03.2070404@bigpond.com>
Date Sun, 17 Feb 2013 00:39:25 -0800
X-Google-Sender-Auth hlySg0H2Zu3u78xf_hdySZU_0i0
Subject Re: Calendar module question
From Chris Rebert <clp2@rebertia.com>
To Phil <phil_lor@bigpond.com>
Content-Type multipart/alternative; boundary=f46d0401f449c4730204d5e78b93
X-Gm-Message-State ALoCoQn642cVMBVx+hDdSTH9tZMbTdbwCVBn+EYrmP/CRhx0wpUjCHOiudjV4bhTbWXTmCSsshHu
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1885.1361090374.2939.python-list@python.org> (permalink)
Lines 88
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361090374 news.xs4all.nl 6947 [2001:888:2000:d::a6]:39525
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39019

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Saturday, February 16, 2013, Phil wrote:

> Thank you for reading this.
>
> My adventures with Python have just begun and during the few weeks I have
> tried many IDEs. The following piece of code fails under all IDEs, and the
> interpreter, except under the Wing IDE.
>
> Why would this code work under the Wing IDE and nowhere else? Could there
> be a different calendar module included with Wing?
>
> import calendar
>
> cal = calendar.prcal(2013)
> print cal
>
> Traceback (most recent call last):
>   File "calendar.py", line 1, in <module>
>     import calendar
>   File "/home/phil/calendar.py", line 3, in <module>
>     cal = calendar.prcal(2013)
> AttributeError: 'module' object has no attribute 'prcal'
>

You named your own script file "calendar.py". As a result, when you
did `import calendar`, due to the way Python 2.x searches for modules, it
imports your file instead of the `calendar` module in the standard library,
thus leading to the above exception. Because of this sort of problem, it
is/was considered bad practice to give a module/package the same name as
any std lib module.

However, if you are running a recent-ish version of Python, adding `from
__future__ import absolute_import` may resolve the problem. See PEP 328 for
details. Absolute imports were thankfully made the default in Python 3.


-- 
Cheers,
Chris
--
http://rebertia.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Calendar module question Chris Rebert <clp2@rebertia.com> - 2013-02-17 00:39 -0800

csiph-web