473,231 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Accessing docstrings at runtime?

How do I print the docstring for a class property?

When I run the code below, I get the docstring for the string module
and not the one I set for the property.

# NOTE: Found in Python docs defining built-in functions (such as
# property()). FIXED: Bug in getx, setx, and delx where "__x"
# was misreferenced as "_x".
class C(object):
def __init__(self):
self.__x = None
def getx(self):
return self.__x
def setx(self, value):
self.__x = value
def delx(self):
del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")

if __name__ == "__main__"
y = C()
y.x = 'test'
print y.x
print y.x.__doc__

I get the following output:

str(object) -string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

What am I doing wrong?

Kenneth Love

P.S. If I want a docstring and I do not want a delete function,
do I just pass 'None' (minus quotes) for that parameter?

Kenneth Love | Oklahoma Tax Commission
DP Programmer/Analyst | Information Technology
(405) 522 - 5864 | http://www.tax.ok.gov/

Aug 29 '07 #1
0 832

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

Similar topics

by: Sridhar R | last post by:
When writing a python library, we can use docstrings for methods and functions that are part of API. But what about comments for non-API objects or python application code? For applications,...
by: Craig Ringer | last post by:
Hi folks I'm currently working on a fairly well internationalised app that embeds a Python intepreter. I'd like to make the docstrings translatable, but am running into the issue that the...
by: Steven Bethard | last post by:
I have two classes that implement the same interface, e.g. something like: class C(object): def foo(self): """Foo things""" ... def bar(self): """Bar things""" ... def baz(self):
by: Michael Muller | last post by:
I've observed something strange about property docstrings and I'm wondering if anyone here can clarify what's going on: if I create a class derived from property, the docstrings of the instances...
by: Kamilche | last post by:
I have a large project that is getting complex, and I would like to print the docstrings without importing the modules. The only Python utility I could find references is apparently defunct and...
by: Edward Loper | last post by:
Epydoc 3 supports extracting information about Python modules by parsing. As a result, it can extract "docstrings" for variables. There are several possible ways these docstrings could be...
by: jelle | last post by:
That's basically the idea... Often i find myself annotating what variables actually stand for, so to refer back to the code in half a year or so. # check if ID's or coords self.pointIDs = ptIDs...
by: bartonc | last post by:
You will be rewarded sooner than you think when you use docstrings to document your classes and functions. Whether you ever intend to publish your work or not, docstrings will help you in several...
by: tjhnson | last post by:
The topic of docstrings for variables has come up many times before. In fact, a PEP was proposed and rejected on this very topic. http://www.python.org/dev/peps/pep-0224/ When creating...
by: Steve Brown | last post by:
I've got a series of modules which look like this: #************ # # Temperature Sense Test # #************ class Test3(ar_test.AR_TEST): """Temperature Sense Test"""
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.