473,542 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Information about including module?

Is there any way to print the docstring of the including module? I'd
like to be able to do something like the following
file one.py:

"some docstring"
include two
file two.py:
from magicmodule import getincluder
print getincluder()._ _doc__
Running one.py would print the docstring.

Thanks!
Buck
Jan 3 '08 #1
1 1017
On Jan 2, 4:52 pm, bukzor <workithar...@g mail.comwrote:
Is there any way to print the docstring of the including module? I'd
like to be able to do something like the following

file one.py:

"some docstring"
include two

file two.py:
from magicmodule import getincluder
print getincluder()._ _doc__

Running one.py would print the docstring.

Thanks!
Buck

Answered my own question:

def getimporter():
from inspect import stack
for info in stack():
text = info[4][0].split()
if 'import' in text and text[0] in ('from', 'import'):
return info[0].f_locals
print getimporter()['__doc__']
This is a simplified version of the recipe here:
http://aspn.activestate.com/ASPN/Coo.../Recipe/473823
Jan 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3113
by: simonc | last post by:
I've been programming in assembler and C/C++ for a number of years, but I'm only just starting down the road of PHP & MYSQL. I have a couple of questions: (1) Before I start writing my own code, to learn from, and also avoid re-inventing the wheel, does anyone know of any existing source that implements a (basic or complex) play-by-email...
5
4010
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me your setup.py scipt, please). Thanks in advance, Rene O.
4
1609
by: Mudcat | last post by:
Hi, I'm wondering the best way to do the following. I would like to use a map webpage (like yahoo maps) to find the distance between two places that are pulled in from a text file. I want to accomplish this without displaying the browser. I am looking at several options right now, including urllib, httplib, packet trace, etc. But I...
3
2814
by: Cers | last post by:
Hello All I would like to print a barcode on a HP Laserjet printer. I know that exist some module (from Jetcaps) to print barcode. I´m programming an aplication in VC++, and I would like to print pages including barcode, and it would be better if that works with any printer. If anybody know where can I find this information, or know...
0
801
by: Paul Bromley | last post by:
I am trying to 'mature' in my coding at the moment and have put a lot of effort into learning about classes and now I can see very good results with far shorter code and re-useable elements. I wish to continue in this way. My main problem at the moment is that when I use a class I sometimes want to update information on an EXISTING fom -...
8
1173
by: John Salerno | last post by:
I was just thinking, since Python 3.0 is supposed to clean up a lot of the unnecessary or redundant features of Python and make other things more streamlined, does it seem to anyone that including SQLite goes against this goal? This is just me thinking out loud, mind you, but it seems like including a database module (especially one that...
27
2743
by: matt | last post by:
Hello group, I'm trying to become familiar with the information hiding design rules, and I have a lot (3) of questions for all you experts. AFAIK, a generic module has 2 files: ================ module.h ================ #ifndef __MODULE_HDR_INCLUDED__
3
5504
by: Noorain | last post by:
I designed a site. i want to header,footer,left & right column fixed but body information only scrolling. this site screen to be 800/600 px. i designed this way but when i used position fixed all information to show as displace. please help me. my coding are as below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1
6361
by: jadeite100 | last post by:
Hi All: I installed oracle report server 10.1.2.02 I tried the following url and it display the page properly that ask Test run Job: http://xxx/reports/rwwebservice?operation=runJob When I tried the url: http://xxx/reports/rwservlet/showJobs?server=rep_xxx_oracleas3 It is suppose to redirect me to an url to login. It did the first time....
0
7392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7721
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5246
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
943
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.