How to run script from interpreter?

Chris Angelico rosuav at gmail.com
Fri May 30 03:19:00 EDT 2014


On Fri, May 30, 2014 at 4:20 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>> It's on par with creating a file with a name beginning with a
>> hyphen, and then fiddling around with various commands as you try to
>> manipulate it (tip: "rm ./-r" works); programs will happily interpret
>> "-r" as an option rather than a file name, without being concerned that
>> it's technically legal.
>
> I don't see any connection between the two.

-r is a valid file name, just as . is a valid line of input. But with
the rm command, you can't provide it with -r as a file name - you have
to use ./-r or somesuch, because the parser gets to it first. That's
the connection.

ChrisA



More information about the Python-list mailing list