Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Launch file in Notepad

Reply
Thread Tools

Launch file in Notepad

 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      05-12-2005
On Thu, 12 May 2005 15:14:09 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Bengt Richter) declaimed
the following in comp.lang.python:


>
> I don't know why MS used backslashes when unix had a perfectly good path syntax
> (not to mention drive letter idiocy). Maybe some legal idiocy, wanting to be
> different to be safe from SCO types?
>

The MS-DOS precursor (and/or CP/M) used "/" to introduce command
line options. This meant, when subdirectories were introduced, they had
to come up with a new separator character.

--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      05-12-2005
Brian van den Broek wrote:

> > I'm trying to lauch Notepad from Python to open a textfile:
> >
> > import os
> > b1="c:\test.txt"
> > os.system('notepad.exe ' + b1)
> >
> > However, the t of test is escaped by the \, resulting in Notepad trying
> > to open "c: est.txt".
> >
> > How do I solve this?

>
> There are several ways, but the preferred solution is to switch the
> slash direction: "c:/test.txt". Python's smart enough to notice its
> running on Windows and do the right thing with the slash.


that's slightly misleading: on the API level, most functions can handle
both kinds of slashes. functions like open(), os.remove(), shutil.copy()
etc. handles either case just fine. and in most cases, this is handled
on the Win API level (or in the C library), not by Python.

however, in this case, the user passes a string to os.system(). that
string is passed *as is* to the command shell (which, in this case,
passes it on to notepad.exe as is).

</F>



 
Reply With Quote
 
 
 
 
Bengt Richter
Guest
Posts: n/a
 
      05-12-2005
On Thu, 12 May 2005 16:30:36 GMT, Dennis Lee Bieber <(E-Mail Removed)> wrote:

>On Thu, 12 May 2005 15:14:09 GMT, (E-Mail Removed) (Bengt Richter) declaimed
>the following in comp.lang.python:
>
>
>>
>> I don't know why MS used backslashes when unix had a perfectly good path syntax
>> (not to mention drive letter idiocy). Maybe some legal idiocy, wanting to be
>> different to be safe from SCO types?
>>

> The MS-DOS precursor (and/or CP/M) used "/" to introduce command
>line options. This meant, when subdirectories were introduced, they had
>to come up with a new separator character.
>

Or overcome some NIH and switch to '-' for command line options?

Regards,
Bengt Richter
 
Reply With Quote
 
Greg Krohn
Guest
Posts: n/a
 
      05-12-2005
George wrote:
> Newbie question:
>
> I'm trying to lauch Notepad from Python to open a textfile:
>
> import os
> b1="c:\test.txt"
> os.system('notepad.exe ' + b1)
>
> However, the t of test is escaped by the \, resulting in Notepad trying
> to open "c: est.txt".
>
> How do I solve this?
>
> (By the way, b1 comes from a command line parameter, so the user enters
> c:\test.txt as command line parameter.)
>
> George


The \t will only be interpreted as TAB if it was entered as part of
your python code. If the \t was entered as a command line arg it will
be interpreted as a \ and a t. For example:


#test.py
import sys
b1 = sys.argv[1]
b2 = "C:\test.txt"
print b1
print b2

will result in this:

C:\>test.py C:\test.txt
C:\test.txt
C: est.txt


-greg
 
Reply With Quote
 
Brian van den Broek
Guest
Posts: n/a
 
      05-12-2005
Fredrik Lundh said unto the world upon 2005-05-12 13:52:
> Brian van den Broek wrote:
>
>
>>>I'm trying to lauch Notepad from Python to open a textfile:
>>>
>>>import os
>>>b1="c:\test.txt"
>>>os.system('notepad.exe ' + b1)
>>>
>>>However, the t of test is escaped by the \, resulting in Notepad trying
>>>to open "c: est.txt".
>>>
>>>How do I solve this?

>>
>>There are several ways, but the preferred solution is to switch the
>>slash direction: "c:/test.txt". Python's smart enough to notice its
>>running on Windows and do the right thing with the slash.

