LinuxProgramming: Migrating from Perl to Python: Objects and OperatorsAug 22, 2000, 13:18 (0 Talkback[s])
(Other stories by Martin C. Brown)
WEBINAR: On-demand Event
Replace Oracle with the NoSQL Engagement Database: Why and how leading companies are making the switch REGISTER >
[ Thanks to Kevin Reichard for this link. ]
"Python, as we already know, is object based. This means that all of the variables types supported by Python are objects. This is very different to Perl--although internally the individual variables, scalars, hashes and so on, could be considered as objects they aren't really. Furthermore, the object system in Perl is less than ideal."
"The object approach provides some benefits. All Python objects belong to different base classes which means that many of the objects share the same attributes, operators and methods. Also, when it comes to creating new objects, we've already got some base objects on which to base them. Best of all though from an object-oriented programmers perspective is that we can introduce and overload operators so that they work with our own custom object. This means that you can merge two objects together using the humble + operator!"
"Perl's built in object types work almost in reverse when compared to C's variable types. With C, the problem of storing information is based on supplying the lowest common denominator, with more complex variables being made up of a combination of these base values. For example, a C string isn't a string at all, it's an array of individual characters."
0 Talkback[s] (click to add your comment)