Suggested coding style

R

rantingrick

By the way OP Passiday the title of the topic is "Suggested coding
style".

Are you suggesting a coding style or asking for a Python coding style
or are you asking what IS the Python coding style.

If you are asking what is the Python coding style. Google The Zen of
Python. It's pretty much the dictum of coding style and referred to
alot by many Pythoneers.

The Python zen is a very general outline of our collective religious
beliefs concerning programming (and it could be applied to many
fields). Every Python programmer should know the zen by heart. Which
can be very beneficial in a war of words when some smart mouth decides
to quote the zen in an attempt to defeat you. Since, like the bible
the zen is self contradicting, any argument utilizing the zen can be
defeated utilizing the zen.

If however you want to learn about the accepted rules for formatting
code then you need to read "PEP-8"! PEP 8 is our style guide. It is
not perfect as i have pointed out on many occasions HOWEVER it is the
only thing we have that keeps multiplicity from reproducing like
leporidae.

http://www.python.org/dev/peps/pep-0008/
 
A

alex23

rantingrick said:
Since, like the bible
the zen is self contradicting, any argument utilizing the zen can be
defeated utilizing the zen.

And like the Bible, the Zen was created by humans as a joke. If you're
taking it too seriously, that's your problem.
If however you want to learn about the accepted rules for formatting
code then you need to read "PEP-8"! PEP 8 is our style guide.

PEP 8 is the _standard library style guide_. There's a difference.
It is
not perfect as i have pointed out on many occasions HOWEVER it is the
only thing we have that keeps multiplicity from reproducing like
leporidae.

Yes, save us from multiplicity, variety and difference. Nothing good
comes from them anyway.
 
D

DevPlayer

And like the Bible, the Zen was created by humans as a joke. If you're
taking it too seriously, that's your problem.
Contradiction is only seen by narrow perspectve.

Calling the Bible a joke is used to hurt people, not enlighten them.
Those words show bitter arrogance, not constructive critism as it
ignores how others feel about that book. What benefit to others is
gained by calling someones belief a joke? To put the "believers" minds
straight? I think not. I think the unsensitive person who attackes
others beliefs, even if illogical or unrealistic, is after some kind
of self grandizement or to illude themself into thinking "they know
the truth of the universe" and should attack others to prove they do.

Although this is not the place to defend about such things it is also
not the place to attack those same things (that being someone's
faith). There is no real forum to defend a faith or religion, or words
in a book about that, other then where such faiths are in fact
attacked.

However I did laugh at the ironic use of using any-kind of zen to
seriously, even Python's, as that is very unzen-like. That is a
contradiction by it's very own definitions!
 
T

Tim Johnson

* DevPlayer said:
Contradiction is only seen by narrow perspectve.

Calling the Bible a joke is used to hurt people, not enlighten them.
Those words show bitter arrogance, not constructive critism as it
ignores how others feel about that book. What benefit to others is
gained by calling someones belief a joke?

My wife and I are devout christians, but not fundamentalist. We
would not take rantingrick too seriously. If _you_ take him
seriously, you're just giving him 'street cred'.
 
S

Steven D'Aprano

DevPlayer said:
And like the Bible, the Zen was created by humans as a joke. If you're
taking it too seriously, that's your problem.
[...]
Calling the Bible a joke is used to hurt people, not enlighten them.
Those words show bitter arrogance, not constructive critism as it
ignores how others feel about that book. What benefit to others is
gained by calling someones belief a joke?

