In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use Python's FuckIt.py. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
FuckIt.py uses the most advanced technology to make your code no matter what kind of errors, you just FuckIt, the program can be "normal" execution, soldiers to cover up the water.
Let's start with an example of how to use it.
Installation
Pip install fuckit
Suppose there is a target file: broke.py
Def f (): broken_code print ('fuckit chaining works') forlet's just assume this is a big module of shitty code.x = yy = x1 / 0 # Oh shhhiiiiiiivar = "Are you proud of what you've done?"
There are several obvious errors in broke.py, including syntax errors, the variable broken_code is not defined, and 0 is treated as a divisor.
If you go directly to import broke, you will definitely report an error.
> import broke
File "broke.py", line 5
For
^
SyntaxError: invalid syntax
At this point you can use fuckit to import broke.
> import fuckit
> fuckit ("broke")
> broke
An error will also be reported when calling the function f
> > broke.f ()
NameError: global name 'broken_code' is not defined
You can use chained fuckit to call this problematic function
> fuckit (broke) .f ()
Fuckit chaining works
Or
> fuckit (fuckit ("broke")) .f ()
Fuckit chaining works
In addition, fuckit can also be used as a decorator and context manager.
Decoration function
> @ fuckit
... Def broken_function ():
... Non_existant_variable # Let's create a NameError
... Return 'Function decorator works'
...
> > print (broken_function ())
None
Decorative category
> @ fuckit
... Class BrokenClass (object):
... Def f (self):
... Self.black_hole = 1 / 0
... Return 'Class decorator works'
...
> print (BrokenClass () .f ())
None
Context Manager
> with fuckit:
... Print ('Context manager works')
... Raise RuntimeError ()
...
Equivalent to
Try:
Print ('Context manager works')
Except RuntimeError:
Pass
See here, do you feel that fuckit is very violent, so what scenarios can it be used in? Personally, I think this library is very chicken, because your code should not tolerate these errors, and if there are errors, you should fix them immediately, but one possible use scenario is that you have just taken over a piece of super-complex code with all kinds of code that you can't understand, and when there is an error in the fucking code from time to time, and you can't control it, you can use fuckit.
These are all the contents of the article "how to use Python's FuckIt.py". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.