set and dict iteration

2012-08-16 Thread Aaron Brady
Hello, I observed an inconsistency in the behavior of 'set' and 'dict' iterators. It is "by design" according to the docs. ''' http://docs.python.org/dev/library/stdtypes.html#dict-views iter(dictview). Iterating views while adding or deleting entries in the dictionary may raise a RuntimeErr

Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 6:07:40 PM UTC-5, Ian wrote: > On Thu, Aug 16, 2012 at 4:55 PM, Ian Kelly wrote: > > > On Thu, Aug 16, 2012 at 12:00 PM, Aaron Brady wrote: > > >> The inconsistency is, if we remove an element from a set and add another > >> during

Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 8:01:39 PM UTC-5, Paul Rubin wrote: > Ian Kelly writes: > > > With regard to key insertion and deletion while iterating over a dict > > > or set, though, there is just no good reason to be doing that > > > (especially as the result is very implementation-specific),

Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 9:30:42 PM UTC-5, Paul Rubin wrote: > Steven D'Aprano writes: > > > Luckily, Python is open source. If anyone thinks that sets and dicts > > > should include more code protecting against mutation-during-iteration, > > > they are more than welcome to come up with a

Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 9:24:44 PM UTC-5, Steven D'Aprano wrote: > On Thu, 16 Aug 2012 19:11:19 -0400, Dave Angel wrote: > > > > > On 08/16/2012 05:26 PM, Paul Rubin wrote: > > >> Dave Angel writes: > > >>> Everything else is implementation defined. Why should an > > >>> implementation

Re: set and dict iteration

2012-08-18 Thread Aaron Brady
On Friday, August 17, 2012 4:57:41 PM UTC-5, Chris Angelico wrote: > On Sat, Aug 18, 2012 at 4:37 AM, Aaron Brady wrote: > > > Is there a problem with hacking on the Beta? > > > > Nope. Hack on the beta, then when the release arrives, rebase your > > work ont

Re: set and dict iteration

2012-08-18 Thread Aaron Brady
On Saturday, August 18, 2012 5:14:05 PM UTC-5, MRAB wrote: > On 18/08/2012 21:29, Aaron Brady wrote: > > > On Friday, August 17, 2012 4:57:41 PM UTC-5, Chris Angelico wrote: > > >> On Sat, Aug 18, 2012 at 4:37 AM, Aaron Brady wrote: > > >> > > >&g

Re: set and dict iteration

2012-08-23 Thread Aaron Brady
On Saturday, August 18, 2012 9:28:32 PM UTC-5, Aaron Brady wrote: > On Saturday, August 18, 2012 5:14:05 PM UTC-5, MRAB wrote: > > > On 18/08/2012 21:29, Aaron Brady wrote: > > > > On Friday, August 17, 2012 4:57:41 PM UTC-5, Chris Angelico wrote: > > > >>

Re: set and dict iteration

2012-08-27 Thread Aaron Brady
On Thursday, August 23, 2012 1:11:14 PM UTC-5, Steven D'Aprano wrote: > On Thu, 23 Aug 2012 09:49:41 -0700, Aaron Brady wrote: > > > > [...] > > > The patch for the above is only 40-60 lines. However it introduces two > > > new concepts. > > >

Re: Looking for an IPC solution

2012-09-01 Thread Aaron Brady
On Friday, August 31, 2012 2:22:00 PM UTC-5, Laszlo Nagy wrote: > There are just so many IPC modules out there. I'm looking for a solution > > for developing a new a multi-tier application. The core application will > > be running on a single computer, so the IPC should be using shared > > me

Re: set and dict iteration

2012-09-02 Thread Aaron Brady
On Monday, August 27, 2012 2:17:45 PM UTC-5, Ian wrote: > On Thu, Aug 23, 2012 at 10:49 AM, Aaron Brady wrote: > > > The patch for the above is only 40-60 lines. However it introduces two new > > concepts. > > > > Is there a link to the patch? Please see b

Re: set and dict iteration

2012-09-03 Thread Aaron Brady
On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: > On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: > > > We could use a Python long object for the version index to prevent > > overflow. Combined with P. Rubin's idea to count the number of open > > it

Re: set and dict iteration

2012-09-03 Thread Aaron Brady
On Monday, September 3, 2012 3:28:28 PM UTC-5, Dave Angel wrote: > On 09/03/2012 04:04 PM, Aaron Brady wrote: > > > On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: > > >> On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: > > >> > > >

Re: set and dict iteration

2012-09-08 Thread Aaron Brady
On Monday, September 3, 2012 8:59:16 PM UTC-5, Steven D'Aprano wrote: > On Mon, 03 Sep 2012 21:50:57 -0400, Dave Angel wrote: > > > > > On 09/03/2012 09:26 PM, Steven D'Aprano wrote: > > > > >> An unsigned C int can count up to 4,294,967,295. I propose that you say > > >> that is enough iter

Re: set and dict iteration

2012-09-08 Thread Aaron Brady
On Thursday, August 23, 2012 1:11:14 PM UTC-5, Steven D'Aprano wrote: > On Thu, 23 Aug 2012 09:49:41 -0700, Aaron Brady wrote: > > > > [...] > > > The patch for the above is only 40-60 lines. However it introduces two > > > new concepts. > > >

unit test strategy

2012-09-14 Thread Aaron Brady
Hello, I've developing a test script. There's a lot of repetition. I want to introduce a strategy for approaching it, but I don't want the program to be discredited because of the test script. Therefore, I'd like to know what people's reactions to and thoughts about it are. The first strate

Re: unit test strategy

2012-09-15 Thread Aaron Brady
On Friday, September 14, 2012 10:32:47 PM UTC-5, David Hutto wrote: > On Fri, Sep 14, 2012 at 11:26 PM, Dwight Hutto wrote: > > > On Fri, Sep 14, 2012 at 10:59 PM, Aaron Brady wrote: > > >> Hello, > > >> > > >> I've developing a

Re: unit test strategy

2012-09-16 Thread Aaron Brady
On Sunday, September 16, 2012 2:42:09 AM UTC-5, Steven D'Aprano wrote: > On Fri, 14 Sep 2012 19:59:29 -0700, Aaron Brady wrote: > > > > > Hello, > > > > > > I've developing a test script. There's a lot of repetition. I want to > &g

Re: unit test strategy

2012-09-22 Thread Aaron Brady
On Sunday, September 16, 2012 3:01:11 PM UTC-5, Steven D'Aprano wrote: > On Sun, 16 Sep 2012 11:38:15 -0700, Aaron Brady wrote: > > Here is an example of some repetitive code. > > > > for view_meth in [ dict.items, dict.keys, dict.values ]: > > dict0= dict

Re: COM connection point

2005-03-18 Thread Aaron Brady
That appears to do just the job! Much obliged, -OY - Original Message - From: "Stefan Schukat" <[EMAIL PROTECTED]> To: "Oy Politics" <[EMAIL PROTECTED]>; Sent: Friday, March 18, 2005 6:05 AM Subject: RE: COM connection point > Just use > > obj = win32com.client.Dispatch(obj) > >

inspect.getblock()

2007-04-22 Thread Aaron Brady
inspect.getblock() seems to halt prematurely. This code only prints 6 lines of the 12 line input file. assume it's by design, but the docs don't mention getblock. docstring is "Extract the block of code at the top of the given list of lines," which should be "code *from* the top." ###whati

function object.func_default off the console

2007-04-24 Thread Aaron Brady
>>> f.func_defaults[0] [2, 3] >>> f.func_defaults[0]+=[4] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> f.func_defaults[0] [2, 3, 4] V. interesting. Operation succeeds but with a throw. Er, raise. -- http://mail.python.

shelf membership

2007-03-31 Thread Aaron Brady
can you shelve objects with membership? this gives you: TypeError: object does not support item assignment dict 0 True Exception exceptions.TypeError: 'object does not support item assignment' in ignored > ignored is a bit mysterious. tx in advance. from shelve import * class MyShelf(Dbfilen

Re: why cannot assign to function call

2009-01-10 Thread Aaron Brady
On Jan 9, 9:30 am, Joe Strout wrote: > Aaron Brady wrote: > > Possible compromise.  You can think of functions as mutation-only. > > You pass the object, and it gets a new (additional) name.  The old > > name doesn't go in.   > > That's correct.  The r

Re: why cannot assign to function call

2009-01-11 Thread Aaron Brady
On Jan 10, 1:49 pm, Joe Strout wrote: > Aaron Brady wrote: > >> Aaron Brady wrote: > >>> Possible compromise.  You can think of functions as mutation-only. > >>> You pass the object, and it gets a new (additional) name.  The old > >>> name does

Re: if-else statement

2009-01-11 Thread Aaron Brady
On Jan 10, 2:28 pm, bearophileh...@lycos.com wrote: > Scott David Daniels: > > >       if checking: > >           my_var = 'string' > >       else: > >           my_var = 'other string' > > > remember, vertical space only kills trees if printed. > > I value clarity a lot. But this is more DRY, some

Re: why cannot assign to function call

2009-01-11 Thread Aaron Brady
On Jan 11, 8:32 am, Paul Rubin wrote: > Steven D'Aprano writes: > > If it walks like pass-by-reference, and smells like pass-by-reference, > > and swims like pass-by-reference, is it still your contention that it is > > pass-by-value? > > Of course the C example is p

Re: Standard IPC for Python?

2009-01-13 Thread Aaron Brady
On Jan 13, 2:04 pm, Laszlo Nagy wrote: > - create a wrapper, using ctypes, /windll / cdll/ to access API functions > - use CreateFileMapping on the page file to create shared memory (a la > windows:http://msdn.microsoft.com/en-us/library/aa366537.aspx) > - use CreateEvent/WaitForSingleObject for s

Re: ctype problem

2009-01-13 Thread Aaron Brady
On Jan 13, 10:22 am, Grimson wrote: > hello out there, > I have a problem with c-types. > I made a c-library, which expects a pointer to a self defined structure. > > let the funtion call myfunction(struct interface* iface) > > and the struct: > struct interface > { >     int a; >     int b; >    

Re: why cannot assign to function call

2009-01-13 Thread Aaron Brady
On Jan 13, 5:06 pm, Mark Wooding wrote: snip > I'm going to move away from the formal semantics stuff and try a > different tack.  Here's what I think is the defining property of > pass-by-value (distilled from the formal approach I described earlier, > but shorn of the symbolism): > >   The calle

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Aaron Brady
On Jan 13, 7:02 pm, Catherine Moroney wrote: > Hello everybody, > > I know how to spawn a sub-process and then wait until it > completes.  I'm wondering if I can do the same thing with > a Python function. > > I would like to spawn off multiple instances of a function > and run them simultaneously

Re: why cannot assign to function call

2009-01-14 Thread Aaron Brady
On Jan 14, 3:51 am, Mark Wooding wrote: > Aaron Brady wrote: > > On Jan 13, 5:06 pm, Mark Wooding wrote: > > snip > > > I'm going to move away from the formal semantics stuff and try a > > > different tack.  Here's what I think is the defining property

reverse dict lookup & Relation class

2009-01-14 Thread Aaron Brady
Hi, this is a continuation of something that comes up now and again about reverse lookups on dictionaries, as well as a follow-up to my pursuit of a Relation class from earlier. For a reverse lookup, you just need two lookups. name= {} phone= {} name[ '555-963' ]= 'Joan' phone[ 'Joan' ]= '555-963'

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Aaron Brady
On Jan 14, 6:00 pm, Cameron Simpson wrote: > On 14Jan2009 15:50, Catherine Moroney > wrote: > > > James Mills wrote: > >> On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney > >> wrote: > >>> I would like to spawn off multiple instances of a function > >>> and run them simultaneously and then w

Re: Why this code is working?

2009-01-15 Thread Aaron Brady
On Jan 14, 7:21 am, "Diez B. Roggisch" wrote: > r wrote: > > Listen Hussien, > > Granted, with a name of "r", spelling it wrong is hard, and thus you might > not be trained in the art of spelling names proper. Or spelling proper names! Bah ha. -- http://mail.python.org/mailman/listinfo/python-li

Re: Convention vs. fascism

2009-01-15 Thread Aaron Brady
On Jan 15, 6:41 pm, Steven D'Aprano wrote: > On Fri, 16 Jan 2009 10:24:19 +1100, Ben Finney wrote: > > Steven D'Aprano writes: > > >> On Fri, 16 Jan 2009 07:58:49 +1100, Ben Finney wrote: > > >> > Steven D'Aprano writes: > > >> >> On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: > > >

Re: reverse dict lookup & Relation class

2009-01-16 Thread Aaron Brady
On Jan 14, 7:04 pm, Chris Rebert wrote: > On Wed, Jan 14, 2009 at 4:30 PM, Aaron Brady wrote: > > Hi, this is a continuation of something that comes up now and again > > about reverse lookups on dictionaries, as well as a follow-up to my > > pursuit of a Relation class from

Re: reverse dict lookup & Relation class

2009-01-16 Thread Aaron Brady
On Jan 14, 7:54 pm, MRAB wrote: > Aaron Brady wrote: > > Hi, this is a continuation of something that comes up now and again > > about reverse lookups on dictionaries, as well as a follow-up to my > > pursuit of a Relation class from earlier. > > > For a reverse loo

Re: reverse dict lookup & Relation class

2009-01-17 Thread Aaron Brady
On Jan 16, 5:03 am, Steven D'Aprano wrote: > On Wed, 14 Jan 2009 16:30:36 -0800, Aaron Brady wrote: > > Hi, this is a continuation of something that comes up now and again > > about reverse lookups on dictionaries, as well as a follow-up to my > > pursuit of a R

Re: multiprocessing question/error

2009-01-17 Thread Aaron Brady
On Jan 16, 11:39 pm, Eduardo Lenz wrote: > Hi, > > I was using the former processing package with python 2.5 with no problems. > After switching to python 2.6.1 I am having some problems with the same code. > The problem seems to be related to the fact that I am using Pool.map > with a bounded met

Re: English-like Python

2009-01-17 Thread Aaron Brady
On Jan 15, 7:02 pm, The Music Guy wrote: > Just out of curiousity, have there been any attempts to make a version > of Python that looks like actual English text? I mean, so much of Python > is already based on the English language that it seems like the next > natural step would be to make a prog

Re: reverse dict lookup & Relation class

2009-01-17 Thread Aaron Brady
On Jan 17, 10:45 am, Steven D'Aprano wrote: > On Sat, 17 Jan 2009 00:24:21 -0800, Aaron Brady wrote: > > Can you make it work for a 3-way lookup? > > What do you mean "3-way lookup"? > > I'm going to take a guess... > > A maps to B, B maps to C,

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Aaron Brady
On Jan 18, 6:56 am, andrew cooke wrote: > On Jan 18, 9:40 am, Marc 'BlackJack' Rintsch wrote: > > > On Sun, 18 Jan 2009 04:24:04 -0800, andrew cooke wrote: > > > my argument was that *= is not treated as = and *, but as a completely > > > new operator (the docs even say that the implementation ne

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 8:19 am, Reckoner wrote: > I  would like to do: > > def foo(self,x,y=self.a) > > where the default value for y=self.a. Since this is not possible, I > wind up doing > > def foo(self,x,y=None) >   if not y: >     y=self.a > > but that seems kind of clumsy. > > Is there a better way to do

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 9:36 am, Paul Rubin wrote: > Steven D'Aprano writes: > > def foo(self, x, y=None): > >     if y is None: > >         y = self.a > > > I don't find that clumsy in the least. I find it perfectly readable and a > > standard idiom. > > That has the same proble

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread Aaron Brady
On Jan 18, 9:52 am, David Pratt wrote: > Hi list. I use 'type' to generate classes but have a need to order   > the attributes for the generated class. Of course a dict is not going   > to maintain ordering. Is there any way to dynamically generate a   > class with attributes in specific order? >

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 10:44 am, Rob Williscroft wrote: > Aaron Brady wrote > innews:6a10378f-addb-4d56-bc1b-0c382b3cb...@t26g2000prh.googlegroups.com > in comp.lang.python: > > > > > On Jan 18, 9:36 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > >> Steven D&#x

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 12:42 pm, andrew cooke wrote: > >     sentinel = object() > >     ... > > >     def foo(x, y=sentinel): > >       if y is sentinel: > >           y = self.a > > it just struck me you could also do: > >      def foo(self, x, *y_args) >        y = y_args[0] if y_args self.a > > which more

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 12:02 pm, Rob Williscroft wrote: > Aaron Brady wrote > innews:582ef883-0176-4984-9521-6c1894636...@a26g2000prf.googlegroups.com > in comp.lang.python: > > > > > On Jan 18, 10:44 am, Rob Williscroft wrote: > >> Aaron Brady wrote > >>

Re: problem in implementing multiprocessing

2009-01-19 Thread Aaron Brady
On Jan 19, 3:09 am, Carl Banks wrote: snip > Since multiprocessing serializes and deserializes the data while > passing > it from process to process, passing very large objects would have a > very > high latency and overhead.  IOW, gopal's diagnosis is correct.  It's > just not practical to share

Re: English-like Python

2009-01-20 Thread Aaron Brady
On Jan 17, 6:10 pm, The Music Guy wrote: > Wow, impressive responses. > > It sounds like the general consensus is that English would not be a good > choice for programming even if there were an interpreter capable of > turning human language into machine language. But that makes sense; even > Engl

Re: English-like Python

2009-01-20 Thread Aaron Brady
On Jan 20, 12:58 pm, Joe Strout wrote: > Aaron Brady wrote: > > I think it would be a good step if you could make some sensible > > interpretation of a typical statement without its parentheses. > > > f "abc" 123 > > --> > > f( "abc&q

Re: English-like Python

2009-01-21 Thread Aaron Brady
On Jan 20, 9:16 pm, MRAB wrote: > Terry Reedy wrote: > > Joe Strout wrote: > >> Aaron Brady wrote: > > >>> I think it would be a good step if you could make some sensible > >>> interpretation of a typical statement without its parentheses. >

Re: English-like Python

2009-01-21 Thread Aaron Brady
On Jan 21, 2:36 am, Steven D'Aprano wrote: > On Tue, 20 Jan 2009 11:58:46 -0700, Joe Strout wrote: > > Aaron Brady wrote: > > >> I think it would be a good step if you could make some sensible > >> interpretation of a typical statement without its parentheses.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Aaron Brady
On Jan 17, 11:28 pm, Steven D'Aprano wrote: > On Sat, 17 Jan 2009 20:49:38 +0100, Bruno Desthuilliers wrote: > > Russ P. a écrit : > >> On Jan 15, 12:21 pm, Bruno Desthuilliers > >> wrote: > > >>> Once again, the important point is that there's a *clear* distinction > >>> between interface and im

Re: English-like Python

2009-01-21 Thread Aaron Brady
On Jan 21, 9:24 am, Joe Strout wrote: > Aaron Brady wrote: > > Where functions are first-class objects, a bare function object isn't > > distinguishable either from its call. > > That depends not on whether functions are first-class objects, but on > the *synt

Re: English-like Python

2009-01-21 Thread Aaron Brady
On Jan 21, 2:50 pm, Scott David Daniels wrote: > Benjamin J. Racine wrote: > > I think it would be a good step if you could make some sensible > > interpretation of a typical statement without its parentheses. > > > f "abc" 123 > > --> > > f( "abc", 123 ) > > > It would be just the thing in a cou

Re: English-like Python

2009-01-22 Thread Aaron Brady
On Jan 22, 1:46 am, Steven D'Aprano wrote: > On Wed, 21 Jan 2009 00:57:49 -0800, Aaron Brady wrote: > > Natural language doesn't have the equivalent of parentheses, > > I take it you mean natural language doesn't have the equivalent of > parentheses for *cal

Re: English-like Python

2009-01-22 Thread Aaron Brady
On Jan 22, 2:17 am, Steven D'Aprano wrote: > On Wed, 21 Jan 2009 08:17:34 -0700, Joe Strout wrote: > > But of course.  Any method call is legal only if the form of the call > > matches the method prototype -- if you try to call a function that > > requires 4 parameters, and give it only 3, that's

subclass PyDictObject -- any gotchas?

2009-01-22 Thread Aaron Brady
Hello all, I am trying to create a mapping class similar to the base dictionary, but with some added behaviors that affect pointers on a low level. I have a bare-bones version I compiled with MinGW, and it is working! I want to know if there is anything that is going to bite me later, when I sta

Re: subclass PyDictObject -- any gotchas?

2009-01-22 Thread Aaron Brady
On Jan 22, 7:49 am, Aaron Brady wrote: > Hello all, > > I am trying to create a mapping class similar to the base dictionary, > but with some added behaviors that affect pointers on a low level.  I > have a bare-bones version I compiled with MinGW, and it is working!  I > want t

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Aaron Brady
On Jan 23, 7:01 pm, Mark Wooding wrote: > Steven D'Aprano writes: > > I did? Where did I make that assumption? > > I inferred it from the juxtaposition, apparently in error.  Sorry. > > > What I said was that the model "The code is the whole team's ownership" > > doesn't work well for large proje

ob_type in shared memory

2009-01-25 Thread Aaron Brady
Hello, I am writing an extension using shared memory. I need a data type that is able to reassign its 'ob_type' field depending on what process is calling it. Object 'A' is of type 'Ta'. When process 'P' is looking at it, it needs to have an 'ob_type' that is 'Ta' as process 'P' sees it. When

Re: ob_type in shared memory

2009-01-26 Thread Aaron Brady
Hi Mark, nice to have your comment. On Jan 25, 9:47 pm, Mark Wooding wrote: > Aaron Brady writes: snip > > Object 'A' is of type 'Ta'.  When process 'P' is looking at it, it > > needs to have an 'ob_type' that is 'Ta' as process

Re: ob_type in shared memory

2009-01-26 Thread Aaron Brady
Hi, Mark, Do you mind if I approach you off the group about this? Aaron On Jan 25, 9:47 pm, Mark Wooding wrote: > Aaron Brady writes: > > I am writing an extension using shared memory.  I need a data type > > that is able to reassign its 'ob_type' field dependi

Re: ob_type in shared memory

2009-01-26 Thread Aaron Brady
On Jan 26, 9:20 pm, Aaron Brady wrote: > Hi, Mark, snip > On Jan 25, 9:47 pm, Mark Wooding wrote:> Aaron Brady > writes: > > > I am writing an extension using shared memory.  I need a data type > > > that is able to reassign its 'ob_type' field depen

Re: self-aware list of objects able to sense constituent member alterations?

2009-01-28 Thread Aaron Brady
On Jan 27, 3:16 pm, Reckoner wrote: > I'm not sure this is possible, but I would like to have > a list of  objects > > A=[a,b,c,d,...,z] > > where,  in the midst of a lot of processing I might do something like, > > A[0].do_something_which_changes_the_properties() > > which alter the properties of

Re: writing large dictionaries to file using cPickle

2009-01-28 Thread Aaron Brady
On Jan 28, 10:13 am, perfr...@gmail.com wrote: > hello all, > > i have a large dictionary which contains about 10 keys, each key has a > value which is a list containing about 1 to 5 million (small) > dictionaries. for example, snip > but this takes just as long... any ideas ? is there a different

Re: dicts,instances,containers, slotted instances, et cetera.

2009-01-28 Thread Aaron Brady
On Jan 28, 2:38 pm, ocsch...@gmail.com wrote: > Hi, all. > > I have an application that that creates, manipulates, and finally > archives on disk 10^6 instances of an object that in CS/DB terms is > best described as a relation. > > It has 8 members, all of them common Python datatypes. 6 of these

Re: writing large dictionaries to file using cPickle

2009-01-28 Thread Aaron Brady
On Jan 28, 4:43 pm, perfr...@gmail.com wrote: > On Jan 28, 5:14 pm, John Machin wrote: > > > > > On Jan 29, 3:13 am, perfr...@gmail.com wrote: > > > > hello all, > > > > i have a large dictionary which contains about 10 keys, each key has a > > > value which is a list containing about 1 to 5 milli

Re: writing large dictionaries to file using cPickle

2009-01-30 Thread Aaron Brady
On Jan 30, 2:44 pm, perfr...@gmail.com wrote: > On Jan 28, 6:08 pm, Aaron Brady wrote: > > > > > On Jan 28, 4:43 pm, perfr...@gmail.com wrote: > > > > On Jan 28, 5:14 pm, John Machin wrote: > > > > > On Jan 29, 3:13 am, perfr...@gmail.com wrote: >

Re: Why doesn't eval of generator expression work with locals?

2009-01-31 Thread Aaron Brady
On Jan 31, 1:08 am, "Hendrik van Rooyen" wrote: > "Gabriel Genellina" wrote: snip > >or even like this: > > >def foo(L, M, A): > >   for x in L: > >     for y in M: > >       yield x+A > >g = foo(iter(L), iter(M), A) > > >In particular, I like the 2nd (all late binding). Seems this topic was   >

Re: English-like Python

2009-02-03 Thread Aaron Brady
On Feb 3, 2:01 pm, "J. Cliff Dyer" wrote: > On Tue, 2009-02-03 at 08:33 -0700, Joe Strout wrote: > > J. Cliff Dyer wrote: > > > > But what if your language allows functions to be used as first class > > > objects?  (Mine does :))   > > > > x = Beep > > > > Does that assign the name x to the Beep o

generator object or 'send' method?

2009-02-09 Thread Aaron Brady
Hello, I am writing a generator to return a sequence of numbers with some variation. The parameters of the variation can be changed by the caller, even after the generator is started. My question is, is it better to wrap the generator in an object, so that the parameters can be changed just by a

Re: generator object or 'send' method?

2009-02-10 Thread Aaron Brady
On Feb 10, 6:30 am, "andrew cooke" wrote: > steven probably knows this, but to flag the issue for people who are > looking at generators/coroutines for the first time: there's a little > "gotcha" about exactly how the two sides of the conversation are > synchronized.  in simple terms: send also re

Re: Avoiding argument checking in recursive calls

2009-02-11 Thread Aaron Brady
On Feb 10, 7:58 pm, Steven D'Aprano wrote: > I sometimes write recursive functions like this simple factorial: > > def fact(n): >     if n < 0: raise ValueError >     if n = 0: return 1 >     return fact(n-1)*n > > At the risk of premature optimization, I wonder if there is an idiom for > avoiding

Re: generator object or 'send' method?

2009-02-11 Thread Aaron Brady
On Feb 11, 4:41 am, greg wrote: > Aaron Brady wrote: > > It would receive the 'send' from a different point in control > > flow than its usual 'next'.  Should it repeat a value if it receives a > > 'send'? > > No. This requirement clea

pdb in 3.0 very buggy (Win XP Home)

2009-02-13 Thread Aaron Brady
Hi, got a freeze when running 'pdb' in 3.0. The program executes correctly with the command 'c', but freezes part way through when running successive 'n' commands. Platform Windows XP Home. Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win32. The 'list' command wa

Re: Pickling classes (not class instances)

2009-02-14 Thread Aaron Brady
On Feb 14, 2:19 am, Nicolas M. Thiéry wrote: >          Dear python developers, > > I got no answer to my previous post on this thread "Pickling classes > (not class instances)". > This issue is a show stopper for our project. Any suggestion for where > to ask? snip to http://groups.google.com/gro

Re: How to peek inside a decorated function

2009-02-15 Thread Aaron Brady
On Feb 15, 4:27 am, Hrvoje Niksic wrote: > Steven D'Aprano writes: > > Suppose I have a function f() which I know has been decorated, but I don't > > have access to the original undecorated function any longer: > > > def reverse(func): > >     def f(*args): > >         args = list(args) > >      

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Aaron Brady
On Feb 16, 11:21 pm, Yuanxin Xi wrote: > I'm having some problems with the memory recycling/garbage collecting > of the following testing code: > > >>> a=[str(i) for i in xrange(1000)] > > This takes 635m/552m/2044 memory (VIRT/RES/SHR) > > >>> b={} > >>> for i in xrange(1000): > > ...    

PyTypeObject subclass

2009-02-18 Thread Aaron Brady
Hi, Is it ok to subclass PyTypeObject, so that my custom 'tp_' fields can appear at the bottom of it? Is there anything like size requirements going on in its code? Or is it better to use 'tp_dict' or slots? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-22 Thread Aaron Brady
On Nov 22, 8:40 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 22, 2008, at 4:08 AM, Aaron Brady wrote: > > > Furthermore, to apply c-b-v to Python, you have to > > introduce the concept of pointers, which is ostensibly non-native for > > human programmers. >

Re: initialization in argument definitions

2008-11-22 Thread Aaron Brady
On Nov 21, 3:25 pm, Brentt <[EMAIL PROTECTED]> wrote: > Hi, I know this is a terribly simple question, but the docs seem to be > designed for people who probably find a the answer to this question > terribly obvious. But its not at all obvious to me. > > I can't figure out why when I define a funct

Re: Getting in to metaprogramming

2008-11-25 Thread Aaron Brady
On Nov 25, 4:08 am, Rafe <[EMAIL PROTECTED]> wrote: > Hi, > > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". That is, using code to write code (right?) > > Cheers, > > - Rafe Python programs

Re: Getting in to metaprogramming

2008-11-25 Thread Aaron Brady
On Nov 25, 5:20 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Nov 25, 12:12 pm, Rafe <[EMAIL PROTECTED]> wrote: > > > is it really as simple as gathering strings of code? > > Yes. Yes. > > Sort of like generating HTML or XML directly? Is there any other framework > > or > > pattern set t

Re: Python C/API simple debugging

2008-11-26 Thread Aaron Brady
On Nov 26, 5:27 am, k3xji <[EMAIL PROTECTED]> wrote: > Hi all, > > I am new to Python C API and finding it difficult to debug C > extensions. So, basically I want to see the value of an integer value > during the C API. Here is the code: > > #define LAST_MIX_VAL 0xDEADBEEF > > static PyObject * > c

Re: Getting in to metaprogramming

2008-11-26 Thread Aaron Brady
On Nov 26, 10:41 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >  "Steven D'Aprano" wrote: > > > > > Well, I don't know about "any problem". And it's not so much about > > whether metaprograms can solve problems that can't be solved by anything > > else, as whether metaprograms can solve pro

Re: Getting in to metaprogramming

2008-11-26 Thread Aaron Brady
On Nov 26, 6:29 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 27 Nov 2008 06:41:47 +0200, Hendrik van Rooyen wrote: > > I am using the term in the restricted sense of Python writing Python > > source. > > > Given that, can anybody think of an example that you could not do with a > > clas

Re: what's so difficult about namespace?

2008-11-26 Thread Aaron Brady
On Nov 26, 6:57 pm, Kaz Kylheku <[EMAIL PROTECTED]> wrote: > The theory is that the adoption of some technology is driven by > a function of the ratio: > >    perceived crisis >     >    perceived pain of adoption > > These perceptions may not be accurate. The crisis may be larger

Re: HELP!...Google SketchUp needs a Python API

2008-11-28 Thread Aaron Brady
On Nov 27, 9:45 pm, r <[EMAIL PROTECTED]> wrote: > On Nov 27, 9:31 pm, alex23 <[EMAIL PROTECTED]> wrote: > > On Nov 28, 12:49 pm, r <[EMAIL PROTECTED]> wrote: > > > Well... 3 for Ruby 1 for python. Not looking good so far. Any more > > > votes? > > > I don't see -any- of the responses in this threa

Re: Using thread in an asyncronous application

2008-11-28 Thread Aaron Brady
On Nov 27, 9:03 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Hi, > I'm the maintainer of an asynchronous FTP server implementation based > on asyncore. > Some days ago I thought it would be interesting to add a class > offering the possibility to run the asyncore loop into a thread so > tha

Re: Getting in to metaprogramming

2008-11-28 Thread Aaron Brady
On Nov 27, 9:28 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >  "Aaron Brady" <[EMAIL PROTECTED]> wrote: ... > >As you can see, the 'visit' method is mechanical for classes A and B. > >One might want to autogenerate those in some lang

Re: Getting in to metaprogramming

2008-11-28 Thread Aaron Brady
On Nov 27, 8:21 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: snip > body = 'L.append(None)\n' > make_file('dumb.py', 'Create a big list the dumb way.', >     'L = []\n', body*numitems) > make_file('smart.py', 'Create a big list the smart way.', >     '', 'L = [None]*%d\n' % num

Re: HELP!...Google SketchUp needs a Python API

2008-11-29 Thread Aaron Brady
On Nov 28, 10:42 pm, r <[EMAIL PROTECTED]> wrote: > Arron, i give you an A++ just for writing a longer post than me =D Hey wow, lucky me. Maybe someone will read it too. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using thread in an asyncronous application

2008-11-29 Thread Aaron Brady
On Nov 29, 5:27 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > On 29 Nov, 02:24, Aaron Brady <[EMAIL PROTECTED]> wrote: > > > > > On Nov 27, 9:03 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > > > > H

Re: HELP!...Google SketchUp needs a Python API

2008-11-30 Thread Aaron Brady
> > r, i am with you! i will back Python!!! we MUST spread > > Python throughout the world! sketchup is the first step, > > only the first step. > > First step? Really? AFAIK, Python is already used in: OpenOffice.Org, > Blender, GIMP, Inkscape, Scribus, etc. I've never used these tools, > but I

Re: HELP!...Google SketchUp needs a Python API

2008-12-01 Thread Aaron Brady
On Dec 1, 2:29 pm, r <[EMAIL PROTECTED]> wrote: > Rome is Burning! > Pay particular attention to the second paragraph. > > Narcissistic culture > > Main article: The Culture of Narcissism > Historian and social critic Christopher Lasch described this topic in > his book, "The Culture of Narcissism"

Re: HELP!...Google SketchUp needs a Python API

2008-12-02 Thread Aaron Brady
On Dec 2, 6:24 pm, r <[EMAIL PROTECTED]> wrote: > I added you name to my "for" list. thanks +1 entertaining thread. -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding a method at the instance level on a subclass of a builtin type

2008-12-02 Thread Aaron Brady
On Dec 2, 6:58 pm, "Zac Burns" <[EMAIL PROTECTED]> wrote: > Sorry for the long subject. > > I'm trying to create a subclass dictionary that runs extra init code > on the first __getitem__ call. However, the performance of __getitem__ > is quite important - so I'm trying in the subclassed __getitem_

  1   2   3   4   5   6   >