Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python?

I'm looking for something simple to use and that makes pretty graphs easily. I can barely make graphs with Excel, and I barely want to make these graphs anyway so I don't have a lot of motivation to learn something complex.

CairoPlot almost fits the bill, but it hasn't had a release since 2008.

Adbot
ADBOT LOVES YOU

Nippashish
Nov 2, 2005

Let me see you dance!

Thermopyle posted:

Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python?

I'm looking for something simple to use and that makes pretty graphs easily. I can barely make graphs with Excel, and I barely want to make these graphs anyway so I don't have a lot of motivation to learn something complex.

CairoPlot almost fits the bill, but it hasn't had a release since 2008.

I use matplotlib for python plots. Their pyplot module is pretty easy to use.

TURTLE SLUT
Dec 12, 2005

This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy.

I have a bunch of code that deals with XML with the QtXml module from PyQt4. Right now I can feed it XML files and it will validate it and do a bunch of stuff with it. I intend to move this program to a Unix server, so I upload files to the server and have the validate the files with a Python script.

The problem is that there doesn't seem to be any way to install only QtXml into the Unix server. If there is I couldn't figure it out. All the Unix installers for Qt just want to install the whole SDK thing, and I don't have the permissions for that, not to mention I'd still have to somehow gently caress around with PyQt to make the QtXml communicate with Python... seems overly complicated.

So I thought I'd just use lxml that's already installed to the server I'm going to use, and restructure the code to use lxml instead of QtXml. The problem is that I can't seem to install lxml on my Windows machine, where I'll actually do all the development. The lxml module seems to have dependencies to libxml2 and libxlst, but I haven't got the faintest clue how to install those for Windows or where they are even supposed to be installed. All the instructions are just for Unix machines.

