Never do this in Python

Hacking Truth
0

 

Never do this in Python

 

 

The Secrets About python logic only a handful of people know


  • Python is a general purpose programming language that is often applied in scripting roles.
  • So, Python is programming language as well as scripting language.
  • Python is also called as Interpreted language 
  • Python is an experiment in how much freedom programmers need.
  • Too much freedom and nobody can read another's code; too little and expressiveness is endangered. 

 

 

Python Program

 

There is a two program file, one is actual program file and another is a file of as a package.

please never do this in Python here I have two packages and all I want to do is use the sleep function from the time module.

So you'll see that it's going to take seconds which of course I have provided here and when we run the program we'll expect the function to be delayed one second


 

neverdothisinpython.py

 

 

from time import *
from fake_package import *


def func():
    sleep(1)
    print("Hello HackingTruth.in")


func() 
 
 
 

 
 

 

fake_package.py

 

 

def sleep():
    print("I will never sleep")




 



 

 

Now Lets run this program -

 






But instead we're going to get an error that says that we have sleep that takes zero positional arguments but one was given and why isthat and to answer that question we've Fallen victim to a very bad practice and that is importing everything because even if we manage to import sleep from the correct package we also happen to import the exact same function from a different package and as you can see here this is not the same implementation and this can be impossible to debug because we will get the correct documentation here but we are using the wrong function.



Also Read - The python Logic


Disclaimer

All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
 
 

 

 

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !