On Mon, 25 Jan 2010 01:06:45 -0000 "Alan Gauld" <alan.ga...@btinternet.com> wrote:
> > "Lie Ryan" <lie.1...@gmail.com> wrote > > >> and used print, I thought they would be considered the same whether as > >> a variable, or as a direct line, guess not. > > what is equivalent: > > print (a, b, c) > > > > and > > x = a, b, c > > print x > > > > both construct a tuple and prints a,b,c as tuple > > Not quite: > > >>> a = 1 > >>> b = 2 > >>> c = 3 > >>> x = a,b,c > >>> print a,b,c > 1 2 3 > >>> print x > (1, 2, 3) > >>> > > The first form prints multiple values the second prints the repr of a > single tuple value. The output is different. > > Alan G. Lie's example actually was: >>> a,b,c = 1,2,3 >>> print (a,b,c) # here parenthesized (1, 2, 3) >>> x = a,b,c >>> print x (1, 2, 3) Both output values are tuples. Denis ________________________________ la vita e estrany http://spir.wikidot.com/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor