[Python-3000] sets in P3K? (original) (raw)
Ian Bicking ianb at colorstudy.com
Mon Apr 24 19:42:46 CEST 2006
- Previous message: [Python-3000] sets in P3K?
- Next message: [Python-3000] sets in P3K?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Wilson wrote:
Interesting --- I think that being able to write down a data structure using the same sort of notation you'd use on a whiteboard in a high school math class is one of the great strengths of scripting languages, and one of the things that makes it possible to use Python, Perl, and Ruby as configuration languages (instead of the XML that Java/C# users have to put up with). I think most newcomers will find:
x = {2, 3, 5, 7} more appealing than: x = set(2, 3, 5, 7)
That looks fine to me, except of course it doesn't work :(
Instead you get set([2, 3, 5, 7]), which is much less attractive and introduces an unneeded intermediate data structure. Or set((2, 3, 5, 7))... which is typographically prettier, but probably more confusing to a newbie.
Generator comprehensions + dict() were a nice alternative to dict comprehension, and also replace the need for set comprehension. I feel like there might be some clever way to constructing sets? Not that there's any direct relation to generator expressions that I can see, but maybe something in the same vein.
-- Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
- Previous message: [Python-3000] sets in P3K?
- Next message: [Python-3000] sets in P3K?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]