Python-ideas summary [2018-09]

Pre-conditions and post-conditions

The discussion from last month continues. How do contracts differ from asserts? What is their relationship with unit tests?

Keyword only argument on function call

Anders HovmΓΆller suggests a syntax for specifying keyword arguments where the local variable name matches the formal parameter name:

foo(a=a, b=b, c=c, d=3, e=e) # current syntax
foo(*, a, b, c, d=3, e) # equivalent

Related discussion.

Python dialect that compiles into python

Robert Vanden Eynde suggests a python transpiler that compiles syntax extensions into standard python:

  • a,b += f(x) β†’ _t = f(x); a += _t; b += _t; (augmented assignement unpacking)
  • a = 2x + 1 β†’ a = 2*x + 1 (juxtaposition is product)
  • f(*, x, y) β†’ f(x=x, y=y) (simplekwargs)
  • DSL specific language
  • all def become @partially def
  • etc...

Add Unicode-aware str.reverse() function?

Paddy3118 proposes that python should have a string-reversing function that doesn't mess up combining characters and such. The ensuing discussion has some interesting examples of problems with RTL, combining characters, etc. As Stephan Houben notes, though, it is rarely necessary to reverse a string outside of programming puzzles.

Retire or reword the "Beautiful is better than ugly" Zen clause

Samantha Quan suggests that the statement "Beautiful is better than ugly." in the Zen of Python is Lookist and will make people feel excluded, so it should be changed or removed. Some participants in the discussion opine that Quan is trolling (perhaps following from a recent python issue), some reject the proposal as politically correct nonsense, and some at least mildly support the idea.

One post suggested that "the Language should be renamed to Cobra, after the brilliant military strategist Cobra Commander" so as not to offend humorless people with all the Monty Python references.

Pattern Matching Syntax (reprise)

Tobias Kohn posts a followup to a previous discussion on pattern matching. He has produced a pattern matching library, pyPMatch, and offers it up along with some discussion about his design choices.

todo