[python-win32] return & tuples (& lists)

Michel Claveau mc at mclaveau.com
Sun Jun 29 09:42:57 CEST 2008


Hi!

Not a question. Only a little note...  (for readers without Sunday activity)


In (pure) Python, consider this code:
    def ftest():
        vret=(111,222,333)
        return(vret)

    print ftest()     #give:  (111, 222, 333)


In (COM) Python, the same method of the class of a dynamic-COM-server give 
other return:
    def ftest():
        vret=(111,222,333)
        return(vret)

    pv = win32com.client.Dispatch('.......
    print pv.ftest()     #give:  111



In (pure) Python, this code:
    def ftest():
        vret=(111,222,333)
        return(vret,)   #note the comma!

    print ftest()     #give:  ((111, 222, 333),)


In (COM) Python, the same method of the class of a dynamic-COM-server give 
other return:
    def ftest():
        vret=(111,222,333)
        return(vret,)  #note the comma!

    pv = win32com.client.Dispatch('.......
    print pv.ftest()     #give:  (111, 222, 333)


Another detail:
    def ftest():
        vret=[111,222,333]  #list in the place of tuple
        return(vret)

    pv = win32com.client.Dispatch('.......
    print pv.ftest()     #give:  (111, 222, 333)


And, to finish: in COM,  return(vret) & return(vret,)  give the same result.



I wish you marvellous Sunday, with sun, bathe and aperitif.
-- 
Michel Claveau








More information about the python-win32 mailing list