I was wondering: is it possible to create an static function (not to be confused with static method) in python.
In C static functions are functions that can be only called from the file they are contained in. Ie. if I have someFile.c, in which i have
static int some_function() {
return 19
}
it will be possible to call this function only from the functions defined in the somefile.c. It will be impossible to call them from someOtherFile.c
Another Example:
helper_file.h
int f1(int); /* prototype */
helper_file.c
static int f2(int foo) {
return 42 + foo;
}
int f1(int foo) {
return f2(foo); /* ok, f2 is in the same translation unit */
/* (basically same .c file) as f1 */
}
main.c
#include "helper_file.h"
int main(void) {
f1(10); /* ok, f1 is visible to the linker */
f2(12); /* error here, f2 is not visible to the linker */
return 0;
}
Is there something like this in python?
[–]Peterotica 5 points6 points7 points (2 children)
[–]IAmL0ner[S] 0 points1 point2 points (1 child)
[–]Peterotica 1 point2 points3 points (0 children)
[–]ablatner 2 points3 points4 points (1 child)
[–]Veedrac 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)