Top "Python-2.x" questions

For questions about Python programming that are specific to version 2.x of the language.

Pretty print JSON dumps

I use this code to pretty print a dict into JSON: import json d = {'a': 'blah', 'b': 'foo', 'c': [1,2,3]} print …

python json dictionary python-2.x dump
List minimum in Python with None?

Is there any clever in-built function or something that will return 1 for the min() example below? (I bet there is …

python list max python-2.x minimum
Checking user input using isnan function of NumPy

I'm trying to use NumPy to check if user input is numerical. I've tried using: import numpy as np a = …

python numpy input python-2.x notimplementedexception
Python: min(None, x)

I would like to perform the following: a=max(a,3) b=min(b,3) However sometimes a and b may be …

python python-2.x
Is there a convenient way to apply a lookup table to a large array in numpy?

I’ve got an image read into numpy with quite a few pixels in my resulting array. I calculated a …

arrays numpy python-2.x lookup-tables
How to change the stdin and stdout encoding on Python 2

I'm using Windows and Linux machines for the same project. The default encoding for stdin on Windows is cp1252, and …

encoding stdout stdin python-2.x
Call a python subprocess as daemon and exit

I'm using a pair of python programs, one of which should call the second. But this should be done in …

python daemon python-2.x
How to compare pandas DataFrame against None in Python?

How do I compare a pandas DataFrame with None? I have a constructor that takes one of a parameter_file …

python pandas python-2.x nonetype
Python2: Should I use Pickle or cPickle?

Python 2 has both the pickle and cPickle modules for serialization. cPickle has an obvious advantage over pickle: speed. What, if …

python serialization pickle python-2.x
Check for mutability in Python?

Consider this code: a = {...} # a is an dict with arbitrary contents b = a.copy() What role does mutability play in …

python python-3.x immutability python-2.x hashable