Is it true that I can't use curly braces in Python?

If foo: #{ print "it's true" #} else: #{ print "it's false! " #} (Obviously, this is a joke. ).

Oh Lars, you funny little man! :) – Kaitsu Dec 20 '09 at 16:14 2 You so funny! I think I'm going to do that now every time I use python – Matt S.

Dec 20 '09 at 17:07 So it's possible. Cool! – openfrog Dec 25 '09 at 16:47 @openfrog: no, it's not, these are just single-line code comments... (and he did say it was a joke) – Abel Dec 27 '09 at 23:31 @Abel is correct.

I should have explained the joke in a comment, just in case. – Lars Wirzenius Dec 28 '09 at 10:04.

You can try to add support for braces using a future import statement, but it's not yet supported, so you'll get a syntax error: >>> from __future__ import braces File "", line 1 SyntaxError: not a chance.

Yes. Curly braces are not used. Instead, you use the : symbol to introduce new blocks, like so: if True: DoSomething() SomethingElse() else: Something().

But better to follow the convention of 98% of Python code and not put that spurious space in front of the colon. The more surprises you throw in front of readers, the more they'll be distracted from the real meaning of the code. – Peter Hansen Dec 20 '09 at 16:39 Gah.

Old habits die hard, eh? Will fix. Thanks :).

– Lucas Jones Dec 20 '09 at 16:48.

Yes. If True: #dosomething else: #dosomething else #continue on with whatever you were doing Basically, wherever you would've had an opening curly brace, use a colon instead. Unindent to close the region.It doesn't take long for it to feel completely natural.

Yup. However, you define dictionaries in Python using curly braces: dict = { 'key': 'value', } Ahhhhhh.

Yup :) And there's (usually) a difference between 4 spaces and a tab, so make sure you standardize the usage ..

1 ghly recommended to uses 4 spaces over tab too, so please change old habits if you currently use tabs :) – Jordan Messina Dec 20 '09 at 17:17.

As others have mentioned, you are correct, no curly braces in Python. Also, you do not have no end or endif or endfor or anything like that (as in pascal or ruby). All code blocks are indentation based.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions