Re: A problem with opening a file -- again

2020-11-30 Thread Chris Angelico
On Tue, Dec 1, 2020 at 5:36 AM Dennis Lee Bieber wrote: > Off-hand, since you aren't explicitly using "del lf" it means that > __del__() is being called during the process shutdown. Thing is, there is > no guarantee during shutdown of when things are deleted. There is a faint > possibility

Re: A problem with opening a file -- again

2020-11-29 Thread Eryk Sun
On 11/29/20, Chris Angelico wrote: > > This seems like a really REALLY bad idea. You're putting a lot of work > into your __del__ function, and that's not getting called until > everything's shutting down. (Also, xrange doesn't exist, hence the > "exception ignored" thing.) > > Avoid putting this

Re: A problem with opening a file -- again

2020-11-29 Thread dn via Python-list
On 30/11/2020 10:36, Gabor Urban wrote: Hi guys, I tried to solve the problem once again. I have inserted some print statements the check the variables. The actual code (naplo.py) is copy-pasted here: Thanks = helpful +1 @Chris' response! Meantime, what happens if you start python, and ent

Re: A problem with opening a file -- again

2020-11-29 Thread Chris Angelico
On Mon, Nov 30, 2020 at 8:37 AM Gabor Urban wrote: > class Naplo: > def __del__(self): > if self.sor != 0: > if self.start: > trc = open(self.logNev,self.startMode) > else: > trc = open(self.logNev,self.mode) > for idx

A problem with opening a file -- again

2020-11-29 Thread Gabor Urban
Hi guys, I tried to solve the problem once again. I have inserted some print statements the check the variables. The actual code (naplo.py) is copy-pasted here: class Naplo: def __init__(self, pNeve, pMeret, pMode = 'a'): self.logNev = pNeve self.meret = pMeret

Re: A problem with opening a file

2020-11-29 Thread Dieter Maurer
Gabor Urban wrote at 2020-11-29 08:56 +0100: >I am facing an issue I was not able to solve yet. I have a class saving >messages to a file. The relevant code is: > > > >import OS >import sys > >class MxClass: > >def __init__(self, fName, fMode,): >self.fileName = fName >s

Re: A problem with opening a file

2020-11-29 Thread dn via Python-list
On 29/11/2020 20:56, Gabor Urban wrote: Hi, I am facing an issue I was not able to solve yet. I have a class saving messages to a file. The relevant code is: import OS if you're wanting the Python Standard Library, this should not be in upper-case import sys are these two imports

A problem with opening a file

2020-11-28 Thread Gabor Urban
Hi, I am facing an issue I was not able to solve yet. I have a class saving messages to a file. The relevant code is: import OS import sys class MxClass: def __init__(self, fName, fMode,): self.fileName = fName self.fileMode = fMode def writeMetho

Re: Permission denied when opening a file that was created concurrently by os.rename (Windows)

2015-04-05 Thread Terry Reedy
On 4/5/2015 1:45 PM, Alexey Izbyshev wrote: Hello! I've hit a strange problem that I reduced to the following test case: * Run several python processes in parallel that spin in the following loop: while True: if os.path.isfile(fname): with open(fname, 'rb') as f: f.read()

Re: Permission denied when opening a file that was created concurrently by os.rename (Windows)

2015-04-05 Thread Dave Angel
On 04/05/2015 01:45 PM, Alexey Izbyshev wrote: Hello! I've hit a strange problem that I reduced to the following test case: * Run several python processes in parallel that spin in the following loop: while True: if os.path.isfile(fname): with open(fname, 'rb') as f: f.read()

Re: Permission denied when opening a file that was created concurrently by os.rename (Windows)

2015-04-05 Thread Chris Angelico
On Mon, Apr 6, 2015 at 3:45 AM, Alexey Izbyshev wrote: > The test case is attached, the main file is test.bat. Python is expected to > be in PATH. Stderr of readers is redirected to *.log. You may need to run > several times to hit the issue. You have an interesting-looking problem, but the attac

Permission denied when opening a file that was created concurrently by os.rename (Windows)

2015-04-05 Thread Alexey Izbyshev
Hello! I've hit a strange problem that I reduced to the following test case: * Run several python processes in parallel that spin in the following loop: while True: if os.path.isfile(fname): with open(fname, 'rb') as f: f.read() break * Then, run another process that creates a t

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

opening a file

2011-06-19 Thread Tim Hanson
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') Can't I work with files using Unix expressions? -- http://mail.

Re: ipython problem in opening a file

2010-07-09 Thread Youngung Jeong
Thanks a lot! Youngung On Fri, Jul 9, 2010 at 10:17 PM, Eli Bendersky wrote: > On Fri, Jul 9, 2010 at 16:07, Youngung Jeong > wrote: > > Thank you for your kindness. > > I found you're right. It's running in that folder. > > What should I do for making this work? > > Could you please tell me

Re: ipython problem in opening a file

2010-07-09 Thread Eli Bendersky
On Fri, Jul 9, 2010 at 16:07, Youngung Jeong wrote: > Thank you for your kindness. > I found you're right. It's running in that folder. > What should I do for making this work? > Could you please tell me a bit more... > > Youngung You can change the "current directory" ipython executes in, by eit

Re: ipython problem in opening a file

2010-07-09 Thread Eli Bendersky
> One of the many things I tried, is as below. > > * > > > f=open('od.txt','w') > --- > IOError                                   Traceback (most recent call > last) > > C:\Window

ipython problem in opening a file

2010-07-09 Thread youngung
Hello pythoners! I just dived into ipython since I'd like to make use of matplotlib. Over the trials, I came across a problem. One of the scripts that I have is not working with ipython, while it has been and still is working well with Python GUI. The problem is, even though I have the file in th

Re: I run into a problem in opening a file in Python

2010-06-18 Thread Terry Reedy
On 6/18/2010 4:26 PM, Justin Park wrote: The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, beca

Re: I run into a problem in opening a file in Python

2010-06-18 Thread D'Arcy J.M. Cain
On Fri, 18 Jun 2010 17:22:00 -0400 "D'Arcy J.M. Cain" wrote: > By the way, your email address doesn't work. I get a "relay access > denied" message. Ignore that. It was a local problem that I fixed before sending but forgot to remove this paragraph. -- D'Arcy J.M. Cain | Democracy i

Re: I run into a problem in opening a file in Python

2010-06-18 Thread D'Arcy J.M. Cain
On Fri, 18 Jun 2010 15:26:14 -0500 Justin Park wrote: > But when I change the file access mode into "a", > it returns an error message of "IOError: [Errno 9] Bad file descriptor. " Exact test script and traceback please. I would like to see what line gives you the error. Are you trying to read

Re: I run into a problem in opening a file in Python

2010-06-18 Thread MRAB
Justin Park wrote: The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, because I can do for line

Re: I run into a problem in opening a file in Python

2010-06-18 Thread Ian Kelly
On Fri, Jun 18, 2010 at 2:26 PM, Justin Park wrote: > But when I change the file access mode into "a", > it returns an error message of "IOError: [Errno 9] Bad file descriptor. " > > What have I done wrong? "a" is for appending only. You can't read from a file opened in that mode. If you want t

I run into a problem in opening a file in Python

2010-06-18 Thread Justin Park
The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using >>> fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, because I can do >>> for line in fd: ...

Re: Presumably an import is no faster or slower than opening a file?

2008-04-07 Thread tinnews
Paul McGuire <[EMAIL PROTECTED]> wrote: > On Apr 6, 8:41 am, [EMAIL PROTECTED] wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lots >

Re: Presumably an import is no faster or slower than opening a file?

2008-04-06 Thread Paul McGuire
On Apr 6, 8:41 am, [EMAIL PROTECTED] wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an eas

Re: Presumably an import is no faster or slower than opening a file?

2008-04-06 Thread tinnews
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 6 avr, 15:41, [EMAIL PROTECTED] wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lot

Re: Presumably an import is no faster or slower than opening a file?

2008-04-06 Thread [EMAIL PROTECTED]
On 6 avr, 15:41, [EMAIL PROTECTED] wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an easy

Presumably an import is no faster or slower than opening a file?