It is the same benefit as the little boy who pointed out that the Emperor
was not wearing any clothes. (In real life, the story was called "The
Little Boy Who Said The Emperor Wasn't Wearing Any Clothes, and Got
Arrested and Thrown in Prison Together With His Parents for Insulting The
Emperor".)

To put the "believers" minds
straight? I think not. I think the unsensitive person who attackes
others beliefs, even if illogical or unrealistic, is after some kind
of self grandizement or to illude themself into thinking "they know
the truth of the universe" and should attack others to prove they do.

There is a difference between attacking ideas and attacking people.

"The Bible is a joke" attacks the idea.

"Insensitive people after self-aggrandisement deluding themselves" attacks
the person.

We live in a world where religion is privileged, where governments pander to
the most sick and twisted, hateful, bigoted beliefs because of religion,
where organised conspiracies to support and protect child molesters and
sexual predators are nevertheless looked up to as sources of morality.

There are some ideas that are simply incompatible with civilization, and the
idea that religious beliefs should be beyond criticism is one of them.
Forget money, or even the love of money. The idea that one mustn't
criticise another person's beliefs is the root of all evil.
 
D

Devin Jeanpierre

Forget money, or even the love of money. The idea that one mustn't
criticise another person's beliefs is the root of all evil.

This was a technical discussion, and calling the bible a joke was not
necessary at all. It creates a hostile atmosphere.

Can't you pick somewhere else to attack Christianity?

Devin

DevPlayer said:
And like the Bible, the Zen was created by humans as a joke. If you're
taking it too seriously, that's your problem.
[...]
Calling the Bible a joke is used to hurt people, not enlighten them.
Those words show bitter arrogance, not constructive critism as it
ignores how others feel about that book. What benefit to others is
gained by calling someones belief a joke?

It is the same benefit as the little boy who pointed out that the Emperor
was not wearing any clothes. (In real life, the story was called "The
Little Boy Who Said The Emperor Wasn't Wearing Any Clothes, and Got
Arrested and Thrown in Prison Together With His Parents for Insulting The
Emperor".)

To put the "believers" minds
straight? I think not. I think the unsensitive person who attackes
others beliefs, even if illogical or unrealistic, is after some kind
of self grandizement or to illude themself into thinking "they know
the truth of the universe" and should attack others to prove they do.

There is a difference between attacking ideas and attacking people.

"The Bible is a joke" attacks the idea.

"Insensitive people after self-aggrandisement deluding themselves" attacks
the person.

We live in a world where religion is privileged, where governments panderto
the most sick and twisted, hateful, bigoted beliefs because of religion,
where organised conspiracies to support and protect child molesters and
sexual predators are nevertheless looked up to as sources of morality.

There are some ideas that are simply incompatible with civilization, and the
idea that religious beliefs should be beyond criticism is one of them.
Forget money, or even the love of money. The idea that one mustn't
criticise another person's beliefs is the root of all evil.
 
R

rantingrick

 My wife and I are devout christians, but not fundamentalist. We
 would not take rantingrick too seriously. If _you_ take him
 seriously, you're just giving him 'street cred'.

DevPlayer was not even talking about what i said, he was replying to a
statement by Alex23 who said (and i quote) "And like the Bible, the
Zen was created by humans as a joke". Maybe you should spend the next
fifteen or so minutes catching up to the conversation...(ಠ_ಠ)...of
course only *after* you clean that egg from your face.
 
D

DevPlayer

Oh I was just testing my intellecual-enlightenment-from-ranter-
conversation algorithm found in a previous post. I think my OOP model
failed as I'm just too tired to finished that pattern test. He had
some good points which fit the process I layed out. But the original
topic is just so much better:

Suggested coding style Options
 
A

alex23

Calling the Bible a joke is used to hurt people, not enlighten them.

Y'know, I wouldn't even bother responding to this if Xianists were as
open, forgiving and accepting as their messiah told them to be. It was
a *flippant remark*. If you want to establish intent, aggression and
religio-politico-philosophy from every throwaway remark made on the
internet, you're not really going to have much time for Python.

My belief system isn't your's. Hell, my belief system doesn't even
require that I have *any respect whatsoever* for your's. If it's okay
for Xianists to "suffer not a witch to live", then I'm going to assert
my making light jokes about those whose world view is in direct
opposition to mine isn't even comparable to that mentality.

from attitude import humour

(Since we're already fully derailed here, I've always preferred
Borges' suggestion that it was actually Judas who carried the full
weight of man's sins, given that his betrayal of Christ and inevitable
condemnation to hell was a necessity. Then again, I'm able to safely
view this as *allegory* and am genuinely interested in the opinions of
modern minds over something first begun by nomads millenia ago...)
 
D

Dennis Lee Bieber

This was a technical discussion, and calling the bible a joke was not
necessary at all. It creates a hostile atmosphere.
Well... We could try for equality in offense -- the Torah or the
Koran? Maybe the Tripitaka or Sutras?

To borrow from Lackey's Valdemar: There is no one true way...
 
W

Westley Martínez

DevPlayer was not even talking about what i said, he was replying to a
statement by Alex23 who said (and i quote) "And like the Bible, the
Zen was created by humans as a joke". Maybe you should spend the next
fifteen or so minutes catching up to the conversation...(ಠ_ಠ)...of
course only *after* you clean that egg from your face

Perhaps you should spend a little less time on the mailing list and a
little more time in church.
 
I

Ian Kelly

Perhaps you should spend a little less time on the mailing list and a
little more time in church.

You must not like churchgoers very much if you want to inflict
rantingrick on them...
 
I

Ian Kelly

You must not like churchgoers very much if you want to inflict
rantingrick on them...

Although come to think of it, I bet he could deliver a pretty mean sermon. ;-)
 
P

Passiday

Oh, my. Who could expect this topic would iterate to some whining about religion (please don't respond on this remark of mine).

Here's a summary of what I take from this longwinded thread:
Read the Zen of Pthon for some fun: http://www.python.org/dev/peps/pep-0020
Read the PEP-8 for some good guidelines: http://www.python.org/dev/peps/pep-0008

My topic was "Suggested coding style" because I hoped there is some common understanding which of the ancient methods/functions are so not where they should be that the use of them should be depreciated. I can fully understand that when the language evolves, it might implement some ugly methods. Perhaps it was some quick itching need to format some numbers that drove some antique Python programmer so mad that he decided this belongs to the stringclass, instead of some number/date/string formatting class that attempts to build on existing well established standards. And so, the str.zfill() wasborn. But I'd expect that there exists some leadership who are brave enough to admit some bad decisions and lead the people by announcing that using certain methods is "bad style". No need to take them out of the implementation, that might unnecessary break some code in obscure places. However, guiding programmers for better coding practice and avoid ugly bloating of nicescripting language should be considered a holy (please don't rant on use of this word) mission.

Passiday
 
S

Steven D'Aprano

Westley said:
Perhaps you should spend a little less time on the mailing list and a
little more time in church.

Is that meant as punishment for Rick or for the churchgoers?
 
R

rantingrick

Here's a summary of what I take from this longwinded thread:
Read the Zen of Pthon for some fun:http://www.python.org/dev/peps/pep-0020
Read the PEP-8 for some good guidelines:http://www.python.org/dev/peps/pep-0008

That's the point of all this, yes. You see, around here, once the
point is made there is an unwritten rule that the thread must then
descend into chaos. However, it seems you "may" have brought this
train wreck back to reality below... whether the trolls will allow
that happen remains to be seen...?
My topic was "Suggested coding style" because I hoped
there is some common understanding which of the ancient
methods/functions are so not where they should be that the
use of them should be depreciated.

I agree. Whilst zfill is useful, and probably should be a part of the
stlib somewhere, the string module is no place for it. The only way
zfill WOULD work as a string method is if it were changed to accept a
user defined fill char. Even then i don't like it as a string method;
too specific!

A specific method for padding a string with ONLY zeros is ludicrous
and exposes the narrow mindedness of the creator. The only thing worse
than "zfill" as a string method is making zfill into built-in
function! The ONLY proper place for zfill is as an option in the
str.format() method.

py> "{0:zf10}".format(1234) -> "00000000001234"

When are they going to see that I am the best API designer this
community has ever had the privilege to work with! GvR should be
texting me every night in hopes that some of my API genius will rub
off on him.
I can fully understand
that when the language evolves, it might implement some
ugly methods. Perhaps it was some quick itching need to
format some numbers that drove some antique Python
programmer so mad that he decided this belongs to the
string class, instead of some number/date/string
formatting class that attempts to build on existing well
established standards. And so, the str.zfill() was born.

zfills foster home placement is akin to the missing Path object we
still don't have. Both are a result of poor planning. Now zfill is
like some red headed step child that nobody wants, but nobody has the
balls to return the abortion to it's rightful place.
But I'd expect that there exists some leadership who are
brave enough to admit some bad decisions and lead the
people by announcing that using certain methods is "bad
style".

Ha! I would not hold my breath waiting for "leadership" to admit wrong
doings; these people think they are beyond reproach.
No need to take them out of the implementation,
that might unnecessary break some code in obscure places.

What is so bad about breaking code in obscure places? We changed print
to a function which broke just about every piece of code every written
in this language. (BTW, print should ALWAYS have been a function!)
What is so bad then about breaking some very obscure code? We could
always have a lengthy deprecation period.
However, guiding programmers for better coding practice
and avoid ugly bloating of nice scripting language should
be considered a holy (please don't rant on use of this
word) mission.

I agree. I think you'll agree also with me in the fact that Mr Van
Rossum has created the cleanest, most simplistically elegant, and no
nonsense language this world has ever seen. However. He is not immune
to the wicked influence of a few high ranking people within this
community who have "hidden agendas" and want to mutate Python into a
clone of some other nasty languages.

I believe GvR had a "mid-dev-crisis" and realized the err of his ways.
He attempted to turn back the clock with Python 3000, HOWEVER he did
not go far enough! Much more cleanup is in order to get this language
back on track to what it should be, and COULD be!
 
R

rantingrick

A specific method for padding a string with ONLY zeros is ludicrous
and exposes the narrow mindedness of the creator. The only thing worse
than "zfill" as a string method is making zfill into built-in
function! The ONLY proper place for zfill is as an option in the
str.format() method.

py> "{0:zf10}".format(1234) -> "00000000001234"


If something like "zfill" where to be included as a string method, it
should be more general like this:

class String:
def pad(self, char, count, side='left') => str

py> "".pad(0, 10)
'00000000001234'

However the same can be accomplished with:

py> '{0}1234'.format("0"*10)
'00000000001234'

py> "0"*10+'1234'
'00000000001234'

Seems like pollution either way you go. Best to just let the
programmer handle it. Python IS NOT a 100% OOP language (and for good
reason!) so we don't need methods to scratch every little itch -- and
this itch seems to have originated in the "nether regions" instead of
the "Netherlands".
 
W

Westley Martínez

What is so bad about breaking code in obscure places? We changed print
to a function which broke just about every piece of code every written
in this language. (BTW, print should ALWAYS have been a function!)
What is so bad then about breaking some very obscure code? We could
always have a lengthy deprecation period.

Well, I once thought that a print function made a lot of sense. In C,
printf is a function, however then I think why print is a function. In
C, just about every function has side effects (the return values are
more often than not either pointers or status codes). In Python
functions are encouraged to not have side-effects, so the implementation
of print as a statement or a method makes far more sense than as a
function.

But maybe I'm just batty as you all think I am.
 
C

Chris Angelico

But maybe I'm just batty as you all think I am.

Yes, I'm afraid so. Bonkers. Off your head. But let me tell you a
secret... All the best people are.
Well, I once thought that a print function made a lot of sense.  In C,
printf is a function, however then I think why print is a function.  In
C, just about every function has side effects (the return values are
more often than not either pointers or status codes).  In Python
functions are encouraged to not have side-effects, so the implementation
of print as a statement or a method makes far more sense than as a
function.

Since functions and methods in Python are practically the same thing,
I don't know that there really need be any difference in policy. But I
do like any reduction in the number of "special features" of a
language. If screen output can be done as an ordinary function taking
ordinary arguments, that's better than having a special language
construct. Also, it's just plain stupid and yet just plain cool to be
able to:

print = sys.stderr.write

and smoothly redirect all your prints to stderr. (Unfortunately this
doesn't quite work, as it means you don't get your newlines put in for
you, but there's sure to be an equally stupid/cool reassignment
available.)

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top