4 ms·
Also, the last line to check for 'one-liners' won't get them all: $ grep -r "if __name__ == '__main__'" /path/to/lib Should be: $ grep -r "if __name__
by pgorla 14y ago
Also, the last line to check for 'one-liners' won't get them all:
$ grep -r "if __name__ == '__main__'" /path/to/lib
Should be:
$ grep -r "if __name__ == ['\"]__main__['\"]" /path/to/lib
- cabalamat 14y agoYou could also do this: grep -n __main__ *.py|grep __name__ which turns up few false positives.
- e12e 14y agoIf you're not storing that somewhere, but rather typing it, I find you're often better off by being a little more forgiving, eg: $ grep -r "if __name__ == .__main__." /path/to/lib or even: $ grep -Er 'if\W__name__\W==\W.__main__.'