Live data from Hacker News

Python’s Preprocessor

pydong.org

61–70 of 109 posts

Re: Python’s Preprocessor

#61
post #14

>>> from __future__ import braces File " ", line 1 SyntaxError: not a chance For those interested in how this (hilarious) error text came to be, it's been hardcoded in cpython since 2001! https://github.com/python/cpython/commit/ad3d3f2f3f19833f59f... The author, Jeremy Hylton, is now a Principal Engineer at Google working on AI search quality. It's quite remarkable that in 24 years, a single person's career has gone…

Reminds me of `break rust;` causing the Rust compiler to emit an internal compiler error. I wonder which other languages have similar easter eggs.

Tcl really became “Enterprise-ready”[0] at this time.

[0] https://stackoverflow.com/a/1026619

Re: Python’s Preprocessor

#62
post #14

>>> from __future__ import braces File " ", line 1 SyntaxError: not a chance For those interested in how this (hilarious) error text came to be, it's been hardcoded in cpython since 2001! https://github.com/python/cpython/commit/ad3d3f2f3f19833f59f... The author, Jeremy Hylton, is now a Principal Engineer at Google working on AI search quality. It's quite remarkable that in 24 years, a single person's career has gone…

Reminds me of `break rust;` causing the Rust compiler to emit an internal compiler error. I wonder which other languages have similar easter eggs.

> `break rust;` causing the Rust compiler to emit an internal compiler error

Is this real?

Re: Python’s Preprocessor

#63
post #62

Earlier quoted context omitted.

Reminds me of `break rust;` causing the Rust compiler to emit an internal compiler error. I wonder which other languages have similar easter eggs.

> `break rust;` causing the Rust compiler to emit an internal compiler error Is this real?

https://play.rust-lang.org/?version=stable&mode=debug&editio...

> error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?

> --> src/main.rs:2:5

> |

> 2 | break rust;

> | ^^^^^^^^^^

> |

> = note: the compiler expectedly panicked. this is a feature.

> = note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-...

Re: Python’s Preprocessor

#64
post #62

Earlier quoted context omitted.

Reminds me of `break rust;` causing the Rust compiler to emit an internal compiler error. I wonder which other languages have similar easter eggs.

> `break rust;` causing the Rust compiler to emit an internal compiler error Is this real?

Yes

https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re: Python’s Preprocessor

#65
post #62

Earlier quoted context omitted.

> `break rust;` causing the Rust compiler to emit an internal compiler error Is this real?

Yes https://play.rust-lang.org/?version=stable&mode=debug&editio...

> error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?

Lovely, and the word game is just great.

Re: Python’s Preprocessor

#67
That's quite interesting.

Now, I'm left to wonder if this could have been used to better handle the Python 2-to-3 transition, e.g '# coding: six.python2' would adjust Python2 code to be valid Python3, or '# coding: six.python3' would adjust Python3 code to run under Python2 - e.g adding/removing the b"..." or u"..." prefixes!

Re: Python’s Preprocessor

#68

> the Python developers have strong opinions except when it comes to downloading, installing, or running anything Python related. maybe by 2124 we can give users a python app and let them run it without 20 steps. (oh who am i kidding, by then we'll rewrite everything in whatever comes after Rust)

https://pyinstaller.org/en/stable/

Re: Python’s Preprocessor

#69

That's quite interesting. Now, I'm left to wonder if this could have been used to better handle the Python 2-to-3 transition, e.g '# coding: six.python2' would adjust Python2 code to be valid Python3, or '# coding: six.python3' would adjust Python3 code to run under Python2 - e.g adding/removing the b"..." or u"..." prefixes!

It could help, but the parts it would help with are the easy parts. The challenges of py2 to py3 were the runtime behavior change: a Unicode and regular string containing ASCII were the same string in py2, as in you could use them as keys of a dict and they'd key the same entry. In py3 a bytes and str of the same ASCII would identify different entries in the same dict.

Some more nasty changes: various built ins like .keys() and .values() return lists in py2 but iterators in py3. Code gets very verbose if you use the six utilities or other workarounds to translate code safely - most times those are called they are used once, but every once in a while they are used twice.

Imo if you have such a tool that can rewrite at import time you should just commit the transformed code, and clean it up incrementally. The hard parts are the behavior changes that can cross long distances like the str v bytes behaving so different than py2 Unicode v str

Re: Python’s Preprocessor

#70
post #14

>>> from __future__ import braces File " ", line 1 SyntaxError: not a chance For those interested in how this (hilarious) error text came to be, it's been hardcoded in cpython since 2001! https://github.com/python/cpython/commit/ad3d3f2f3f19833f59f... The author, Jeremy Hylton, is now a Principal Engineer at Google working on AI search quality. It's quite remarkable that in 24 years, a single person's career has gone…

Reminds me of `break rust;` causing the Rust compiler to emit an internal compiler error. I wonder which other languages have similar easter eggs.

This one in Haskell is coincidental, but used as a joke:

``` import Data.Function

main = do let it = fix error print it ```

Post reply on HN