I want to know if short preview is working.
Short preview is supposed to only show the first paragraph in the RSS feed.
So, I have a problem if I see this line in my feedreader.
Errk! That second paragraph appeared! Now let me add lots and lots of gibberish text.
This python code allows you to add docstrings to variables:
def with_vardoc(C):
"""
Return a class that has an instance attribute ._vardoc. Allow
__init__ to accept a keyword argument vardoc="blah".
Future improvements:
* Figure out how to play nice with pprint.
* Figure out how to keep _vardoc in repr output, but still allow
the object to use eval().
"""
class C2(C):
def __new__(cls, *args, **kwargs):
copied_kwargs = copy.copy(kwargs)
if 'vardoc' in kwargs:
copied_kwargs.pop('vardoc')
o = cls.__bases__[0].__new__(cls, *args, **copied_kwargs)
return o
def __init__(self, *args, **kwargs):
vardoc = kwargs.get("vardoc")
if vardoc:
kwargs.pop("vardoc")
C.__init__(self, *args, **kwargs)
self._vardoc = vardoc
def __repr__(self):
if self._vardoc:
return self._vardoc + "\n" + C.__repr__(self)
else:
return C.__repr__(self)
def __str_(self):
if self._vardoc:
return self._vardoc + "\n" + C.__str__(self)
else:
return C.__str__(self)
return C2


0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home