This is itching at me, too.

On Fri, 6 Jan 2006, John Corry wrote:

> Can anyone understand or tell me why this works but the following code does
> not:-
> 
> import win32api
> filename = "testprint.txt"
> fileobj=open (filename, "w")
> fileobj.write ("This is a test")
> fileobj.close()
> win32api.ShellExecute (
>   0,
>   "print",
>   filename,
>   None,
>   ".",
>   0
> )

I'm wondering if ShellExecute needs a full path to find it under W98.

Try this; add to the top of your code:

import os.path

and change your ShellExecute to this:

win32api.ShellExecute (
  0,
  "print",
  os.path.abspath(filename),
  None,
  ".",
  0
)


I have no idea if this will work; and the error message you're getting,
 
> The code above gives me the error: (31, 'ShellExecute', 'A device attached
> to the system is not functioning.') 

doesn't seem to indicate it, but it's one less thing.

I'd love to know the answer when you get it.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to