Features you won't find in PythonFebruary 03. 2012
Some Features you won't find in PythonGood news: Wirbel does not only lack some features of Python but also introduces some new features which we will summarize in this article. Automatic EnumsWirbel has special enumeration datatype and a builtin mechanism for automatically create globally unique enumeration atoms on the fly. There is no long any need to define integers for flags like tty.BOLD, mode.READONLY or filetype.SYMLINK. You can use `bold, `readonly and `symlink without any prior declaration and Wirbel makes sure that they take distinct values. BitsetsBitsets are similar to enumeration values. Bitsets form a special datatype. A bitset value can combine up to 64 independend binary values. All C-like operators for bitwise operations like |, & and friends are supported. Dict comprehensionsJust as lists, also dictionaries can be built with comprehensions. An optional a filter expression can used to select items of choice. Look at the following example: dict_comprehension.w
squares = { a : a*a for a in [ 1, 2, 3, 4 ] if a > 1 }
print(squares)
This will form the following dictionary:
user@host> wirbel dict_comprehension.w
{2:4, 3:9, 4:16}
Set comprehensionJust as with lists comprehension can also be used to create sets from either other sets or even lists. The new set is edirectly constructed (and not first as list and than converted to a set). |
| ||||||||||||||||||||||||||||||