Recent Events for foo.be MainPageDiary (Blog) Previous Next

2007-05-27 Java vs Python

I don't like to feed useless discussion about comparison in computer science. But I found this one to be very funny, it's just an except of the documentation in Java and in Python about "the simple" rename function.

The Java version :

renameTo(File dest) Hide

Renames the file denoted by this abstract pathname.

Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be 
able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file 
with the destination abstract pathname already exists. The return value should always be checked to make sure 
that the rename operation was successful.
dest	

The new abstract pathname for the named file
return	

true if and only if the renaming succeeded; false otherwise
Throws	SecurityException:

If a security manager exists and its checkWrite(java.lang.String)

method denies write access to either the old or new pathnames
Throws	NullPointerException:

If parameter dest is null

and the Python version :

rename(src, dst)
    Rename the file or directory src to dst. If dst is a directory, OSError will be raised. 
On Unix, if dst exists and is a file, it will be removed silently if the user has permission. 
The operation may fail on some Unix flavors if src and dst are on different filesystems. 
If successful, the renaming will be an atomic operation (this is a POSIX requirement). 
On Windows, if dst already exists, OSError will be raised even if it is a file; there may be no way to 
implement an atomic rename when dst names an existing file. Availability: Macintosh, Unix, Windows.

When you are writing programs, you are expecting a clear documentation of the behavior from the functions used. What do you think ? Will you choose Java or Python ?

Tags:

geo: Les Bulles, Chiny