Replies: 7 comments 2 replies
-
Also, if I type this:
I get:
But if I put these 2 lines in a module and import that module, it works! |
Beta Was this translation helpful? Give feedback.
-
When you assign a value to a symbol using |
Beta Was this translation helpful? Give feedback.
-
Ok, I understand for the first example. So const() is more like creating an alias/define? (the documentation is not very clear about that) But I don't understand your second answer:
So it still exists between the 2 calls. So why it can't use it in the next const() definition? |
Beta Was this translation helpful? Give feedback.
-
Mmm, yes and no:
It only fails when used in const()... |
Beta Was this translation helpful? Give feedback.
-
Another strange thing:
I think I will stay away from const() for now ;o) |
Beta Was this translation helpful? Give feedback.
-
_WIDTH = const(256) and later in your code you have def foo(x):
y = x + _WIDTH the bytecode compiler use the number 256 instead of looking up a global variable. Saves time and code. |
Beta Was this translation helpful? Give feedback.
-
Ok, but why does it have to become global? Why not follow the Python object hierarchy? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I found a strange behaviour, probably due to my lack of const() understanding.
If the test.py module contains:
and I try to import this module, I get:
What I did wrong?
Beta Was this translation helpful? Give feedback.
All reactions