Skip to content
Advertisement

Tag: module

Better place to put common functions?

I’m working on building a custom package for functions I commonly use, and it has several functions that do not fit in any specific module and are used by several modules. I’ve been putting them in __init__.py, and it works, but I’ve seen many tutorials that recommend a very small __init__.py. Is there any better place I can put them?

What Does This Output Represent?

I’m trying to get my RPi to send temp data to Xively and I’m having a horrible time getting my code to work. This is the latest reponse I get when I run the python script… Can someone explain to me what this means and what I need to do to correct? Thanks. Answer The xively module is expecting the

Python DNS module import error

I have been using python dns module.I was trying to use it on a new Linux installation but the module is not getting loaded. I have tried to clean up and install but the installation does not seem to be working. $ python –version Python 2.7.3 $ sudo pip install dnspython Downloading/unpacking dnspython Downloading dnspython-1.11.1.zip (220Kb): 220Kb downloaded Running setup.py

Python 3: ImportError “No Module named Setuptools”

I’m having troubles with installing packages in Python 3. I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get: I have no idea what to do because I didn’t have setuptools installed in the past. Still, I was able to install many packages with setup.py install without setuptools. Why should

ImportError: No module named six

I’m trying to build OpenERP project, done with dependencies. It’s giving this error now Could someone guide what’s wrong and how it can be fixed??? Answer You probably don’t have the six Python module installed. You can find it on pypi. To install it: (if you have pip installed, use pip install six instead)

Can’t import my own modules in Python

I’m having a hard time understanding how module importing works in Python (I’ve never done it in any other language before either). Let’s say I have: Now I’m trying to get something like this: However, I’m definitely doing something wrong as Python can’t see that myapp is a module: Answer In your particular case it looks like you’re trying to

What does a . in an import statement in Python mean?

I’m looking over the code for Python’s multiprocessing module, and it contains this line: instead of the subtle difference being the period before _multiprocessing. What does that mean? Why the period? Answer That’s the syntax for explicit relative imports. It means import from the current package.

Importing modules inside python class

I’m currently writing a class that needs os, stat and some others. What’s the best way to import these modules in my class? I’m thinking about when others will use it, I want the ‘dependency’ modules to be already imported when the class is instantiated. Now I’m importing them in my methods, but maybe there’s a better solution. Answer If

Check if module exists, if not install it

I want to check if a module exists, if it doesn’t I want to install it. How should I do this? So far I have this code which correctly prints f if the module doesn’t exist. Answer Here is how it should be done, and if I am wrong, please correct me. However, Noufal seems to confirm it in another

Advertisement