Python Dingus source

2 views
Skip to first unread message

Gary Bernhardt

unread,
Dec 12, 2008, 9:39:37 PM12/12/08
to CleRB
Assuming Google Groups allows attachments, you'll find Dingus
attached. As I mentioned at the meeting, it grew organically out of
another library, and its tests were bolted on later. So neither dingus
nor its tests are necessarily good examples of code, but its behavior
has been refined quite a bit from my experience using it. :)
Hopefully, I'll release it properly soon and do a screencast.

--
Gary
http://blog.extracheese.org

dingus.zip

Matt Wilson

unread,
Dec 14, 2008, 2:33:28 PM12/14/08
to CleRB
Reading it now. Not a single docstring in the entire project!

You have any thoughts about hosting this somewhere like bitbucket or
github or google code? If that were to happen, the first thing I
would contribute is the boring setup.py stuff and then register it on
pypi so I can install this with easy_install, and make it a dependency
when I use it in other projects.

Matt

Gary Bernhardt

unread,
Dec 14, 2008, 3:28:20 PM12/14/08
to cl...@googlegroups.com
On Sun, Dec 14, 2008 at 2:33 PM, Matt Wilson <mw4...@gmail.com> wrote:
>
> Reading it now. Not a single docstring in the entire project!

Yep - docstrings are basically comments and you know that I'm not a
fan of those. ;) Dingus is probably quite hard to understand, though,
because it grew by accretion and I only wrote the tests after it was
pretty mature.

> You have any thoughts about hosting this somewhere like bitbucket or
> github or google code? If that were to happen, the first thing I
> would contribute is the boring setup.py stuff and then register it on
> pypi so I can install this with easy_install, and make it a dependency
> when I use it in other projects.

I'm planning on doing all of this ASAP, maybe even today. I'm at the
Cleveland Code Co-op meeting right now, so I'm going to do a little
bugfixing and test writing for geopy, then hopefully work on releasing
dingus.

(We're at the Gypsy Beans Cafe at Detroit and W. 65th, by the way. You
should all be here. ;)

--
Gary
http://blog.extracheese.org

Matt Wilson

unread,
Dec 14, 2008, 4:29:11 PM12/14/08
to CleRB
On Dec 14, 3:28 pm, "Gary Bernhardt" <gary.bernha...@gmail.com> wrote:
>
> (We're at the Gypsy Beans Cafe at Detroit and W. 65th, by the way. You
> should all be here. ;)

I'll try to come to another one some other time.

Anyhow, I made a little progress on the infinite-looping issue I
emailed about. It's not a bug in your stuff. It's an interaction
between your stuff and a special hack added into ipython for some
corner case.

You can recreate the infinite loop like this:

>>> x = [1, 2, 3]
>>> d = Dingus()
>>> x.extend(d)

That will never finish and x will get fatter and fatter and fatter.

Here's the specific ipython code responsible. Ipython defines a
special dir2 inside a file named genutils.py. This dir2 starts with
the results of a regular dir and then adds on extra stuff.

This is the block causing the problem:

# this is the 'dir' function for objects with Enthought's traits
if hasattr(obj, 'trait_names'):
try:
print "about to run words.extend..."
words.extend(obj.trait_names())
print "finished with that!"
may_have_dupes = True
except TypeError:
# This will happen if `obj` is a class and not an
instance.
pass

Your dinguses always say they have every attribute, and they seem to
be infinitely iterable, so, I never see my print statement "finished
with that!".

Gonna post to the ipython mailing list and ask those guys for advice.

Gary Bernhardt

unread,
Dec 15, 2008, 5:08:52 PM12/15/08
to cl...@googlegroups.com, Matt Wilson
On Sun, Dec 14, 2008 at 4:29 PM, Matt Wilson <mw4...@gmail.com> wrote:
>
> Your dinguses always say they have every attribute, and they seem to
> be infinitely iterable, so, I never see my print statement "finished
> with that!".
>
> Gonna post to the ipython mailing list and ask those guys for advice.

Did they have any ideas?

--
Gary
http://blog.extracheese.org

Matt Wilson

unread,
Dec 15, 2008, 6:13:46 PM12/15/08
to CleRB
On Dec 15, 5:08 pm, "Gary Bernhardt" <gary.bernha...@gmail.com> wrote:
> On Sun, Dec 14, 2008 at 4:29 PM, Matt Wilson <mw44...@gmail.com> wrote:
>
> > Your dinguses always say they have every attribute, and they seem to
> > be infinitely iterable, so, I never see my print statement "finished
> > with that!".
>
> > Gonna post to the ipython mailing list and ask those guys for advice.
>
> Did they have any ideas?

Nobody replied yet to my post:

http://permalink.gmane.org/gmane.comp.python.ipython.user/4226

There's this one guy Fernando who always seems to reply eventually,
but it sometimes takes him a few weeks.

The simplest thing I can think of is to return False on hasattr(obj,
'trait_names'). It's ghetto but it gets the job done.

Gary Bernhardt

unread,
Dec 15, 2008, 6:19:31 PM12/15/08
to cl...@googlegroups.com

I guess that could be done as a last resort, but I hate to start
carving out attribute names that aren't dingusable.

The more drastic solution would be to change dinguses' behavior when
iterated. Dinguses could be empty instead of infinite, for example.
Maybe I'll try that change and see how it affects BitBacker's test
suite. I know there have been tests where iterating over dinguses
mattered, but I don't think there were many, so maybe it'll work out.

--
Gary
http://blog.extracheese.org

Reply all
Reply to author
Forward
0 new messages