Python is going to be hard

Rustom Mody rustompmody at gmail.com
Thu Sep 4 02:23:04 EDT 2014


On Thursday, September 4, 2014 10:33:38 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Sep 4, 2014 at 2:11 PM, Rustom Mody wrote:
> > Is there some PEP filed called "Abolish print in python 4" ?
> > I dont remember filing any such...

> You screamed "NO PRINT" at us in the voice of Edna Mode. (At least,
> that's how I imagined it being said. YMMV.)

> > Perhaps you should think of the relevance (rather than the
> > correctness) of your arguments Chris!  Are you arguing
> > 1. With me?
> > If 1 then yeah I know when to use prints and when not

> This. Then why are you advocating their non-use to new programmers?
> Are you really saying print() is for experienced people only? Or, more
> generally, that it should be possible for new programmers to do
> absolutely all their coding at the REPL, never using any function with
> side effects or mutating any state? (I was going to say "or using any
> mutable objects", but since Python doesn't have tuple comprehensions,
> you'd have to use lists. But if you never change what a list contains,
> it comes to the same thing.)

A patient goes to hospital. The first thing the nurses do (even before the
doctor arrives) is to stick all kinds of tubes into... eyes, nose, ears and
other unmentionable places.  The doctor arrives and orders a few more invasions.
Some of these are for helping eg a saline drip to a dehydrated patient, mostly
they are for 'debugging' the patient -- what things are there in the blood (etc)
that should not be or what is defcient that should be etc etc

Would you consider it acceptable that when the patient is declared cured,
he/she is sent home with these tubes hanging out?

Sure there are exceptions -- eg a patient needs a plaster/pacemaker etc.
As a rule he/she should be freed from all this.

You seem to think a print hanging out of a program to be ok, normal.
I consider it exceptional.

At the level of expertise of the OP -- this thread starts with
confusion about a for -- the foll. is totally irrelevant.  However
since you are bringing in heavy-duty examples like 'ray-tracing
animation' lets see a few examples:

1. Program is a gui -- There can be no meaningful prints, only
GUI-toolkit dialogs.
2. Program is a web-app -- It is painful and inefficient to generate
the html with prints. The correct approach is to use a templating engine
3. Program is a classic unix filter. If it is doing something entirely trivial
-- eg cat -- it matters little how its written.  If it is doing something significant
it is best structured into IO and computation separated
4. Programmer is a noob. You would start him on scripts.
I would start him in the REPL

> Because that is what I'm arguing against. New programmers and
> experienced programmers alike need their code to produce output, and
> return values are just one form of that. Excluding all other forms is
> unnecessary.

There is such a thing as law of primacy -- what is learnt first is remembered 
most. And there are many important things when learning programming/python.
One of them is debugging. print is excellent for that.

But there are more important things than that -- like structuring code and
using appropriate data structures. Putting print in the place of primacy
screws up that learning curve



> > Is there some PEP filed called "Abolish print in python 4" ?
> > I dont remember filing any such...

> You screamed "NO PRINT" at us in the voice of Edna Mode. (At least,
> that's how I imagined it being said. YMMV.) 

Dos and donts for adults and for children are different (at least in
my part of the world) ;-)



More information about the Python-list mailing list