How to create a self-destructing Tkinter dialog box?

2009-12-16 Thread mrstevegross
Ok, I would like to put together a Python/Tkinter dialog box that displays a simple message and self-destructs after N seconds. Is there a simple way to do this? Thanks, --Steve -- http://mail.python.org/mailman/listinfo/python-list

How to import pydoc and then use it?

2009-07-20 Thread mrstevegross
I know how to use pydoc from the command line. However, because of complicated environmental setup, it would be preferable to run it within a python script as a native API call. That is, my python runner looks a bit like this: import pydoc pydoc.generate_html_docs_for(someFile) However, it's

Guidance on initialization code in a module

2009-06-16 Thread mrstevegross
Is there a common way to initialize various stuff in a module? That is, I have some code in my module that I want to run whenever the module is imported. Currently, my module looks like this: === foo.py === def something(): ... def somethingelse(): ... something() === EOF === Is the 'someth

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> That works for me.  There isn't an "InterruptedSystemCall" error or > equivalent in the standard exception hierarchy.  EnvironmentError is > the parent of OSError & IOError, which is where you'll most likely be > encountering that state. Thanks! --Steve -- http://mail.python.org/mailman/listinf

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError >... > exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__ Is there a single parent exception to all those? Or should I just write it as: try: ... catch Exception: ... Thanks, --Steve -- http://

What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
I'm trying to write a try/catch block to handle an "interrupted system call". However, I can't seem to locate information on the actual typename of the exception. Does anyone know what it would be? I want my code to look like this: try: ... except InterruptedSystemCall # what's the right name?

Re: Safe to import __builtin__ ?

2009-06-03 Thread mrstevegross
> Yes, it's safe (and this is what the ‘__builtin__’ module is intended > for: http://docs.python.org/library/__builtin__>). > > Be careful, though: there's a separate name, ‘__builtins__’, that is > *not* meant to be imported. It's also implementation-specific, so > shouldn't be relied upon. My ad

Re: Safe to import __builtin__ ?

2009-06-02 Thread mrstevegross
> Why do you want to import it? > > Seehttp://docs.python.org/library/__builtin__.html I'm using a weird python environment that overloads a few builtin functions. In order to run them, I need to explicitly invoke "__builtin__.foo()" to make sure I get the real builtin version, not the overloaded

Safe to import __builtin__ ?

2009-06-02 Thread mrstevegross
Is it generally safe to explicitly import __builtin__ in python? That is, my code reads like this: === foo.py === import __builtin__ ... print __builtin__.type('a') === EOF === It seems like it should be a safe import, but I just want to make sure. Thanks, --Steve -- http://mail.python.org/mail

Re: Import w/ '.' syntax

2009-05-15 Thread mrstevegross
> In that specific case, you're looking for a module 'bar' in the 'foo' > package, which should be located somewhere on sys.path. > > http://docs.python.org/tutorial/modules.html > > That covers it pretty well. Aha! 'packages'! That makes sense. Thanks, --Steve -- http://mail.python.org/mailman/

Import w/ '.' syntax

2009-05-15 Thread mrstevegross
Remind me: is it possible to craft an import statement like this: import foo.bar If so, what's going on here exactly? Is Python looking for a module called 'bar', in a directory called 'foo', in a search path somewhere? Or am I totally misunderstanding the import semantics. Thanks, --Steve --

How to abort module evaluation?

2009-05-12 Thread mrstevegross
I have a python script that is pretty simple: when executed, it imports a bunch of stuff and then runs some logic. When *imported*, it defines some variables and exits. Here's what it looks like: === foo.py === if __name__ != '__main__': x = 1 exit_somehow import bar do_some_stuff... === EOF

An idea for method_missing

2009-04-29 Thread mrstevegross
I was exploring techniques for implementing method_missing in Python. I've seen a few posts out there on the subject... One tricky aspect is if it's possible to not just intercept a method_missing call, but actually dynamically add a new function to an existing class. I realized you can modify the

How to import a module so that the current globals are available to the module?

2009-04-09 Thread mrstevegross
I'm trying to import a module so that the globals() of the importer module are available to the imported module itself. Consider the following scenario: === mymod.py === def go(): some_special_function(1,2) # 'some_special_function' is a built-in function available in the scope of foo.py (see

Re: Weird behavior with lexical scope

2008-11-06 Thread mrstevegross
> def __init__(self, Inner=Inner): Ok, the Inner=Inner trick works. What the heck does that do, anyway? I've never seen that formulation. --Steve -- http://mail.python.org/mailman/listinfo/python-list

Weird behavior with lexical scope

2008-11-06 Thread mrstevegross
I ran into a weird behavior with lexical scope in Python. I'm hoping someone on this forum can explain it to me. Here's the situation: I have an Outer class. In the Outer class, I define a nested class 'Inner' with a simple constructor. Outer's constructor creates an instance of Inner. The code lo