Silly (maybe) question re imported module(s)

Alan Gauld learn2program at gmail.com
Fri May 19 18:49:42 EDT 2023


On 19/05/2023 19:46, Grizzy Adams wrote:

> Tried that
> ================ RESTART: D:\Shades\Tools\Python\Temp\cube.py ================
>>>> cubes()
> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in <module>
>     cubes()
> TypeError: 'list' object is not callable

Ah, now I understand. cubes is a literal list defined in the module.


> But that was spot on, thanks 
> 
>>>> import cube
>>>> cube.cubes
> [0, 1, 8, 27, 64, 125, 216, 343, 512, 729]

Glad to help.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list