Speaking of which, is there some place you or anyone can recommend on picking up all the constructs for list comprehension & generator comprehension. I've perused the python.org documents and have just been building them according to example.
How can I pick up more advanced usage? I mostly catch myself using it to return a list of functions like: >>> class foo(object): ... def __init__(self, bar): ... self.bar = bar ... >>> [(foo(i)) for i in range(0,10)] [<__main__.foo object at 0x00C54FD0>, <__main__.foo object at 0x00C54FF0>, <__ma in__.foo object at 0x00C54F50>, <__main__.foo object at 0x00C54F30>, <__main__.f oo object at 0x00C59050>, <__main__.foo object at 0x00C59070>, <__main__.foo obj ect at 0x00C590B0>, <__main__.foo object at 0x00C590D0>, <__main__.foo object at 0x00C59110>, <__main__.foo object at 0x00C59130>] On Thu, Aug 5, 2010 at 3:25 AM, James Mills <prolo...@shortcircuit.net.au>wrote: > On Thu, Aug 5, 2010 at 2:38 PM, Vikram K <kpguy1...@gmail.com> wrote: > > Suppose i have this string: > > z = 'AT/CG' > > > > How do i get this list: > > > > zlist = ['A','T/C','G'] > > >>> import re > >>> z = 'AT/CG' > >>> [x for x in re.split("([A-Z]\/[A-Z])|([A-Z])", z) if x] > ['A', 'T/C', 'G'] > >>> > > cheers > James > > -- > -- James Mills > -- > -- "Problems are solved by method" > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor