mystilleef said:
Thank you, that was helpful.
What am I supposed to say ? You choose a bad name for a public symbol,
used it in 27000 lines of Python code (which certainly took some time to
write), and all of a sudden you realize the name is bad and proceed to
fix the problem. If you know of any other way than a massive
find/replace, please share. But blaming the language for your error
won't help.
What does it matter? There are 10 million and one reasons from given
identifiers bad names.
And how many reasons to use a bad name in 27000 LOCs before deciding to
fix the problem ?
Yes you did. May I quote ?
"""
"tmp" is obvious to me, but not necessarily to others. Now compare that
to the accessors. Not only do they improve readability at the expense
of more code, they actually allow me to change the lousily named
attribute "tmp" to "temporary_buffer" without grepping, seding,
searching, replacing and praying.
"""
This obviously implies that you don't understand 'tmp' as being an accessor.
I didn't name the attribute temporary_buffer, I named it tmp.
You didn't name the *accessor* 'temporary_buffer', you named it 'tmp'.
You are *exactly* in the same situation as if you had used getter/setter
named "get_tmp" and 'set_tmp". And your point about getters/setters
"improving readability" is moot.
May I quote what wou wrote a few lines above in this very same post ?
"""
"""
Don't you see any contradiction here ?
In Java there's a clear distinction between attributes
and methods.
Yes, and that's a big weakness of Java. But that's another point, and
absolutely irrelevant here. Failing to understand a language semantics
gives no right to complain about the language.
I choose good names for most of my APIs. But there cases when you never
know an attribute will actually be an API before hand.
Then don't make it part of the API. And anyway, 27000 lines of Python
take some time to write, so you had the opportunity to address the
problem long ago - FWIW, you could have fixed it as soon as you noticed
you were accessing this attribute in client code.
Ha, right! I bet you are perfect developer.
Certainly not, but I wouldn't confuse my own problems with a general
rule. Note FWIW that I wouldn't blame a language (or my lack of
understanding of that language) for my own errors.
I didn't say attributes weren't objects.
Nope, but you constantly bring that false "data/method" dichotomy in
your justifications for having badly named a public symbol.
I don't see the confusion.
Was just an advice against a very common mistake.
For what ? You "don't hold data attributes to such standard". As a
consequence (and as a result of not having addressed the problem
sooner), you end up fixing 27000 lines of code. Too bad for you then.
Some would haved learned from the mistake, which then would have turned
into experience. Seems more and more obvious that you prefer to come
whining here instead and blaming the language for your own errors. Too
bad for you again.
I thought that too was unpythonic.
It's a well-known convention, as you would have noticed if you had read
some existing python code, read PEP8, or just looked/asked for Python
naming conventions. FWIW, that's one of the first thing I learned with
Python.
Or objects have state and behavior. Data attributes represent state and
methods represent behavior.
Is a getter "behaviour" ? If yes, how does this differ from public
"data" attributes from a semantic POV ?
Are you me to know what I feel ?
Compassion doesn't imply agreeing on wrong arguments.
I'm not new to Python
either.
New enough to not understand how Python's object model, semantic and
overall philosophy strongly differs from Java/C++.
I've been using it for over 2 years in several capacities. I
only recently decided to use it for a large project.
I never intended it to be part of the API.
So you should not have used it outside the class.
It evolved to be an
important part of the system.
Then you had plenty of occasions to address the problem.
Your opinion. Facts tell otherwise.
I only just noticed because I was trying to implement
a plug-in system and I needed to expose an important class. I would not
have considered the issue a problem without this requirement. Except
you are a prophet, you sometimes can't know before hand how certain
classes will end up being used especially if requirements suddenly
change.
Yes, that's something I'm well aware of. And that's why I pay attention
to naming and to interface/implementation separation.
Saying it's my fault to make yourself feel better about your
favorite language doesn't help solve my problem.
I don't say it's your fault to "make (myself) feel better about (my)
favorite language, but because the problem is entirely and only yours.
Python has it's share of warts, and I'm not denying it.
I didn't come here to
be berated.
Nope, but you came here blaming the language for your own errors, and
constantly refuse to aknowledge that *you* got it wrong.
I came here to learn the Pythonic way to implementing
accessors.
With public attributes when there's no processing to do, with computed
attributes (based on descriptors, property being the most commonly used)
else. But this is totally unrelated to the issue with badly chosen
public names.
And of course how to deal with issues like the one I have in
medium size to large scale projects. People make mistakes, we deal with
an move on.
When one makes mistake, one can either choose to aknowledge the fact and
learn from it, or to find something/someone else to blame and not learn
anything.