4 ms·
I hate adding syntax but you know what's really useful? Django's `for .. empty` template syntax. I would like to see this in Python: for i in []: print
by benwilber0 8y ago
I hate adding syntax but you know what's really useful? Django's `for .. empty` template syntax.
I would like to see this in Python:
for i in []:
print(i)
empty:
print("Sequence was empty!")
- askvictor 8y agoWrite up a PEP! It's a great idea. Syntax can be good if it makes sense and makes code easier to read and write.
- mixmastamyk 8y agoWon't be accepted. Recognized as a problem, but now set in stone.
- askvictor 8y agoMaybe in python 4...
- mixmastamyk 8y agoNope, been discussed many times on the lists, neither planned.
- maccam94 8y agoExcept the python "for/else" executes regardless of whether there's a sequence. I've used it before for retry logic, but it confuses the heck out of people.
- Nition 8y agoI think the user you're replying to is just saying that a for...empty would be nice too.