python-3.3

Python3 – reload() can not be called on __import__ object?

Python3 – reload() can not be called on __import__ object? Question: Ok so for a number of reasons, I’ve been using s = __import__(‘parse’) for the longest time in Python2, now I sorta need to being my transitions to Python3 for certain projects (mainly due to SSL). But there’s no reload() equivilant in Python3 as …

Total answers: 1

Removing non numeric characters from a string

Removing non numeric characters from a string Question: I have been given the task to remove all non numeric characters including spaces from a either text file or string and then print the new result next to the old characters for example: Before: sd67637 8 After: 676378 As i am a beginner i do not …

Total answers: 9

Numpy-MKL for OS X

Numpy-MKL for OS X Question: I love being able to use Christoph Gohlke’s numpy-MKL version of NumPy linked to Intel’s Math Kernel Library on Windows. However, I have been unable to find a similar version for OS X, preferably NumPy 1.7 linked for Python 3.3 on Mountain Lion. Does anyone know where this might be …

Total answers: 3

Why is dictionary ordering non-deterministic?

Why is dictionary ordering non-deterministic? Question: I recently switched from Python 2.7 to Python 3.3, and it seems that while in Python 2 the ordering of dictionary keys was arbitrary but consistent, in Python 3 the ordering of the keys of a dictionary obtained with e.g. vars() appears non-deterministic. If I run: class Test(object): pass …

Total answers: 2

Writing to CSV with Python adds blank lines

Writing to CSV with Python adds blank lines Question: I am trying to write to CSV file but there are blank rows in between. How can I remove the blank rows? import csv b = open(‘test.csv’, ‘w’) a = csv.writer(b) data = [[‘Me’, ‘You’], [‘293’, ‘219’], [’54’, ’13’]] a.writerows(data) b.close() Asked By: user2031063 || Source …

Total answers: 5

Python 3: ImportError "No Module named Setuptools"

Python 3: ImportError "No Module named Setuptools" Question: I’m having troubles with installing packages in Python 3. I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get: importerror "No Module named Setuptools" I have no idea what to do because I didn’t have setuptools installed …

Total answers: 22

itertools.accumulate() versus functools.reduce()

itertools.accumulate() versus functools.reduce() Question: In Python 3.3, itertools.accumulate(), which normally repeatedly applies an addition operation to the supplied iterable, can now take a function argument as a parameter; this means it now overlaps with functools.reduce(). With a cursory look, the main differences between the two now would seem to be: accumulate() defaults to summing but …

Total answers: 3

Is python package virtualenv necessary when I use python 3.3?

Is python package virtualenv necessary when I use python 3.3? Question: I was looking in Cristoph Gohlke’s python packages and I noticed that there is a package Virtualenv for Python 3.3. Since there is a package venv in the standard python library v3.3, I was wondering if there is an advantage to install this package …

Total answers: 3