Back in the day, access to the Internet was very expensive in my locality. We only had mobile data with max 20GB per month, and after that - 7KB/s unlimited for ~20% of average local salary. Having no job, it was very hard to pay that amount for the Internet, so I came up with a solution. I have set up a cloud server for 10$/month, got couple of SIM cards with that internet plan, and started developing a Linux tunnel program, which would join bandwidth of multiple interfaces into one by directing packets to my server. The server then forwards the packets further. I hadn't used it for long but it was very fun and satisfying to do it.
Here is the greatest inconvenience of Python exceptions for me. Say you have to try 10 different methods, and you only need one to work. Then you have to write 10 try...except blocks so that each next block is indented relative to previous. This creates unreadable code and does not scale for say 100 methods.
The solution that came to mind is labeling try blocks and referring them in except blocks. For example:
try as method1:
method1()
except@method1 try as method2:
method2()
except@method2 try as method3:
method3()
except@method3:
raise NoMethodWorked()
I can't think of a single time I've needed a large collection of "backup" methods in case of a chain of failures; I can't even think of an example which could scale to 100. Anyways, this solution does scale:
methods = [method1, method2, method3, method4]
for method in methods:
try:
method()
except Exception:
pass
else:
break
else:
raise NoMethodWorked()
You can even pair specific exceptions to each method:
methods = [(method1, TypeError), (method2, KeyError)]
for m, e in methods:
try: m()
except e: ...
But the whole thing really sounds like you're trying to do too much with one function and you really should rethink the whole structure of your code.
There are several solutions that occured to me off the top of my head, here's the simplest one:
try:
method1()
return
except Exception: # or a more specific exception type
pass # try the next method
try:
method2()
return
except Exception:
pass
# ...
try:
method10()
except Exception:
raise NoMethodWorked()
Seriously, there are so many ways to solve this in a readable, maintainable way, without resorting to introducing weird new syntax.
Fingerprint scan and Facial recognition can not replace password authentication because both face and fingerprint are public information, while password is meant to be private. You cannot hide your face or fingerprint from others.
The more I think about it, the more I think this is a bluf to push drone designers to overengineer their devices.
Eagles are not scalable, but it is way simpler to train a handful of them as a proof of concept than to eagle-proof existing designs of drones. And given physical and engineering limits, every countermeasure implemented in a drone will cut into the effective payload that is available for the drone to carry on its actual function.
The eagles were never meant to defeat the drones, but to force their designers to handicap those.