[Tutor] drag-and-drop argument passing

Pijus Virketis virketis@post.harvard.edu
Sun, 30 Jun 2002 23:05:08 +0300


<HTML><HEAD>
<BASEFONT FACE=3D"Arial" SIZE=3D"2" COLOR=3D"#000000">
</HEAD>
<BODY>
<div>Danny,</div>
<div> </div>
<div>&gt; PATHEXT environmental variable controls if Windows=
 thinks some file</div>
<div>&gt; is executable or not, so perhaps this might have=
 something to do</div>
<div>&gt; with things.</div>
<div> </div>
<div>Setting PATHEXT does not do the trick. However, I turned my=
 script into an .exe with py2exe, and - voila - I could=
 drag-and-drop anything I pleased on it. So, I guess that's how=
 one can go about </div>
<div>it.:) The arguments get passed on as you might expect, with=
 the sys.argv[] containing the paths to all the files that were=
 dropped.</div>
<div> </div>
<div>Now, there is only one thing left in my way, but it is very=
 vexing. I don't know how to generate raw strings on the fly. For=
 example: this path would choke my script, because &quot;\f&quot;=
 is a token:</div>
<div> </div>
<div>&gt;&gt;&gt; &quot;c:\ftp\test.txt&quot;</div>
<div>'c:\x0ctp\test.txt'</div>
<div>&nbsp;</div>
<div>Interactively, I can get around this by making it=
 raw:</div>
<div> </div>
<div>&gt;&gt;&gt; r&quot;c:\ftp\test.txt&quot;</div>
<div>'c:\\ftp\\test.txt'</div>
<div> </div>
<div>But how do I turn a string in a list, like sys.argv[], into=
 a raw string? Is there a conversion function between the two or=
 something?</div>
<div>Then, I could do (pseudocode):</div>
<div> </div>
<div>for path in sys.argv[1:]:</div>
<div>&nbsp;&nbsp;&nbsp; make_raw(path)</div>
<div> </div>
<div>Thanks,</div>
<div> </div>
<div>Pijus</div>
<div>-- </div>
<div>&quot;Anyone attempting to generate random numbers by=
 deterministic means is, of course, living in a state of=
 sin.&quot; -- John Von Neumann</div>
</body></html>