Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111112

Re: How well do you know Python?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: How well do you know Python?
Date Tue, 05 Jul 2016 10:36:04 +0200
Organization None
Lines 49
Message-ID <mailman.91.1467707774.2295.python-list@python.org> (permalink)
References <CAPTjJmoZobGYDh8jWDPPWQqoN-gid+-HUp9-dtKX_Vp=BgHc+w@mail.gmail.com> <nlfrhl$bq1$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de 4UGQNLBUGfz9UvVsFKp2/Aec1lJLJvEfQSrBJmQvutBg==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'python3': 0.05; 'subject:How': 0.09; '__future__': 0.09; 'absent': 0.09; 'craft': 0.09; 'integers': 0.09; 'operator,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'valueerror': 0.09; 'python': 0.10; 'assume': 0.11; 'exception': 0.13; '2.7?': 0.16; '3.0,': 0.16; 'anyhow,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'reinstated': 0.16; 'wrote:': 0.16; 'string': 0.17; 'programmer': 0.18; '3.x': 0.22; 'pass': 0.22; 'tried': 0.24; 'import': 0.24; 'discussion': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'looks': 0.29; 'cat': 0.29; 'operators': 0.29; 'rails': 0.29; 'stated.': 0.29; 'print': 0.30; "i'd": 0.31; 'core': 0.32; 'class': 0.33; 'foo': 0.33; 'replace': 0.35; 'but': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'difference': 0.38; 'skip:p 20': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'some': 0.40; 'questions': 0.40; 'future': 0.60; 'provide': 0.61; 'more': 0.63; 'different': 0.63; 'between': 0.65; 'case?': 0.84; 'construct': 0.84; 'subject:you': 0.85; 'subject:know': 0.91; 'why?': 0.91; 'tricky': 0.93
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd87fc.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <nlfrhl$bq1$1@ger.gmane.org>
X-Mailman-Original-References <CAPTjJmoZobGYDh8jWDPPWQqoN-gid+-HUp9-dtKX_Vp=BgHc+w@mail.gmail.com>
Xref csiph.com comp.lang.python:111112

Show key headers only | View raw


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?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: How well do you know Python? Peter Otten <__peter__@web.de> - 2016-07-05 10:36 +0200
  Re: How well do you know Python? Steven D'Aprano <steve@pearwood.info> - 2016-07-05 20:35 +1000

csiph-web