Skip to content

Tag: python

How to get instance given a method of the instance?

Now can you get a reference to myInstance if you now only have access to methodReference? Answer If you are using Python 3: Otherwise: and by a similar token, for the class: For this kind of code discovery you should install iPython and use tab, for instance, in your case myReference.+TAB would give: Hence, y…

Embed R code in python

I need to make computations in a python program, and I would prefer to make some of them in R. Is it possible to embed R code in python ? Answer You should take a look at rpy (link to documentation here). This allows you to do: And then you can use the object called r to do computations just

SQLAlchemy ORM select multiple entities from subquery

I need to query multiple entities, something like session.query(Entity1, Entity2), only from a subquery rather than directly from the tables. The docs have something about selecting one entity from a subquery but I can’t find how to select more than one, either in the docs or by experimentation. My use …

How to set self.maxDiff in nose to get full diff output?

When using nose 1.2.1 with Python 3.3.0, I sometimes get an error message similar to the following one In many situations, to figure out what the error really is, I need to see the full diff output. However, I have no idea of how to set that self.maxDiff. Googling for nose and maxDiff does not help. With the …