OOP only in modules

newpyth newpyth at gmail.com
Sun Apr 10 18:53:47 CEST 2011


Hi all,
I must thank before Andrea Crotti and Steven D'Aprano, which kindly
replayed to my post... they deserve an answer.
To Andrea Crotti's "OOP makes life easier also to the user"... that is
NOT
my experience...
I'm not pretending that everyone else thinks like me (also if many
people do...
load any search engine with "againt OOP" or "criticisms againt OO" to
verify...)
I was trying to get caller-callee tree from the module trace (like do
cflow
with C sources, together with xref)... I think that UML is a loss of
time...
"trace" has three classes whose methods I can't easily arrange in the
caller-callee tree, mainly because IMHO they are similar to functions
declared inside another function.
So I taught to move classes in a module (trace_classes.py) saved
in the same folder of the python source to be traced.
Only using "from trace_classes import *" in the trace_noclasses.py
which contained
the residual part of trace after removing classes, you had the same
result as
the original trace...
In fact "python trace -t mysource.py" worked the same as:
"python trace_noclasses.py -t mysource.py" if you of course load the
classes
by "from trace_classes import * (as mentioned before)
To trace the module trace.py you can use:
python trace.py -t trace.py - t mysource.py (it seems that you must
include
at least a source to be traced".)
The problems arise if you want to use the standard import...with the
two
components of trace (w/ or w/o classes)... because  of the instances
or the obiects defined with class template...
For me its enough to study a module with classes and instances
defined outside them and can use it without referring to internal
istances...
Do you know a module of this kind (trace itself could be the answer
but the
source is too complicated for me...)
I would not like to be compelled to revert to another language as the
suggestion
of Andrea Crotti ("I think that you should probably use another
language if you don't like OOP so much...")
As far Steven D'Aprano and his "Python is based on objects, but it is
not an object-oriented language." is concerned, I could agree with him
(... with some difficulty, however...)
For him (and I agree) "python is a multi-paradigm language: it
includes elements of OOP, functional, procedural and imperative
programming", but the OO example is merily "mylist.sort()  # object-
oriented", without citing the classes and the
multiple inheritance or other obscure property.
My main goal is to arrange OO in a paradigmatic manner in order to
apply to it the
procedural scheme. especially to the caller or called modules.
Bye.



More information about the Python-list mailing list