newbie: self.member syntax seems /really/ annoying - Python
This is a discussion on newbie: self.member syntax seems /really/ annoying - Python ; Bruno Desthuilliers wrote:
> OTHO, simple math-illeterate programmers like me will have hard time
> maintaining such a code.
Certainly, but again: Such main people are not the intended audience.
The code is for people that know how to read ...
-
Re: newbie: self.member syntax seems /really/ annoying
Bruno Desthuilliers wrote:
> OTHO, simple math-illeterate programmers like me will have hard time
> maintaining such a code.
Certainly, but again: Such main people are not the intended audience.
The code is for people that know how to read these equations. I think a
general rule of (any form of) writing is to write with your audience in
mind. I always do that and happily, that audience is usually naked.
> Also and FWIW, it's not always possible to make
> a direct translation of a mathematic formula|algorithm in Python, and
> even when it is, it's not always the best thing to do wrt/ perfs (I
> recently had such a case, and after a pythonic rewrite the code was
> about 75% shorter, 50% faster, and 200% more readable for average joe
> programmer).
>
Your point. Different game, but still your point. 
>> ... my 2 sents, anyway ...
>
> May I add my 2 cents - or should I send them ?-)
>
No, actually you're supposed to smell them. Oh, how I love homophones!
/W
-
Re: newbie: self.member syntax seems /really/ annoying
Wildemar Wildenburger wrote:
> Bruno Desthuilliers wrote:
>
>> OTHO, simple math-illeterate programmers like me will have hard time
>> maintaining such a code.
>>
> Certainly, but again: Such main people are not the intended audience.
> The code is for people that know how to read these equations. I think a
> general rule of (any form of) writing is to write with your audience in
> mind. I always do that and happily, that audience is usually naked.
>
>
>
Wouldn't Mathematica, Maple or MathCad be a far better choice ?
cheers,
Stef Mientki
-
Re: newbie: self.member syntax seems /really/ annoying
stef mientki wrote:
> Wildemar Wildenburger wrote:
>> Bruno Desthuilliers wrote:
>>
>>> OTHO, simple math-illeterate programmers like me will have hard time
>>> maintaining such a code.
>>>
>> Certainly, but again: Such main people are not the intended audience.
>> The code is for people that know how to read these equations. I think
>> a general rule of (any form of) writing is to write with your audience
>> in mind. I always do that and happily, that audience is usually naked.
>>
>>
>>
> Wouldn't Mathematica, Maple or MathCad be a far better choice ?
>
Well, those cost money ...
Hey, why am *I* arguing here at all? This isn't my thread!
Well, I guess the scientist in me felt tickled.
/W
-
Re: newbie: self.member syntax seems /really/ annoying
On Thu, 13 Sep 2007 13:14:25 -0400, J. Clifford Dyer wrote:
> On Thu, Sep 13, 2007 at 04:21:36PM -0000, Steven D'Aprano wrote
> regarding Re: newbie: self.member syntax seems /really/ annoying:
>>
>> It's not just a matter of taste.
>>
>> Reading comprehensibility is an objective, measurable quantity, and I
>> would bet that "(self.foo + self.bar) * self.baz" would be measurably
>> more readable on average than either of your two alternatives _even for
>> those people who claim to hate it_.
>>
>>
> It may be measurable, but it is also contextual. Depending on what
> you've been trained in, one way or the other might be more readable.
> For a teenager in a major city, tagging is far more readable than a
> Fraktur font, but for Mad King Ludwig, it was certainly quite the
> opposite.
Cliff, we're discussing Python programming, not Java programming or
assembly language programming or tagging trains. Let the damn taggers
invent their own programming language and stop graffiti-ing Python.
And speaking of readability... your post shows up in my news reader with
each paragraph as a single, long, long LONG line scrolling about five
full screens to the right. Please configure your software to follow the
Usenet convention of putting newline characters at the end of each line,
or every 72 (?) characters, whichever comes first.
> Moreover, it may be that the best solution is to stop trying for an
> object-oriented solution. Why not use a functional programming style to
> represent mathematical functions?
Go back to the beginning of the thread, and you'll see that that's just
what I suggested.
--
Steven.
-
Re: newbie: self.member syntax seems /really/ annoying
>>> Certainly, but again: Such main people are not the intended audience.
>>> The code is for people that know how to read these equations. I think
>>> a general rule of (any form of) writing is to write with your audience
>>> in mind. I always do that and happily, that audience is usually naked.
>>>
>>>
>>>
>>>
>> Wouldn't Mathematica, Maple or MathCad be a far better choice ?
>>
>>
> Well, those cost money ...
>
>
Indeed, so I wondered why there isn't open source alternative (at least
I didn't find one).
some Latex derivate + wxPython + Python could do the job
> Hey, why am *I* arguing here at all? This isn't my thread!
> Well, I guess the scientist in me felt tickled.
>
Well, i'm on the sideline too ;-)
cheers,
Stef
-
Re: newbie: self.member syntax seems /really/ annoying
On Thu, 13 Sep 2007 12:47:27 -0700, Carl Banks wrote:
> On Sep 13, 9:55 am, Steven D'Aprano <st...@REMOVE-THIS-
> cybersource.com.au> wrote:
>> On Thu, 13 Sep 2007 12:10:03 +0000, timothy.soehn... wrote:
>> > Why not use '_' as the self variable. It is minimal and achieves
>> > close to '.var', as '_.var' isn't that different. I know its a
>> > little perl-esque, but its not a bad convention if you are aiming to
>> > up readability of your code.
>>
>> I think the definitions of "up" or "readability" you are using are very
>> different from mine. To me, to up something means to increase it, and
>> readability means the ease of comprehension when reading something. You
>> seem to be using the opposite definition for one or the other.
>
>
> He's not. People who've never done a lot of numerical programming might
> have a hard time understanding this, but what is considered readable for
> "ordinary" programming is just does not apply when reading and writing
> pages of mathematical formulae.
Teaching your grandmother to suck eggs. I'm not a professional coder, but
I'm not a stranger to numerical programming either.
[snip]
> The most readable numerical code looks as much like the printed
> equations as possible. "self." is a distraction; it's not in the
> original formula; it's boilerplate. It takes away from the readability
> of the code. Assuming that you can't get rid of the attribute syntax,
Why would you assume that?
Go back to the beginning of this thread, and you'll see that I suggested
that the Original Poster stop forcing his maths functions into classes
and put them in functions where they belong. As far as I'm concerned,
this thread has clearly evolved to no longer be specifically about the
OP's problem that classes don't read like maths functions (that's a
solved problem -- don't use classes) and is now discussing the generic
issue that some people don't have good taste when it comes to programming
languages.
--
Steven.
-
Re: newbie: self.member syntax seems /really/ annoying
stef mientki wrote:
> Indeed, so I wondered why there isn't open source alternative (at
> least I didn't find one).
Have a look at scilab and octave. Not sure if it's GPL though.
Regards,
Björn
--
BOFH excuse #387:
Your computer's union contract is set to expire at midnight.
-
Re: newbie: self.member syntax seems /really/ annoying
Wildemar Wildenburger wrote:
> stef mientki wrote:
>> Wildemar Wildenburger wrote:
>>> Bruno Desthuilliers wrote:
>>>
>>>> OTHO, simple math-illeterate programmers like me will have hard
>>>> time maintaining such a code.
>>>>
>>> Certainly, but again: Such main people are not the intended
>>> audience. The code is for people that know how to read these
>>> equations. I think a general rule of (any form of) writing is to
>>> write with your audience in mind. I always do that and happily, that
>>> audience is usually naked.
>>>
>>>
>>>
>> Wouldn't Mathematica, Maple or MathCad be a far better choice ?
>>
> Well, those cost money ...
Maxima doesn't
cheers,
Stef
-
Re: newbie: self.member syntax seems /really/ annoying
BJörn Lindqvist wrote:
> On 9/12/07, Dave Hansen <iddw@hotmail.com> wrote:
>> The name "self" is just a convention. You can give it any name you
>> wish. Using "s" is common.
>
> Not it's not common. And the name "self" is a convention codified in
> PEP8 which you shouldn't violate.
>
> And I agree with the OP that the convention is really annoying.
>
> self.rect.width = self.foo(self.rect.x + self.rect.y) * self.boo()
>
> is much less concise than
>
> s.rect.width = s.foo(s.rect.x + s.rect.y) * s.boo()
>
Yes, but the OP went a step further, he suggested:
..rect.width = .foo(.rect.x + .rect.y) * .boo()
Among the many responses, I didn't spot anyone who dealt with this issue.
Does this preceding "." create parsing problems?
Colin W.
-
Re: newbie: self.member syntax seems /really/ annoying
"Colin J. Williams" <cjw@sympatico.ca> writes:
> .rect.width = .foo(.rect.x + .rect.y) * .boo()
>
> Does this preceding "." create parsing problems?
Perhaps not for the computer, but certainly for the human. A leading
"." is far too easy to miss when visually scanning the code, and fails
the "explicit" principle.
--
\ "I have the simplest tastes. I am always satisfied with the |
`\ best." -- Oscar Wilde |
_o__) |
Ben Finney
Similar Threads
-
By Application Development in forum c++
Replies: 6
Last Post: 08-29-2006, 11:59 AM
-
By Application Development in forum c++
Replies: 1
Last Post: 06-02-2006, 10:55 AM
-
By Application Development in forum c++
Replies: 0
Last Post: 06-01-2006, 10:35 AM
-
By Application Development in forum Java
Replies: 0
Last Post: 12-03-2004, 04:40 PM