xxviw.over-blog.com/
18 Janvier 2021
Many beginning Python users are wondering with which version of Python they should start. My answer to this question is usually something along the lines 'just go with the version your favorite tutorial was written in, and check out the differences later on.'
Python 2 reached the end of life on January 1, 2020. Python 3 has been available since 2008, but converting from 2 to 3 has been slow because of dependencies on libraries that were not available in Python 3 initially, earlier versions of python 3 were slower than python 2 and also because Python 2 was working quite well for many people. Switching between Python 2 and Python 3 environments¶ You can easily maintain separate environments for Python 2 programs and Python 3 programs on the same computer, without worrying about the programs interacting with each other. Switching to an environment is called activating it.
After considering declining support for Python 2 programming language and added benefits from upgrades to Python 3, it is always advisable for a new developer to select Python version 3. However, if a job demands Python 2 capabilities, that would be an only compelling reason to use this version. (mysql-connector-python-2.1.8-py2.7-windows-x86-32bit.msi) MD5: 84de80bf841f3df72b3a2bd18e37446e Signature Windows (x86, 64-bit), MSI Installer Python 3.4: 2.1.8.

But what if you are starting a new project and have the choice to pick? I would say there is currently no 'right' or 'wrong' as long as both Python 2.7.x and Python 3.x support the libraries that you are planning to use. However, it is worthwhile to have a look at the major differences between those two most popular versions of Python to avoid common pitfalls when writing the code for either one of them, or if you are planning to port your project.
__contains__ method for range objects in Python 3__future__ modulePython 3.x introduced some Python 2-incompatible keywords and features that can be imported via the in-built __future__ module in Python 2. It is recommended to use __future__ imports it if you are planning Python 3.x support for your code. For example, if we want Python 3.x's integer division behavior in Python 2, we can import it via
More features that can be imported from the __future__ module are listed in the table below:
| feature | optional in | mandatory in | effect |
|---|---|---|---|
| nested_scopes | 2.1.0b1 | 2.2 | PEP 227:Statically Nested Scopes |
| generators | 2.2.0a1 | 2.3 | PEP 255:Simple Generators |
| division | 2.2.0a2 | 3.0 | PEP 238:Changing the Division Operator |
| absolute_import | 2.5.0a1 | 3.0 | PEP 328:Imports: Multi-Line and Absolute/Relative |
| with_statement | 2.5.0a1 | 2.6 | PEP 343:The 'with' Statement |
| print_function | 2.6.0a2 | 3.0 | PEP 3105:Make print a function |
| unicode_literals | 2.6.0a2 | 3.0 | PEP 3112:Bytes literals in Python 3000 |
Very trivial, and the change in the print-syntax is probably the most widely known change, but still it is worth mentioning: Python 2's print statement has been replaced by the print() function, meaning that we have to wrap the object that we want to print in parantheses.
Python 2 doesn't have a problem with additional parantheses, but in contrast, Python 3 would raise a SyntaxError if we called the print function the Python 2-way without the parentheses.
Note:
Printing 'Hello, World' above via Python 2 looked quite 'normal'. However, if we have multiple objects inside the parantheses, we will create a tuple, since print is a 'statement' in Python 2, not a function call.
This change is particularly dangerous if you are porting code, or if you are executing Python 3 code in Python 2, since the change in integer-division behavior can often go unnoticed (it doesn't raise a SyntaxError).
So, I still tend to use a float(3)/2 or 3/2.0 instead of a 3/2 in my Python 3 scripts to save the Python 2 guys some trouble (and vice versa, I recommend a from __future__ import division in your Python 2 scripts).
Python 2 has ASCII str() types, separate unicode(), but no byte type.
Now, in Python 3, we finally have Unicode (utf-8) strings, and 2 byte classes: byte and bytearrays.
The usage of xrange() is very popular in Python 2.x for creating an iterable object, e.g., in a for-loop or list/set-dictionary-comprehension.
The behavior was quite similar to a generator (i.e., 'lazy evaluation'), but here the xrange-iterable is not exhaustible - meaning, you could iterate over it infinitely.
Thanks to its 'lazy-evaluation', the advantage of the regular range() is that xrange() is generally faster if you have to iterate over it only once (e.g., in a for-loop). However, in contrast to 1-time iterations, it is not recommended if you repeat the iteration multiple times, since the generation happens every time from scratch!
In Python 3, the range() was implemented like the xrange() function so that a dedicated xrange() function does not exist anymore (xrange() raises a NameError in Python 3).
__contains__ method for range objects in Python 3Another thing worth mentioning is that range got a 'new' __contains__ method in Python 3.x (thanks to Yuchen Ying, who pointed this out). The __contains__ method can speedup 'look-ups' in Python 3.x range significantly for integer and Boolean types.
Based on the timeit results above, you see that the execution for the 'look up' was about 60,000 faster when it was of an integer type rather than a float. However, since Python 2.x's range or xrange doesn't have a __contains__ method, the 'look-up speed' wouldn't be that much different for integers or floats:
Below the 'proofs' that the __contain__ method wasn't added to Python 2.x yet:
Some people pointed out the speed difference between Python 3's range() and Python2's xrange(). Since they are implemented the same way one would expect the same speed. However the difference here just comes from the fact that Python 3 generally tends to run slower than Python 2.
Where Python 2 accepts both notations, the ‘old' and the ‘new' syntax, Python 3 chokes (and raises a SyntaxError in turn) if we don't enclose the exception argument in parentheses:
The proper way to raise an exception in Python 3:
Also the handling of exceptions has slightly changed in Python 3. In Python 3 we have to use the 'as' keyword now

Since next() (.next()) is such a commonly used function (method), this is another syntax change (or rather change in implementation) that is worth mentioning: where you can use both the function and method syntax in Python 2.7.5, the next() function is all that remains in Python 3 (calling the .next() method raises an AttributeError).
Good news is: In Python 3.x for-loop variables don't leak into the global namespace anymore!
This goes back to a change that was made in Python 3.x and is described in What's New In Python 3.0 as follows:
'List comprehensions no longer support the syntactic form [.. for var in item1, item2, ..]. Use [.. for var in (item1, item2, ..)] instead. Also note that list comprehensions have different semantics: they are closer to syntactic sugar for a generator expression inside a list() constructor, and in particular the loop control variables are no longer leaked into the surrounding scope.'
Another nice change in Python 3 is that a TypeError is raised as warning if we try to compare unorderable types.
Fortunately, the input() function was fixed in Python 3 so that it always stores the user inputs as str objects. In order to avoid the dangerous behavior in Python 2 to read in other types than strings, we have to use raw_input() instead.
As we have already seen in the xrange section, some functions and methods return iterable objects in Python 3 now - instead of lists in Python 2.
Since we usually iterate over those only once anyway, I think this change makes a lot of sense to save memory. However, it is also possible - in contrast to generators - to iterate over those multiple times if needed, it is only not so efficient.
And for those cases where we really need the list-objects, we can simply convert the iterable object into a list via the list() function.
Some more commonly used functions and methods that don't return lists anymore in Python 3:
zip()
map()
filter()
dictionary's .keys() method
dictionary's .values() method
dictionary's .items() method
Python 3 adopted the now standard way of rounding decimals when it results in a tie (.5) at the last significant digits. Now, in Python 3, decimals are rounded to the nearest even number. Although it's an inconvenience for code portability, it's supposedly a better way of rounding compared to rounding up as it avoids the bias towards large numbers. For more information, see the excellent Wikipedia articles and paragraphs:
Here is a list of some good articles concerning Python 2 and 3 that I would recommend as a follow-up.
// Porting to Python 3
// Pro and anti Python 3
Latest versionReleased:
PyInstaller bundles a Python application and all its dependencies into a single package.
PyInstaller bundles a Python application and all its dependencies into a singlepackage. The user can run the packaged app without installing a Pythoninterpreter or any modules.
Help keeping PyInstaller alive:Maintaining PyInstaller is a huge amount of work.PyInstaller development can only continueif users and companies provide sustainable funding. Seehttp://www.pyinstaller.org/funding.html for how to support PyInstaller.
| Documentation: | https://pyinstaller.readthedocs.io/ |
|---|---|
| Website: | http://www.pyinstaller.org/ |
| Code: | https://github.com/pyinstaller/pyinstaller |
| Donate, Fund: | http://www.pyinstaller.org/funding.html |
PyInstaller reads a Python script written by you. It analyzes your codeto discover every other module and library your script needs in order toexecute. Then it collects copies of all those files – including the activePython interpreter! – and puts them with your script in a single folder, oroptionally in a single executable file.
PyInstaller is tested against Windows, Mac OS X, and GNU/Linux.However, it is not a cross-compiler:to make a Windows app you run PyInstaller in Windows; to makea GNU/Linux app you run it in GNU/Linux, etc.PyInstaller has been used successfullywith AIX, Solaris, FreeBSD and OpenBSD,but is not tested against them as part of the continuous integration tests.
PyInstaller is available on PyPI. You can install it through pip:
Basic usage is very simple, just run it against your main script:
For more details, see the manual.
The following platforms have been contributed and any feedback orenhancements on these are welcome.
Before using any contributed platform, you need to build the PyInstallerbootloader, as we do not ship binary packages. Download PyInstallersource, and build the bootloader:
Then install PyInstaller:
or simply use it directly from the source (pyinstaller.py).
See http://www.pyinstaller.org/support.html for how to find help as well asfor commercial support.
Maintaining PyInstaller is a huge amount of work.PyInstaller development can only continueif users and companies provide sustainable funding. Seehttp://www.pyinstaller.org/funding.html for how to support PyInstaller.
You can find a detailed list of changes in this releasein the change log section of the manual. Ipad in usa kaufen 2018.
4.1
4.0
3.6
3.5
3.4
3.3.1
3.3
3.2.1
3.2
3.1.1
3.1
3.0
2.1
2.0
1.5.1
1.5
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
| Filename, size | File type | Python version | Upload date | Hashes |
|---|---|---|---|---|
| Filename, size pyinstaller-4.1.tar.gz (3.5 MB) | File type Source | Python version None | Upload date | Hashes |
| Algorithm | Hash digest |
|---|---|
| SHA256 | 954ae81de9a4bc096ff02433b3e245b9272fe53f27cac319e71fe7540952bd3d |
| MD5 | 460df9d5125df109a23cd7be8d0e1a3a |
| BLAKE2-256 | 9eedfbdad7f5d8f794c901076b814b8e9f5ce31d32c0bc3b63ddd27b61db9530 |
Released:
Python interface for YARA
With this library you can use YARA fromyour Python programs. It covers all YARA's features, from compiling, savingand loading rules to scanning files, strings and processes.
Here it goes a little example:
The easiest way of installing YARA is by using pip:
But you can also get the source from GitHub and compile it yourself:
Notice the --recursive option used with git. This is important becausewe need to download the yara subproject containing the source code forlibyara (the core YARA library). It's also important to note that the twomethods above link libyara statically into yara-python. If you want to linkdynamically against a shared libyara library use:
For this option to work you must build and installYARA separately before installingyara-python.
Find more information about how to use yara-python athttps://yara.readthedocs.org/en/latest/yarapython.html.
4.0.2
4.0.1
4.0.0
Starcraft 2 come out. 3.11.0
3.10.0
3.9.0
3.8.1
3.8.0
3.7.0
3.6.3
3.6.2
3.6.1
3.6.0
3.5.0
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
| Filename, size | File type | Python version | Upload date | Hashes |
|---|---|---|---|---|
| Filename, size yara_python-4.0.2-cp35-cp35m-win32.whl (747.5 kB) | File type Wheel | Python version cp35 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp35-cp35m-win_amd64.whl (1.1 MB) | File type Wheel | Python version cp35 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp36-cp36m-win32.whl (747.5 kB) | File type Wheel | Python version cp36 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp36-cp36m-win_amd64.whl (1.1 MB) | File type Wheel | Python version cp36 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp37-cp37m-win32.whl (747.5 kB) | File type Wheel | Python version cp37 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp37-cp37m-win_amd64.whl (1.1 MB) | File type Wheel | Python version cp37 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp38-cp38m-win32.whl (747.5 kB) | File type Wheel | Python version cp38 | Upload date | Hashes |
| Filename, size yara_python-4.0.2-cp38-cp38m-win_amd64.whl (1.1 MB) | File type Wheel | Python version cp38 | Upload date | Hashes |
| Filename, size yara-python-4.0.2.tar.gz (405.9 kB) | File type Source | Python version None | Upload date | Hashes |
| Algorithm | Hash digest |
|---|---|
| SHA256 | 7c8fc1275c77551bdef057b5b5b243896ca21b42e15ed9416884bffe4bec584b |
| MD5 | 4000e0e4df58a89a53659dd30878592a |
| BLAKE2-256 | 210d522ec9d664657384e37dc93e5370061555885db8314fc5539ecb77b2f0be |
| Algorithm | Hash digest |
|---|---|
| SHA256 | a8f403a9c9180532258ca3f01c04b9fb12907003bd0840524c7188c10f6989ae |
| MD5 | e9eb7cd2d5bace490e931b7fdcf1390b |
| BLAKE2-256 | a9bdda0308f209df9ee1c0b17731cc25e5692341f48f52668e5f7cc14bb09fd8 |
| Algorithm | Hash digest |
|---|---|
| SHA256 | b34cf660918e90351829ae68c7dd3bd4927cd39a4f05fc37966da50abbbb9468 |
| MD5 | 940f310015cf634e3d51a55bac81c5b6 |
| BLAKE2-256 | 7a5af26128f10a7f2350623c51896bb40eca14a9930186984c9b17c83cf924dd |
| Algorithm | Hash digest |
|---|---|
| SHA256 | cd18d31cd044a7e383c63617f4a1c7047209b14312ab527a3741eaca79f3f88c |
| MD5 | 5d34705f74f63f5e381c2ba45ae7bd8b |
| BLAKE2-256 | 99d50d2746c5567e5ce999da0a94f3215315d81beb0ffbe452cf37502dda5a34 |
| Algorithm | Hash digest |
|---|---|
| SHA256 | b0aa7135fef4ef2ede35d425ff777feeed174f3171faa520daa7bd99b54e082b |
| MD5 | 0d4092ddfcbfae5cc2ae40645c8b4d58 |
| BLAKE2-256 | c0c42c4e22bf9941dd87868114af1ede69ec8652830dc828b8e7ff3b15492774 |
| Algorithm | Hash digest |
|---|---|
| SHA256 | 3843ffead5b88a62582173f74f7277c0765b1d60ae55583ab95b31361fc24715 |
| MD5 | f866ef9ad88aaf4280c9ab5485542360 |
| BLAKE2-256 | a22b08e41537a1ed09a45e839d0055ebdd31c1a5f0d2ebf4819a8cfe9a75354d |
| Algorithm | Hash digest |
|---|---|
| SHA256 | da37edad1e724cf586be0c78451cc3e3e3673b28676ed423e750f5cb793f22ee |
| MD5 | 8ce64e8583523638bef578b245714ae5 |
| BLAKE2-256 | 6aeeb2332f1f22c69eb063a8cc26925b9749b8964b3cd9040f99095ea89fec17 |
| Algorithm | Hash digest |
|---|---|
| SHA256 | 2199f11e3f14dd176a4ccf3e9d46a366f9a8723cd95066eb4e22625d1774da3e |
| MD5 | 9e10873a08fefd029d857f9dec30008d |
| BLAKE2-256 | a1f4572ec37bca6019d6666351f36a3809d4c46510e2c9c3a3f8ac4c7f670704 |
| Algorithm | Hash digest |
|---|---|
| SHA256 | c446e15a7ef1de56129eb311b3a920417ea3c3b4806b6ba979136bf861fa51d9 |
| MD5 | efb4061b02a5b1556e34d24cd4790b3c |
| BLAKE2-256 | 5f3223a3234978d746acfad00f306b13446a1935c52ec74a033416f457328239 |
