Re: How well do you know Python?

2016-07-05 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Tue, 5 Jul 2016 07:51 pm, Jussi Piitulainen wrote: > >> Chris Angelico writes: >> >>> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: It looks like $ python3 -c 'print({1, 2})' {1, 2} $ python3 -c 'print({2, 1})' {1, 2} will

Re: How well do you know Python?

2016-07-05 Thread Lawrence D’Oliveiro
On Tuesday, July 5, 2016 at 9:51:21 PM UTC+12, Jussi Piitulainen wrote: > > Chris Angelico writes: > >> Then hash randomization kicks in, and you can run the exact same line >> of code multiple times and get different results. It's a coin toss. > > Oh, nice, a new way to generate random bits in s

Re: How well do you know Python?

2016-07-05 Thread Carl Meyer
On 07/05/2016 05:50 AM, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 9:33 PM, Peter Otten <__pete...@web.de> wrote: >> Chris Angelico wrote: >> >>> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: What will $ cat foo.py import foo class A: pass p

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 9:33 PM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: >>> What will >>> >>> $ cat foo.py >>> import foo >>> class A: pass >>> print(isinstance(foo.A(), A)) >>> $ python -c 'import foo'

Re: How well do you know Python?

2016-07-05 Thread Peter Otten
Chris Angelico wrote: > On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: >> What will >> >> $ cat foo.py >> import foo >> class A: pass >> print(isinstance(foo.A(), A)) >> $ python -c 'import foo' >> ... >> $ python foo.py >> ... >> >> print? > > I refuse to play around with

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tue, 5 Jul 2016 07:51 pm, Jussi Piitulainen wrote: > Chris Angelico writes: > >> On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: >>> 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 c

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tue, 5 Jul 2016 06:36 pm, Peter Otten wrote: > 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? Define "s

Re: How well do you know Python?

2016-07-05 Thread Jussi Piitulainen
Chris Angelico writes: > On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten wrote: >> 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

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano wrote: > > Got any other tricky questions to add? S P O I L E R S P A C E A N D A B I T M O R E [Thanks Steven, I just copied and pasted your space. See? You can copy and paste blank space and use it over and over. Could be a useful tip for t

Re: How well do you know Python?

2016-07-05 Thread Chris Angelico
On Tue, Jul 5, 2016 at 6:36 PM, Peter Otten <__pete...@web.de> wrote: > What will > > $ cat foo.py > import foo > class A: pass > print(isinstance(foo.A(), A)) > $ python -c 'import foo' > ... > $ python foo.py > ... > > print? I refuse to play around with isinstance and old-style classes. Particu

Re: How well do you know Python?

2016-07-05 Thread Christian Gollwitzer
Am 05.07.16 um 10:22 schrieb Steven D'Aprano: On Tuesday 05 July 2016 16:38, Chris Angelico wrote: On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano wrote: What happens in this code snippet? L = [1] t = (L,) t[0] += 1 Explain what value t has, and why. Not sure you have that que

Re: How well do you know Python?

2016-07-05 Thread Peter Otten
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 f

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tuesday 05 July 2016 16:38, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano > wrote: >> What happens in this code snippet? >> >> L = [1] >> t = (L,) >> t[0] += 1 >> >> Explain what value t has, and why. > > Not sure you have that question right, because it

Re: How well do you know Python?

2016-07-04 Thread Chris Angelico
On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano wrote: > What happens in this code snippet? > > L = [1] > t = (L,) > t[0] += 1 > > Explain what value t has, and why. Not sure you have that question right, because it simply gives a TypeError. You can't add an integer to a list. ChrisA

Re: How well do you know Python?

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:02, 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 functiona

Re: How well do you know Python?

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:02, 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 functiona

How well do you know Python?

2016-07-04 Thread Chris Angelico
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