"Fuzzing" In Python Can PREVENT Your Functions From FAILING
Vložit
- čas přidán 28. 08. 2024
- Have you heard of fuzzing? In this lesson we will be going over what it is, and how we can use it to make sure that our functions are robust and cannot be broken.
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
Thanks!
Hi I have a question, when you write:
text:str="hello world"
What does the ":" mean?
Thanks in advance !
It’s syntax used for type hints
@@Indently tks but how does it work?
@@christlebeau7848 just tells u what data type is the variable is, read pep 0484
Although it looks interesting approach, would it be better to use something like Hypothesis librarym that not only searches for inputs that may fail and provides that data, but also have some more tricks?
Good stuff and good example as it very simple and not opinioned so to show the concept. But would be nice if you show a real life scenario where to use i. For instance I dont think do this makes sense everywhere but only in some places /block of codes, but where it does yea , could save in apfront huge amunt of money to a company!
great work
Correct me if Im wrong, but this concept doesnt seem very useful in practice because of its (possibly infinite) runtime (unless stop condition) and resource consumption. Testing functions with random inputs doesnt seem very systematic, since the tests will pass once and fail next time.
If the inputs were not random, then maybe one is better of using some library for that, e.g. hypothesis.
Good shit! 😀
Why are you using an int as a boolean value?
You can totally use int as a bool shorthand as they actually represent truthy/falsey values where True == 1, and False == 0. If you test that out, they do truly equal each other
@@aaronater1088 "It's possible" isn't really an explanation of *why* you'd do it.
@@SkyyySi Well, I believe I did explain why, it's more of a "shorthand". Though, it would be more concise to use True/False. What he did is no different than replacing them with True or False. So question you asked is why do it then? Again, quick way of representing True or False. Different code bases have used that merely out of preference, and now if you spot that in code, you'll know what they doin. Of course, you'll need to evaluate the context what the code is doing, but yeh
got enumerate?
Isn't better to just use
''.join(random.choices(characters, k=length))
?
I didn't really focus on optimisations during this video.
If you can explain why you think it's better, I would love to hear about it?
I think it's better in readability, since both of them are doing the same thing I think it's also better to just use one that's already made for that job.
Performance wise never really test it, most of the times it doesn't matter anyway.
Also a question, I've seen your video about uuid and I'm interested in checking which one is better to do.
I'm using the random generator, usually just with string.hexdigits to generate id for like ever. Most of the times it's for simple things but I do want to know, can I just use this or is there any problem with this method.
Great video! Also, why are you STILL CHANGING THE PROFILE PICTURE? (by now most youtube channels would have stuck to a single icon)
Most channels do a lot of things, eventually I will hire a brand designer, and stick to one, but until then, no promises :)
Thanks but how do type hints work ?
they don't. They just sit there are look annoying.
My corpse will be preserved in the cold my corpse will be preserved in the cold my corpse will be preserved in the cold my corpse will be preserved in the cold
next level bro 🤟🏾🤟🏾
nig
Hi, what editor is that?
fleet by jetbrains
it's still in free preview phase
@@firstprinciples4078 It's actually PyCharm by JetBrains.
@@EpicNoobx Oh thank you
My mistake
They do look kind of similar
@@firstprinciples4078 yeah there is a new ui
@@firstprinciples4078 Thanks!
Well made! Great video.
The historical reasons why this technique was invented is quite interesting as well. en.wikipedia.org/wiki/Fuzzing#History