java 5 could like python?

Roy Smith roy at panix.com
Sat Jan 15 10:23:20 EST 2005


vegetax <vegeta.z at gmail.com> wrote:
> -No naming convention. The speech of "it fits in my head" is no longer valid
> when i use a lot of functionality,modules,classes in a large proyect.
> 
> For example if i remember a function i want ie:get attribute, i dont
> remember if the module implementer coded it as
> getAttribute,GetAttribute,get_attribute, then i have to go and check the
> doc, every time,which is a waste of time.

It is indeed unfortunate that the standard library doesn't use a more 
consistent naming convention.  Perhaps in Python-3000 this will get 
fixed.  In the meantime, if I know what I'm looking for, but just can't 
remember the exact name, I usually find it's pretty quick to pop into an 
interactive session, create an object, and see what attributes it has 
with dir():

>>> l = []
>>> dir (l)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 
'__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', 
'__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', 
'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', 
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', 
'__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 
'remove', 'reverse', 'sort']

> -Is python library half object oriented? half functional oriented? I can
> understand that python allows some functional programing components when
> they are necesary,but there are libraries that totaly ignore object
> orientation which makes them problematic to use.for example,Whats with the
> os.path module and files? why do i have to say os.path.getfilesize(f.name)
> all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
> items instead of an URL object? why there isnt an URL object? and so on..

Again, you are correct that things are not as consistent as they might 
be.  The newer bits of the library tend to be more OO than the older 
bits, and those parts of the library which are thin wrappers around 
classic unix functions (like much of the os module) tend to be more 
procedural.  Things are not perfect.

I think the real message is that while you can certainly find lots of 
places where there are imperfections and inconsistencies, overall it's a 
very easy to use system.  Java may be much more consistent, but I find I 
get bogged down in details like re-exporting exceptions, declaring (and 
casting) variable types.  To each their own.



More information about the Python-list mailing list