Created
October 20, 2020 14:58
-
-
Save davidszotten/bceffbab7e5241047536749da6609ac4 to your computer and use it in GitHub Desktop.
python filename to module syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
def main(): | |
try: | |
filename = sys.argv[1] | |
except IndexError: | |
filename = '' | |
if filename.startswith('src/'): | |
filename = filename[4:] | |
print(filename.replace('.py', '').replace('/', '.')) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment