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: 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-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

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: 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. > > >

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-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-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-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: 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-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: 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-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-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-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-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 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 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

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: Rich comparison methods don't work in sets?

2009-06-20 Thread Aaron Brady
On Jun 20, 9:27 am, MRAB wrote: > Gustavo Narea wrote: > > Hello again, everybody. > > > Thank you very much for your responses. You guessed right, I didn't > > use the __hash__ method (and I forgot to mention that, sorry). > > > And unfortunately, I think I can't make them hashable, because the >

Re: persistent composites

2009-06-20 Thread Aaron Brady
On Jun 19, 7:00 am, "Rhodri James" wrote: > On Fri, 19 Jun 2009 14:24:34 +0100, Aaron Brady   > wrote: > > > You are not being any help, Rhodri, in your question. > > To you, perhaps not.  To me, it has at least had the effect of making > what you'r

Re: persistent composites

2009-06-19 Thread Aaron Brady
On Jun 19, 7:45 am, a...@pythoncraft.com (Aahz) wrote: > In article > , > Aaron Brady   wrote: > > > > >You are not being any help, Rhodri, in your question.   > > Maybe not, but honestly, you're getting pretty close to going back in my > killfile.  Althoug

Re: Exotic Logics

2009-06-19 Thread Aaron Brady
On Jun 17, 10:32 am, Aaron Brady wrote: > On Jun 17, 10:23 am, Mensanator wrote: snip > > > I think high and low /voltages/, though continuous and approximate, > > > might satisfy this. > > > > There are no such things as electrons, > > > I'

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Aaron Brady
On Jun 19, 12:42 pm, Chris Rebert wrote: > On Fri, Jun 19, 2009 at 12:02 PM, Gustavo Narea wrote: > > Hello, everyone. > > > I've noticed that if I have a class with so-called "rich comparison" > > methods > > (__eq__, __ne__, etc.), when its instances are included in a set, > > set.__contains__/_

Re: fastest native python database?

2009-06-19 Thread Aaron Brady
On Jun 17, 8:28 pm, per wrote: > hi all, > > i'm looking for a native python package to run a very simple data > base. i was originally using cpickle with dictionaries for my problem, > but i was making dictionaries out of very large text files (around > 1000MB in size) and pickling was simply too

Re: persistent composites

2009-06-19 Thread Aaron Brady
On Jun 17, 3:53 pm, "Rhodri James" wrote: > On Wed, 17 Jun 2009 16:06:22 +0100, Aaron Brady   > wrote: > > > > > On Jun 16, 10:09 am, Mike Kazantsev wrote: > >> On Tue, 16 Jun 2009 06:57:13 -0700 (PDT) > > >> Aaron Brady wrote: > >

Re: Regarding Python is scripting language or not

2009-06-18 Thread Aaron Brady
On Jun 18, 6:07 am, Jochen Schulz wrote: > Terry Reedy: > > > Jochen Schulz wrote: > > >> If, by "object-oriented" you mean "everything has to be put into > >> classes", then Python is not object-oriented. > > > That depends on what you mean by 'put into classes' (and 'everything'). > > :) What I

Re: Regarding Python is scripting language or not

2009-06-17 Thread Aaron Brady
On Jun 17, 7:38 am, Jean-Michel Pichavant wrote: > abhishek goswami wrote: > > Hi, > > I have very basic question about Python that do we consider pyhton as > > script language. > > I searched in google but it becomes more confusion for me. After some > > analysis I came to know that Python suppor

Re: Exotic Logics

2009-06-17 Thread Aaron Brady
On Jun 17, 10:23 am, Mensanator wrote: > On Jun 17, 11:59 am, Aaron Brady wrote: > > > > > On Jun 17, 1:44 am, Steven D'Aprano > > > wrote: > > > On Tue, 16 Jun 2009 22:46:14 -0700, William Clifford wrote: > > > > I was staring at a

Re: Exotic Logics

2009-06-17 Thread Aaron Brady
On Jun 17, 10:05 am, pdpi wrote: > On Jun 17, 5:37 pm, Lie Ryan wrote: > > > > > Steven D'Aprano wrote: > > > On Tue, 16 Jun 2009 22:46:14 -0700, William Clifford wrote: > > > >> I was staring at a logic table the other day, and I asked myself, "what > > >> if one wanted to play with exotic logic