>
>
> that's slightly misleading: on the API level, most functions can handle
> both kinds of slashes. functions like open(), os.remove(), shutil.copy()
> etc. handles either case just fine. and in most cases, this is handled
> on the Win API level (or in the C library), not by Python.
>
> however, in this case, the user passes a string to os.system(). that
> string is passed *as is* to the command shell (which, in this case,
> passes it on to notepad.exe as is).
>
> </F>


Thanks to Fredrik and everyone else who contributed to the thread to
correct my mistake.

Best to all,

Brian vdB

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      05-13-2005
On Thu, 12 May 2005 15:34:39 -0000, Grant Edwards <(E-Mail Removed)>
declaimed the following in comp.lang.python:


> I think the use of forward slashes for command line switches
> was adopted by CP/M from DEC's OSes (e.g. RSX-11). CP/M didn't
> have directories in the beginning, so nobody worried about what
> to use for path separators (DEC used colons, IIRC). DOS was a


I can't speak for the various PDP-11 family, but VMS syntax was:

hardware:[toplevel.nextlevel.ad.infinitum]filename.ext;version

where hardware could be a drive specification or a logical name (only
other OS I've encountered with logical names is AmigaOS, which also
allowed one to specify disks by volume label -- and would prompt the
user to insert volume X into a drive if needed!)

--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      05-13-2005
On 2005-05-13, Dennis Lee Bieber <(E-Mail Removed)> wrote:

> On Thu, 12 May 2005 15:34:39 -0000, Grant Edwards <(E-Mail Removed)>
> declaimed the following in comp.lang.python:
>
>> I think the use of forward slashes for command line switches
>> was adopted by CP/M from DEC's OSes (e.g. RSX-11). CP/M didn't
>> have directories in the beginning, so nobody worried about what
>> to use for path separators (DEC used colons, IIRC). DOS was a

>
> I can't speak for the various PDP-11 family, but VMS syntax was:
>
> hardware:[toplevel.nextlevel.ad.infinitum]filename.ext;version


Ah yes, that's looking familiar. The colon separated the
"logical drive" from the path in brackets, in which the
seperator was a dot. I spent most of my time under VMS running
DECShell, so I used mostly 'normal' Unix path syntax.

> where hardware could be a drive specification or a logical name (only
> other OS I've encountered with logical names is AmigaOS, which also
> allowed one to specify disks by volume label -- and would prompt the
> user to insert volume X into a drive if needed!)


--
Grant Edwards grante Yow! Don't hit me!! I'm in
at the Twilight Zone!!!
visi.com
 
Reply With Quote
 
Roger Upole
Guest
Posts: n/a
 
      05-13-2005

"Dennis Lee Bieber" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Thu, 12 May 2005 15:34:39 -0000, Grant Edwards <(E-Mail Removed)>
> declaimed the following in comp.lang.python:
>
>
>> I think the use of forward slashes for command line switches
>> was adopted by CP/M from DEC's OSes (e.g. RSX-11). CP/M didn't
>> have directories in the beginning, so nobody worried about what
>> to use for path separators (DEC used colons, IIRC). DOS was a

>
> I can't speak for the various PDP-11 family, but VMS syntax was:
>
> hardware:[toplevel.nextlevel.ad.infinitum]filename.ext;version
>


And in a clustered VMS environment, there's also
nodename::hardware:[toplevel.nextlevel.ad.infinitum]filename.ext;version
(somewhat analogous to a UNC path)

Roger

--
This signature was intentionally left blank.
(except it's not, wtf ??????)





----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot launch simple applications (notepad, java) using Apache and PERL(CGI) JDS Perl 4 11-11-2008 08:50 PM
How to open text file (.log, .txt etc) in notepad from aspnet =?Utf-8?B?Uk4gRGFz?= ASP .Net 5 05-23-2008 06:53 AM
how to use io operations with open/save file dialog box in file menu for simple notepad boris Java 1 07-22-2007 04:13 PM
RE: Launch file in Notepad Michael.Coll-Barth@VerizonWireless.com Python 0 05-12-2005 01:52 PM
Cannot launch simple applications (notepad, java) using Apache and PERL(CGI) JDS Perl Misc 3 05-24-2004 06:33 PM



Advertisments