Skip to main content

Home/ Mac Attack/ Group items tagged python

Rss Feed Group items tagged

Benjamin Bandt-Horn

Chapter 1. python 2.0 - 1.55.0 - 0 views

  • The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler. It is designed to wrap C++ interfaces non-intrusively, so that you should not have to change the C++ code at all in order to wrap it, making Boost.Python ideal for exposing 3rd-party libraries to Python. The library's use of advanced metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).
  •  
    The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler. It is designed to wrap C++ interfaces non-intrusively, so that you should not have to change the C++ code at all in order to wrap it, making Boost.Python ideal for exposing 3rd-party libraries to Python. The library's use of advanced metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).
Benjamin Bandt-Horn

Stackless Python - Wikipedia, the free encyclopedia - 0 views

  • Stackless Python, or Stackless, is a Python programming language interpreter, so named because it avoids depending on the C call stack for its own stack. The most prominent feature of Stackless is microthreads, which avoid much of the overhead associated with usual operating system threads. In addition to Python features, Stackless also adds support for coroutines, communication channels and task serialization.
  •  
    Stackless Python, or Stackless, is a Python programming language interpreter, so named because it avoids depending on the C call stack for its own stack. The most prominent feature of Stackless is microthreads, which avoid much of the overhead associated with usual operating system threads. In addition to Python features, Stackless also adds support for coroutines, communication channels and task serialization.
Benjamin Bandt-Horn

Unicode and new style string formatting ~ The Voidspace Techie Blog - 0 views

  • Unicode and new style string formatting Python 2.6 and Python 3 gain a new style of string formatting, which is apparently based on the string formatting in C#. I wasn't a big fan of the string formatting in C# and so wasn't very excited about it moving into Python, but as is to be expected it has grown a bit on me.
  • As always, the best solution is to not mix Unicode and byte-strings but to keep all strings in Unicode and only perform the encode when actually needed.
  • So why does this behaviour matter? Well it particularly matters for framework authors formatting messages based on 'user' input. This is the case with unittest, which creates error messages when tests fail. The error messages internally in unittest are byte-strings and they are often mixed with user supplied messages using string formatting. We use old-style (% based) formatting, so if the user supplies byte-strings then the resulting messages will be byte-strings. If the user supplies Unicode strings then the resulting messages will be in Unicode. Because all the internal unittest messages are ascii only we can guarantee than an implicit decode to Unicode will succeed - so the user can choose the output type by varying the type of the messages they provide.
  •  
     Python 2.6 and Python 3 gain a new style of string formatting, which is apparently based on the string formatting in C#. I wasn't a big fan of the string formatting in C# and so wasn't very excited about it moving into Python, but as is to be expected it has grown a bit on me.
Benjamin Bandt-Horn

