On Sun, Nov 23, 2014, at 00:59, Steven D'Aprano wrote:
> >> It works fine now (Python 3.3).
> >>
> >> py> L = []
> >> py> t = (L, None)
> >> py> L.append(L)
> >> py> L.append(t) # For good measure.
> >> py> print(t)
> >> ([[...], (...)], None)
> >
> > This is a tuple in a list in a tuple, not
Ethan Furman wrote:
> On 11/21/2014 08:43 PM, Steven D'Aprano wrote:
>> random...@fastmail.us wrote:
>>>
>>> I think I tried on at least one python version and printing the tuple
>>> crashed with a recursion depth error, since it had no special protection
>>> for this case the way list printing d
On 11/21/2014 2:30 PM, Zachary Ware wrote:
On Fri, Nov 21, 2014 at 12:37 PM, Ian Kelly wrote:
Here's a nice crash. I thought this might similarly produce a
recursion depth error, but no, it's a seg fault!
$ cat test.py
import itertools
l = []
it = itertools.chain.from_iterable(l)
l.append(it)
On 11/21/2014 08:43 PM, Steven D'Aprano wrote:
> random...@fastmail.us wrote:
>>
>> I think I tried on at least one python version and printing the tuple
>> crashed with a recursion depth error, since it had no special protection
>> for this case the way list printing does.
>
> It works fine now
On Saturday, November 22, 2014 10:40:23 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Nov 22, 2014 at 4:02 PM, Rustom Mody wrote:
> > Thats not a single expression; which is possible with a lazy
> > evaluation language like Haskell.
> > Prelude> let ones = 1 : ones
>
> I'm not sure "lazy evaluatio
On Sat, Nov 22, 2014 at 4:02 PM, Rustom Mody wrote:
> Thats not a single expression; which is possible with a lazy
> evaluation language like Haskell.
> Prelude> let ones = 1 : ones
I'm not sure "lazy evaluation" is the key here, unless it also does
name lookups lazily. What happens if you do thi
On Saturday, November 22, 2014 10:20:36 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Nov 22, 2014 at 3:43 PM, Steven D'Aprano wrote:
> > random832 wrote:
> >
> >> There's no reason not to allow it with tuples, but you can't do it.
> >> Mainly because doing it in a single literal would require speci
On Sat, Nov 22, 2014 at 3:43 PM, Steven D'Aprano
wrote:
> random...@fastmail.us wrote:
>
>> There's no reason not to allow it with tuples, but you can't do it.
>> Mainly because doing it in a single literal would require special
>> syntax, whereas you can simply append to a list a reference to its
random...@fastmail.us wrote:
> On Fri, Nov 21, 2014, at 02:00, Marko Rauhamaa wrote:
>> Gill Shen :
>>
>> > How is this [nesting] behavior implemented under the hood?
>>
>> Pointers.
>>
>> > And why is this allowed at all?
>>
>> There's no reason not to.
>
> There's no reason not to allow it
On Fri, Nov 21, 2014 at 12:37 PM, Ian Kelly wrote:
> Here's a nice crash. I thought this might similarly produce a
> recursion depth error, but no, it's a seg fault!
>
> $ cat test.py
> import itertools
>
> l = []
> it = itertools.chain.from_iterable(l)
> l.append(it)
> next(it)
> $ python3 test.p
On Fri, Nov 21, 2014 at 10:39 AM, wrote:
> On Fri, Nov 21, 2014, at 02:00, Marko Rauhamaa wrote:
>> Gill Shen :
>>
>> > How is this [nesting] behavior implemented under the hood?
>>
>> Pointers.
>>
>> > And why is this allowed at all?
>>
>> There's no reason not to.
>
> There's no reason not to a
On Fri, Nov 21, 2014, at 12:47, Chris Angelico wrote:
> You can do it in C, I believe - PyTuple_New() followed by
> PyTuple_SetItem(x, 0, x) should do it.
Yeah, that's how I did it. I think python 2 crashed and python 3
didn't... or maybe it was the interactive interpreter that crashed and
calling
On Sat, Nov 22, 2014 at 4:39 AM, wrote:
> There's no reason not to allow it with tuples, but you can't do it.
> Mainly because doing it in a single literal would require special
> syntax, whereas you can simply append to a list a reference to itself.
>
> I think I tried on at least one python ver
On Fri, Nov 21, 2014, at 02:00, Marko Rauhamaa wrote:
> Gill Shen :
>
> > How is this [nesting] behavior implemented under the hood?
>
> Pointers.
>
> > And why is this allowed at all?
>
> There's no reason not to.
There's no reason not to allow it with tuples, but you can't do it.
Mainly beca
On Thu, Nov 20, 2014 at 10:54 PM, Gill Shen wrote:
> How is this behavior implemented under the hood? And why is this allowed at
> all? Is it just a curiosity or can you do something useful with it?
Reference cycles are common in Python and other OO languages. For
example, adding a widget to a w
Gill Shen :
> How is this [nesting] behavior implemented under the hood?
Pointers.
> And why is this allowed at all?
There's no reason not to.
> Is it just a curiosity or can you do something useful with it?
It absolutely does arise every here and there. It's so natural you don't
even pay att
On Fri, Nov 21, 2014 at 4:54 PM, Gill Shen wrote:
> How is this behavior implemented under the hood? And why is this allowed at
> all? Is it just a curiosity or can you do something useful with it?
Simple: The list contains itself. When you dereference the list, you
get back the original list. I
17 matches
Mail list logo