Old Man Yells At Cloud
John Pote
johnpote at jptechnical.co.uk
Sat Sep 16 20:15:41 EDT 2017
On 16/09/2017 19:00, Stefan Ram wrote:
> Steve D'Aprano <steve+python at pearwood.info> writes:
>> "Hi, I've been programming in Python for what seems like days now, and here's
>> all the things that you guys are doing wrong.
> I never ever have written a line of Python 2. I started with
> Python 3.6.0. Yet a very frequent mistake of mine is the
> imission of parentheses after »print«.
>
> WRT my other common errors, It thought of writing
> a program that autocorrects my source code as follows:
>
> Whenever the next line is indented more, add a colon:
>
> abd def ghi
> jkl mno pqr
I've used Komodo in the past and that editor works other way round, type
a ':' at the end of a line and the next line is indented. I would
presume other language aware editors take the same approach.
print """
Your idea would require considerable inteligence in the editor,
1. Otherwise the previous line would print with a ':'
2. That would frustrate me.....
"""
>
> --------------------->
>
> abd def ghi:
> jkl mno pqr
>
> Whenever the next line is indented more, add "def" to
> what looks like a call (and does not start with »class«
> or »def«;
>
> f( x ):
> return x * x
>
> --------------------->
>
> def f( x ):
> return x * x
>
> Whenever a line starts with "print" and no parentheses
> are following, add them:
>
> print x, 2
Strangely I find it irksome to have to write print as a function call in
Python 3. Must reflect those long ago days when I started to program
(oops, I mean code - programming came later). Come to think of it
there's something irksome about every language I've ever used. Python
probably the least.....
>
> --------------------->
>
> print( x, 2 )
>
> Implementing algorithms from "The Art of Computer
> Programming" might sometimes be difficult in Python, since
> those algorithms IIRC often use »goto«.
Good point. I also have a copy of that work of art (and the fascicles -
I must get out more). Sadly little work these days requires diving into
them. In fairness to Knuth his pseudo code is a high level assembler
fully described in Vol:1 and done as such so folk from any high level
language background could follow the algorithms. Back then many like
myself, or indeed most coders, had a hardware background and well used
to assembler. The nearest thing most silicon has to structured
programming is call and return, gotos are everywhere.
I always think one of the reasons Basic became so popular was its /goto
/statement. The other was the run command, no need to compile.
See /http://entrian.com/goto// for a Python implementation from many
years ago. No idea if it still works. To be honist never needed it -
Python has exceptions.
Also there was a interesting thread '/"Goto" statement in Python/' in
April this year (not the 1st). Although mainly interesting for its
references to gotos in 'C' which I use daily now. err 'C' that is. . . .
. .
Used to wind up colleagues by saying loudly "Great, I can use a /*goto
*/here.....". This attracted considerable verbal abuse from purists in
earshot and instruction from the boss NOT TO which I pretended to
ignore. After all Python programming is supposed to be fun!
>
More information about the Python-list
mailing list