analitics

Pages

Monday, September 9, 2013

News - Python 3.4.0 Alpha 2 was released .

From python official website I found this :

Python 3.4.0 alpha 2 was released on September 9th, 2013. This is a preview release of the next major release of Python, Python 3.4, and is not suitable for production environments.

Major new features of the 3.4 series, compared to 3.3

Python 3.4 includes a range of improvements of the 3.x series, including hundreds of small improvements and bug fixes. Major new features and changes in the 3.4 release series so far include:

PEP 435, a standardized "enum" module

PEP 442, improved semantics for object finalization

PEP 443, adding single-dispatch generic functions to the standard library

PEP 445, a new C API for implementing custom memory allocators

PEP 446, changing file descriptors to not be inherited by default in subprocesses...

Saturday, August 17, 2013

Working with PEP 8 conventions ...

I am wrote my own python scripts to long time ago and now I saw many of this scripts are a mess  in terms of PEP criteria.
What is the pep criteria? The PEP describing style guidelines for the C code in the C implementation of Python.
If you using Blender 3D/Python development  then you need to follow the PEP 8.
The PEP 8 and can be found here and the authors are: Guido van Rossum , Barry Warsaw and Nick Coghlan.
Today I will show you a brief listing of pep8 criteria:
-indentation of 4 spaces not use tabs
-camel caps for class names: MyClass , AnotherClass
-all lower case underscore separated module names: my_module, another_module
-use explicit imports, not importing '*'
-imports should usually be on separate lines, not import os,sys
-adding whitespace around the operators , not 1+2 or 7+ 3
-don't use spaces around the = sign , not a = b +1
-use single quotes for enums, and double quotes for strings
-each line of a block comment starts with a # and a single space
-don't make comments that contradict the code
-if you want to writing good documentation strings then follow the PEP 257 conventions.
-run checks for pep8 compliance
# <pep8 compliant=""></pep8>
-and enable line length checks use this instead
# <pep8-80 compliant=""></pep8-80>
-don't use multiple statements on the same line, like:
if foo == 'test': do_test_thing()
one_test(); two_test()
... this is the correct way:
if foo == 'test':
    do_test_thing()
one_test()
two_test()
Also you can read about Blender 3D/Python and PEP 8 best practice here.