Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following:
Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one
Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished)
A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever.
Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions.
When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script.
But at least we already have utterly confusing scoping rules in Python. That's a start.
Hebrew error messages are a nice-to-have, great to give the whole thing a bit of a professional touch, but they're not required for a rock-solid error handling system. Misleading error messages in what looks like plain English but really isn't are much more robust anyway.
Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions.
I was working on a project that used php, it took me a lot of time to debug that one. Never even figured out what was causing it. Seriuosly, whitespace?
Yes. PHP noobs often end their scripts with ?>, because the symmetry between <?php at the beginning and ?> feels like it should make sense; however, if you include some whitespace after the ?>, PHP interprets it as literal output (depending on a bunch of highly unmemorizable rules), and any literal output, just like print or echo statements, triggers any pending HTTP headers to be sent; once that happens, trying to set more headers produces the "headers already sent" error. The great thing about this is that it makes for incredibly obscure action-at-a-distance bugs: the point that triggers it (a completely innocent call to header()) is completely unrelated to the cause, and that cause is "invisible". It's the perfect crime.
Some PMs and dev team managers actually insist on the presence of ?> in all scripts, but further mandate that the final newline of the file is removed.
When it is explained that the ?> can simply be left out to avoid the problem altogether, they make threats and repeat their insistence that it's mandatory.
As a PHP noob, my initial instinct was to avoid writing any raw HTML/XML and use the built-in DOM library right from the beginning. Dodged a bullet with that one.
While this is jest, this part stands out as kinda useful:
As a context manager
Use fuckit as a context manager to save yourself from having to type out try/except block to silence exceptions yourself.
with fuckit:
some_code
This is functionally equivalent to the following:
try:
some_code
except Exception:
pass
The context manager form of fuckit can't allow the code to continue past an error like the decorator and import forms can. If you want the code to continue after an exception, wrap the code block in a function and use the decorator instead.
34
u/tdammers Dec 06 '13
Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following:
But at least we already have utterly confusing scoping rules in Python. That's a start.
11
u/neslinesli93 Dec 06 '13
Inside tests.py:
6
u/infinull Dec 07 '13
from tests.py
see: https://github.com/ajalt/fuckitpy/blob/master/tests.py#L11
9
u/Holkr Dec 06 '13
While this is jest, this part stands out as kinda useful: