an
saurus
tags:
context-menu
python
urllib2
send-to
views:
657
answers:
2
+2
Q:
Accepting File Argument in Python (from Send To context menu)
+1
A:
import sys for arg in sys.argv: print arg
Loïc Wolff
2009-01-01 22:56:55
Exactly what I was looking for. Thanks for the code!
Salty
2009-01-01 23:05:28
+5
A:
Find out what the dragged file was:
http://docs.python.org/library/sys.html#sys.argv
Open it:
http://docs.python.org/library/functions.html#open
Read it in:
http://docs.python.org/library/stdtypes.html#file.read
Post it:
http://docs.python.org/library/urllib2.html#urllib2.urlopen
hop
2009-01-01 22:57:47
actually, i'm no windows user and thus not entirely sure the file ends up in argv[1], but it probably does.
hop
2009-01-01 23:02:34
Perfect. Thanks so much for the links. This'll be a breeze now :)
Salty
2009-01-01 23:04:57
related questions
Programmatically talking to a Serial Port in OS X or Linux
Best ways to teach a beginner to program?
Calling a Function From a String With the Function's Name in Python
An executable Python app
Text Editor For Linux (Besides Vi)?
What Hosting Service is best for Django applications?
File size differences after copying a file to a server vía FTP
Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each?
Python: What OS am I running on?
How do I make a menu in python that does not require the user to press (enter) to make a selection?
How do you express binary literals in Python?
What is the most efficient graph data structure in Python?
Adding a Method to an Existing Object
How to learn Python: Good Example Code?
How do I use Python's itertools.groupby()?
Python and MySQL
Class views in Django
Is there an IDE that provides code completion for Python
Using 'in' to match an attribute of Python objects in an array
cx_Oracle - what is the best way to iterate over a result set?
cx_Oracle - How do I access Oracle from Python?
Continuous Integration System for a Python Codebase
Get a preview jpeg of a pdf on windows?
How can I find the full path to a font from its display name on a Mac?
XML Processing in Python