Rapid GUI Programming with Python and Qt - 0 views

  • From PyQt4.6, PyQt has two APIs, API#1 (the original), and API#2 (new). API#2 is more Pythonic and eliminates QString and QVariant, and is a bit nicer to use. API#1 remains best for those using PyQt to prototype C++/Qt applications. API#1 is the default for PyQt4.x with Python 2.x, and for PyQt4.0-4.5 with Python 3.x. API#2 is the default for PyQt4.6+ with Python 3.x, and for PySide.
  • most of the changes affect uses of QDataStream, QSettings, and QTextStream, and of course any use of QString methods (since in API#2, QString is gone, so we use str).
  • To convert any particular example to PySide the steps are as follows: Replace python3 in the first line with python. Add the following statements before the first import: from __future__ import division from __future__ import print_function from future_builtins import * Replace PyQt4 with PySide throughout (e.g., in the imports) If using Python 2.6 replace {} in format strings with {0}, {1}, etc., as appropriate. Add [0] at the end of every QFileDialog.*() function call. (In PyQt these return a—possibly empty—filename; in PySide they return a filename–filter 2-tuple, but all the examples only need the filename.) Replace QT_VERSION_STR with qVersion(). Replace PYQT_VERSION_STR with PySide.__version__; you will also need to add import PySide in the imports after the future imports. Replace @pyqtSignature with @Slot. Replace def isAlive(qobj): ... with def isAlive(qobj): return True. (There is currently no PySide equivalent.) Replace chr with unichr.
Benjamin Bandt-Horn

gevent: A coroutine-based network library for Python - 0 views

  • gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev event loop. Features include: Fast event loop based on libev (epoll on Linux, kqueue on FreeBSD). Lightweight execution units based on greenlet. API that re-uses concepts from the Python standard library (for example there are Events and Queues). Cooperative sockets with SSL support » DNS queries performed through threadpool or c-ares. Monkey patching utility to get 3rd party modules to become cooperative »
  •  
    gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev event loop. Features include: Fast event loop based on libev (epoll on Linux, kqueue on FreeBSD). Lightweight execution units based on greenlet. API that re-uses concepts from the Python standard library (for example there are Events and Queues). Cooperative sockets with SSL support » DNS queries performed through threadpool or c-ares. Monkey patching utility to get 3rd party modules to become cooperative »
Benjamin Bandt-Horn

The Python Computer Graphics Kit - 0 views

  • The Python Computer Graphics Kit is an Open Source software package containing a collection of Python modules, plugins and utilities that are meant to be useful for any domain where you have to deal with 3D data of any kind, be it for visualization, creating photorealistic images, Virtual Reality or even games.
  • Provides access to specialized input hardware such as SpaceMouse/SpaceBall, data glove or tablet via wrappers around the 3DxWare SDK by 3Dconnexion, the Wintab Developer Kit by LCS/Telegraphics and the Data Glove SDK by Fifth Dimension Technologies.
  •  
    The Python Computer Graphics Kit is an Open Source software package containing a collection of Python modules, plugins and utilities that are meant to be useful for any domain where you have to deal with 3D data of any kind, be it for visualization, creating photorealistic images, Virtual Reality or even games.
Benjamin Bandt-Horn

Binary Search Tree library in Python | Laurent Luce's Blog - 0 views

  • This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
  • https://laurentluce@github.com/laurentluce/python-algorithms.git
  • binary search tree
  • ...5 more annotations...
  • Delete method
  • There are 3 possibilities to handle: 1- The node to remove has no child. 2- The node to remove has 1 child. 3- The node to remove has 2 children.
  • look for its successor by going right then left until we reach a leaf
  • if node is None:
  • ‘A’ < ‘B’ is True in Python.
  •  
    This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
Benjamin Bandt-Horn

Skencil, a vector drawing program - 0 views

  • Skencil is a Free Software interactive vector drawing appliction. Known to run on GNU/Linux and other UNIX-compatible systems, it is a flexible and powerful tool for illustrations, diagrams and other purposes. A somewhat unique (for a drawing program) feature of Skencil is that it is implemented almost completely in a very high-level, interpreted language, Python. Python is powerful, object-oriented and yet easy to use. Just a few highlights about Skencil's features Bézier Curves Transformed text and images Bézier curves, rectangles and ellipses can be used as guides Gradient fills Blend groups Writes EPS files Text along a path many more...
  •  
    Skencil is a Free Software interactive vector drawing appliction. Known to run on GNU/Linux and other UNIX-compatible systems, it is a flexible and powerful tool for illustrations, diagrams and other purposes. A somewhat unique (for a drawing program) feature of Skencil is that it is implemented almost completely in a very high-level, interpreted language, Python. Python is powerful, object-oriented and yet easy to use. Just a few highlights about Skencil's features Bézier Curves Transformed text and images Bézier curves, rectangles and ellipses can be used as guides Gradient fills Blend groups Writes EPS files Text along a path many more...
Benjamin Bandt-Horn

Invent With Python ~ Chapter 1 - 0 views

  • Pygame only supports Python 2 and not Python 3. However, the programs in this book work with both Python 2 and 3.
  •  
    Installing Python and PyGame
Benjamin Bandt-Horn

The Architecture of Open Source Applications: Python Packaging - 0 views

  • There are two schools of thought when it comes to installing applications
  • each application is its own standalone "appliance", and installing and removing them should not disturb the rest of the OS. If the application needs an uncommon library, that library is included in the application's distribution
  • a collection of small self-contained units called packages
  • ...8 more annotations...
  • Libraries are bundled into packages
  • Self-contained applications also make the developer's life easier when she needs to support several operating systems. Some projects go so far as to release portable applications that remove any interaction with the hosting system by working in a self-contained directory, even for log files.
  • Fellowship of the Packaging
  • In Python a package is a directory containing Python files. Python files are called modules. That definition makes the usage of the word "package" a bit vague since it is also used by many systems to refer to a release of a project.
  • use the term "Python packages" when we talk about a directory containing Python modules
  • The term "release" is used to define one version of a project
  • "distribution" defines a source or a binary distribution of a release as something like a tarball or zip file
  • advanced tools like Setuptools, which add features on the top of it, or Distribute, a fork of Setuptools. There's also Pip, a more advanced installer, that relies on Setuptools
  •  
    There are two schools of thought when it comes to installing applications
Benjamin Bandt-Horn

Why are there no ++ and --​ operators in Python? - Stack Overflow - 0 views

  • You don't write things like for(int i = 0; i < 10; ++i) in Python very often; instead you do things like for i in range(0, 10).
  • it would add opcodes to the language (implying a larger, and therefore slower, VM engine)
  • in the "C" world it is most effectively used (not most commonly) with pointers. There is a direct mapping to some instructions sets that support pre- or post-increment of address registers
  • ...2 more annotations...
  • Python doesn't have tricks to convey intentions to the assembler because it doesn't use one.
  • this 'koan' also hints that increment/decrement operators are non-obvious
  •  
    You don't write things like for(int i = 0; i < 10; ++i) in Python very often; instead you do things like for i in range(0, 10).
Benjamin Bandt-Horn

How does polymorphism work in Python? - Stack Overflow - 0 views

  • idiomatic Python dictates that you (almost) never do type-checking, but instead rely on duck-typing for polymorphic behavior. There's nothing wrong with using isinstance to understand inheritance, but it should generally be avoided in "production" code
  •  
    idiomatic Python dictates that you (almost) never do type-checking, but instead rely on duck-typing for polymorphic behavior. There's nothing wrong with using isinstance to understand inheritance, but it should generally be avoided in "production" code
Benjamin Bandt-Horn

IntegratingPythonWithOtherLanguages - Python Wiki - 0 views

  • ActiveState research Python for .NET is a near-seamless integration of the CPython runtime with the .NET Common Language Runtime (CLR). IronPython is an implementation of Python for .net, which allows you to import .net class libraries seamlessly in Python.
Benjamin Bandt-Horn

25.2. doctest - Test interactive Python examples - Python v2.7.6 documentation - 0 views

  • common ways to use doctest: To check that a module’s docstrings are up-to-date by verifying that all interactive examples still work as documented. To perform regression testing by verifying that interactive examples from a test file or a test object work as expected. To write tutorial documentation for a package, liberally illustrated with input-output examples. Depending on whether the examples or the expository text are emphasized, this has the flavor of “literate testing” or “executable documentation”.
  • Running the module as a script causes the examples in the docstrings to get executed and verified
  • The file content is treated as if it were a single giant docstring; the file doesn’t need to contain a Python program! For example, perhaps example.txt contains this
  • ...8 more annotations...
  • You can instruct the Python interpreter to run the doctest module directly from the standard library and pass the file name(s) on the command line:
  • if M.__test__ exists and “is true”, it must be a dict, and each entry maps a (string) name to a function object, class object, or string
  • Which Docstrings Are Examined?
  • Any expected output must immediately follow the final '&gt;&gt;&gt; ' or '... ' line containing the code, and the expected output (if any) extends to the next '&gt;&gt;&gt; ' or all-whitespace line.
  • Execution Context?
  • Directives
  • Whitespace is not allowed between the + or - and the directive option name. The directive option name can be any of the option flag names explained above
  • Unittest
  •  
    Freaking Amazing.
Benjamin Bandt-Horn

Python Package Structure with Unit Testing, Injection and Mocking - Dev Notes - 0 views

  • This describes setting up a professional Python project with a real package structure, injection and tests.
  • Since you are intended to run .py files directly, Python projects should not have source (src) or binary (bin) folders
  • For the same reason, the test folder should not be separate. &nbsp;It should be a package in the main project
  • ...3 more annotations...
  • Example
  • You should specify exactly one class per file. &nbsp;It makes your code easier to find and read.
  • Injection is essential for unit tests
  •  
    This describes setting up a professional Python project with a real package structure, injection and tests.
Benjamin Bandt-Horn

3. An Informal Introduction to Python - Python v2.7.6 documentation - 0 views

  •  
    Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. List items need not all have the same type.
Benjamin Bandt-Horn

Twisted (software) - Wikipedia, the free encyclopedia - 0 views

  • Twisted is an event-driven network programming framework written in Python
  •  
    Twisted is an event-driven network programming framework written in Python.
Benjamin Bandt-Horn

Tornado (web server) - Wikipedia, the free encyclopedia - 0 views

  • Tornado is a scalable, non-blocking web server and web application framework written in Python.
  •  
    Tornado is a scalable, non-blocking web server and web application framework written in Python.
Benjamin Bandt-Horn

PyX - Python graphics package - 0 views

  • PyX is a Python package for the creation of PostScript and PDF files. It combines an abstraction of the PostScript drawing model with a TeX/LaTeX interface. Complex tasks like 2d and 3d plots in publication-ready quality are built out of these primitives.
  •  
    PyX is a Python package for the creation of PostScript and PDF files. It combines an abstraction of the PostScript drawing model with a TeX/LaTeX interface. Complex tasks like 2d and 3d plots in publication-ready quality are built out of these primitives.
Benjamin Bandt-Horn

BitwiseOperators - Python Wiki - 0 views

  • x &lt;&lt; yReturns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). This is the same as multiplying x by 2**y.
  • x &gt;&gt; yReturns x with the bits shifted to the right by y places. This is the same as //'ing x by 2**y.
  • x &amp; yDoes a "bitwise and". Each bit of the output is 1 if the corresponding bit of x AND of y is 1, otherwise it's 0.
  • ...5 more annotations...
  • x ^ yDoes a "bitwise exclusive or". Each bit of the output is the same as the corresponding bit in x if that bit in y is 0, and it's the complement of the bit in x if that bit in y is 1.
  • x | yDoes a "bitwise or". Each bit of the output is 0 if the corresponding bit of x AND of y is 0, otherwise it's 1.
  • ~ x Returns the complement of x - the number you get by switching each 1 for a 0 and each 0 for a 1. This is the same as -x - 1.
  • Just remember about that infinite series of 1 bits in a negative number, and these should all make sense.
  • One more point: Python allows operator overloading, so some classes may be written to allow the bitwise operators, but with some other meaning. For instance, the new sets module for Python 2.3 uses | and &amp; for union and intersection.
  •  
    The Operators: x << y Returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). This is the same as multiplying x by 2**y.
1 - 20 of 60 Next › Last »
Showing 20 items per page