python-module

how to pip install 64 bit packages while having both 64 bit and 32 bit versions?

how to pip install 64 bit packages while having both 64 bit and 32 bit versions? Question: I have decided to learn generic algorithms recently and I needed to install Tensorflow package. Tensorflow run on python 64 bit only, so i install python 3.5.0 64 bit without uninstalling python 32 bit. because i was afraid …

Total answers: 6

How to change the PARSER_FORMATTER when using python's argh library

How to change the PARSER_FORMATTER when using python's argh library Question: Using the Argh library for Python I want to provide another PARSER_FORMATTER when I dispatch my function with argh.dispatch_command. I tried: import argh import argparse argh.PARSER_FORMATTER = argparse.RawTextHelpFormatter def myfunct(arg, param=None): pass # here my working code if __name__ == ‘__main__’: argh.dispatch_command(myfunct) But when …

Total answers: 2

Difference between Module and Class in Python

Difference between Module and Class in Python Question: Can I assign value to a variable in the module? If yes, what is the difference between a class and module? PS: I’m a Java guy (in case it helps in the way of explaining). Thanks. Asked By: liwevire || Source Answers: Module: A module is a …

Total answers: 5

Mock an entire module in python

Mock an entire module in python Question: I have an application that imports a module from PyPI. I want to write unittests for that application’s source code, but I do not want to use the module from PyPI in those tests. I want to mock it entirely (the testing machine will not contain that PyPI …

Total answers: 3

Persistent history in python cmd module

Persistent history in python cmd module Question: Is there any way to configure the CMD module from Python to keep a persistent history even after the interactive shell has been closed? When I press the up and down keys I would like to access commands that were previously entered into the shell on previous occasions …

Total answers: 1

Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"

Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError Question: I have a script named requests.py that needs to use the third-party requests package. The script either can’t import the package, or can’t access its functionality. Why isn’t this working, and how do I …

Total answers: 2

__init__.py can't find local modules

__init__.py can't find local modules Question: Borrowing a simplified example at http://pythoncentral.io/how-to-create-a-python-package/ I have an analogous file structure as follows, where Mammals.py and Birds.py define classes with the same names: Project/ Animals/ __init__.py Mammals.py Birds.py When running an ipython interpreter within the Project/ directory and with __init__.py being empty, the following works: from Animals.Mammals import …

Total answers: 2

Import a module with parameter in python

Import a module with parameter in python Question: Is it possible to import a module with some parameter in python ? All I mean by parameter is that there exists a variable in the module which is not initialized in that module, still I am using that variable in that module. In short, I want …

Total answers: 7

What is Python's heapq module?

What is Python's heapq module? Question: I tried “heapq” and arrived at the conclusion that my expectations differ from what I see on the screen. I need somebody to explain how it works and where it can be useful. From the book Python Module of the Week under paragraph 2.2 Sorting it is written If …

Total answers: 4

Where are math.py and sys.py?

Where are math.py and sys.py? Question: I found all the other modules in Python33/Lib, but I can’t find these. I’m sure there are others “missing” too, but these are the only ones I’ve noticed. They work just fine when I import them, I just can’t find them. I checked sys.path and they weren’t anywhere in …

Total answers: 5