Re: Exotic Logics

2009-06-17 Thread Aaron Brady
On Jun 17, 10:04 am, Aaron Brady wrote: snip > You (OP) may be interested in the definitions of the fuzzy operators: > > and( x, y ) := min( x, y ) > or( x, y ) := max( x, y ) > not( x ) := 1 (one)- x > nand( x, y ) := not( and( x, y ) ) = 1- min( x, y ) > > Defining

Re: Exotic Logics

2009-06-17 Thread Aaron Brady
On Jun 17, 1:28 am, Steven D'Aprano wrote: > On Tue, 16 Jun 2009 22:46:14 -0700, William Clifford wrote: > > I was staring at a logic table the other day, and I asked myself, "what > > if one wanted to play with exotic logics; how might one do it?" > > First question: what's an exotic logics? > >

Re: Exotic Logics

2009-06-17 Thread Aaron Brady
On Jun 17, 1:44 am, Steven D'Aprano wrote: > On Tue, 16 Jun 2009 22:46:14 -0700, William Clifford wrote: > > I was staring at a logic table the other day, and I asked myself, "what > > if one wanted to play with exotic logics; how might one do it?" > > This might be useful for you, and if not usef

Re: Executing a python script while it is running

2009-06-17 Thread Aaron Brady
On Jun 16, 3:48 pm, Zach Hobesh wrote: > > A lot more information would be useful.  What version of Python, and what > > operating system environment?  Exactly what would you like to happen when > > the batch file is invoked a second time? > > I'm running Python 2.6.2 on Windows.  I'm passing file

Re: Question about None

2009-06-17 Thread Aaron Brady
On Jun 17, 5:47 am, Bruno Desthuilliers wrote: > John Yeung a écrit : > > But mathematically speaking, it's intuitive that "nothing" would match > > any type. > > IOW, what's the OP is after is not the None type, but some yet > unexisting "Anything" type !-) The behaviors of the 'anything' object

Re: persistent composites

2009-06-17 Thread Aaron Brady
On Jun 16, 10:09 am, Mike Kazantsev wrote: > On Tue, 16 Jun 2009 06:57:13 -0700 (PDT) > > Aaron Brady wrote: > > Making the charitable interpretation that this was the extent of c-l- > > py's support and enthusiasm for my idea, I will now go into mourning. > > De

Re: persistent composites

2009-06-16 Thread Aaron Brady
On Jun 15, 4:56 pm, Aaron Brady wrote: > On Jun 15, 11:10 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > > > Aaron Brady writes: > > > > A real-world application of persistent data structures can be found > > > > here: > > > >http://

Re: persistent composites

2009-06-15 Thread Aaron Brady
On Jun 15, 11:10 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > Aaron Brady writes: > > > A real-world application of persistent data structures can be found here: > > >http://stevekrenzel.com/persistent-list > > > Jaime, thanks for the link.  I cont

Re: persistent composites

2009-06-15 Thread Aaron Brady
On Jun 15, 8:37 am, a...@pythoncraft.com (Aahz) wrote: > In article <79mtt7f1r480...@mid.uni-berlin.de>, > Diez B. Roggisch wrote: > > >Aaron Brady wrote: > > >> Some time ago, I recommended a pursuit of keeping 'persistent > >> composite' typ

Re: Question about None

2009-06-15 Thread Aaron Brady
On Jun 14, 9:50 pm, Steven D'Aprano wrote: > On Sun, 14 Jun 2009 19:14:10 -0400, Terry Reedy wrote: > > Steven D'Aprano wrote: > > >> So-called "vacuous truth". It's often useful to have all([]) return > >> true, but it's not *always* useful -- there are reasonable cases where > >> the opposite be

Re: persistent composites

2009-06-15 Thread Aaron Brady
On Jun 14, 10:18 am, Jaime Fernandez del Rio wrote: > On Sun, Jun 14, 2009 at 4:27 PM, Aaron Brady wrote: > > > Before I go and flesh out the entire interfaces for the provided > > types, does anyone have a use for it? > > A real-world application of persistent data stru

Re: persistent composites

2009-06-15 Thread Aaron Brady
On Jun 15, 5:45 am, "Diez B. Roggisch" wrote: > Aaron Brady wrote: > > Hi, please forgive the multi-posting on this general topic. > > > Some time ago, I recommended a pursuit of keeping 'persistent > > composite' types on disk, to be read and u

Re: Question about None

2009-06-14 Thread Aaron Brady
On Jun 14, 12:37 pm, Paul Rubin wrote: > Andre Engels writes: snip > > type "thingy". A car is a single car. Nothing is zero cars, which is > > not a car, just like two cars is not a car. > > That seems to confuse values with collections of them.  A car is not > the

Re: Question about None

2009-06-14 Thread Aaron Brady
On Jun 14, 10:02 am, Arnaud Delobelle wrote: snip > guilt, it doesn't mean they will be convicted.  There needs to be enough > evidence to convince the jury.  So it would be something like: > > if sum(guilt_weight(e) for e in evidence) > GUILT_THRESHOLD: >    the defendant is guilty >    ... > > -

Re: persistent composites

2009-06-14 Thread Aaron Brady
On Jun 14, 8:24 am, Steven D'Aprano wrote: > Aaron Brady wrote: > > Some time ago, I recommended a pursuit of keeping 'persistent > > composite' types on disk, to be read and updated at other times by > > other processes.  Databases provide this functionalit

persistent composites

2009-06-14 Thread Aaron Brady
Hi, please forgive the multi-posting on this general topic. Some time ago, I recommended a pursuit of keeping 'persistent composite' types on disk, to be read and updated at other times by other processes. Databases provide this functionality, with the exception that field types in any given tabl

Re: Different types of dicts with letter before the curly braces.

2009-06-14 Thread Aaron Brady
On Jun 14, 6:30 am, kindly wrote: > On Jun 14, 1:59 pm, Steven D'Aprano snip > I am glad the ordered dict will be in 2.7 and 3.1. I > was just imagining what would be the next step in definition of > structures. New languages like clojure have adopted the dict as top > level.  I imagine immutable/

Re: Different types of dicts with letter before the curly braces.

2009-06-14 Thread Aaron Brady
On Jun 14, 4:02 am, kindly wrote: > I am sure people have thought of this before, but I cant find where. > I think that python should adapt a way of defining different types of > mapping functions by proceeding a letter before the curly brackets. > i.e   ordered = o{},  multidict = m{}  (like past

Re: can it be shorter?

2009-06-08 Thread Aaron Brady
On Jun 8, 9:50 am, Jean-Michel Pichavant wrote: > Aaron Brady wrote: > > Shorter is always better. > > > url+= { '/': '' }.get( url[ -1 ], '/' ) > > Why bother with spaces or 3 letter-wide token, check this  :o) : > x+={'/':'

Re: can it be shorter?

2009-06-08 Thread Aaron Brady
On Jun 7, 6:13 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > Aaron Brady writes: > > url+= { '/': '' }.get( url[ -1 ], '/' ) > > > Shorter is always better. > > url = url.rstrip('/') + '/' I was joking. Sheesh. -- http://mail.python.org/mailman/listinfo/python-list

Re: can it be shorter?

2009-06-07 Thread Aaron Brady
On Jun 6, 8:07 am, "tsangpo" wrote: > I want to ensure that the url ends with a '/', now I have to do thisa like > below. > url = url + '' if url[-1] == '/' else '/' > > Is there a better way? url+= { '/': '' }.get( url[ -1 ], '/' ) Shorter is always better. -- http://mail.python.org/mailman/li

Re: fastest way to test file for string?

2009-06-05 Thread Aaron Brady
On Jun 5, 5:50 am, kj wrote: > Hi.  I need to implement, within a Python script, the same > functionality as that of Unix's > >    grep -rl some_string some_directory > > I.e. find all the files under some_directory that contain the string > "some_string". snip The 'mmap.mmap' class has a 'find'

Re: hash and __eq__

2009-05-30 Thread Aaron Brady
On May 30, 12:11 pm, Dennis Lee Bieber wrote: > On Sat, 30 May 2009 11:20:47 -0700 (PDT), Aaron Brady > declaimed the following in > gmane.comp.python.general: > > > P.S.  I always feel like my posts should start like, "A mapping object > > am writing I."  Not t

hash and __eq__

2009-05-30 Thread Aaron Brady
I am writing a mapping object, and I want to ask about the details of __hash__ and __eq__. IIUC if I understand correctly, the Python dict's keys' hash codes are looked up first in O( 1 ), then all the matching hash entries are compared on equality in O( n ). That is, the hash code just really na

Re: try except inside exec

2009-05-29 Thread Aaron Brady
On May 29, 9:55 am, Michele Petrazzo wrote: > Aaron Brady wrote: > > STR = """ > > class Globals: > >    err = 0 > > def a_funct(): > >    try: > >       1/0 > >    except ZeroDivisionError: > >       import traceback > >

Re: try except inside exec

2009-05-29 Thread Aaron Brady
On May 29, 8:21 am, Michele Petrazzo wrote: > Hi all, > I want to execute a python code inside a string and so I use the exec > statement. The strange thing is that the try/except couple don't catch > the exception and so it return to the main code. > Is there a solution to convert or make this co

Re: Adding a Par construct to Python?

2009-05-28 Thread Aaron Brady
On May 27, 11:07 pm, Steven D'Aprano wrote: > On Wed, 27 May 2009 12:58:02 +, Albert van der Horst wrote: > > >>And how is reduce() supposed to know whether or not some arbitrary > >>function is commutative? > > > Why would it or need it? A Python that understands the ``par'' keyword > > is su

Re: Adding a Par construct to Python?

2009-05-19 Thread Aaron Brady
On May 19, 11:20 pm, Paul Rubin wrote: > Steven D'Aprano writes: > > (4) the caller is responsible for making sure he never shares data while > > looping over it. > > > I don't think I've missed any possibilities. You have to pick one of > > those four. > > I wonder

Re: Adding a Par construct to Python?

2009-05-19 Thread Aaron Brady
On May 17, 7:05 am, jer...@martinfamily.freeserve.co.uk wrote: > From a user point of view I think that adding a 'par' construct to > Python for parallel loops would add a lot of power and simplicity, > e.g. > > par i in list: >     updatePartition(i) > > There would be no locking and it would be t

Re: Why there is a parameter named "self" for classmethod function?

2009-05-09 Thread Aaron Brady
On May 8, 7:52 pm, Steven D'Aprano wrote: > On Thu, 07 May 2009 04:27:15 -0700, Aaron Brady wrote: > >> Can be, but if there's reason enough to keep it with a class, there's > >> no reason not to. > > > That's a bit of hyperbole; the usu

Re: Why there is a parameter named "self" for classmethod function?

2009-05-07 Thread Aaron Brady
On May 7, 1:29 am, Steven D'Aprano wrote: > On Thu, 07 May 2009 00:39:28 -0400, Terry Reedy wrote: > > Functions that refer to neither the class nor an instance thereof can > > usually be moved outside the class altogether.  Python is not Java.  I > > believe staticmethod() was mainly added becaus

Re: object query assigned variable name?

2009-05-06 Thread Aaron Brady
On May 6, 12:56 am, John O'Hagan wrote: > On Tue, 5 May 2009, Sion Arrowsmith wrote: > > John O'Hagan   wrote: > > >I can see that it's tantalizing, though, because _somebody_ must know > > > about the assignment; after all, we just executed it! > > > Except we haven't, if we're talking about repo

Re: Self function

2009-05-06 Thread Aaron Brady
On May 6, 6:49 am, Lie Ryan wrote: > Luis Zarrabeitia wrote: > > Btw, is there any way to inject a name into a function's namespace? > > Following > > the python tradition, maybe we should try to create a more general solution! > > How about a mechanism to pass arguments that are optional to acce

Re: Self function

2009-05-06 Thread Aaron Brady
On May 6, 2:23 am, Arnaud Delobelle wrote: > On May 5, 10:20 pm, Aaron Brady wrote: > > > def auto( f ): > >     def _inner( *ar, **kw ): > >         return f( _inner, *ar, **kw ) > >     return _inner > > Quoting myself near the start of this thread: > &

Re: Self function

2009-05-05 Thread Aaron Brady
On May 5, 3:54 pm, bearophileh...@lycos.com wrote: > Aaron Brady: > > > >>> def auto( f ): > > > ...     def _inner( *ar, **kw ): > > ...             return f( g, *ar, **kw ) > > ...     g= _inner > > ...     return g > > Looks nice, I'll

Re: call function of class instance with no assigned name?

2009-05-05 Thread Aaron Brady
On May 5, 2:17 pm, George Oliver wrote: > On May 5, 11:59 am, Dave Angel wrote: > > > 1) forget about getattr() unless you have hundreds of methods in your > > map.  The real question is why you need two maps. What good is the > > "command string" doing you?   Why not just map the keyvalues direc

Re: Self function

2009-05-05 Thread Aaron Brady
On May 5, 2:50 pm, Steve Howell wrote: > On May 4, 11:08 pm, Steven D'Aprano > > wrote: > > > I propose a small piece of sugar. When a function is entered, Python > > creates an ordinary local name in the function's local namespace, and > > binds the function itself to that name. Two possibilitie

Re: Multiprocessing Pool and functions with many arguments

2009-05-01 Thread Aaron Brady
On Apr 29, 1:01 pm, "psaff...@googlemail.com" wrote: > I'm trying to get to grips with the multiprocessing module, having > only used ParallelPython before. > > based on this example: > > http://docs.python.org/library/multiprocessing.html#using-a-pool-of-w... > > what happens if I want my "f" to

Re: Why bool( object )?

2009-05-01 Thread Aaron Brady
On May 1, 4:30 am, Steven D'Aprano wrote: > On Fri, 01 May 2009 16:30:19 +1200, Lawrence D'Oliveiro wrote: > > I have never written anything so unbelievable in my life. And I hope I > > never will. > > I didn't say you did. If anyone thought I was quoting Lawrence's code, > I'd be surprised. It wa

Re: Multiprocessing.Queue - I want to end.

2009-05-01 Thread Aaron Brady
On Apr 30, 3:49 pm, Luis Zarrabeitia wrote: > Hi. I'm building a script that closely follows a producer-consumer model. In > this case, the producer is disk-bound and the consumer is cpu-bound, so I'm > using the multiprocessing module (python2.5 with the multiprocessing backport > from google.cod

Re: subprocess & shared environments

2009-05-01 Thread Aaron Brady
On May 1, 12:09 am, Robert Dailey wrote: > I'm currently calling subprocess.call() on a batch file (in Windows) > that sets a few environment variables that are needed by further > processes started via subprocess.call(). How can I persist the > environment modifications by the first call() functi

Re: suggestion on a complicated inter-process communication

2009-04-29 Thread Aaron Brady
Um, that's the limit of what I'm familiar with, I'm afraid. I'd have to experiment. On Apr 28, 10:44 am, Way wrote: > Thanks a lot for the reply. I am not familiar with multi-process in > Python. I am now using something like: snip > However, in this case, Process5's stdout cannot be passed to >

Re: Why bool( object )?

2009-04-29 Thread Aaron Brady
On Apr 28, 9:54 pm, Steven D'Aprano wrote: > On Tue, 28 Apr 2009 11:59:18 -0700, Aaron Brady wrote: > >> To steal an idiom from Laura: Python has a float-shaped Nothing 0.0, a > >> list-shaped Nothing [], a dict-shaped Nothing {}, an int-shaped Nothing > >>

Re: Why bool( object )?

2009-04-28 Thread Aaron Brady
On Apr 28, 2:39 am, Steven D'Aprano wrote: > On Mon, 27 Apr 2009 23:11:11 -0700, Aaron Brady wrote: > > What is the rationale for considering all instances true of a user- > > defined type?  Is it strictly a practical stipulation, or is there > > something conce

Re: Why bool( object )?

2009-04-28 Thread Aaron Brady
On Apr 28, 1:35 am, Lie Ryan wrote: > Aaron Brady wrote: > > What is the rationale for considering all instances true of a user- > > defined type?   > > User-defined objects (or type) can override .__len__() [usually > container types] or .__nonzero__() to make bool() re

Why bool( object )?

2009-04-27 Thread Aaron Brady
What is the rationale for considering all instances true of a user- defined type? Is it strictly a practical stipulation, or is there something conceptually true about objects? ''' object.__bool__(self) If a class defines neither __len__() nor __bool__(), all its instances are considered true. ''

Re: Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-27 Thread Aaron Brady
On Apr 28, 12:20 am, Gunter Henriksen wrote: > > If you don't want to use a 3rd party module you could > > use the multiprocessing module > > That is definitely good for when I have a tree of > processes which are all Python applications.  I use > it for that.  But I am looking for something where

Re: suggestion on a complicated inter-process communication

2009-04-27 Thread Aaron Brady
On Apr 27, 10:59 pm, Way wrote: > Hello friends, > > I have a little messy situation on IPC. Please if you can, give me > some suggestion on how to implement. Thanks a lot! > > -> denotes create > > MainProcess -> Process1 -> Process3 (from os.system) >                    | >                     -

Re: Lisp mentality vs. Python mentality

2009-04-26 Thread Aaron Brady
On Apr 26, 10:52 am, Scott David Daniels wrote: > Travis wrote: > > ... I've noticed that every one of you is wrong about programming. > > Since I can't say it effectively, here's someone who can: > >http://www.youtube.com/watch?v=XHosLhPEN3k > > > That's the answer. > > That is a wonderful link.

Re: relation class

2009-04-26 Thread Aaron Brady
On Apr 24, 1:18 am, Aaron Brady wrote: > On Apr 22, 11:34 pm, Aaron Brady wrote: > > > On Apr 22, 11:52 am, Aaron Brady wrote: > > > > On Apr 22, 12:09 am, Chris Rebert wrote: > > > > > On Tue, Apr 21, 2009 at 5:51 PM, Aaron Brady > > > >

Re: relation class

2009-04-23 Thread Aaron Brady
On Apr 22, 11:34 pm, Aaron Brady wrote: > On Apr 22, 11:52 am, Aaron Brady wrote: > > > On Apr 22, 12:09 am, Chris Rebert wrote: > > > > On Tue, Apr 21, 2009 at 5:51 PM, Aaron Brady wrote: > > > > Hi all, > > > > > I think Python s

Re: relation class

2009-04-22 Thread Aaron Brady
On Apr 22, 11:52 am, Aaron Brady wrote: > On Apr 22, 12:09 am, Chris Rebert wrote: > > > On Tue, Apr 21, 2009 at 5:51 PM, Aaron Brady wrote: > > > Hi all, > > > > I think Python should have a relation class in the standard library. > > > Fat chance. >

Re: relation class

2009-04-22 Thread Aaron Brady
On Apr 22, 12:09 am, Chris Rebert wrote: > On Tue, Apr 21, 2009 at 5:51 PM, Aaron Brady wrote: > > Hi all, > > > I think Python should have a relation class in the standard library. > > Fat chance. > > Perhaps I'm not understanding "relation&qu

Re: problem with PyMapping_SetItemString()

2009-04-21 Thread Aaron Brady
On Apr 21, 2:25 am, rahul wrote: > i have a c extension snip >           dict=PyEval_GetLocals(); snip >           PyMapping_SetItemString(dict,varname,newVar_pyvalue); snip > than first two test cases runs correctly and gives result for var1 > "value changed"  but 3rd test case not gives correct

relation class

2009-04-21 Thread Aaron Brady
Hi all, I think Python should have a relation class in the standard library. Fat chance. I want to write a recipe for it, but I don't know how. I want your advice on some of the trade-offs, what it should look like, what the pitfalls are, different strengths and weaknesses, etc. Fundamentally,

Re: generating random tuples in python

2009-04-21 Thread Aaron Brady
On Apr 20, 11:04 pm, per wrote: > On Apr 20, 11:08 pm, Steven D'Aprano > > > > wrote: > > On Mon, 20 Apr 2009 11:39:35 -0700, per wrote: > > > hi all, > > > > i am generating a list of random tuples of numbers between 0 and 1 using > > > the rand() function, as follows: > > > > for i in range(0,

Re: Is there a programming language that is combination of Python andBasic?

2009-04-19 Thread Aaron Brady
On Apr 19, 3:05 am, "Hendrik van Rooyen" wrote: >  "Aaron Brady" wrote: > > On Apr 18, 4:44 am, "Hendrik van Rooyen" wrote: > > >> to untangle some spaghetti code. He did not mention if > >> the spaghetti was actually doing it'

Re: Overriding methods per-object

2009-04-18 Thread Aaron Brady
On Apr 17, 9:41 pm, Steven D'Aprano wrote: > On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote: > > I've got an object which has a method, __nonzero__ The problem is, that > > method is attached to that object not that class > > >> a = GeneralTypeOfObject() > >> a.__nonzero__ = lambda: Fal

Re: python alternatives to C structs??

2009-04-18 Thread Aaron Brady
On Apr 18, 2:25 pm, KoolD wrote: > Hey all, > I need to convert a C code to python please help me figure out how to > do > it. > Suppose the C program's like: > > > typedef struct _str > { > int a; > char *b; > int c;}str; > > int main() > { > str mbr; > fd=ope

Re: Is there a programming language that is combination of Python andBasic?

2009-04-18 Thread Aaron Brady
On Apr 18, 4:44 am, "Hendrik van Rooyen" wrote: > "baykus" wrote: > > I guess I did not articulate myself well enough. I was just looking > > for a toy to play around. I never suggested that Python+Basic would be > > better than Python and everyone should use it. Python is Python and > > Basic is

Re: Something weird about re.finditer()

2009-04-17 Thread Aaron Brady
On Apr 17, 9:37 pm, Steven D'Aprano wrote: > On Sat, 18 Apr 2009 12:37:09 +1200, Lawrence D'Oliveiro wrote: > > In message , > > Steven D'Aprano wrote: > > >> BTW, testing for None with == is not recommended, because one day > >> somebody might pass your function some strange object that compares

Re: Overriding methods per-object

2009-04-17 Thread Aaron Brady
On Apr 17, 9:28 pm, Pavel Panchekha wrote: > > The docs don't say you can do that: > > Thanks, hadn't noticed that. > > > Should you be able to? > > I'd say so. In my case, I need a class that can encapsulate any > object, add a few methods to it, and spit something back that works > just like the

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-17 Thread Aaron Brady
On Apr 17, 3:59 pm, Dale Roberts wrote: > I've started using generators for some "real" work (love them!), and I > need to use send() to send values back into the yield inside the > generator. When I want to use the generator, though, I have to > essentially duplicate the machinery of a "for" loop

Re: large db question about no joins

2009-04-17 Thread Aaron Brady
On Apr 17, 3:16 pm, "Martin P. Hellwig" wrote: > Daniel Fetchinson wrote: > > > > > > > In an relational database setting you would have a table for artists, > > a table for cd's and a table for songs and a table for comments where > > people can comment on songs. All of this with obvious foreign

Re: Overriding methods per-object

2009-04-17 Thread Aaron Brady
On Apr 17, 8:22 pm, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ > The problem is, that method is attached to that object not that class > > > a = GeneralTypeOfObject() > > a.__nonzero__ = lambda: False > > a.__nonzero__() > > False > > But: > > > bool(a) > > True >

Re: Man Bites Python

2009-04-17 Thread Aaron Brady
On Apr 17, 7:03 pm, "AD." wrote: > On Apr 17, 11:11 pm, Aaron Brady wrote: > > > Man bites python. > > Python bites dog. > > Dog bites man. > > or just: > > man,python bites python,man > > No need for the temporary value in Python. Is Py

Re: Help improve program for parsing simple rules

2009-04-17 Thread Aaron Brady
On Apr 17, 2:01 pm, Paul McGuire wrote: > On Apr 17, 1:26 pm, Aaron Brady wrote: > > > Hi, not to offend; I don't know your background.   > > Courtesy on Usenet!!!  I'm going to go buy a lottery ticket! > > Not to worry, I'm a big boy.  People have even

Re: Lambda alternative?

2009-04-17 Thread Aaron Brady
On Apr 17, 1:43 pm, "J. Cliff Dyer" wrote: > On Thu, 2009-04-16 at 13:33 +0200, Hrvoje Niksic wrote: > > mousemeat writes: > > > > Correct me if i am wrong, but i can pickle an object that contains a > > > bound method (it's own bound method). > > > No, you can't: > > > >>> import cPickle as p >

Re: Help improve program for parsing simple rules

2009-04-17 Thread Aaron Brady
On Apr 17, 12:15 pm, Paul McGuire wrote: > On Apr 17, 10:43 am, John Machin wrote: snip > not only does this handle > "0.00 LE A LE 4.00", but it could also evaluate "0.00 LE A LE 4.00 LE > E > D".  (I see that I should actually do some short-circuiting here - > if ret is false after calling fn(v

Re: Help improve program for parsing simple rules

2009-04-17 Thread Aaron Brady
On Apr 17, 7:37 am, prueba...@latinmail.com wrote: > On Apr 16, 3:59 pm, Aaron Brady wrote: > > > > > On Apr 16, 10:57 am, prueba...@latinmail.com wrote: > > > > Another interesting task for those that are looking for some > > > interesting problem: > &g

  1   2   3   4   5   6   >