On Mon, 23 Nov 2009 22:27:24 -0800, alex23 wrote:
> As a very rough example:
>
> def g(x):
> try:
> assert isinstance(x, int)
> except AssertionError:
> raise TypeError, "excepted int, got %s" % type(x)
> # ... function code goes here
>
> d
On Mon, 23 Nov 2009 12:02:36 -0500, John Guenther wrote:
> This is Mac related. I am running snow leopard. I am using Python 2.6.3.
>
> I had a lot of difficulty figuring out how to add a directory to
> sys.path that would be there every time I launched Idle.
[...]
For a comprehensive discussion
On Mon, 23 Nov 2009 19:57:05 -0800, Richard Thomas wrote:
> Not sure exactly how you're representing graphs, this seems like the
> simplest way of listing the edges.
>
> def complete_partite(*sizes):
> total = sum(sizes)
> nodes, edges = range(total), []
> for group in xrange(len(size
I was wondering if there were any neat tools (like for instance,
something from itertools) that would help me write the following function
more elegantly. The return value should, of course, be the complete $k$-
partite graph $K_{n_1, n_2, \dots, n_k}$:
def completeGraph (*ns):
'''
Retu
On Fri, 06 Jun 2008 18:01:45 -0700, Mensanator wrote:
> What happens if your iterables aren't the same length?
I chose not to consider that case, since they were the same length in the
original post. Based on the variable names, it seemed reasonable that
there would always be a 1-to-1 corresp
On Sun, 17 Feb 2008 11:35:35 -0800, MartinRinehart wrote:
> Tkinter gets no respect. But IDLE's a Tkinter-based app and every
> example I've Googled up shows Tkinter as needing about half as much code
> as wx to do the same job. I'm beginning to Tkinter up my language
> application. Am I making a
On Mon, 26 May 2008 15:49:33 -0400, Dan Upton wrote:
> On Mon, May 26, 2008 at 3:22 PM, <[EMAIL PROTECTED]> wrote:
> I don't know if it would necessarily look like the CPython VM, except
> for the decode stage (this being said without any knowledge of the
> CPython implementation, but with more
Does anyone know of any (preferably largish) examples of literate
programs written using Python? Alternatively, does anyone know of any
literate programming tools which support Python well? (I am aware of
Leo and I've been to literateprogramming.com, but any additional
pointers would be much appr
I'm looking at doing some currency calculations in some Python code
integrated with a C++ application. I want to be able to come up with the
same values I get in an Excel spreadsheet.
I've been poking around for a couple of days and haven't come across a
definitive method for dealing with curre
In the language documentation, all that is said about thread.error is
that it's raised "on thread-specific errors." Is there anywhere a
list of conditions which will cause thread.error to be raised? (I
mean, other than the thread library C source, of course.)
Thanks!
Paul
--
http://mail.pytho
Bastion and rexec have been deprecated since Python 2.2, so it seems
we (the Python community) have gotten along well enough without them.
Have these modules not been reimplemented because:
a) There are no valid use cases for them.
b) Doing so would be difficult and prone to breakage as new featur
Paul Miller wrote:
> I had some code that used to work that now doesn't. It's an embedded
> Python interpreter that uses numpy internally. The code calls
> "import_array()", which now fails (and generates a "ImportError: No
> module named _numpy" error)
I had some code that used to work that now doesn't. It's an embedded
Python interpreter that uses numpy internally. The code calls
"import_array()", which now fails (and generates a "ImportError: No
module named _numpy" error).
This is on the latest OS X 10.4 release. I have Numeric installed i
Robert Kern wrote:
> Paul Miller wrote:
>
>>Robert Kern wrote:
>
>
>>>MacPython 2.2 has been long abandoned. The
>>>official OS X binary for Python 2.4.1 can be found here:
>>>
>>>http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.
Robert Kern wrote:
> Paul Miller wrote:
>
>>I have a user who is is having trouble getting MacPython on his OS X
>>10.3.8 system.
>>
>>When he runs ConfigurePythonCarbon, he gets this error:
>>
>>[terminated]
>>'import site' faile
I have a user who is is having trouble getting MacPython on his OS X
10.3.8 system.
When he runs ConfigurePythonCarbon, he gets this error:
[terminated]
'import site' failed; use -v for traceback
traceback )most recent call last):
File "Moes:SWdev:Jack:Python2.2:Mac:script:configurePython.py", l
Paul Miller wrote:
I note the documentation for InteractiveConsole, which is implemented in
Python. Is there any example code for using this from within C/C++ code
to emulate the command-line interpreter inside a GUI app?
I've gotten my text edit widget to send InteractiveConsole strings to
Michael Hoffman wrote:
Paul Miller wrote:
While on the subject, is there an equivalent for "methodcaller"?
ie. if I want to bind a function which calls a specific method of an
object with a specific parameter?
def funccaller(func, *args, **kwargs):
def _return_func():
r
I did this YEARS ago with Python 1.5, and I recall it being slightly
painful. I have an embedded Python interpreter and I want to provide an
interactive console (implemented in my GUI application with a Qt
TextEdit widget). I can handle the GUI part of it, but I'm wondering
what the latest Pyth
Michael Hoffman wrote:
Dave Benjamin wrote:
I think you meant to write something like this:
def attrsetter(obj, name, value):
def _return_func():
return setattr(obj, name, value)
return _return_func
Sure did. Sorry.
You guys have been very helpful!
While on the subject, is there an
Michael Hoffman wrote:
That's what lambda does. But it's going away, you'll have to use def
when it does, unless the language designers come up with something better.
Yeah, I'm using lamda now it works nicely/cleanly.
If a lot of the bindings are actually setting variables, you could do
something
I see lambda is "going away", so I want to use something that will be
around for awhile.
All I want to do is provide an "inline function" as an argument to
another function.
For example, let's say I have a function which binds a key to a function
call. I want to do something "simple" in this f
22 matches
Mail list logo