background preloader

Scientific Computing Tools For Python — Numpy

Scientific Computing Tools For Python — Numpy

VPython Be careful with exec and eval in Python written on Tuesday, February 1, 2011 One of the perceived features of a dynamic programming language like Python is the ability to execute code from a string. In fact many people are under the impression that this is the main difference between something like Python and C#. That might have been true when the people compared Python to things like C. Wait what. This post was inspired by a discussion on reddit about the use of the execfile function in the web2py web framework but also applies to other projects. Disclaimer beforehand: the numbers for this post are taken from Python 2.7 on OS X. Behind the Scenes of Imports Let's start with everybody's favourite topic: Performance. it locates the module (surprise). Now first of all, none of the above steps ever passed a string to the exec keyword or function. >>> code = compile('a = 1 + 2', '<string>', 'exec')>>> exec code>>> print a3 As you can see, exec happily executes bytecode too. Why should you do that? Performance Characteristics

Matplotlib matplotlib: python plotting — Matplotlib v1.0.1 documentation PEP 8 -- Style Guide for Python Code Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b. This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

Geany : Home Page Intro to Unintrusive JavaScript with Django There are quite a number of tutorials looking at using Ajax with Django. Despite that, it is still a topic that leaves many confused. I think the fundamental issue is that there are three very different groups looking for tutorials on using Ajax with Django: Experienced web developers who have used a multitude of other frameworks (and used to administer networks composed of passenger pigeons in their younger days) who just need a couple of low-level details. Web developers who have mastered one other framework (often Ruby on Rails), but need a slightly higher level of detail to get used to the differences between Django's way of doing things and their previous experience. Usually tutorials for group one get written first, because they usually only need to be a couple of paragraphs and a code snippet (and they make up the majority of early adopters). If you've walked through the Django tutorial then you're ready to get started with unintrusive JavaScript and Ajax. Overview That's it.

Python Programming Language – Official Website Big A Little i (Practical Artificial Intelligence in Python) by Tendayi Mawushe for EuroPython 2012 These days it is difficult for software to meet users’ expectations to behave intelligently. When a program displays a lack of even the most basic awareness of context it is jarring. At the same time organisations are seeking to gain a competitive advantage through software that behaves adaptively based on the information at hand. Solving these problems is a challenge for today’s developers. There is general agreement among seasoned developers that having a good understanding of basic computer science data structures and algorithms is essential.

Related: