python
[Python] Two ways to import a module
# Option 1: we have to specify 'sys'
import sys
if len(sys.argv) == 1:
print("No arguments specified")
print("This is the name of the script:", sys.argv[0] )
# Option 2
from sys import argv
if len(argv) == 1:
print("No arguments specified")
print("This is the name of the script:", argv[0] )
Was this helpful?
Similar Posts
- [Python] Different ways to test multiple flags at once in Python
- How to import all coreutils
- Python Measure the execution time of small bits of Python code with the timeit module
- [Python] Get nodeid, module, function name using Pytest request built-in fixture
- [Python] Using inspect.stack() to get module name, path, function name
- How to generate a random number in python using random module
- Join two tuples in python