Generator oddity

2009-05-01 Thread opstad
I'm a little baffled by the inconsistency here. Anyone have any explanations? >>> def gen(): ... yield 'a' ... yield 'b' ... yield 'c' ... >>> [c1 + c2 for c1 in gen() for c2 in gen()] ['aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc'] >>> list(c1 + c2 for c1 in gen() for c2 in gen()) [

Re: Generator oddity

2009-05-01 Thread opstad
D'oh! Many thanks for the explanation; I should have seen that myself. -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHONDOCS on OSX

2005-11-28 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, "Robert Hicks" <[EMAIL PROTECTED]> wrote: > How do I set this variable in my .bash_profile? I have the html docs in > /usr/local/PythonDocs. I have a line in my .profile like this: export PYTHONDOCS='/Users/opstad/Documents/Devel

Awkwardness of C API for making tuples

2005-02-01 Thread Dave Opstad
to set the tuple's items. Whew. Does anyone know of a simpler way? I can't use Py_BuildValue because I don't know at compile-time how many values there are going to be. And there doesn't seem to be a PyTuple_FromArray() function. If I'm overlooking something obvious, plea

Re: Awkwardness of C API for making tuples

2005-02-01 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, "John Machin" <[EMAIL PROTECTED]> wrote: > What is the purpose of this first loop? Error handling. If I can't successfully create all the PyInts then I can dispose the ones I've made and not bother making the tuple at all. > > In what variable-length storage are

Odd slicing behavior?

2005-06-22 Thread Dave Opstad
Take a look at this snippet: >>> class L(list): ... def __init__(self, v): ... super(L, self).__init__(v) ... def __setitem__(self, key, value): ... print key.indices(len(self)) ... >>> v = L(range(10)) >>> v [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> v[::] = [1] (0, 10, 1) >>> v[0:10:1] = [1

Re: Odd slicing behavior?

2005-06-22 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > So - the rationale seems to be: "When using slice-assignment, a form > like l[a:b:c] imposes possibly a non-continous section in l, for which > the semantics are unclear - so we forbid it" But it isn't forbidden:

Using Python to make Cocoa apps on Mac OS X

2005-08-17 Thread Dave Opstad
FYI: A new article has been posted at the Apple Developer website: http://developer.apple.com/cocoa/pyobjc.html Cheers! Dave -- http://mail.python.org/mailman/listinfo/python-list

__setslice__ and classes derived from list

2005-09-02 Thread Dave Opstad
According to the documentation the __setslice__ method has been deprecated since Python 2.0. However, if I'm deriving classes from the builtin list class, I've discovered I can't really ignore __setslice__. Have a look at this snippet: >>> cl

Re: __setslice__ and classes derived from list

2005-09-02 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Perhaps you should submit a feature request? It must be time to get rid > of __setslice__, if not now, then maybe by Python 3.0. I'm happy to submit a feature request, once I figure out how to do it! Dave -- http://m

Initializing subclasses of tuple

2005-03-01 Thread Dave Opstad
File "", line 1, in ? TypeError: iteration over non-sequence -- How do I initialize instances of a class derived from tuple, if it's not in the __init__ method? Thanks for any help! Dave Opstad -- http://mail.python.org/mailman/listinfo/python-list

Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Dave Opstad
In this snippet: d = {'x': 1} value = d.get('x', bigscaryfunction()) the bigscaryfunction is always called, even though 'x' is a valid key. Is there a "short-circuit" version of get that doesn't evaluate the second argument if the first is a valid key? For now I'll code around it, but this beh

Attributes and built-in types

2005-04-01 Thread Dave Opstad
Is it just an implementation limitation that attributes cannot be assigned to instances of internal types? --- >>> x = 4 >>> type(x) >>> class Test(int): ... pass ... >>> y = Test(4) >>> type(y) >>> y.someattr = 10 >>> x.someattr = 10 Traceback (most recent call last)

Re: pack a three byte int

2006-11-09 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Can Python not express the idea of a three-byte int? > > For instance, in the working example below, can we somehow collapse the > three calls of struct.pack into one? > > >>> import struct > >>> > >>> skip = 0x123456 ; count = 0x80 > >

Re: pack a three byte int

2006-11-09 Thread Dave Opstad
Sorry, that should have been: cdb += struct.pack(">L", skip)[1:] Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is fun (useless social thread) ;-)

2006-06-15 Thread Dave Opstad
ompany that lets me do 95%+ of my work in Python, and I'm having the time of my life. My copy of the Martelli book is seriously dog-eared at this point; I'm glad a new edition is being released in a few months. In short: Python rocks. Dave Opstad -- http://mail.python.org/mailman/listinfo/python-list

Re: py2app console

2006-10-03 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > Does anyone know of the most straightforward way to get rid of the > intensely annoying "console" window that py2app feels so compelled to > create? I include this code in my apps: if (sys.platform != "win32") and h

Re: py2app semi-standalone semi-works

2006-10-04 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > I am trying to create a semi-standalone with the vendor python on OS X > 10.4 (python 2.3.5). I tried to include some packages with both > --packages from the command and the 'packages' option in setup.py. While > the pa

Re: Tkinter / Aqua (OS X) question (canvas borders)

2006-02-20 Thread Dave Opstad
fferent for OS X and Windows. In the end I just made sure everything I draw is no closer than 5 pixels from the edge of the Canvas, and that seems to work on all the platforms I'm deploying on. Dave Opstad -- http://mail.python.org/mailman/listinfo/python-list

Re: Outdated Python Info on www.unicode.org

2006-03-06 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Dennis Benzinger <[EMAIL PROTECTED]> wrote: > Could someone who knows the current state of Unicode support in Python > update this information? I've just passed this along to the folks at the Unicode Consortium. Dave -- http://mail.python.org/mailman/listinfo/p

Unusable outer edge of Tkinter canvases?

2005-05-25 Thread Dave Opstad
When drawing rectangles in Tkinter canvases I've noticed the outer edges (say 3-5 pixels) don't always draw. For instance, try typing this in an interactive session (Terminal in OS X or Command Prompt in Windows XP): >>> import Tkinter as T >>> root = T.Tk() >>> f = T.Frame(root) >>> f.grid() >>

Re: Unusable outer edge of Tkinter canvases?

2005-05-25 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > to fix this, you can either set the border width to zero, add scrollbars > to the widget (this fixes the coordinate system), or explicitly reset the > coordinate system: > > w.xview_moveto(0) > w.yview_moveto(0)

Re: struct.pack oddity

2007-03-13 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Larry Bates <[EMAIL PROTECTED]> wrote: > 1) You can't put 10 into a half-word. The limit is 2**16 > or 65535. On Python 2.5 I get: Yes, I know. I used that example to illustrate the problem. If a value does not fit a format then Python should report that con

Re: struct.pack oddity

2007-03-13 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, "Erik Johnson" <[EMAIL PROTECTED]> wrote: > Barring anyone else disagreeing with classifying it as a bug, I would > suggest reporting it. Proper procedure for reporting a bug appears to be > covered in section B of the Python Library Reference: > http://docs.py

Re: Tkinter menu question--how to pass arguments

2007-03-30 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Kevin Walzer <[EMAIL PROTECTED]> wrote: > I'm having difficulty structuring a Tkinter menu entry. Here is the > command in question: > > self.finkmenu.add_command(label='Update List of Packages', > command=self.authorizeCommand(self.scanPackages)) > > When I st

Re: builtin set literal

2007-02-21 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: > [...] However, Python seems to use the -ed suffix for the > non-mutating versions of these functions, e.g. sorted(list) instead > of the mutating list.sort(). I've found this to be useful in my own Python librari

Re: List of all Python's ____ ?

2008-04-25 Thread Dave Opstad
In article <[EMAIL PROTECTED]>, John Machin <[EMAIL PROTECTED]> wrote: > Hrvoje Niksic wrote: > > [EMAIL PROTECTED] writes: > > > >> Is there an official list of all Python's ? > > > > http://docs.python.org/ref/specialnames.html > > __missing__ is missing :-) > > see note (10) at the bot

Manipulating sets from the 2.4 C API?

2006-04-11 Thread Dave Opstad
cit set support somewhere I'm not seeing? Thanks, Dave Opstad -- http://mail.python.org/mailman/listinfo/python-list