Home 0P3N Blog Python 2.7 Or 3.x?
Ready to Start Your Career?
Create Free Account
authors profile image
January 1, 2016

Python 2.7 Or 3.x?

January 1, 2016
authors profile image
January 1, 2016
Which is better for creating hacking tools? Python 2.7 or Python 3.x? I am still a n00b in pen testing and am learning from the aspect of creating my own small scripts to work different custom tools. Any information would be greatly appreciated. Also, I work on Linux machines, Ubuntu and Kali Linux. There is little or no difference between choosing Python 2.7 or 3.x when it comes to pen-testing or learning. I would pick the latest. The choice would be more important if you wanted to distribute your software later on, whereas you ought to look at what is the most likely version installed for instance to minimize extra requirements. There might be a variation in available packages and that may also rule your choice, of course. I would strongly suggest that, right from the beginning, you get used to python "virtualenv". With that you will be able to seamlessly control and change your python environment on a per project basis. Also look at "virtualenvwrapper" which makes it even more powerful. see: https://docs.python-guide.org/en/latest/dev/virtualenvs/ great information thanks For pen.testing there should be little or no difference. Be aware that most code from others do tend to use python 2.7 ( old habit I guess). :) Python 3.x is definitly the future, but not all (third-Party)modules are useable yet in python 3, because python 3 has several difference for example: print "test" (Python 2.7) print("test") (Python 3.x) So the Syntax is a bit different, but in general, you can do all with python 3 what you can do in python2. You just may need more time if a specific third-party-modul doesnt work on python3. However if you know how programming works it is easy to switch to another language (or in this case version). As Wireshark said, 3 is the future, but it doesn't support all the modules that you may want to use. I always use 2.7 because I've never had any compatibility issues. The differences between the two aren't that great outside of that (once again, Wireshark took the example I was going to use) for now, learn both they are not that incredibly different. like others said: 3 is the future, it's gaining ground, but there are still alot of systems that don't have 3 installed and libraries that don't work in 3 If you can, I'd suggest go with 3.x but if you need to use any 3rd party libraries make sure they support 3.x. Just note that most systems that do have python already installed would likely have a variation of 2.x. So if you are writing an exploit that needs to be used on a remote system, it'll likely be 2.x Hey dude. For the the purpose of PenTesting and similar, i would suggest v2.7. The course is also done in v2, so it will be easier to follow. On the other hand, there is no much difference between the two, and you can find it [here](http://www.cs.carleton.edu/faculty/jgoldfea/cs201/spring11/Python2vs3.pdf). Note also that you can run both versions side by side, on the same computer. Good luck! :) If just learning, I would recommend 2.7... there is nearly infinitely more information and support for version 2 than there is for 3. You can always learn the diffs down the road when you're a python wizard. Just my .02.
Schedule Demo

Build your Cybersecurity or IT Career

Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry