Re: closures and dynamic binding

2008-09-29 Thread Aaron "Castironpi" Brady
On Sep 29, 9:14 am, Paul Boddie <[EMAIL PROTECTED]> wrote: > On 29 Sep, 05:56, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > As I understand it, partly from postings here years ago... > > > Lexical: The namespace scope of 'n' in inner is determined by where > > inner is located in the code -- wh

Re: Music knowledge representation

2008-09-29 Thread Aaron "Castironpi" Brady
On Sep 29, 3:56 pm, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > On Mon, 29 Sep 2008 20:29:44 +0200 > > "Mr.SpOOn" <[EMAIL PROTECTED]> wrote: > > > Couldn't the note class simply have a list of all the notes and have a > > > simple method calculate the actual pitch? > > > That's not really how i

Re: closures and dynamic binding

2008-10-01 Thread Aaron "Castironpi" Brady
On Oct 1, 5:43 am, jhermann <[EMAIL PROTECTED]> wrote: > I didn't see this mentioned in the thread yet: the double-lambda is > unnecessary (and a hack). What you should do when you need early > binding is... early binding. ;) > > Namely: > > f = [lambda n=n: n for n in range(10)] > print f[0]() > p

Re: What is not objects in Python?

2008-10-01 Thread Aaron "Castironpi" Brady
On Sep 30, 7:39 am, Steve Holden <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > On Mon, 29 Sep 2008 21:03:07 -0700, namekuseijin wrote: > > >>> Why isn't len implemented as a str.len and list.len method instead of a > >>> len(list) function? > >> Because postfix notation sucks.  The natura

Re: Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Aaron "Castironpi" Brady
On Oct 1, 9:46 am, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > Hi there. > > For most use cases I think about, the iterator protocol is more than enough. > However, on a few cases, I've needed some ugly hacks. > > Ex 1: > > a = iter([1,2,3,4,5]) # assume you got the iterator from a function and >

Re: Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Aaron "Castironpi" Brady
On Oct 1, 3:14 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Luis Zarrabeitia wrote: > > Hi there. > > > For most use cases I think about, the iterator protocol is more than enough. > > However, on a few cases, I've needed some ugly hacks. > > > Ex 1: > > > a = iter([1,2,3,4,5]) # assume you got the

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread Aaron "Castironpi" Brady
On Oct 1, 2:50 pm, est <[EMAIL PROTECTED]> wrote: > >>> import md5 > >>> a=md5.md5() > >>> import pickle > >>> pickle.dumps(a) > > Traceback (most recent call last): >   File "", line 1, in >   File "C:\Python25\lib\pickle.py", line 1366, in dumps >     Pickler(file, protocol).dump(obj) >   File "

Re: Odd Errors

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 12:52 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>, Steven > > D'Aprano wrote: > > On Wed, 01 Oct 2008 22:14:49 +1300, Lawrence D'Oliveiro wrote: > > >> In message > &g

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 2:44 am, est <[EMAIL PROTECTED]> wrote: > On Oct 2, 1:51 pm, "James Mills" <[EMAIL PROTECTED]> wrote: > > > On Thu, Oct 2, 2008 at 3:34 PM, est <[EMAIL PROTECTED]> wrote: > > > wow. It's giga-size file. I need stream reading it, md5 it. It may > > > break for a while. > > > So use generat

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 4:03 am, est <[EMAIL PROTECTED]> wrote: > On Oct 2, 4:22 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> > wrote: > > > > > On Oct 2, 2:44 am, est <[EMAIL PROTECTED]> wrote: > > > > On Oct 2, 1:51 pm, "Jame

Re: how best to use a dictionary in this function?

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 4:18 am, Terrence Brannon <[EMAIL PROTECTED]> wrote: > Ok, here is some code: > > def calc_profit(std_clicks, vip_clicks, ad_rate=200, > upline_status=None): >     payout = {} >     payout_std = std_clicks * rates['std'].per_click >     payout_vip = vip_clicks * rates['vip'].per_click > >

Re: Inheritance but only partly?

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 3:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? That implies that the 5 you do include don't rely on or

2.6 multiprocessing and pdb

2008-10-02 Thread Aaron "Castironpi" Brady
Hi, I'm trying to step through a subprocess I launch with multiprocessing. Does anyone know what hack to add? The actual call comes in forking.Popen.__init__, Windows version, forking.py, line 222: hp, ht, pid, tid = _subprocess.CreateProcess( _python_exe, cmd, None,

Re: closures and dynamic binding

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 3:44 am, greg <[EMAIL PROTECTED]> wrote: > jhermann wrote: > > I didn't see this mentioned in the thread yet: the double-lambda is > > unnecessary (and a hack). > > Well, the alternative -- abusing default argument values -- > is seen by many to be a hack as well, possibly a worse one. >

