Do you think Python is a little bit not so unified?

A forum for general discussion of the Python programming language.

Do you think Python is a little bit not so unified?

Postby bluephoenix » Thu Jan 02, 2014 3:52 pm

I just start to learn Python for almost half one month.
But there is uncertainty for the style of Python, for example:
we can use "function(class)" to accomplish some targets while we also need to use "class.function" to accomplish some other targets.
I accept we should use some reserved function, like "print", to be used in front of CLASS. But as Python comes from community, different contributor makes their module in different ways, this causes the current status.
I think this is not easy for the beginner. And I wish there should be a regularity.
I don't know if Ruby could be better in this prospect.
Do you have good explanation? Thanks!
Last edited by Yoriz on Thu Jan 02, 2014 4:50 pm, edited 1 time in total.
Reason: first post lock
bluephoenix
 
Posts: 4
Joined: Tue Dec 24, 2013 2:48 pm

Re: Do you think Python is a little bit not so unified?

Postby Somelauw » Thu Jan 02, 2014 7:08 pm

The python FAQ offers an explanation;
http://docs.python.org/2/faq/design.htm ... g-len-list

Python FAQ wrote:Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))?

The major reason is history. Functions were used for those operations that were generic for a group of types and which were intended to work even for objects that didn’t have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when you use the functional features of Python (map(), zip() et al).

In fact, implementing len(), max(), min() as a built-in function is actually less code than implementing them as methods for each type. One can quibble about individual cases but it’s a part of Python, and it’s too late to make such fundamental changes now. The functions have to remain to avoid massive code breakage.
Join the #python-forum IRC channel on irc.freenode.net!
Somelauw
 
Posts: 68
Joined: Tue Feb 12, 2013 8:30 pm

Re: Do you think Python is a little bit not so unified?

Postby bluephoenix » Fri Jan 03, 2014 8:17 pm

Many thanks, Somelauw!
bluephoenix
 
Posts: 4
Joined: Tue Dec 24, 2013 2:48 pm


Return to General Discussions

Who is online

Users browsing this forum: pyt03 and 1 guest

cron