473,806 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is not objects in Python?

I have heard some criticism about Python, that it is not fully object-
oriented.

What is not an object in Python?

Why isn't len implemented as a str.len and list.len method instead of
a len(list) function?
Sep 28 '08
41 1617
On Mon, 29 Sep 2008 05:41:02 -0700, George Sakkis wrote:
For example I would be much less
opposed to len() being defined as, say, |x| if "|...|" was a valid
operator.
Arghh! No!!! |x| should be abs(x), not len(x). Just ask mathematicians
and physicists.

*wink*

Actually there's a serious point there. There aren't that many
unambiguous operators that are available on a standard keyboard that
(nearly) everyone can agree on.
--
Steven
Sep 29 '08 #21
Steven D'Aprano wrote:
On Mon, 29 Sep 2008 05:41:02 -0700, George Sakkis wrote:
>For example I would be much less
opposed to len() being defined as, say, |x| if "|...|" was a valid
operator.

Arghh! No!!! |x| should be abs(x), not len(x). Just ask mathematicians
and physicists.
It should be both, just as + is addition for numbers and concatenation
for sequences. Or we could have just one built-in -- size() instead of
abs() and len(). For non-sequence collections, size() would be better
than len() anyway.

tjr

Sep 30 '08 #22
On 28 set, 15:29, process <circularf...@g mail.comwrote:
I have heard some criticism about Python, that it is not fully object-
oriented.
So what?
Why isn't len implemented as a str.len and list.len method instead of
a len(list) function?
Because postfix notation sucks. The natural way of spelling is
adjective+noun and verb+predicate. That's one of the reasons I like
Lisp better than Python.
Sep 30 '08 #23
In article <ma************ *************** ***********@pyt hon.org>,
Terry Reedy <tj*****@udel.e duwrote:
It should be both, just as + is addition for numbers and concatenation
for sequences.
Actually, the math folks would argue that using + for concatenation is
wrong, since by normal math rules, + denotes a commutative operation.

Of course, the math folks think that i^2 = -1, so what do they know? All
right-thinking people know that j^2 = -1.
Sep 30 '08 #24
On Mon, 29 Sep 2008 21:03:07 -0700, namekuseijin wrote:
>Why isn't len implemented as a str.len and list.len method instead of a
len(list) function?

Because postfix notation sucks. The natural way of spelling is
adjective+noun and verb+predicate.
"Natural"?

You mean phrases like "heir apparent" and "worst choice imaginable" are
unnatural? To say nothing of languages like Spanish, Albanian, Italian,
Cornish, Vietnamese, Hebrew...

--
Steven
Sep 30 '08 #25
En Tue, 30 Sep 2008 01:03:07 -0300, namekuseijin <na**********@g mail.com>
escribió:
On 28 set, 15:29, process <circularf...@g mail.comwrote:
>Why isn't len implemented as a str.len and list.len method instead of
a len(list) function?

Because postfix notation sucks. The natural way of spelling is
adjective+noun and verb+predicate. That's one of the reasons I like
Lisp better than Python.
Well, "natural" for English-speaking people... Noun+adjective is usually
more "natural" In Spanish than the English word ordering.

Back to the original question, len(x) allows for a fast response without
paying the overhead of a name lookup and then a method call.
len(some_list) doesn't invoke some_list.__len __(), it just returns the
value stored somewhere in the list object; same for other built-in
objects. __len__ is searched as a last resort only.
The optimization could not be done if it were spelled x.len()

--
Gabriel Genellina

Sep 30 '08 #26
Terry Reedy wrote:
Steven D'Aprano wrote:
>On Mon, 29 Sep 2008 05:41:02 -0700, George Sakkis wrote:
>>For example I would be much less
opposed to len() being defined as, say, |x| if "|...|" was a valid
operator.

Arghh! No!!! |x| should be abs(x), not len(x). Just ask mathematicians
and physicists.

It should be both, just as + is addition for numbers and concatenation
for sequences. Or we could have just one built-in -- size() instead of
abs() and len(). For non-sequence collections, size() would be better
than len() anyway.
And how are these "non-sequence collections" to be distinguished? And
how does size() differ from len() in that case?

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 30 '08 #27
On Mon, 2008-09-29 at 21:03 -0700, namekuseijin wrote:
On 28 set, 15:29, process <circularf...@g mail.comwrote:
I have heard some criticism about Python, that it is not fully object-
oriented.

