[pyar] Nueva version del tutorial de 8 clases

Joaquin Sorianello soriasoft en gmail.com
Mar Dic 7 12:23:58 ART 2010


2010/12/7 nicolás rosbaco <antiyanki en gmail.com>:
> una duda con respecto a la página 9 del primer capítulo:
>
> se lee este ejemplo:
>>>> a=[1,2,3] #esto es una lista
>>>> print(a,sep=';')
> [1, 2, 3]
>>>> print(*a,sep=';')
> 1;2;3
>
>
> yo lo pruebo y me pasa esto:
>
>>>> a=[1,2,3]
>>>> print(a)
> [1, 2, 3]
>>>> print(*a,sep=';')
>   File "<stdin>", line 1
>     print(*a,sep=';')
>           ^
> SyntaxError: invalid syntax

Probablemente el curso es para python >= 3

pero desde python 2.6 (si no me equivoco)  podes hacer from __future__
import print_function

Python 2.6.5 (r265:79063, Apr  1 2010, 05:28:39)
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> print("hola")
hola
>>> a = [1,2,3]
>>> print(a, sep=';')
[1, 2, 3]
>>> print(*a, sep=';')
1;2;3
>>>


-- 
Joaquín Sorianello

Sea libre, use software libre



More information about the pyar mailing list