Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

python-module

What does if __name__ == “__main__”: do?

August 22, 2022 by Magenaut

What does this do?

Categories Python, Q&A Tags idioms, main, namespaces, python, python-module Leave a comment

How to do relative imports in Python?

August 22, 2022 by Magenaut

Imagine this directory structure:

Categories Python, Q&A Tags python, python-import, python-module Leave a comment

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

August 22, 2022 by Magenaut

I have a script named requests.py that imports the requests package. The script either can’t access attributes from the package, or can’t import them. Why isn’t this working and how do I fix it?

Categories Python, Q&A Tags exception, python, python-module, shadowing Leave a comment

How can I import other Python files?

August 22, 2022 by Magenaut

How do I import other files in Python?

Categories Python, Q&A Tags python, python-import, python-module, python-packaging Leave a comment

Installing python module within code

August 21, 2022 by Magenaut

I need to install a package from PyPi straight within my script.
Maybe there’s some module or distutils (distribute, pip etc.) feature which allows me to just execute something like pypi.install('requests') and requests will be installed into my virtualenv.

Categories Python, Q&A Tags pip, pypi, python, python-module Leave a comment

What exactly is a “raw string regex” and how can you use it?

August 20, 2022 by Magenaut

From the python documentation on regex, regarding the '' character:

Categories Python, Q&A Tags python, python-module, rawstring, regex Leave a comment

Unable to import a module that is definitely installed

August 20, 2022 by Magenaut

After installing mechanize, I don’t seem to be able to import it.

Categories Python, Q&A Tags mechanize, python, python-module Leave a comment

How to write a Python module/package?

August 19, 2022 by Magenaut

I’ve been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wrapper for a REST API. I have absolutely no idea on how to start and I need help.

Categories Python, Q&A Tags python, python-2.7, python-module Leave a comment

Collapse multiple submodules to one Cython extension

August 19, 2022 by Magenaut

This setup.py:

Categories Python, Q&A Tags cython, distutils, python, python-module Leave a comment

What’s the difference between __builtin__ and __builtins__?

August 17, 2022 by Magenaut

I was coding today and noticed something. If I open a new interpreter session (IDLE) and check what’s defined with the dir function I get this:

Categories Python, Q&A Tags language-design, python, python-2.7, python-3.x, python-module Leave a comment
Older posts
Page1 Page2 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress