News for hackers. Stuff that matters.
Re:Python command line oneliners by pgorla on Wednesday February 20, 2013 @07:53AM (#5250132)
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
Re:Python command line oneliners by e12e on Wednesday February 20, 2013 @10:57AM (#5251118)
If 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__.'
Re:Python command line oneliners by cabalamat on Wednesday February 20, 2013 @08:55AM (#5250391)
You could also do this:

    grep -n __main__ *.py|grep __name__
which turns up few false positives.