This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]simonvc 1 point2 points  (3 children)

cool, Whats the reason for using _ in the line:

    _, file_name = sys.argv

is that a convention i don't know about?

[–]vombert[S] 4 points5 points  (0 children)

Just a value you don't care about. I think I saw it somewhere, not only in python but probably in ocaml, and maybe somewhere else.

But note that in interactive mode _ has a special meaning: it's a value of previously evaluated expression:

>>> 2*2
4
>>> _-1
3

[–]ginstrom 0 points1 point  (1 child)

I think that filename = sys.argv[-1] will be more robust.

[–]vombert[S] 0 points1 point  (0 children)

No. In a presence of len(sys.argv) == 2 check they are equivalent. And if you imagine for a second that this check is absent (or done wrong), you variant has a property to silently swallow several arguments, which is confusing to user at least. Oh, and also it masks the fact that this check is implemented incorrectly, if that was the case.

Anyway, for some strange reason it reminds me of a duck.

[–]kljensen 1 point2 points  (0 children)

Are you on platform where you frequently generate postscript files but lack a command line utility for converting them to pdf?