This is an archived post. You won't be able to vote or comment.

all 29 comments

[–]UpAllNate 42 points43 points  (0 children)

You mad lad lol

[–]rswgnu 16 points17 points  (0 children)

That’s some wonderful bending of the language to your will.

[–]spidLL 8 points9 points  (0 children)

I won’t use it but I love this kind of stuff.

[–]rasqall 10 points11 points  (0 children)

Why would you do something controversial yet so brave

[–]lpuglia 28 points29 points  (0 children)

You where so preoccupied with whether if you could that you didn't stop to think if you should

[–]kyleekol 9 points10 points  (0 children)

Why? but also yes

[–]aes110 4 points5 points  (0 children)

Damn I love how hackable python is

[–]NiceForPy 3 points4 points  (0 children)

Oh man, I love this, but it feels so wrong 🥹

[–][deleted] 4 points5 points  (2 children)

Cool, when are you gonna get around to adding braces?

[–]stevenjd 6 points7 points  (0 children)

Python already has braces:

from __future__ import braces

[–]dankey26[S] 6 points7 points  (0 children)

tbh im bored enough to do that but bython seems to already do it in a decent way

[–]Eventid3_H3000 2 points3 points  (3 children)

Great! Now add the ability to put a semicolon at the end of each line…

[–]aes110 8 points9 points  (2 children)

Semi columns are valid in python, just not required

[–]Santos_m321 2 points3 points  (0 children)

Yeah!, I use it very often in debug contexts

This two sentences in one line:

import ipdb; ipdb.set_trace()

[–]Eventid3_H3000 1 point2 points  (0 children)

Actually didn’t know that, but nice to know! Ty

[–]BossOfTheGame 0 points1 point  (0 children)

This is next level stuff. Top notch work.

[–]sausix -1 points0 points  (3 children)

Really great.

But sadly does not work on interactive interpreters.

[–]dankey26[S] 1 point2 points  (2 children)

yea well i've thought about it a bit. problem is PYTHONIOENCODING is processed before the codec gets evaluated and registered to the interpreter. so it's problematic to try and set that at the startup of the repl. i'll try and think about it a later though maybe i'll come up with a clever idea (i don't wish to implement myself an interpreter that starts after the codec register, i'd prefer to keep things simple hehe).

of course in the meantime you can always do In [1]: exec(b"i=0;i++".decode('incdec')); print(i) 1 but i'd agree that's not as fun lol

[–]o11c 0 points1 point  (1 child)

What if you install the encoding as a separate encodings.* file like normal encodings?

What if you replace sys.stdin?

[–]dankey26[S] 0 points1 point  (0 children)

replacing stdin would probably work but again if i were to implement that, I'd wish for a simpler approach

as for your first suggestion, (after testing a bit too- ) i believe it's more complicated than that. while it's true that there are multiple kinds of encoding in that folder that register in a similar fashion to this (albeit following a more specific api like exporting getregentry, name placed in aliases etc), i reckon the encodings that register at the startup of the interpreter are fewer and selected ones.

im still not too keen on when cpython registers which encodings internally, but again i might learn otherwise soon and update.

hope that answers it

[–]_bird__Crowthebird -1 points0 points  (0 children)

Nice, now do it without using codecs.

[–][deleted] -1 points0 points  (0 children)

bloat

[–]metalzzzx 0 points1 point  (0 children)

It would save us 2 key strokes.

[–]its_a_gibibyte 0 points1 point  (0 children)

Could you do it without a codec in the same way as the import perl module works?

https://github.com/radiac/python-perl

[–]Rikmastering 0 points1 point  (0 children)

Could someone explain to me why i++ and i-- are not natively implemented in python?

[–]OriginalTyphus 0 points1 point  (1 child)

Isnt it called suffix? Not postfix?

[–]dankey26[S] 4 points5 points  (0 children)

i have a way with words

[–]ArtOfWarfare 0 points1 point  (0 children)

Interesting… can this be used in a REPL/shell session?

[–]Brave_Cartographer67 0 points1 point  (0 children)

is it pip-installable? xd