module alias in import statement

Rustom Mody rustompmody at gmail.com
Tue Apr 5 00:27:03 EDT 2016


On Tuesday, April 5, 2016 at 9:53:30 AM UTC+5:30, Chris Angelico wrote:
> On Tue, Apr 5, 2016 at 2:08 PM, Rustom Mody  wrote:
> >> 'import tk.ttk' looks for 'tk' in sys.modules, does not find it, looks
> >> for a module named 'tk' on disk, does not find it, and says so.
> >
> > A well-known quote comes to mind:
> >
> > | There are only two hard things in Computer Science: cache invalidation and
> > | naming things.
> >
> > eg. http://martinfowler.com/bliki/TwoHardThings.html
> >
> > particularly since this seems to be in both categories :-)
> 
> sys.modules isn't really a cache in that sense, though. The "hard
> problem" of cache invalidation comes from the fundamental assumption
> that a cache hit should be semantically identical to a cache miss;

Following looks like a cache miss to me (certainly did to the OP):

On Monday, April 4, 2016 at 9:01:41 PM UTC+5:30, ast wrote:
> hello
> 
> >>> import tkinter as tk
> >>> import tk.ttk as ttk
> 
> Traceback (most recent call last):
>   File "<pyshell#3>", line 1, in <module>
>     import tk.ttk as ttk
> ImportError: No module named 'tk'
> 



More information about the Python-list mailing list