473,661 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1567
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********@mplu sr.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.m issouri.edu> wrote in message
news:ma******** *************** *************** @python.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.m issouri.edu> wrote in message
news:ma******** *************** *************** @python.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
1395
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 class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like meta-classes...
0
1309
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) instead of class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like...
105
5151
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 indenting is what makes Python unique) and sort of Ruby in its use of prefixes to define scoping etc (although there is no reference to this trait being borrowed from Ruby). It also quotes Self as being an influence.
145
6292
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 unecessary? Here is an example of a Python class with all three types of methods (instance, static, and class methods). # Example from Ch.23, p.381-2 of Learning Python, 2nd ed. class Multi:
27
2001
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 were new to the language, but now as > more and more people use them and proclaim their widespread benefits, I have > come to realize that through years of abuse my brain has become addicted to > classic classes. I began using Python since...
14
2847
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" in the subject of any post to this newsgroup. Please ignore the old thread. I've also updated my webpage http://ece.arizona.edu/~edatools/Python Anyone with some good ideas for "Python 3" is welcome to contribute. I hope GvR won't sue me for...
7
3554
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 you do not actually need to fork Python in order to implement prototypes. It seems to me that Python metaclasses + descriptors are more than powerful enough to implementing prototypes in pure Python. I wrote a module that implements part of what...
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.