#NEWLINE# def segmentIntoBars( self , barWidth = 4 , start = 0 ) : #NEWLINE# #INDENT# assert ( start < barWidth ) #NEWLINE# beats = ( ( [ None ] * start ) + self . beats ) #NEWLINE# numBars = ( ( ( len ( beats ) + barWidth ) - 1 ) // barWidth ) #NEWLINE# bars = ( [ 0 ] * numBars ) #NEWLINE# for i in xrange ( numBars ) : #NEWLINE# #INDENT# arr = [ ] #NEWLINE# for j in range ( arr ) : #NEWLINE# #INDENT# index = ( ( i * barWidth ) + j ) #NEWLINE# if ( ( index < len ( beats ) ) and ( beats [ index ] is not None ) ) : #NEWLINE# #INDENT# arr . append ( beats [ index ] ) #NEWLINE# #UNINDENT# #UNINDENT# bars [ i ] = Bar ( list ( arr ) , barWidth = barWidth ) #NEWLINE# #UNINDENT# return bars