Brackets or no brackets in print


#1

Hello Codecademy,
Thanks a lot for your dedication to offering such wonderful knowledge ...for free. We're grateful!
Question- with some other learning resources (e.g. Pyhton.org - Dutch documentation) I learn that this is the right syntax for printing to the console:
print ("Hello world!")

But in this course we're taught the following:
print "Hello world!".

I know of Codecademy that the teaching covers the best practices, so I wonder why the exclusion of brackets in the code.

Cheers,
Khoel


#2

A site used by a lot of programmers is stackoverflow.com
google search
== discussions / opinions ==
python print() vs print site:stackoverflow.com
= http://stackoverflow.com/questions/6182964/why-is-parenthesis-in-print-voluntary-in-python-2-7

python expr vs tuple site:stackoverflow.com
python tuple explained site:stackoverflow.com
= http://stackoverflow.com/questions/3649841/what-are-differences-between-list-dictionary-and-tuple-in-python


#3

Opinion:

Best practice, as it were, is best practiced whence much practice has been done without consideration for it. Same applies to fine tuned syntax. If we focus on the t's and the i's, we miss the p's and q's. In other words write code that works, regardless. Now we begin to deconstruct and study that program. What makes it tick?

We might say, 'well you wrote it, why deconstruct it?' Answer: Because it forces us to look backwards through our own code which is analogous to proofreading from the end to the beginning of a manuscript. We find our mistakes, and often learn through the exercise of correcting those mistakes.

Eventually we become cognizant and conscientious of our code constructs. This is when to kick in best practice protocol. Why now? Because we understand what is expected and why from experience and retrospective examination of our own code. Until this time, any application of best practices is purely rote learning, and a garden path to black and white thinking.


#4

@khoel,

Found an other nice thing...

Python

== guidance ==
http://legacy.python.org/dev/peps/pep-0008/


#5

Thank you @leonhard_wettengmx_n and @mtf for your tips.
@mtf In my humble opinion: learning anything the best way 'possible' right from the beginning deserves the higher rank. Not much philosophy needed there.

I'm grateful guys.

Cheers


#6

@khoel,
Nice to know...
= http://stackoverflow.com/questions/10588317/python-function-global-variables


#7

Very inetersting indeed @leonhard_wettengmx_n. Thank you once more!


#8

"The only way to learn anything is to be confronted by our own misconceptions." Prof. Lawrence Krauss


#9

it can also have a Backfire effect....
= http://youarenotsosmart.com/2011/06/10/the-backfire-effect/


#10

Fortunately for us, programming is not founded upon any world view or belief system. It is rooted in empiricism, for the most part.


#11

http://dev.blog.stackoverflow.com/company/podcasts/page22/
https://blog.stackoverflow.com/2009/05/podcast-53/ <==parrot programmer, that's me...


#12

When people ask for the 'best way' or the 'right way' to do something, they invariably set themselves up to be parrots in an empirical world. That's why I suggest a little clumsy learning before the empiricism is drilled in. There's lots of time to learn syntax once enough mistakes have been made to understand why the syntax exists in the first plaice. That's intuition.

We should let our intuition ride shotgun at all times, Eventually the institutional nuances will funnel in as needs be along the way. The empirical ways will filter in, regardless; we only need to hold them to a trickle over time so our imaginations don't get stymied before we catch what we're on to.

In the final analysis it's a balancing act for anybody, keeping to the straight and narrow while also venturing off the beaten path; not forks in the road so much as diversions from it. We need structure and syntax, that's sure, so long as we don't corrupt the imagination with it.


#13

For any teachable beginner with the same question asked above:

Python 2.x : print "Hello World!" ---> 'print' is a statement
Python 3.x : print("Hello, World!") ---> 'print()' is a function

More on the fundamental contrasts between the two: https://www.youtube.com/watch?v=f_6vDi7ywuA

Many times, the simplest answers are simply the best! Happy learning...