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
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
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
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?
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
--
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
--
Yes, it's safe (and this is what the ‘__builtin__’ module is intended
for: URL: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
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
--
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
--
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
--
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
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
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
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
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
15 matches
Mail list logo