Any ideas? Where the gently caress does lxml assume those packages are installed? Why is installing a simple loving XML module so god drat hard :(

Another idea was using xml.dom.minidom, but it seems too simple for my purposes and doesn't offer Schema validation, which is something I need to do.

Scaevolus
Apr 16, 2007

Cukel posted:

This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy.

I have a bunch of code that deals with XML with the QtXml module from PyQt4. Right now I can feed it XML files and it will validate it and do a bunch of stuff with it. I intend to move this program to a Unix server, so I upload files to the server and have the validate the files with a Python script.

The problem is that there doesn't seem to be any way to install only QtXml into the Unix server. If there is I couldn't figure it out. All the Unix installers for Qt just want to install the whole SDK thing, and I don't have the permissions for that, not to mention I'd still have to somehow gently caress around with PyQt to make the QtXml communicate with Python... seems overly complicated.

So I thought I'd just use lxml that's already installed to the server I'm going to use, and restructure the code to use lxml instead of QtXml. The problem is that I can't seem to install lxml on my Windows machine, where I'll actually do all the development. The lxml module seems to have dependencies to libxml2 and libxlst, but I haven't got the faintest clue how to install those for Windows or where they are even supposed to be installed. All the instructions are just for Unix machines.

Any ideas? Where the gently caress does lxml assume those packages are installed? Why is installing a simple loving XML module so god drat hard :(

Another idea was using xml.dom.minidom, but it seems too simple for my purposes and doesn't offer Schema validation, which is something I need to do.
You can get binary packages for lxml 2.3 here.

TURTLE SLUT
Dec 12, 2005

Scaevolus posted:

You can get binary packages for lxml 2.3 here.
Wow, that was much easier than I expected. I swear I googled eggs but couldn't find any for lxml. Thanks!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Cukel posted:

Wow, that was much easier than I expected. I swear I googled eggs but couldn't find any for lxml. Thanks!

Don't use eggs. Use the Windows installers. setuptools is terrible, eggs are terrible, PJE is terrible.

ufarn
May 30, 2009

Cukel posted:

This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy.

I have a bunch of code that deals with XML with the QtXml module from PyQt4. Right now I can feed it XML files and it will validate it and do a bunch of stuff with it. I intend to move this program to a Unix server, so I upload files to the server and have the validate the files with a Python script.

The problem is that there doesn't seem to be any way to install only QtXml into the Unix server. If there is I couldn't figure it out. All the Unix installers for Qt just want to install the whole SDK thing, and I don't have the permissions for that, not to mention I'd still have to somehow gently caress around with PyQt to make the QtXml communicate with Python... seems overly complicated.

So I thought I'd just use lxml that's already installed to the server I'm going to use, and restructure the code to use lxml instead of QtXml. The problem is that I can't seem to install lxml on my Windows machine, where I'll actually do all the development. The lxml module seems to have dependencies to libxml2 and libxlst, but I haven't got the faintest clue how to install those for Windows or where they are even supposed to be installed. All the instructions are just for Unix machines.

Any ideas? Where the gently caress does lxml assume those packages are installed? Why is installing a simple loving XML module so god drat hard :(

Another idea was using xml.dom.minidom, but it seems too simple for my purposes and doesn't offer Schema validation, which is something I need to do.
What about
code:
easy_install pip

pip install lxml

Scaevolus
Apr 16, 2007

Function default arguments being retained can let you do some cute tricks, like simple memoization:

code:
def fib(n, mem={}):
    if n in mem:
        return mem[n]

    if n <= 1:
        return 1

    r = fib(n - 1) + fib(n - 2)
    mem[n] = r
    return r

print map(fib, range(50))
(You could use a memoize decorator, but being able to manage the cached values explicitly is helpful sometimes.)

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Thermopyle posted:

Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python?

I'm looking for something simple to use and that makes pretty graphs easily. I can barely make graphs with Excel, and I barely want to make these graphs anyway so I don't have a lot of motivation to learn something complex.

CairoPlot almost fits the bill, but it hasn't had a release since 2008.

Echoing matplotlib. It loving rules, and I've even used it in graphs for my professional academic journal articles.

I heartily endorse it.

Pretty much the first thing I do when I get a new machine is Python 2.7, NumPy, SciPy, PyFits and matplotlib.

I also recently got turned on to how awesome iPython really is. I'm really annoyed at myself for resisting using it for so long!

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES
Actually, that's not a bad thing to bring up.

I don't know how popular it is outside of scientific circles, but PyFits loving rules for dealing with FITS files.

Space Telescope puts it out.

http://www.stsci.edu/institute/software_hardware/pyfits

SelfOM
Jun 15, 2010

JetsGuy posted:

Echoing matplotlib. It loving rules, and I've even used it in graphs for my professional academic journal articles.

I heartily endorse it.

Pretty much the first thing I do when I get a new machine is Python 2.7, NumPy, SciPy, PyFits and matplotlib.

I also recently got turned on to how awesome iPython really is. I'm really annoyed at myself for resisting using it for so long!

I recently switched to doing a lot of data analysis in R to IPython + the libraries you mentioned. One of the nice features is the interactive cluster functionality. Also the notebook option is amazing if you haven't tried it yet. Both of these features require zeromq and the latter requires tornado. Here is an example of it in use: http://healthyalgorithms.com/2012/02/09/powells-method-for-maximization-in-pymc/. It would be cool if ipython notebook had a nice export to html function though.

Also check out: http://pandas.pydata.org/. It's a really great data munging package.

Nippashish
Nov 2, 2005

Let me see you dance!

JetsGuy posted:

Pretty much the first thing I do when I get a new machine is Python 2.7, NumPy, SciPy, PyFits and matplotlib.

If you're using python for scientific computing I highly recommend enthought's python distribution if you're not already using it. Its killer feature IMO is that it comes with numpy backed by Intel's MKL, meaning numpy is really, really fast. it's free if you're attached to a university

how!!
Nov 19, 2011

by angerbot
code:
In [2]: __import__('wsgi', fromlist=["giotto.contrib"])
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/srv/Flightloggin-3.0/<ipython-input-2-ca4660bc2450> in <module>()
----> 1 __import__('wsgi', fromlist=["giotto.contrib"])

ImportError: No module named wsgi

In [3]: from giotto.contrib import wsgi #works for some reason
How do you use __import__?

The Gripper
Sep 14, 2004
i am winner

how!! posted:

code:
In [2]: __import__('wsgi', fromlist=["giotto.contrib"])
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/srv/Flightloggin-3.0/<ipython-input-2-ca4660bc2450> in <module>()
----> 1 __import__('wsgi', fromlist=["giotto.contrib"])

ImportError: No module named wsgi

In [3]: from giotto.contrib import wsgi #works for some reason
How do you use __import__?
Backwards to the way you're using it, fromlist is a list of things you're importing from giotto.contrib, so __import__('giotto.contrib', fromlist=['wsgi'])

I think if you're specifying fromlist you might need to do:
code:
x = __import__('giotto.contrib', fromlist=['wsgi'])
wsgi = x.wsgi

how!!
Nov 19, 2011

by angerbot

The Gripper posted:

Backwards to the way you're using it, fromlist is a list of things you're importing from giotto.contrib, so __import__('giotto.contrib', fromlist=['wsgi'])

I think if you're specifying fromlist you might need to do:
code:
x = __import__('giotto.contrib', fromlist=['wsgi'])
wsgi = x.wsgi

the problem was that I was missing the "globals(), locals(), -1" thing:

code:
>>> Handler = __import__('giotto.contrib.wsgi', globals(), locals(), -1).Handler

Chimp_On_Stilts
Aug 31, 2004
Holy Hell.
I am doing Zed Shaw's Learn Python the Hard Way and I've got a quick question about lesson 15.

In this lesson, I am importing a simple text file into my python script, then printing it to the terminal. The entire program's code is this:

code:
from sys import argv

script, filename = argv

txt = open(filename)

print "Here's your file %r:" % filename
print txt.read()

print "I'll also ask you to type it again:"
file_again = raw_input("> ")

txt_again = open(file_again)

print txt_again.read()
When playing in the python interpreter just to learn more, I do the following:
code:
        fy = open("ex15_sample.txt")
        fy.read()
When printing fy before and after doing .read(), the output is different. The output appears to become blank after the .read() command. I do not understand why.

What is going on?

Look Around You
Jan 19, 2009

Chimp_On_Stilts posted:

I am doing Zed Shaw's Learn Python the Hard Way and I've got a quick question about lesson 15.

In this lesson, I am importing a simple text file into my python script, then printing it to the terminal. The entire program's code is this:

code:
from sys import argv

script, filename = argv

txt = open(filename)

print "Here's your file %r:" % filename
print txt.read()

print "I'll also ask you to type it again:"
file_again = raw_input("> ")

txt_again = open(file_again)

print txt_again.read()
When playing in the python interpreter just to learn more, I do the following:
code:
        fy = open("ex15_sample.txt")
        fy.read()
When printing fy before and after doing .read(), the output is different. The output appears to become blank after the .read() command. I do not understand why.

What is going on?

File operations are usually sequential, so there's a special (hidden) thing keeping track of where you are in a file. If you try fy.read(20), it will only read 20 bytes from the file, and put them in a string, and move the internal location 20 bytes from where it was before the read, so that the next call to read() will pick up where it left off. This happens until you reach the end of file, which is signified with EOF. When you call read() without arguments, it reads the whole file until it reaches EOF, and returns the entire contents in a string. So basically, after a call to read() without parameters, the whole file is read, and the pointer is stuck at EOF, meaning subsequent calls don't have anything left to read.

e:
This is the behavior you're talking about right?
code:
>>> txt = open("test.txt")
>>> print txt
<open file 'test.txt', mode 'r' at 0x104a155d0>
>>> intext = txt.read()
>>> print intext
a
b
c
def

>>> print txt
<open file 'test.txt', mode 'r' at 0x104a155d0>
>>> intext2 = txt.read()
>>> print intext2

>>>

Look Around You fucked around with this message at 09:54 on Feb 27, 2012

tef
May 30, 2004

-> some l-system crap ->
http://travis-ci.org now support python :3:

vikingstrike
Sep 23, 2007

whats happening, captain
I'm not sure if this has been posted, but I just found this and it's pretty awesome:

http://fonnesbeck.github.com/ScipySuperpack/

quote:

This shell script will install recent 64-bit builds of Numpy (2.0) and Scipy (0.11), Matplotlib (1.2), iPython (0.13), Pandas (0.7), as well as PyMC (2.2 alpha) for OS X 10.7 (Lion) on Intel Macintosh. All builds are based on recent development code from each package, which means though some bugs may be fixed and features added, they also may be more unstable than the official releases[1]. Distributing them together should improve interoperability, since the supporting packages (Scipy, Matplotlib, PyMC) were all built against the accompanying build of Numpy. I encourage all users to run the appropriate unit tests on each package to ensure that any extant issues do not affect your work. Please report any errors that may be the result of build issues.

These packages were compiled on OS X 10.7.3 using Apple’s Python 2.7.1, gFortran 4.2.3 and LLVM-GCC 4.2.1 (build 5658). To avoid compatibility issues, the installer also optionally downloads and installs the gFortran compiler that is compatible with Xcode 4.2. Before you install the Superpack, ensure that Xcode 4.2 is installed on your system.

The packages are updated approximately every two weeks. Check the repository for the build date.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

tef posted:

http://travis-ci.org now support python :3:

I saw that this morning and threw a project up on it. I really like it! I just wish I could use my tox.ini file instead of some extra .travis.yml file :/

Chimp_On_Stilts
Aug 31, 2004
Holy Hell.

Look Around You posted:


e:
This is the behavior you're talking about right?


Exactly. You answered my question :)


EDIT: A new question:

My current Python lesson has me simply copying the contents of one .txt file to another .txt file. What types of files can Python use the built in open and read functions with? Could I copy a .doc the same way? .psd? .xls?

Chimp_On_Stilts fucked around with this message at 05:38 on Feb 28, 2012

Look Around You
Jan 19, 2009

Chimp_On_Stilts posted:

Exactly. You answered my question :)


EDIT: A new question:

My current Python lesson has me simply copying the contents of one .txt file to another .txt file. What types of files can Python use the built in open and read functions with? Could I copy a .doc the same way? .psd? .xls?

Yeah, you can, but it's a bit different. You need to open the file in binary mode as opposed to text mode. To do this, you append 'b' to the mode string. So you use rd_file = open(in_fname, "rb") for the thing you're copying and wr_file = open(out_fname, "wb") for the one to write to.

e:
The difference is that text mode (the default mode) typically only handles printable characters well, while binary mode will handle all types of data, at the cost of not really being able to print it.

Look Around You fucked around with this message at 05:52 on Feb 28, 2012

the
Jul 18, 2004

by Cowcaster
I need to learn enough Python in the next 4 days to be able to solve three physics problems involving oscillations, fourier series, euler approximation, and the Lyapunov exponent.

I hope I can do this. I have limited programming knowledge but have never used Python.

Look Around You
Jan 19, 2009

the posted:

I need to learn enough Python in the next 4 days to be able to solve three physics problems involving oscillations, fourier series, euler approximation, and the Lyapunov exponent.

I hope I can do this. I have limited programming knowledge but have never used Python.

Are you using Sage (or SciPy/NumPy)?

vikingstrike
Sep 23, 2007

whats happening, captain
I've never programmed those problems before but if you know the math, writing functions should be pretty straight forward. I'd use SciPy/NumPy. I'd bet with a little searching you could find example code online that probably does what you need.

German Joey
Dec 18, 2004
Looking for some advice on creating an elegant "Type" framework for this simulation engine that I'm working on. I've got this base class, DataUnit, that stores data in piecewise waveforms. Until now, data in these waveforms were binary numbers, and, subsequently, the only attribute that DataUnit needed to represent different signals was "num_bits." Needless to say, validation of data was pretty easy, as was conversion between different numbers of bits.

However, now I'd like to make things a little more general. I want to also support hex, integer, float, fixed-point, and string data natively, as well as allow support (without it being a pain in the rear end) to add new datatypes depending on whatever is using the engine (e.g. one type that I'm 99% sure we'll want is waveform data). Each type, however many their are and whatever they are, needs to be able to describe and decode itself (not its data) in a simple string format (e.g. "float" being a float, "fixedpoint9_14" being a fixed-point number with 9 digit to the left of the decimal and 14 to the right, etc), and also convert data in its format to the other formats, with parameters when necessary.

My initial idea here was to create a class called DataType, that could be subclassed by various named types, etc, etc etc. But conversions in that case would be a mess, have trouble dealing with new types, and would mostly replicate already built-in Python types at any rate. So, I figure there's gotta be an easier way here. Does anyone have any ideas?

the
Jul 18, 2004

by Cowcaster

Look Around You posted:

Are you using Sage (or SciPy/NumPy)?

I haven't started using anything, really. What would you recommend? I would think I'd just need something that can run a text file I've done up of the code, just to output a number that I need... ?

German Joey
Dec 18, 2004

the posted:

I haven't started using anything, really. What would you recommend? I would think I'd just need something that can run a text file I've done up of the code, just to output a number that I need... ?

It sounds like, from what you said, that just using regular python is fine for your purposes unless you're also processing quite a lot of data.

the
Jul 18, 2004

by Cowcaster
So I can put all my code in a .py text file, open a command window, and just run it.. right?

edit: \/\/ running on Windows 7 32 bit

the fucked around with this message at 22:05 on Feb 28, 2012

Johnny Cache Hit
Oct 17, 2011

the posted:

So I can put all my code in a .py text file, open a command window, and just run it.. right?

Yep, call python whatever.py.

Or add the right shabang (#!/path/to/my/python/) and make it executable and you can skip the Python -- assuming you're on a *NIX.

Look Around You
Jan 19, 2009

the posted:

So I can put all my code in a .py text file, open a command window, and just run it.. right?

edit: \/\/ running on Windows 7 32 bit

Yeah pretty much this.

If you're doing like... serious numerical or symbolic stuff you may want to try Sage out. It's basically Python bundled with SciPy and NumPy which are two really good libraries for this stuff. It's also got really good documentation.

Um, I just noticed that Sage wants you to set it up w/ VirtualBox on Windows. If you don't want to do that they have an online workbook thing that does the same thing except ~in the cloud~ or whatever. I've heard that's supposed to be pretty good too.

e: To run a python script from the command line you literally need to type python myscript.py . I don't think Windows does shebang lines/auto execution, but I could be wrong.

Look Around You fucked around with this message at 04:52 on Feb 29, 2012

stray
Jun 28, 2005

"It's a jet pack, Michael. What could possibly go wrong?"
Anyone here know about the csv module? I have a CSV file that includes quoted fields, like so:
code:
,CADULT,CDMS,M1366.L67J44 2000,"Lorber, Jeff.","Jeff Lorber, the definitive collection",2000,2061108,
As you can see, the 4th (and sometimes 5th) column is a quoted author/title field. However, if the field doesn't contain a comma, the CSV won't add quotes.

Can the csv module can correctly parse those lines so that I get a list like this?
code:
a = [ 'CADULT', 'CDMS', 'M1366.L67J44 2000', 'Lorber, Jeff.', 'Jeff Lorber, the definitive collection', '2000', '2061108' ]

stray fucked around with this message at 23:15 on Feb 29, 2012

geonetix
Mar 6, 2011


The CSV module can. The first example of the reader object also shows how to set delimiters and quote characters, so that should help you a lot.

the
Jul 18, 2004

by Cowcaster
I have to program a bifurcation diagram for a physics homework question.

I have the following:

code:
import math
from PIL import Image
imgx = 1000
imgy = 500
image = Image.new("RGB", (imgx, imgy))

xa = 3.0
xb = 4.0
maxit = 1000

for i in range(imgx):
    r = xa + (xb - xa) * float(i) / (imgx - 1)
    x = 0.1
    for j in range(maxit):
        x = r * x * (1 - x)
        if j > maxit / 2:
            image.putpixel((i, int(x * imgy)), (255, 255, 255))

image.save("Bifurcation.png", "PNG")
How come when I increase xb from 4.0 to 5.0, I receive:

quote:

Traceback (most recent call last):
File "py411hw63second", line 17, in <module>
image.putpixel((i, int(x * imgy)), (255, 255, 255))
OverflowError: cannot convert float infinity to integer

Johnny Cache Hit
Oct 17, 2011
That code is really loving hard to follow. Here's a minimalsmaller testcase that I believe exhibits the behavior you're seeing.

code:
imgx = 1000
imgy = 500
xa = 3.0
xb = 5.0
maxit = 1000

for i in range(imgx):
    x = 0.1
    for j in range(maxit):
        print x
        x = (xa + (xb - xa) * float(i) / (imgx - 1)) * x * (1 - x)
        print (xa, xb, i, imgx, x)    
        int(x)

Your x value dips just a hair over 1.0 (look in the output for 1.0001990246762804). This throws your system into negative numbers on the next run:

x = (5.0 + 3.0 * float(500) / (999)) * 1.0001990246762804 * (1 - 1.0001990246762804)

x = 6.501501501501501 * 1.0001990246762804 * -0.00019902467628041265

x = -0.0007964564119593775

hi there, now you're going to accelerate really quickly to -inf

When xb = 4.0 x doesn't go over 1.0 (I checked) so your system remains stable.

The big problem here: the way you're converting back and forth from int <-> float is really loving scary and you shouldn't do it. It's very possible that what you're doing is algorithmically correct but an accumulation of error bumps x > 1. It's more likely that what you're doing will never give you the result you need.

Read this:
http://floating-point-gui.de/

Johnny Cache Hit fucked around with this message at 04:19 on Mar 1, 2012

the
Jul 18, 2004

by Cowcaster
I'm sorry, my programming knowledge is rather limited.

I'm trying to do a bifurcation diagram of a logistic map.

The map is given by xi+1 = a*xi(1-xi)^2, for 0 <= x <= 1 and 3 <= a <= 6.5

I need to start at x0 = 0.1 and da = 0.1 as well, and then plot what happens.

What I have there is some code I found online that I am trying to modify to solve this problem, but as you can see it is not going well.

The code I put up does draw a fairly good bifurcation map, but it doesn't represent the function or values that I need.

the
Jul 18, 2004

by Cowcaster
Alright, I rewrote something by myself instead.

Why am I getting an invalid syntax for the <= sign?

code:
import math

x = 0.1
i = 1

for i <= 2000:
    for a < 6.5:
        x = a*x*(1-x)**2
        a = a+0.1
        print a,",",x
    i = i+1

No Safe Word
Feb 26, 2005

the posted:

Alright, I rewrote something by myself instead.

Why am I getting an invalid syntax for the <= sign?

code:
import math

x = 0.1
i = 1

for i <= 2000:
    for a < 6.5:
        x = a*x*(1-x)**2
        a = a+0.1
        print a,",",x
    i = i+1

Because the for statement in Python is always paired with an in.

You want

code:
for i in range(1, 2001):

Look Around You
Jan 19, 2009

the posted:

Alright, I rewrote something by myself instead.

Why am I getting an invalid syntax for the <= sign?

code:
import math

x = 0.1
i = 1

for i <= 2000:
    for a < 6.5:
        x = a*x*(1-x)**2
        a = a+0.1
        print a,",",x
    i = i+1

You can't use just a boolean expression in a for loop, try while instead. for loops can only operate on sequences (or other iterable objects) in Python.

e: or you can do what No Safe Word suggested. range() only does integers I think though, so you may have to try something different for the floats.

Adbot
ADBOT LOVES YOU

Lister_of_smeg
May 25, 2005
Just come across this little snippet of code.

code:
ret = execute(os.system, cmd)
if ret and ret != 0:
    raise Error("%s returned %d" % (cmd, ret))
Am I missing something or is that if statement a bit silly? If ret was 0 it wouldn't evaluate to true.

  • Locked thread