osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tutor] beginning to code


Larry Hudson wrote:
> ROGER GRAYDON CHRISTMAN wrote:

[Note: RODGER's reply is slightly modified for clarity]
    
> > I have not yet mastered how to respond to a particular
> > note in a thread with the mailer that I use, so this is not
> > in response to anyone in particular, but just to some of
> > the sentiments as a whole.
> >
> > if x:
> >     # do something
> >
> > Completely out of context, I would dislike it just because
> > it is far too vague. Is it testing for zero?  for an empty
> > list?  or for some object's completely arbitrary
> > definition of truthiness?
> 
> It is absolutely NOT vague, 

Hmm, and neither are regular expressions, that is, once
you've been "trained" to decipher them. But ask a noob what
this simple Python regexp means:

    r"^([a-zA-Z]{3})(\d{3})$"
    
Even though the answer is as easy as "aBc" and "123" (a la
Jackson Five!), they'll just give you a look of
bewilderment. And even if we expand the digit-group to a
more "intuitive" character set, the student will still be
overwhelmed by the syntax:

    r"^([a-zA-Z]{3})([0-9]{3})$"

> and the answer is Yes for all of the above.  It is well
> defined that ALL values can be used in a boolean sense.

And likewise, it is well defined what the symbols in that
regexp mean, but the meaning is not _obvious_. My point is
that Python source code was meant to be "executable pseudo
code" (Python devs' words not mine!), and while regular
expressions are meant to be cryptic, Python source code was
not.