Chris Angelico wrote: > After some discussion with a Ruby on Rails programmer about where Ruby > ends and where Rails begins (and it's definitely not where I'd have > expected... Rails does a ton of monkey-patching, including of built-in > types, to provide functionality that is strangely absent from the core > language), I tried to come up with some somewhat-challenging Python > questions. But to make them hard, I had to go a smidge more esoteric > than the Ruby questions did.... Anyhow, see how you go. Assume Python > 3.x unless stated. > > 1) Under what circumstances can str.upper() return a string of > different length to its input? > 2) What exception do you get when you craft an impossible class hierarchy? > a. ValueError b. TypeError c. types.ClassInheritanceError d. > SyntaxError > 3) What does `from __future__ import braces` do? > 4) Which operator, removed from Python 3.0, can be reinstated with a > 'joke' future directive? > 5) What is the difference between the `/` and `//` operators in Python > 2.7? In Python 3.x? > > Got any other tricky questions to add?
What will $ cat foo.py import foo class A: pass print(isinstance(foo.A(), A)) $ python -c 'import foo' ... $ python foo.py ... print? It looks like $ python3 -c 'print({1, 2})' {1, 2} $ python3 -c 'print({2, 1})' {1, 2} will always print the same output. Can you construct a set from two small integers where this is not the case? What's the difference? What happens if you replace the ints with strings? Why? -- https://mail.python.org/mailman/listinfo/python-list