473,320 Members | 1,896 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,320 software developers and data experts.

doc strings of properties

Hi,

I reworked a few methods of a class using properties but then realized
that the online help in interactive sessions would not work as I
expected. The reason is the way how doc strings of properties is treated.
Here is an example to illuminate the problem:
class Foo(object): ... def __init__(self):
... self.a = 2
... self.b = 3
... def set(self, x, y):
... 'Set a and b.'
... self.a = x
... self.b = y
... def _axb(self):
... return self.a * self.b
... axb = property(_axb, doc='Return current product a*b.')
...
() print f.a, f.b, f.axb 2 3 6
print f.set.__doc__ Set a and b.
print f.axb.__doc__ int(x[, base]) -> integer

Convert a string or number to an integer, if possible. A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!) When converting a string,
use
the optional base. It is an error to supply a base when converting a
non-string. If the argument is outside the integer range a long object
will be returned instead.
print Foo.axb.__doc__ Return current product a*b.
I have a vague idea why this is happening, nevertheless find it a bit
inconsistent compared to doc strings of standard methods. Things are not
too helpful with help() either.
help(f.set) Help on method set:

set(self, x, y) method of __main__.Foo instance
Set a and b.
help(Foo.set) Help on method set:

set(self, x, y) unbound __main__.Foo method
Set a and b.
help(f.axb) Help on int:

6
help(Foo.axb) Help on property:

<property object>

Although, help on the class gives what one would expect:
help(Foo)

Help on class Foo in module __main__:

class Foo(__builtin__.object)
| Methods defined here:
|
| __init__(self)
|
| set(self, x, y)
| Set a and b.
|
|
----------------------------------------------------------------------
| Properties defined here:
|
| axb
| Return current product a*b.
|
| <get> = _axb(self)
|
...

Is there a way to work around this problem or I am missing something
here.

Thanks,
Peter
Jul 18 '05 #1
0 932

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

Similar topics

16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
26
by: William Park | last post by:
How do you compare 2 strings, and determine how much they are "close" to each other? Eg. aqwerty qwertyb are similar to each other, except for first/last char. But, how do I quantify that? ...
26
by: Nige | last post by:
I'm a complete novice to JS. I want to insert the date and time into a document in the format: WB-MMDDHHmm Where: WB- is a fixed string prefix (the whole string is a reference number) MM...
11
by: ssg31415926 | last post by:
I need to cast a string into an object and vice versa. At the moment, I'm using code like this: int numOfObjects = Values.Length; object objects = new object; for(int i = 0; i < numOfObjects;...
52
by: Paddy | last post by:
I was browsing the Voidspace blog item on "Flattening Lists", and followed up on the use of sum to do the flattening. A solution was: I would not have thought of using sum in this way. When...
14
by: avanti | last post by:
Hi, I need to generate random alphanumeric password strings for the users in my application using Javascript. Are there any links that will have pointers on the same? Thanks, Avanti
1
by: | last post by:
I'm querying Index Server to return search results, both regular properties and some custom properties I've created. Index Server has this preference for thinking about information as strings...
2
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm getting a little confused here. I'm creating a demo in ASP.Net 2.0. I've had to shift databases a couple of times and apparently Visual Studio is automatically adding new connection strings....
35
by: RobG | last post by:
Seems developers of mobile applications are pretty much devoted to UA sniffing: <URL: http://wurfl.sourceforge.net/vodafonerant/index.htm > -- Rob
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.