Re: What is not objects in Python?

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 5:10 am, "Tim Rowe" <[EMAIL PROTECTED]> wrote: > 2008/9/30 Lie Ryan <[EMAIL PROTECTED]>: > > > Actually str.len and len(str) is just like saying "the string's length" > > and "the length of the string". There is no difference between the two > > except for personal preference. (I am no li

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 9:03 am, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to obtain a > class B(A), with all methods of B being the methods of A preceded by a > special method of B called _before_any_method_of_A( self ), and followed by >

Re: how to get a class instance name during creation?

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 1:46 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > dmitrey a écrit : > > > hi all, > > I have a code > > z = MyClass(some_args) > > can I somehow get info in MyClass __init__ function that user uses "z" > > as name of the variable? > > > I.e. to have __init__ function that creates

Re: closures and dynamic binding

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 3:47 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > greg wrote: > > jhermann wrote: > > >> I didn't see this mentioned in the thread yet: the double-lambda is > >> unnecessary (and a hack). > > > Well, the alternative -- abusing default argument values -- > > is seen by many to be a hack as

Re: One class per file?

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 1:51 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > greg a écrit : > > > Bruno Desthuilliers wrote: > > >> OTHO, 'one class per file' is a standard idiom in Java and IIRC in C++ > >> (which both have namespaces one way or another) > > > In Java you don't get a choice, because the co

Re: 2to3 refactoring [was Re: Tuple parameter unpacking in 3.x]

2008-10-05 Thread Aaron "Castironpi" Brady
Steven D'Aprano wrote: PEP 3113 offers the following recommendation for refactoring tuple arguments: def fxn((a, (b, c))): pass will be translated into: def fxn(a_b_c): (a, (b, c)) = a_b_c pass and similar renaming for lambdas. http://www.python.org/dev/peps/pep-3113/ I'd lik

Re: lint for Python?

2008-10-05 Thread Aaron "Castironpi" Brady
Pat wrote: I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my problems. I have two modules. In module one, I have a function: def foo( host, userid,

Re: lint for Python?

2008-10-05 Thread Aaron "Castironpi" Brady
Pat wrote: I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my problems. I have two modules. In module one, I have a function: def foo( host, userid,

Re: lint for Python?

2008-10-05 Thread Aaron "Castironpi" Brady
Pat wrote: I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my problems. I have two modules. In module one, I have a function: def foo( host, userid,

Re: how to get the thighest bit position in big integers?

2008-10-05 Thread Aaron "Castironpi" Brady
Duncan Booth wrote: [EMAIL PROTECTED] wrote: My question to the group: Does anyone know of a non-hackish way to determine the required bit position in python? I know that my two ideas can be combined to get something working. But is there a *better* way, that isn't that hackish? How about usi

Re: del and sets proposal

2008-10-05 Thread Aaron "Castironpi" Brady
Bruno Desthuilliers wrote: Steven D'Aprano a écrit : On Sat, 04 Oct 2008 18:36:28 +0200, Bruno Desthuilliers wrote: Lists are the odd one out, because del alist[x] is used to remove the element at position x, rather than removing an element x. Nope. It's perfectly consistent with dicts, wher

Re: Python 2.6: Determining if a method is inherited

2008-10-05 Thread Aaron "Castironpi" Brady
Fuzzyman wrote: Hello all, I may well be being dumb (it has happened before), but I'm struggling to fix some code breakage with Python 2.6. I have some code that looks for the '__lt__' method on a class: if hasattr(clr, '__lt__'): However - in Python 2.6 object has grown a default implementat

Re: Is Scheme/LISP faster than C/C++

2010-06-14 Thread Aaron W. Hsu
ions, and closures, and you won't find C faster. Benchmarks to compare C with Scheme often don't compare the things Scheme is good at, but focus only on the static things that C was designed for. Aaron W. Hsu -- http://mail.python.org/mailman/listinfo/python-list

Iterating through a list. Upon condition I want to move on to next item in list

2017-05-10 Thread aaron . m . weisberg
Good afternoon, I have a list that I'm iterating thorough in Python. Each item in the list will have between 1-200 urls associated with it. My goal is to move on to the next. I have a variable "associationsCount" that is counting the number of urls and once it gets to 0 i want to move on to

Combining every pair of list items and creating a new list.

2017-07-17 Thread aaron . m . weisberg
Hi, I'm having difficulty thinking about how to do this as a Python beginner. But I have a list that is represented as: [1,2,3,4,5,6,7,8] and I would like the following results: [1,2] [3,4] [5,6] [7,8] Any ideas? Thanks -- https://mail.python.org/mailman/listinfo/python-list

Office COM automatisation - calling python from VBA

2009-07-23 Thread Dushku, Aaron - Amherst, MA
I'd like a copy of that code. Thanks for taking the time for all of us. Sincerely, Aaron Dushku ** Aaron Dushku GIS Specialist USDA-NRCS Amherst, Massachusetts (413) 253-4379 Email: aaron.dushku at ma.usda.gov -- http://mail.python.org/mailman/listinfo/p

<    6   7   8   9   10   11