r/shittyprogramming • • Jan 10 '23
shittyprogramming challenge proposal: new python feature
There's been a large amount of work done recently on this sub to improve the Python language:
Before a PEP can be written and a formal language proposal submitted to the council so these highly requested features can be added to the standard library we should separate the wheat from the chaff. Following in the great tradition of this sub I propose a shittyprogramming challenge to do this. If we work quickly enough there's still time for these additions to make it into 3.12!
Challenge Rules (optional):
- Extend the Python language adding one or more features. This could take the form of a new module, package, or even an extension to the compiler; the sky is the limit!
- Submit a quick write-up including how to utilize your amazing new feature as well as a link to a git repository containing the code in this (or maybe a mod pinned) thread.
- Have fun :)
Credit to u/rcxwhiz for the idea.
93
Upvotes
View all comments
Show parent comment
6
u/moeghoeg Jan 11 '23 edited Jan 11 '23
Better yet, instead of reserving the curly brackets for this purpose, we could save them for something else and just use inverse square brackets instead as is often done for open intervals in mathematics.
So rather than writing
li{i}, you would writeli]i[.li{2:3]would be written asli]2:3]etc.For multi-dimensional lists,
li[0][1][2]with 1-indexing would beli]1[]2[]3[. Or you could conveniently just mix 0- and 1-indexing like:li]1[[1]]3[for instance.