On Fri, Sep 22, 2017 at 4:24 PM Simon Anderson <[email protected]>
wrote:
> That is correct. From my understanding, print will query each objects
> _repr_ which it stores in a tuple and then prints that tuple out.
> The reason why the single value is not a tuple, is that you cannot create
> a tuple with one value.
>
> ie variableA = (), or variableA = (1) should both fail
> if you want to create a tuple with only one value you have to write
> variableA = (1,)
>
The print statement (python 2.x) does not create a tuple. It is printing
the repr of whatever you give it.
The syntax being used is actually creating a tuple:
tup = (1,)
>
> On Friday, 22 September 2017 13:27:19 UTC+10, jettam wrote:
>>
>> I have a question about adding a comma to the end of a these print
>> statements. In the first example ( print (Blah)) with out the comma,
>> it prints the string? and in the second example where I added the comma (
>> print (Blah,) ) It turns it into a tuple? Is my observation correct
>> here?
>>
>> Blah = "the comma changes it into, a tuple!?"
>> print (Blah)
>> # result: the comma changes it into, a tuple!?
>>
>>
>> Blah = "the comma changes it into, a tuple!?"
>> print (Blah,)
>> # result: ('the comma changes it into, a tuple!?',)
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/2a74e97c-21f1-4fed-a2fc-42b2d54d06fb%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/2a74e97c-21f1-4fed-a2fc-42b2d54d06fb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2sDjkEeOjoDW6F8ksAGUepCUxDsZhsi5q1JfJ9Ypbe6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.