[Tutor] class and methods/functions

Eric Walker ewalker at micron.com
Thu Oct 6 22:56:33 CEST 2005


DUH.. I found the answer....

mytest = [name for name in test]

Thanks again..



> > The above four lines could be replaced with a single list comprehension
> > if you like: baseObjectList = [ TPROJ(name) for name in baseList if
> > nameCheck(name) ]
> > http://www.amk.ca/python/2.0/index.html#SECTION000600000000000000000
> >
> > Kent
>
> BOOOOOOOM!!!!!!!!!!!!!!!!
> Let me pick up my skull fragments....
> Ok I understand all but one. Having trouble understanding list
> comprehension. I thought I understood but its barking at me. I would think
> that this would make mytest the same values as test?
>
> >>> test
>
> ['a', 'b', 'c', 'd']
>
> >>> mytest[name for name in test:]
>
>   File "<stdin>", line 1
>     mytest[name for name in test:]
>                   ^
> SyntaxError: invalid syntax
>
> > > _______________________________________________
> > > Tutor maillist  -  Tutor at python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list