2008-04-06 Thread tinnews
I'm trying to minimise the overheads of a small Python utility, I'm not really too fussed about how fast it is but I would like to minimise its loading effect on the system as it could be called lots of times (and, no, I don't think there's an easy way of keeping it running and using the same copy

Re: Problem with Image: Opening a file

2008-02-05 Thread mcl
On Feb 4, 10:43 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Feb 4, 6:51 pm,mcl<[EMAIL PROTECTED]> wrote: > > > > > I am obviously doing something stupid or not understanding the > > difference between HTML file references and python script file > > references. > > > I am trying to create a

Re: Problem with Image: Opening a file

2008-02-04 Thread Graham Dumpleton
On Feb 4, 6:51 pm, mcl <[EMAIL PROTECTED]> wrote: > I am obviously doing something stupid or not understanding the > difference between HTML file references and python script file > references. > > I am trying to create a thumbnail of an existing .jpg file. It is in > the directory 'temp', which is

Problem with Image: Opening a file

2008-02-03 Thread mcl
I am obviously doing something stupid or not understanding the difference between HTML file references and python script file references. I am trying to create a thumbnail of an existing .jpg file. It is in the directory 'temp', which is below my script I can display the file with , but Image.ope

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Georg Brandl
Claudio Grondi wrote: > Tim Peters wrote: >> [Claudio Grondi] >> >>> Here an example of what I mean >>> (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte >>> large file): >>> >>> >>> f = file('veryBigFile.dat','r') >>> >>> f = file('veryBigFile.dat','r+') >>> >>> Traceback (m

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Claudio Grondi
Fredrik Lundh wrote: > Tim Peters wrote: > > >>>Traceback (most recent call last): >>> File "", line 1, in -toplevel- >>> f = file('veryBigFile.dat','r+') >>>IOError: [Errno 2] No such file or directory: 'veryBigFile.dat' >>> >>>Is it a BUG or a FEATURE? >> >>Assuming the file exists and is

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Fredrik Lundh
Tim Peters wrote: >> Traceback (most recent call last): >>File "", line 1, in -toplevel- >> f = file('veryBigFile.dat','r+') >> IOError: [Errno 2] No such file or directory: 'veryBigFile.dat' >> >> Is it a BUG or a FEATURE? > > Assuming the file exists and isn't read-only, I bet it's a Wi

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Claudio Grondi
Tim Peters wrote: > [Claudio Grondi] > >> Here an example of what I mean >> (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte >> large file): >> >> >>> f = file('veryBigFile.dat','r') >> >>> f = file('veryBigFile.dat','r+') >> >> Traceback (most recent call last): >>File

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Fredrik Lundh
Tim Peters wrote: > Assuming the file exists and isn't read-only, I bet it's a Windows > bug, and that if you open in binary mode ("r+b") instead I bet it goes > away (this wouldn't be the first large-file text-mode Windows bug). > dir bigfile.dat 2006-08-28 11:46 5 000 000 000 bigfile.dat

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Tim Peters
[Claudio Grondi] > Here an example of what I mean > (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte > large file): > > >>> f = file('veryBigFile.dat','r') > >>> f = file('veryBigFile.dat','r+') > > Traceback (most recent call last): >File "", line 1, in -toplevel- >

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Claudio Grondi
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Claudio Grondi wrote: > > >>Here an example of what I mean >>(Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte >>large file): >> >> >>> f = file('veryBigFile.dat','r') >> >>> f = file('veryBigFile.dat','r+') > > > Yo

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Claudio Grondi wrote: > > Here an example of what I mean > (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte > large file): > > >>> f = file('veryBigFile.dat','r') > >>> f = file('veryBigFile.dat','r+') You mention the file size and gave a "speaking

Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Claudio Grondi
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): >>> f = file('veryBigFile.dat','r') >>> f = file('veryBigFile.dat','r+') Traceback (most recent call last): File "", line 1, in -toplevel- f = file('veryBigFile.dat','r+')

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

Opening a file with system default application

2006-06-23 Thread [EMAIL PROTECTED]
I'm writing a GUI application in Jython which takes a database text file and performs some operations on the data, finally spitting out a group of CSV files. I generate a log file and several CSV files and I thought it would be helpful if I could add a button the user could click on to automatical

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

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

2005-12-07 Thread spike grobstein
So, I've got this project I'm working on where the app defines various classes that are subclassed by module packages that act like plugins... 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 d

Opening a file in Python using windows.

2004-12-04 Thread Ishwor
On 3 Dec 2004 08:38:37 -0800, ed <[EMAIL PROTECTED]> wrote: > I do have permission toa ccess the file as that file is careted and read my > me. > I have read/write access to that location. regards That shouldn't be really hard. :) okay imagine you have a file called test.txt in C:\Python24\ now