Re: On Java's Interface (the meaning of interface in computer programing)
Don't Feed The Trolls :-) -- http://mail.python.org/mailman/listinfo/python-list
File locking
I'm always disappointed when I find something that Python doesn't handle in a platform independent way. It seems to me that file locking is in that boat. 1. I don't see a way to atomically open a file for writing if and only if it doesn't exist without resorting to os.open and specialized platform O_XXX flags. 2. I don't see a way to atomically open a file for writing and obtain a lock on the file. 3. I don't see a platform independent way to obtain a lock on a file. You have to do something goofy like if sys.platform == win32: import msvcrt else: import fcntl and then similar things to call the correct functions with the correct flags. Please let me know if I'm missing something since they seem like normal file operations that I would hope Python would abstract away. If not, are there any PEPs concerning this for Python3K? Thanks, Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: What about this?
What's more amazing is that anyone would click on the link at all given the increasing number of website that provide hidden content that tries to deliver spyware or viruses just by getting visitors. Jeff Bjoern Schliessmann wrote: new wrote: www.magicoz.com amazing Yeah, it *is* really amazing that someone dares to spam for such an unprofessional homepage. Even too stupid to include a doctype ... Björn -- BOFH excuse #61: not approved by the FCC -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Welfare Part of Capitalism?
Technically, I would call it a manfesto. The manifesto module is probably the most facinating module in Python since it's the only one whose functions consist entirely of doc strings followed by a pass and do no useful work. Jeff Tim Daneliuk wrote: [EMAIL PROTECTED] wrote: This article is dedicated to: SNIP But I am still confused: Is this a statement or an expression? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Doc Error: os.makedirs
Xah Lee wrote: i think the function shouldn't complain if dir already exists. How is a programer to distinguish if the dir already exists, or if there's a problem creating the dir? Of course it should thrown an exception because it was unable to do what it was asked: create a directory. The fact that the directory already exists is irrelevant to the function...it still failed to create the directory. And I have had situations where attempting to create a directory that already exists was an error condition. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Problem building Python on HP-UX
I'm trying to build Python 2.4.1 on HP-UX 11.00 with full tcl/tk IDLE support. So far, I haven't had any luck. I always wind up getting errors of the form: ld: DP relative code in file /ptg/devtools/hppa1.1/pre/lib/libtk8.4.a(tkWindow.o) - shared library must be position independent. Use +z or +Z to recompile. I have tried building tcl/tk without any configure options as well as with --disable-shared and --disable-load but this doesn't help. Anyone seen anything like this or know how to get around it? Jeff -- http://mail.python.org/mailman/listinfo/python-list
HTML/text formatting question
I have a tool that outputs data in either html or text output. Currently I'm writing chucnks like: if html: print 'htmlbody bgcolor=CC' print 'table border=1 bgcolor=FF width=800' print 'trtd colspan=2h2' print 'Differences %s: %s' % (htypestr, lbl1) if html: ... This seems clunky and my next step was going to be to define generic functions which would generate the surrounding html tags only when passed the proper argument. I was wondering if there was a better way to do this with a standard Python library. It looked like formatter might but that it also might be too low-level. Any help is appreciated, Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: On fighting fire with fire...
I was explaining the difference between irony and sarcasm to my daughter just the other day. It was nice of Asad to provide us with such a besutiful example. Not that I'm sure that was his intent... Jeff -- http://mail.python.org/mailman/listinfo/python-list
Something that Perl can do that Python can't?
So here it is: handle unbuffered output from a child process. Here is the child process script (bufcallee.py): import time print 'START' time.sleep(10) print 'STOP' In Perl, I do: open(FILE, python bufcallee.py |); while ($line = FILE) { print LINE: $line; } in which case I get LINE: START followed by a 10 second pause and then LINE: STOP The equivalent in Python: import sys, os FILE = os.popen('python bufcallee.py') for line in FILE: print 'LINE:', line yields a 10 second pause followed by LINE: START LINE: STOP I have tried the subprocess module, the -u on both the original and called script, setting bufsize=0 explicitly but to no avail. I also get the same behavior on Windows and Linux. If anyone can disprove me or show me what I'm doing wrong, it would be appreciated. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Something that Perl can do that Python can't?
Well, I finally managed to solve it myself by looking at some code. The solution in Python is a little non-intuitive but this is how to get it: while 1: line = stdout.readline() if not line: break print 'LINE:', line, If anyone can do it the more Pythonic way with some sort of iteration over stdout, please let me know. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Buffering problem using subprocess module
I am using the subprocess module in 2.4. Here's the fragment: bufcaller.py: import sys, subprocess proc = subprocess.Popen('python bufcallee.py', bufsize=0, shell=True, stdout=subprocess.PIPE) for line in proc.stdout: sys.stdout.write(line) bufcallee.py: import time print 'START' time.sleep(10) print 'STOP' Although the documentation says that the output should be unbuffered (bufsize=0) the program (bufcaller) pauses for 10 seconds and then prints START immediately followed by 'STOP' rather than pausing 10 seconds in between them. Note that I made bufcallee a Python script for ease of the example but in the real-world problem I am trying to solve it is simply an executable. Any ideas? Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Buffering problem using subprocess module
Unfortunatley that doesn't help. Even when callee is started using the -u, I get the same behavior. -- http://mail.python.org/mailman/listinfo/python-list