Newbie ?:A more concise way?
Peter Hansen
peter at engcorp.com
Sun Mar 3 23:50:44 EST 2002
Peter Hansen wrote:
>
> Brian wrote:
> >
> > z = [MyClass() for i in xrange(y)]
> >
> > Is there a way to do this without the use of i?
>
> The big advantage being?
>
> (I'd suggest if you're just trying to save typing five
> keystrokes that you find more critical things to work on first.)
Oops, sorry. That sounds a little callous. I really just meant
to give a response similar to my "programmers always try to optimize
when they don't really need to" diatribe. In other words, to get
you to check what your goal was and decide consciously if it's really
worth finding a more concise approach, or whether you just got
caught up in Perlish "can I save another keystroke" thinking. No
offense intended.
(Dang, now I've gone and offended Perl mongers! Can't win. ;-)
-Peter
More information about the Python-list
mailing list