Issue
My work folder structure is as below,
.
├── hello_darwin.py
├── hello_linux.py
├── hello.py
└── hello_windows.py
hello.py
contains common functions, while others contains platform specific code or function, when my module user imports
from hello import common_function, spec_function
i need spec_function must be platform specific code, where spec_funtion
name is masked to its module user.Is there any builting functions to do it or is there any other ways for this ?
Solution
There is the platform module:
import platform
if platform.system().lower().startswith('win'):
# import windows specific modules
elif platform.system().lower().startswith('lin'):
# import linux specific modules
elif platform.system().lower().startswith('dar'):
# import ...
Answered By - Maurice Meyer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.