I’m playing with functional capacities of Python 3 and I tried to implement classical algorithm for calculating Hamming numbers. That’s the numbers which have as prime factors only 2, 3 or 5. First …
Python inserting variable string as file name
I’m trying to create a file with a unique file name for every time my script runs. I am only intending to do this to every week or month. so I chose to use the date for the file name. is where I’m getting this error. it works if I use a static filename, is there an issue with the
How to check if a specific integer is in a list
I want to know how to make an if statement that executes a clause if a certain integer is in a list. All the other answers I’ve seen ask for a specific condition like prime numbers, duplicates, etc. …
How to get instance given a method of the instance?
class MyClass: def myMethod(self): pass myInstance = MyClass() methodReference = myInstance.myMethod Now can you get a reference to myInstance if you now only have access to …
How to get the index with the key in a dictionary?
I have the key of a python dictionary and I want to get the corresponding index in the dictionary. Suppose I have the following dictionary, d = { ‘a’: 10, ‘b’: 20, ‘c’: 30} Is there a combination of …
dynamically adding callable to class as instance “method”
I implemented a metaclass that tears down the class attributes for classes created with it and builds methods from the data from those arguments, then attaches those dynamically created methods directly to the class object (the class in question allows for easy definition of web form objects for use in a web testing framework). It has been working just fine,
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 …
Pycuda Blocks and Grids to work with big datas
I need help to know the size of my blocks and grids. I’m building a python app to perform metric calculations based on scipy as: Euclidean distance, Manhattan, Pearson, Cosine, joined other. The project is PycudaDistances. It seems to work very well with small arrays. When I perform a more exhaustive test, unfortunately it did not work. I downloaded movielens
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 ====================================================================== FAIL: maxdiff2.test_equal …
displaying fixed width bars for all datasets in matplotlib
I have the following datasets .I need to plot barchats for say 1,2 or all of them.When I plot the chart for a single data item (eg: xdata=[0] and ydata=[1000], xlabels=[‘first’] , the bar is sclaed to …