Your beloved python features

C

CM

GvR got it right when he discarded the superfluous semicolons from the ends
of statements--and then he ADDS superfluous colons to the ends of control
statements? It will probably be as much of a shock to you as it was to me
when I learned after studying parsing that colons, semicolons, "then"'s and
"do"'s, etc.,  are simply noise tokens that serve no purpose except to
clutter up the source.

Some argue that the colon is a useful visual cue that aids in
readability and
that "explicit is better than implicit". I think one can feel either
way about it.
For my part, I prefer to have colons at that point, because it serves
as a
mental primer that a certain type of block follows. Semi-colons at
the end
of statements don't seem to provide any mental priming for me that
can't
better be served by a line break.
As for enforced indentation, back in the late 60's when I was a programming
newbie I remember thinking how cool it would be to just indent the
statements controlled by for loops (we didn't have none of them fancy while
loops in FORTRAN back then! :) )  Not too long after that I saw the havoc
that a buggy editor could wreak on nicely-formatted source. :-( Formatting
held hostage to a significant, invisible whitespace char? An inevitable
accident waiting to happen! Not good, Guido; not good at all.

First, why would you tolerate a buggy editor?

I've had my share of challenges in learning Python, but indentation
problems
would be about 403rd down on the list. A simple indentation error is
shown in
my editor that immediately gets fixed. No havoc at all. And I also
know that
every piece of Python code I ever get from others *has* to be readable
(at
least in terms of the very visually helpful indented blocks).

Che



Che
 
S

Steven D'Aprano

Choose to get your difficult questions about threads in Python ignored.
Oh well..

With an attitude like that, you're damn lucky if you don't get kill-
filed. It was SIX MINUTES since you posted your question about timers,
what did you expect?

Threads are hard, and many people don't use them at all. You might never
get an answer, even without alienating people. Complaining after six DAYS
might be acceptable, if you do it with a sense of humour, but after six
minutes?

Advice on public forums is free, but it doesn't come with an guaranteed
response time. If you want a Service Level Agreement, you will need to
pay somebody for it.
 
S

Steven D'Aprano

GvR got it right when he discarded the superfluous semicolons from the
ends of statements--and then he ADDS superfluous colons to the ends of
control statements?

They're not superfluous, they have a real, practical use.

It will probably be as much of a shock to you as it
was to me when I learned after studying parsing that colons, semicolons,
"then"'s and "do"'s, etc., are simply noise tokens that serve no
purpose except to clutter up the source.

Incorrect, they do have a use. Hint: source code isn't just read by
parsers.


As for enforced indentation, back in the late 60's when I was a
programming newbie I remember thinking how cool it would be to just
indent the statements controlled by for loops (we didn't have none of
them fancy while loops in FORTRAN back then! :) ) Not too long after
that I saw the havoc that a buggy editor could wreak on nicely-formatted
source. :-(

As opposed to how resistant source code is to buggy editors that make
other changes to source code.

If your editor flips the order of characters, or turns the digit "4" into
"7", or deletes braces, or inserts "#" characters at the start of lines,
you would dump the editor in a second. But if the editor inserts or
removes whitespace, we're supposed to continue using the editor and
change the language?

Formatting held hostage to a significant, invisible
whitespace char?

It's not invisible. You can see it by noticing the space between the left
margin and the start of non-whitespace text. Can you see the difference
between these?

hello world

hello world

Of course you can, unless your News reader or mail client is buggy. If it
is deleting whitespace at the start of lines, how can you trust it not to
delete anything else?

Trailing spaces and tabs, on the other hand, *are* invisible. But they're
also insignificant, and so don't matter.

(Except for one little tiny corner case, which I shall leave as an
exercise for the advanced reader.)
 
T

Tim Chase

Steven said:
Trailing spaces and tabs, on the other hand, *are* invisible. But they're
also insignificant, and so don't matter.

(Except for one little tiny corner case, which I shall leave as an
exercise for the advanced reader.)

Drat, now I'm gonna be up at odd hours tonight dredging my brain
for such corner cases. My catalog so far:

- triple-quoted multi-line strings

- "\" line-continuations don't work with trailing whitespace
(though Vim's syntax highlighting flags them, changing their
color if there's whitespace afterwards)

- files that read themselves (or perhaps depend on
introspection/debugging modules to read themselves)

Any others that I missed?

-tkc
 
S

Schif Schaf

My reasoning: I needed a language more powerful than bash, but more  
portable and faster to develop (at least small scripts) than C/C++. So  
I needed a scripting language. Python, Ruby, Perl, Tcl, ...?

Python seems to be the language with the most libraries available,

I like Python a lot. That said, it looks like Perl's CPAN currently
has approximately double the number of packages in the Cheeseshop.

I'm guessing the CPAN is still growing, but I don't know how fast it
is growing compared to the Cheeseshop.

I won't venture a guess as to which has a higher percentage of older
unmaintained packages.
 
A

Anssi Saari

Julian said:
I've asked this question at stackoverflow a few weeks ago, and to make
it clear: this should NOT be a copy of the stackoverflow-thread
"hidden features of Python".

Thanks for the hint, interesting stuff in there.
For those guys would be a poster quite cool which describes the most
popular and beloved python features.

For me as an electronics HW guy, I really like that I can easily
handle binary data without doing tedious and error prone shifting and
anding and oring.
 
A

Aahz

I want to design a poster for an open source conference, the local
usergroup will have a table there, and in the past years there were
some people that came to the python-table just to ask "why should I
use python?".

Readability
 
S

Steven D'Aprano

Well, it's 4 days now. I would be happy to get 50% response rate.
Apparently nobody is really using threads.

Please see my response to your post "timer for a function".
 
J

Julian

hello there,

thanks everyone for that many answers! I'm lying in bed with a bad
cold, so I'll get through all the posts on the weekend.

regards
Julian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,237
Latest member
AvivMNS

Latest Threads

Top