[pyar] [Pyar] Comportamiento de funcion Return devuelve NONE

Javier Baigorri jbaigorri en hotmail.com
Lun Mayo 23 09:36:16 ART 2016


La aplicacion tiene una buena salida cuando utilizo la funcion PRINT, pero cuando lo sustituyo por RETURN me devuelve NONE.No entiendo porque se comporta asi Python.
Salida con funcion PRINT():==== RESTART: C:\Users\...\Python class\listToSplit.py ====
['lst floor, GROUP A: 27.87m3(12.47, 0.99, 14.41)Volume']**********['2nd floor, GROUP A: 147.08m3 Volume']['2nd floor, GROUP B: 102.82m3(57.91, 44.91)Volume']['2nd floor, GROUP C: 64.2m3 Volume']**********['3rd floor, GROUP C: 8.05m3(6.6, 0.67, 0.78)Volume']**********

Salida con funcion RETURN():==== RESTART: C:\Users\...\Python class\listToSplit.py ====
[['lst floor, GROUP A: 27.87m3(12.47, 0.99, 14.41)Volume'], None, ['3rd floor, GROUP C: 8.05m3(6.6, 0.67, 0.78)Volume']]
No entiendo porque me devuelve NONE en lugar de la lista como hace con la funcion PRINT.
He creado una variable local y entonces si que puedo crear la lista que deseo.Salida utilizando una variable local.==== RESTART: C:\Users\...\Python class\listToSplit.py ====
-----[ ['lst floor, GROUP A: 27.87m3(12.47, 0.99, 14.41)Volume'],   ['2nd floor, GROUP A: 147.08m3 Volume'],   ['2nd floor, GROUP B: 102.82m3(57.91, 44.91)Volume'],   ['2nd floor, GROUP C: 64.2m3 Volume'],   ['3rd floor, GROUP C: 8.05m3(6.6, 0.67, 0.78)Volume'] ]
Pero tengo curiosidad por saber porque pasa esto con la funcion RETURN.

Gracias (mi primer contacto con vosotros)
Codigo utilizado:
def lin(lista):    for elem in lista:        volume = 0        volumeStr = ""        lineOut = ""        lnResult = []        if isinstance(elem, list):            tmp = "es una lista"            lin(elem)        else:            lstNum = lista[1:len(lista)-1]            for k in range(0,len(lstNum)):                volume = volume + lstNum[k]                if len(volumeStr) == 0  and len(lstNum) > 1 :                    volumeStr = "(" + str(lstNum[k])                elif len(lstNum) == 1:                    volumeStr = str(lstNum[k])                else:                    volumeStr = volumeStr + ", " + str(lstNum[k])                                if len(lstNum) > 1:                volumeStr = volumeStr + ")"
            lineOut = str(round(volume,2)) + "m3"            if len(lista) > 3:                lineOut = lineOut + volumeStr + "Volume"            else:                lineOut = lineOut + " Volume"                            lineOut = lista[len(lista)-1] + ", " + lista[0] + ": " + lineOut            lnResult.append(lineOut)            print(lnResult)            valor.append(lnResult)            return lnResult            break
lstTotal = []lstA = ["GROUP A", 12.47,0.99,14.41,"lst floor"]lstB = [["GROUP A",147.08,"2nd floor"],["GROUP B",57.91,44.91,"2nd floor"],["GROUP C",64.2,"2nd floor"]]lstC = ["GROUP C",6.6,0.67,0.78,"3rd floor"]lstTotal.append(lstA)lstTotal.append(lstB)lstTotal.append(lstC)
valor = []tmp = ""tmpLine = []cant = 0volumeQ = 0lineStr = ""lineResult = []
for j in range(0, len(lstTotal)):    tmpLine = lstTotal[j]    lineStr = lin(tmpLine)    if not isinstance(tmpLine, list):        lineStr = valor        print("no soy una lista")    print("**********")    lineResult.append(lineStr)

print(lineResult)print("-----")print(valor)
 		 	   		  
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20160523/497cac15/attachment-0001.html>


Más información sobre la lista de distribución pyar