473,408 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

proper use of braces in Python (was: Prothon Prototypes vs PythonClasses)

Right. Then we can have "does the brace go on the same line or the
next line" wars.


int main (void)
{
if (true)
{
}

return 0;
}

There is no other way.

No way, that wastes an entire line of code with a single brace!

int main ( void ) {
if ( true ) {
return 1;
}
return 0;
}

This is clearly better. Compact yet easy to read. I try formatting my
Python code exactly like this and it always complains about my braces..
clearly wrong.

Jul 18 '05 #1
4 1562
Michael wrote:
int main (void)
{
if (true)
{
}

return 0;
}

There is no other way.

No way, that wastes an entire line of code with a single brace!


Why not? It's a cheap way to increase your LOC/month power. :)

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #2
Why not? It's a cheap way to increase your LOC/month power. :)


Good point, but that is why I like to make sure my code is well
documented. The more detailed the code is documented the higher the
LOC/month. :)

Actually, I do document rather well usually. I'm especially fond of
pydoc allowing a program to access it's own documentation. I love being
able to get the help for my XML-RPC methods just by formatting (as HTML)
the existing Python docs for those methods. Very tidy.

Jul 18 '05 #3
"Michael" <mo*****@mlug.missouri.edu> wrote in message
news:ma**************************************@pyth on.org...
Right. Then we can have "does the brace go on the same line or the
next line" wars.


int main (void)
{
if (true)
{
}

return 0;
}

There is no other way.

No way, that wastes an entire line of code with a single brace!

int main ( void ) {
if ( true ) {
return 1;
}
return 0;
}

This is clearly better. Compact yet easy to read. I try formatting my
Python code exactly like this and it always complains about my braces..
clearly wrong.

http://c2.com/cgi/wiki/wiki?WhereDoTheBracesGo

Not having to deal with this #$*^!!@ is just about my favorite feature of
Python! (Although I'm not excited about getting into a thread on an issue
that is so flame-prone. Honestly, though. "There is no other way."? "This
is clearly better."? I really interpret your stance as "This is the way I'm
used to." What's annoying is the added "... and therefore superior."
implication. The visual cues provided by brace placement are extremely
subjective, and what is "clearly better" to one is confusing to another.)

Is it so difficult to accept that this is a personal style/preference issue?
I agree that having a consistent form across an entire project makes things
simpler overall, it's not worth the aggravation of coercing a style on those
who vigorously and adamantly prefer their own. Furthermore,...

Oh wait, Python doesn't *have* braces! Whew! (What a funny subject for a
thread on c.l.py - April Fool's Day is come a bit early?)

-- Paul


Jul 18 '05 #4
Paul McGuire wrote:


"Michael" <mo*****@mlug.missouri.edu> wrote in message
news:ma**************************************@pyth on.org...
>>Right. Then we can have "does the brace go on the same line or the
>>next line" wars.
>>
>>
>
> int main (void)
> {
> if (true)
> {
> }
>
> return 0;
> }
>
>There is no other way.
>
>

No way, that wastes an entire line of code with a single brace!

int main ( void ) {
if ( true ) {
return 1;
}
return 0;
}

This is clearly better. Compact yet easy to read. I try formatting my
Python code exactly like this and it always complains about my braces..
clearly wrong.

http://c2.com/cgi/wiki/wiki?WhereDoTheBracesGo

Not having to deal with this #$*^!!@ is just about my favorite feature of
Python! (Although I'm not excited about getting into a thread on an issue
that is so flame-prone. Honestly, though. "There is no other way."? "This
is clearly better."? I really interpret your stance as "This is the way I'm
used to." What's annoying is the added "... and therefore superior."
implication. The visual cues provided by brace placement are extremely
subjective, and what is "clearly better" to one is confusing to another.)

Paul,

What you're seeing here is a couple Pythonistas mocking C and Java
programmers who take these sorts of arguments dead-seriously. (But
not Perl programmers: they don't actually use braces. :)

Here at Python, we like to think that we argue about more important
things. It's part of the Zen of Python: there should only be one way
to do it. Because when there's more than one way to do it, you get
arguments like this.

"More than one way to do it" has led to the space vs. tab arguments we
have here. As far as I'm concerned, the biggest problem with spaces
and tabs is that you can use either, i.e., there's *unnecessarily*
more than one way to do it. And the Python Gods are rightly getting
rid of that.
--
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Hahn | last post by:
I would like to announce a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of...
0
by: Mark Hahn | last post by:
Ben Collins and I have developed a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html)...
105
by: Peter Hickman | last post by:
Well after all this discussion it would appear that a 'Python like' language has appeared => Prothon. http://www.prothon.org/index.html Very alpha, sort of like Python (if you consider the...
145
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity...
27
by: Michele Simionato | last post by:
> Hello, my name is Skip and I am metaclass-unaware. I've been programming in > Python for about ten years and I have yet to write a metaclass. At first I > thought it was just that metaclasses...
14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
7
by: Michele Simionato | last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self or other prototype-based languages. Still, from the discussion on the mailing list, I have got the strong impression that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.