Quotes out of context with mistaken assumptions, now follow: > >>>> So c[:]() -- or the more recent go(c)() -- executes all those > >>>> behaviors. > > No it doesn't. See below. > > > > If c[:]() works, the so does this, using real world names > > > > orchestra[:].pickle() > > orchestra[conductor()].sequence() > > > > Though, I'm already starting to prefer: > > > > do(orchestra).pickle() > > do(orchestra(conductor)).sequence() > > > Yes, dammit, but c[:]() *DOESN'T WORK* unless you have made some pretty > crufty changes to the underlying object.
I started this thread asking why c[:]() doesn't work. > This is what I'm having difficulty understanding. You said, in your > original post (which, by the way, hijacked another thread about > something completely different): What?!? I started this thread. > > I want to call every object in a tupple, like so: > > > [By the way, that's "tuple", not "tupple"] > > #------------------------------------------ > > def a: print 'a' > > def b: print 'b' > > c = (a,b) > > > >>>> >>>c[:]() # i wanna > > TypeError: 'tupple' object is not callable > > > >>>> >>>c[0]() # expected > > a > >>>> >>>c[:][0] # huh? > > a > This is what I just don't believe. And, of course, the use of "tupple" > above tells us that this *wasn't" just copied and pasted from an > interactive session. Try it. > >>>> >>> [i() for i in c] # too long and ...huh? > > a > > b > > [None,None] > > #------------------------------------------ > This is also clearly made up. I repeat: try it. > In a later email you say: > > > why does c[:][0]() work but c[:]() does not? > > The reason for this ... Stated elsewhere, but thanks > > Why does c[0]() has exactly the same results as c[:][0]() ? > > The reason for this is that c is exactly the same as c[:]. The slicing > notation "[:]" tells the interpreter to use a tuple consisting of > everything in the tuple to which it's applied. Since the interpreter > knows that tuples are immutable (can't be changed), it just uses the > same tuple -- since the immutability there's no way that a difference > could arise between the tuple and a copy of the tuple, Python doesn't > bother to make a copy. > > This behavior is *not* observed with lists, because lists are mutable. But neither tupples or lists work, so immutability isn't an issue. > I realise you are trying to find ways to make Python more productive for > you, and there's nothing wrong with that. But consider the following, > which IS copied and pasted: > > >>> def a(): > ... print "A" > ... > >>> def b(): > ... print "B" > ... > >>> c = (a, b) > >>> c > (<function a at 0x7ff4f764>, <function b at 0x7ff4f64c>) > >>> c[:] > (<function a at 0x7ff4f764>, <function b at 0x7ff4f64c>) > >>> c[0]() > A > >>> c[1]() > B > >>> c() > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'tuple' object is not callable > >>> c[:]() > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'tuple' object is not callable > >>> I never said that c() would execute a list nor did I ever say that c[:]() would execute a list. > I think the fundamental mistake you have made is to convince yourself that > > c[:]() > > is legal Python. It isn't, it never has been. In summation: I started this thread asking why c[:]() wouldn't work I did not hijack another thread I posted working examples (with one typo, not quoted here) I am extremely annoyed by this post Tis best not to assume what other people are thinking -- http://mail.python.org/mailman/listinfo/python-list