![]() |
"compiler" constants
New to Python. Have what I hope is a simple question. I realize Python is interpreted, but I was wondering if there is something in Python equivalent to "compiler constants". To illustrate with a very simple example, suppose I have a function: Code:
def MyFunc(x)Can I assign constant values to "a" "b" and "c" and have the interpreter literally replace all occurrences with the numerical values? |
Re: "compiler" constants
Quote:
I can simply assign values to variables a, b, and c: a = 2 b = 3 c = 1 ... and somehow when I pass MyFunc(x) to the library function as a parameter, it works. It had not expected it to. Does anybody know how this works "under the hood" ? |
Re: "compiler" constants
As you've found out, there are no such things as constants in Python.
There are other oddities that people used to other languages find weird at first. No such thing as private variables in a class or module. Just about everything happens to be a variable of some kind. No enums (though there are neat tricks to simulate enums). For fun, you can also define functions inside other functions: Code:
>>> def some_fn():Code:
>>> def fn(): |
Re: "compiler" constants
Quote:
|
| All times are GMT -5. The time now is 19:50. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi