when typed in console or editor and run with F5 (which saves before it can run)
But sometimes saved work (albeit small) when imported does not work any longer
import mymodule
On 19 May 2023, at 07:44, Grizzy Adams via Python-list <[email protected]> wrote:
Morning All
I'm working through the tutorial and running / saving work that I wish to keep
and build on, most times I can save and (re)import later with no difference to
when typed in console or editor and run with F5 (which saves before it can run)
But sometimes saved work (albeit small) when imported does not work any longer
I assume I have missed something, any pointers to what/how/why please
--
https://mail.python.org/mailman/listinfo/python-list
On 19 May 2023, at 07:44, Grizzy Adams via Python-list <[email protected]> wrote:
Morning All
I'm working through the tutorial and running / saving work that I wish to keep
and build on, most times I can save and (re)import later with no difference to
when typed in console or editor and run with F5 (which saves before it can run)
But sometimes saved work (albeit small) when imported does not work any longer
I assume I have missed something, any pointers to what/how/why please
reimport is not 100% reliable, in simple cases it will work, but as your
code gets more complex it can break.
I rarely use reimport. Usually just exit python and start again.
If you are working on scripts then just run them from the Terminal
will work well with any need to use reimport.
Looks like you are using IDLE?
Yes
From consol
Traceback (most recent call last):import cube
cubes
File "<pyshell#1>", line 1, in <module>
cubes
NameError: name 'cubes' is not defined
File->Open mymodule.module into the editor, then F5 to run all is well
================ RESTART: D:\Shades\Tools\Python\Temp\cube.py ================
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]cubes
Tried that
================ RESTART: D:\Shades\Tools\Python\Temp\cube.py ================
Traceback (most recent call last):cubes()
File "<pyshell#0>", line 1, in <module>
cubes()
TypeError: 'list' object is not callable
But that was spot on, thanks
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]import cube
cube.cubes
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (3 / 13) |
| Uptime: | 158:11:12 |
| Calls: | 12,094 |
| Calls today: | 2 |
| Files: | 15,000 |
| Messages: | 6,517,755 |