[Tutor] Nearly there
Alan Gauld
alan.gauld at freenet.co.uk
Sat Jan 7 12:51:01 CET 2006
I'm also curious, although not surprised - since this is why I tend not
to try to print using the API!, but another possibility is that Win98
doesn't recognise the dot shortcut for a path.
You may need to fill in the explicit path info:
> win32api.ShellExecute (
> 0,
> "print",
> os.path.abspath(filename),
> None,
> ".", <--- try the full path here too.
> 0
> )
HTH,
Alan G.
----- Original Message -----
From: "Terry Carroll" <carroll at tjc.com>
To: <tutor at python.org>
Sent: Saturday, January 07, 2006 12:23 AM
Subject: Re: [Tutor] Nearly there
> 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.
>
>
>
More information about the Tutor
mailing list