Silly (maybe) question re imported module(s)
Alan Gauld
learn2program at gmail.com
Fri May 19 13:18:35 EDT 2023
On 19/05/2023 13:36, Grizzy Adams wrote:
>> Looks like you are using IDLE?
>
> Yes
>
>
> From consol
>
>>>> import cube
>>>> cubes
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> cubes
> NameError: name 'cubes' is not defined
You imported cube but tried to use cubes. I'm guessing
cubes is defined inside cube so you would need
cube.cubes
> File->Open mymodule.module into the editor, then F5 to run all is well
>
>>>>
> ================ RESTART: D:\Shades\Tools\Python\Temp\cube.py ================
>>>> cubes
> [0, 1, 8, 27, 64, 125, 216, 343, 512, 729]
cubes looks like it should be a function but in that case there
should be parens after it. So I'm not sure how that is working!
I'd expect that you need to do:
import cube
cube.cubes()
--
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