Python

  • submit to reddit

Mocking of 'Open' as a Context Manager Made Simple In Python



This content is part of the Python Zone, which is presented to you by DZone and New Relic. Visit the Python Zone for news, tips, and tutorials on the Python programming language.  provides the resources and best practices to help you monitor these applications.

Using open as a context manager is a great way to ensure your file handles are closed properly and is becoming common:with open('/some/path', 'w') as f: f.write('something')The issue is that even if you mock out the call to open it is the returned object...

0 replies - 1357 views - 01/15/12 by Michael Foord in Articles

NumPy 1.5 Beginner's Guide Review

I got the chance to read the book NumPy 1.5 Beginner's Guide written by Ivan Idris and published by Packt Publishing last month. My impression of the book was quite positive. It's a book based on examples, which incrementally introduce all the main features...

0 replies - 1735 views - 01/14/12 by Giuseppe Vettigli in Articles

Squeezing Python into an Android with a Single APK

While the use of Python on Android has been made possible for some time now through SL4A, the Python for Android project has set out to make things even easier.  SL4A allows you to edit scripts and execute interactive interpreters directly on an Android...

0 replies - 2470 views - 01/10/12 by Christopher Smith in Articles

Fixed point iteration

A fixed point for a function is a point at which the value of the function does not change when the function is applied. More formally, x is a fixed point for a given function f if

0 replies - 2715 views - 01/09/12 by Giuseppe Vettigli in Articles

NumPy Book Giveaway!

Packt Publishing offered to organize a contest with prize – 2 print copies and 2 ebooks of the book NumPy Beginner’s Guide. How to Win NumPy Beginner’s Guide You can enter by writing a comment here explaining why you would like to have the book.

0 replies - 643 views - 01/05/12 by Idis Sa in Announcements

MongoDB's Write Lock Performance: 1.8 vs. 2.0

MongoDB, as some of you may know, has a process-wide write lock. This has caused some degree of ridicule from database purists when they discover such a primitive locking model. Now per-database and per-collection locking is on the roadmap for MongoDB, but...

0 replies - 2760 views - 01/04/12 by Rick Copeland in Articles

Python vs Ruby: Maintainability

One of my favorite subjects is comparing and contrasting tools and frameworks available today. Python and Ruby are probably the big 2 languages right now in web development. Now, a language is less important than the framework. However, the language...

4 replies - 6431 views - 12/16/11 by Jeff Dickey in Articles

MontySolr: A Search Solution for Python Lovers With the Speed of Native Java

The folks at CERN wanted a better way to search High Energy Physics fulltext paper repositories and bibliographical databases that produce result set numbers in the multi-millions.  INSPIRE, the that merges the sources' query results, though, is written in...

0 replies - 2738 views - 11/26/11 by David Pell in Articles

Embedded Neo4j Graph Database Now Works in Python

First of all, we’re really sorry. We have been saying that Python support for the embedded database is coming in “a few weeks” or “next month" for over half a year now, and so far, you have waited patiently, and you have waited in vain.

0 replies - 3230 views - 11/17/11 by Jacob Hansson in Articles

Developing (a.k.a. Testing) in Python - Part 1: Python and Java

Before coming to Fiesta I had worked with Java almost exclusive for the past six years. The codebase at my previous company was about 2,000 files and 300,000 LOC. I’m fairly fluent in Java, but I’ve also been a longtime Python advocate; I was excited...

1 replies - 2699 views - 11/14/11 by Daniel Gottlieb in Articles

Beginning with OpenCV in Python

OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision [Ref]. In this post we will see how to use some of the basic functions of OpenCV in Python. The following code opens an image from the disk, prints some...

0 replies - 2539 views - 11/12/11 by Giuseppe Vettigli in Articles

Stackato, a Private PaaS for Python, PHP, Java, and more, gets Management and Monitoring

I’ve been really positive about Cloud Foundry, seeing it as doing the sort of things for PaaS that OpenStack does for IaaS. If Cloud Foundry succeeds in its aim, Organizations will have a PaaS solution that they can use where they want, with whichever...

0 replies - 3181 views - 11/08/11 by Ben Kepes in News

"Strict" Unit Testing -- Everything In Isolation Is Too Much Work

Folks like to claim that unit testing absolutely requires each class be tested in isolation using mocks for all dependencies.  This is a noble aspiration, but doesn't work out perfectly well in Python. First, "unit" is intentionally vague....

4 replies - 5468 views - 09/24/11 by Steven Lott in News

Daily Dose: The End is Nigh - IBM Builds Cognitive Computing Chips

The brilliant engineers and scientists over at Cyberdyne Systems IBM introduced the "first computing core that combines digital 'neurons' and on-chip 'synapses' in working silicon." The chip demonstrates "synaptic plasticity", which...

2 replies - 19980 views - 08/18/11 by Ross Jernigan in Daily Dose

Your test cases should sometimes fail!

I'm an avid subscriber of the delightful weekly (sometimes) Python-URL! email, highlighting the past week's interesting discussions across the numerous Python lists. Each summary starts with the best quote from the week; here's last week's quote:

1 replies - 6583 views - 08/18/11 by Michael Mccandless in News