On Tue, 14 Sep 2010 02:08:43 pm Vince Spicer wrote:

> Hey Tyler you can simplify this with a onliner.
>
> rg1, rg2, rg3 = rgenre + ["NA"]*(3-len(rgenre[:3]))

There's no real need to calculate the exact length that you want:

rg1, rg2, rg3 = (rgenre + ["NA"]*3)[:3]

For small numbers of items -- and three is pretty small -- that will be 
plenty efficient enough. If you had thousands of items, perhaps not, 
but for three, it's not worth the effort to try to be more clever.



-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to