[Tutor] (no subject)

Liam Clarke cyresse at gmail.com
Tue Nov 30 01:23:42 CET 2004


Hi Jeff, 

You can do that, just chuck it in brackets. 

i.e.

a=(1+2+3+4+5+6+7+8+9+
     10+11+12+13+14+14+15
       +19+20+212)

or for a list - 

a=[1,2,3,4,5,6,7,8,9,10,
      11,12,13,14,15,16,17,
       18,29,20]

You can also do it for lists of lists, good for the array mindset.

a=[
     [1,2,3],
     [4,5,6],
     [7,8,9]
      ]

Makes it easier to think of as a 2D array.

or dictionaries

a={ 'a':1,
        'b':2, 'c':3, 'd':4,
         'e':5
        }

Python knows to keep reading until the closing bracket.

HTH

Liam Clarke

On Mon, 29 Nov 2004 15:58:29 -0800 (PST), Jeff Peery
<jeffpeery at yahoo.com> wrote:
> 
> Hello, 
>   
> was wondering how python handles multi-line code. for example if I have a
> really long equation and I don't want to have to scroll over to look at it,
> can I just continue the equation on the next line? is this good practice?
> similarly can I do this for things like dictionaries and lists? 
>   
> thanks. 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list