So what?
Why isn't len implemented as a str.len and list.len method instead of
a len(list) function?

Because postfix notation sucks. The natural way of spelling is
adjective+noun and verb+predicate. That's one of the reasons I like
Lisp better than Python.
--
http://mail.python.org/mailman/listinfo/python-list
Actually str.len and len(str) is just like saying "the string's length"
and "the length of the string". There is no difference between the two
except for personal preference. (I am no linguist-- not even a native
speaker of English --but I think there is a subtle difference on
emphasis, "the string's length" emphasizes on the length being string's
property, while "the length of the string" emphasizes on the length
itself, am I correct?)
Sep 30 '08 #28
Steven D'Aprano wrote:
On Mon, 29 Sep 2008 21:03:07 -0700, namekuseijin wrote:
>>Why isn't len implemented as a str.len and list.len method instead of a
len(list) function?
Because postfix notation sucks. The natural way of spelling is
adjective+no un and verb+predicate.

"Natural"?

You mean phrases like "heir apparent" and "worst choice imaginable" are
unnatural?
They are certainly far from normal usage, as my dog yellow would be
certain to agree.
To say nothing of languages like Spanish, Albanian, Italian,
Cornish, Vietnamese, Hebrew...
It's long been a convention in the Western programming world to pretend
no other language than English and no other codes than ASCII exist.

The fact that Python is beginning to come to terms with Unicode is a
tribute to certain developers' persistence.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 30 '08 #29
Steven D'Aprano wrote:
On Mon, 29 Sep 2008 21:03:07 -0700, namekuseijin wrote:
>>Why isn't len implemented as a str.len and list.len method instead of a
len(list) function?
Because postfix notation sucks. The natural way of spelling is
adjective+no un and verb+predicate.

"Natural"?

You mean phrases like "heir apparent" and "worst choice imaginable" are
unnatural?
They are certainly far from normal usage, as my dog yellow would be
certain to agree.
To say nothing of languages like Spanish, Albanian, Italian,
Cornish, Vietnamese, Hebrew...
It's long been a convention in the Western programming world to pretend
no other language than English and no other codes than ASCII exist.

The fact that Python is beginning to come to terms with Unicode is a
tribute to certain developers' persistence.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 30 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3653
by: Ng Pheng Siong | last post by:
Hi, I just noticed that demo/evp_ciph_test.py of my M2Crypto package causes a core dump. It used to not do that. ;-) The core dump happens when the program is exiting; in the output below, rc2_40_cbc is the last test run by the program: $ python evp_ciph_test.py ...
220
19201
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
54
6588
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO FRICKIN' COOL!!! ***MAN*** that would save me a buttload of work and make my life sooooo much easier!" As opposed to minor differences of this feature here, that feature there. Variations on style are of no interest to me. I'm coming at this from a...
28
3312
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
7
2402
by: Bo Peng | last post by:
Dear Python group: I am planning on an application that involves several complicated C++ classes. Basically, there will be one or two big data objects and some "action" objects that can act on the data. I would like to use a script language to control the interaction between these c++ objects. I become interested in Python since it can load C++ objects and can even extend C++ classes. However, I am not quite sure to what extent can...
2
1415
by: Sells, Fred | last post by:
I have a legacy system with data stored in binary files on a remote server. I need to access and modify the content of those files from a webserver running on a different host. (All Linux) I would like to install a server on the legacy host that would use my python code to translate between the legacy files and Python Objects that represent the subset of data I care about, then pass those Python objects back and forth to my webserver,...
137
7209
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
21
1620
by: godwin | last post by:
Hi all, I wanna thank Martin for helping out with my ignorance concerning execution of stored procedure with python. Now i have decided to write a web app that googles into my companies proprietary database. I need to know whether zope is good for that job. But even the introduction to zope in the zope book was intimidating. Are there any simple options? If so plz tell me how i can obtain it and study it. I should say that i am new to web...
4
1323
by: Gre7g Luterman | last post by:
I suppose I was lulled into complacency by how Python makes so many things look like classes, but I'm starting to realize that they're not, are they? I'm writing a C program which handles Python objects in different ways based on their type. I do a PyInstance_Check(PyObj) to determine if the PyObj is an instance, but it is returning 0 on a lot of stuff that I thought would be an instance. So I did the following simple test on three things...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.