How do you use subprocess.check_output() in Python?

The right answer (using Python 2.7 and later, since check_output() was introduced then) is: To demonstrate, here are my two programs: py2.py: py3.py: Running it: Here’s what’s wrong with each of your versions: First, str(‘python py2.py’) is exactly the same thing as ‘python py2.py’—you’re taking a str, and calling str to convert it to an str. This makes the code harder to read, longer, … Read more

Python – from . import

There is a PEP for everything. Quote from PEP8: Imports Explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose: Guido’s decision in PEP328 Imports: Multi-Line and Absolute/Relative Copy Pasta from PEP328 Here’s a sample package layout: Assuming that the current file is either moduleX.py or subpackage1/__init__.py , … Read more

ValueError: max() arg is an empty sequence

I’ve created a GUI using wxFormBuilder that should allow a user to enter the names of “visitors to a business” into a list and then click one of two buttons to return the most frequent and least frequent visitors to the business. I created an earlier version that, unfortunately, gave me the range of visitors, … Read more

Is the standard Python implementation considered as a programming language or a scripting language?

As mentioned in What’s the difference between Scripting and Programming Languages? article: Basically, all scripting languages are programming languages. The theoretical difference between the two is that scripting languages do not require the compilation step and are rather interpreted. For example, normally, a C program needs to be compiled before running whereas normally, a scripting language like … Read more

Updating matplotlib in virtualenv with pip

I am trying to update my matplotlib in virtualenv and now it seems everything crashed 🙁what I did till now is basically, I had previously matplotlib 1.3 now if I activate py virtual environment and check the matplotlib version it shows 2.1 but I cannot import Axes3D from matplotlib. I working on linux platform and using Python 2.7. Further problem, I saw, If I … Read more