Python has plenty of warts[1], but I don't think the syntax is one of them (yet). Some of the more concerning warts:
# Mutable defaults in function parameters.
def fn(arg=[]):
arg.append(1)
print(arg)
fn() # [1]
fn() # [1, 1]
fn() # [1, 1, 1]
# Loop variables are shared across executions.
lambda_list = [lambda: print(i) for i in range(5)]
for fn in lambda_list: fn()
# 4
# 4
# 4
# 4
# 4
# Iterating over an exhausted generator yields an empty list.
numbers = (i for i in range(5))
assert 1 in numbers
print(list(numbers))
# []
# I hate this one because it could have easily been an error, it's
# hard to track down, and lots of stdlib functions return generators.
# Chained operators can sometimes be very unintuitive.
should_be_ascending = True
assert 1 < 2 == should_be_ascending
# AssertionError because it was interpreted as
# `(1 < 2) and (2 == should_be_ascending)`
[1]: https://github.com/satwikkansal/wtfpython"Mutating the immutable" is my personal favourite - the second line of code fails with an exception despite having already succeeded:
>>> t = ([1, 2], 5, 6)
>>> t[0] += [3, 4]
TypeError: 'tuple' object does not support item assignment
>>> print(t)
([1, 2, 3, 4], 5, 6)
I've never been a fan of the decision to have `a += b` sometimes do `a = a + b` and sometimes update `a` in place. My objection was initially just due to theoretical inelegance - but this code shows that decision directly causing a concrete problem."What the fuck Python?"
https://github.com/satwikkansal/wtfpython
Along with the corresponding HN discussion:
https://news.ycombinator.com/item?id=31566031 (450 points, 153 comments)
https://github.com/satwikkansal/wtfpython
HN thread: https://news.ycombinator.com/item?id=26097732 (163 comments)
PS: found with a site I'm building: https://discussions.xojoc.pw/?q=Understanding+Python+through...
Python's "easy to use" is just a lie, https://github.com/satwikkansal/wtfpython
The common lisp CFFI module is nothing short of Python's.
But, I know, people hate to put their `(` in front of their function names, and people hate to omit `,` between there function arguments.
BTW, that's not the "biggest" WTF feature; it's just my favorite. There's a long list of WTF features here:
https://github.com/satwikkansal/wtfpython
Otherwise, I agree, it's a pretty good going :-)
* https://dabeaz-course.github.io/practical-python/Notes/Conte... by David Beazley --> covers foundational aspects of Python programming with an emphasis on script writing, data manipulation, and program organization
* https://python-patterns.guide/ by Brandon Rhodes --> inspired from Gang of Four book
* https://github.com/satwikkansal/wtfpython (this is more of a collection) --> Exploring and understanding Python through surprising snippets
Also, my ebook Python re(gex)? covering re and regex modules is free to read online: https://learnbyexample.github.io/py_regular_expressions/ (pdf/epub is paid, available via leanpub/gumroad)
If you know what skills you are looking for (hint: lots of companies and recruiters don't), this is not actually that hard.
For every skill, there are questions that should be really easy to answer for everybody with expertise, but are suprising/hard to answer for everybody who pretends to have knowledge. This enables you to check quite quickly whether the claimed skills are actually there or not.
For example, the easier sections in
> https://github.com/satwikkansal/wtfpython
might give you a hint for topics that most seasoned Python programmers should know blindfolded while they are probably rather surprising for anybody with shallow Python knowledge. Let the applicant explain how they came up with their solution for, say, some of the problems, and you will see rather fast whether the claimed skills are actually there or not.
Itβs a collection of snippets to explain behaviors that may be considered unexpected.