Re: opening a file

2011-06-20 Thread Hans Mulder
On 20/06/11 08:14:14, Florencio Cano wrote: This works: infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') This doesn't: infile=open('~/prog/py_modules/this_is_a_test','r') Can't I work with files using Unix expressions? You can use the glob module: http://docs.python.org/library/glob

Re: opening a file

2011-06-20 Thread Nobody
On Sun, 19 Jun 2011 23:00:38 -0700, Tim Hanson wrote: > This works: > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > This doesn't: > infile=open('~/prog/py_modules/this_is_a_test','r') > > Can't I work with files using Unix expressions? The argument is treated literally, just li

Re: opening a file

2011-06-19 Thread Chris Rebert
On Sun, Jun 19, 2011 at 11:00 PM, Tim Hanson wrote: > Using linux and Python 2.6, learning how to work with files from a Windows > oriented textbook: > > This works: > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > This doesn't: > infile=open('~/prog/py_modules/this_is_a_test','r')

Re: opening a file

2011-06-19 Thread Paul Scott
On Mon, 2011-06-20 at 08:14 +0200, Florencio Cano wrote: > > This works: > > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > > > This doesn't: > > infile=open('~/prog/py_modules/this_is_a_test','r') > > > > Can't I work with files using Unix expressions? > > You can use the glob mod

Re: opening a file

2011-06-19 Thread Florencio Cano
> This works: > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > This doesn't: > infile=open('~/prog/py_modules/this_is_a_test','r') > > Can't I work with files using Unix expressions? You can use the glob module: http://docs.python.org/library/glob.html#module-glob -- http://mail.p

Re: Opening a file with system default application

2006-06-23 Thread BartlebyScrivener
>>> That also pops up a command shell window, which may not be >>> desirable. On Windows, there is >>> os.startfile("someknown.type") Ack. You're right. I get them mixed up. And os.startfile is Windows only. Sorry. rd -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening a file with system default application

2006-06-23 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >In <[EMAIL PROTECTED]>, >BartlebyScrivener wrote: > It would probably break like mad under *nix >> >> I bet it would work the same way on linux or os x; it's the equivalent >> of double-clicking on the file.

Re: Opening a file with system default application

2006-06-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, BartlebyScrivener wrote: >>> It would probably break like mad under *nix > > I bet it would work the same way on linux or os x; it's the equivalent > of double-clicking on the file. No it doesn't work. Double clicking is not an OS thing but a a GUI thing. Ciao,

Re: Opening a file with system default application

2006-06-23 Thread BartlebyScrivener
>> It would probably break like mad under *nix I bet it would work the same way on linux or os x; it's the equivalent of double-clicking on the file. rd -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening a file with system default application

2006-06-23 Thread tac-tics
BartlebyScrivener wrote: > don't know Jython, but in Python, I think you want: > > import os > > os.system('mytextfile.txt') > > Whatever file you reference should open in the application associated > with it. At least that's the way it works on Win XP > > rd I didn't think about that. It would pr

Re: Opening a file with system default application

2006-06-23 Thread BartlebyScrivener
don't know Jython, but in Python, I think you want: import os os.system('mytextfile.txt') Whatever file you reference should open in the application associated with it. At least that's the way it works on Win XP rd -- http://mail.python.org/mailman/listinfo/python-list

Re: opening a file using a relative path from a subclass in a package

2005-12-07 Thread Fredrik Lundh
"spike grobstein" write: > I understand why it wasn't working and it makes sense based on the > structure of namespaces that python defines, however, I'm just > surprised that there isn't some kind of built-in facility for dealing > with these types of things. > > Module packages are a spectacular

Re: opening a file using a relative path from a subclass in a package

2005-12-07 Thread spike grobstein
I understand why it wasn't working and it makes sense based on the structure of namespaces that python defines, however, I'm just surprised that there isn't some kind of built-in facility for dealing with these types of things. Module packages are a spectacular idea, it is just kinda easy to get c

Re: opening a file using a relative path from a subclass in a package

2005-12-07 Thread Heiko Wundram
spike grobstein wrote: > so, since python supports module packages like it does, you'd think > that it would have ways of making add-on or extension modules to be > more self contained. Errm... You're not quite understanding what the problem is about. A class is just an object. A class object may

Re: opening a file using a relative path from a subclass in a package

2005-12-07 Thread spike grobstein
oh, wow. that works!!! thanks for the help! so, since python supports module packages like it does, you'd think that it would have ways of making add-on or extension modules to be more self contained. Thanks, again! -- http://mail.python.org/mailman/listinfo/python-list

Re: opening a file using a relative path from a subclass in a package

2005-12-07 Thread Heiko Wundram
spike grobstein wrote: > I'd like the packages to define a file path for supporting files > (graphics, etc) that are stored inside the package. The problem is that > the superclass's definition (stored elsewhere) has all of the code for > actually opening the files, so when I use the > os.path.dirn