Re: How to transfer data structure or class from Python to C/C++?

2008-10-17 Thread Aaron Castironpi Brady
' to this function. After some process in Python, I want it return 'Tdemo1' back to the C/C++ application. I research boost.python and think it is not a reasonable solution because it make the C/C++ application too complex. Thanks. On Oct 16, 12:09 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED

Re: How to transfer data structure or class from Python to C/C++?

2008-10-17 Thread Aaron Castironpi Brady
' to this function. After some process in Python, I want it return 'Tdemo1' back to the C/C++ application. I research boost.python and think it is not a reasonable solution because it make the C/C++ application too complex. Thanks. On Oct 16, 12:09 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED

Re: default value in __init__

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 6:56 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 17 Oct 2008 23:04:52 +1300, Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Duncan Booth wrote: We already get people asking why code like this doesn't return 3: fns = [ lambda: x for x in

Re: Normalizing arguments

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 12:37 pm, Dan Ellis [EMAIL PROTECTED] wrote: On Oct 17, 6:17 pm, Chris Rebert [EMAIL PROTECTED] wrote: Why do you want/need this magical g() function considering that, as you yourself point out, Python already performs this normalization for you? A caching idea I'm playing

Re: Finding the instance reference of an object

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 10:56 am, Joe Strout [EMAIL PROTECTED] wrote: On Oct 16, 2008, at 11:23 PM, Dennis Lee Bieber wrote: snip    But, it seems, you are the only one arguing that the semantics are all the same... Doesn't that suggest that they aren't the same? No, it suggests to me that there's a lot

Re: Finding the instance reference of an object

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 4:03 pm, Joe Strout [EMAIL PROTECTED] wrote: On Oct 17, 2008, at 2:36 PM, Steve Holden wrote: snip And here, you're doing an assignment -- this is the only test of the   three that tests whether the parameter is passed by reference or by   value.  The result: it's by value. So,

Re: How to transfer data structure or class from Python to C/C++?

2008-10-17 Thread Aaron Castironpi Brady
On Oct 16, 9:10 am, Hongtian [EMAIL PROTECTED] wrote: Not exactly. In my C/C++ application, I have following function or flow: void func1() {     call PyFunc(struct Tdemo, struct Tdemo1); } I mean I want to invoke Python function 'PyFunc' and transfer a data structure 'Tdemo' to

Re: 'Hidden Features of Python'

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 11:00 am, coldpizza [EMAIL PROTECTED] wrote: Having read through the link below I finally managed to grasp some concepts that I only read about in the docs but never got to really understand. Maybe it will be helpful for people like myself who are not yet fully comfortable with some

Re: Help with Iteration

2008-10-17 Thread Aaron Castironpi Brady
On Oct 17, 10:44 pm, Chris McComas [EMAIL PROTECTED] wrote: i have a python script that is computing ratings of sports teams. what i'm trying to do is setup an iteration for the rating so that the python program recomputes the rating if any of the value difference is 0.5. it's common

Re: Finding the instance reference of an object

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 12:25 pm, Astley Le Jasper [EMAIL PROTECTED] wrote: Thanks for all the responses. That helps. Ta ALJ If you're sure it's unique, why not just scan through the pairs in locals()? for k, v in locals(): if v is the_object_im_looking_for: name_im_looking_for= k This method can

Re: default value in __init__

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 1:05 am, Chris Rebert [EMAIL PROTECTED] wrote: On Wed, Oct 15, 2008 at 9:43 PM, Aaron Castironpi Brady [EMAIL PROTECTED] wrote: On Oct 15, 11:33 pm, Steve Holden [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: [about how default argument behavior should, in his

Re: default value in __init__

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 12:23 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Thu, 16 Oct 2008 17:05:40 +1300, Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Steven D'Aprano wrote: On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote: On Oct 9, 10:14 am,

Re: How to transfer data structure or class from Python to C/C++?

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 9:10 am, Hongtian [EMAIL PROTECTED] wrote: Not exactly. In my C/C++ application, I have following function or flow: void func1() {     call PyFunc(struct Tdemo, struct Tdemo1); } I mean I want to invoke Python function 'PyFunc' and transfer a data structure 'Tdemo' to

Re: default value in __init__

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 7:54 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Thu, 16 Oct 2008 12:18:49 -0700, Aaron \Castironpi\ Brady wrote: [snip] If Python re-evaluated the default value i=i at runtime, the above would break. Not with a mere extra lambda. Not so. It has

Re: Finding the instance reference of an object

2008-10-16 Thread Aaron Castironpi Brady
On Oct 16, 8:30 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Thu, 16 Oct 2008 11:51:43 -0700, Aaron \Castironpi\ Brady wrote: If you're sure it's unique, why not just scan through the pairs in locals()? for k, v in locals():   if v is the_object_im_looking_for

Re: Overloading operators

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 7:34 am, Mr.SpOOn [EMAIL PROTECTED] wrote: Hi, in a project I'm overloading a lot of comparison and arithmetic operators to make them working with more complex classes that I defined. Sometimes I need a different behavior of the operator depending on the argument. For example, if

Re: File Management

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 12:47 pm, erict1689 [EMAIL PROTECTED] wrote: I am writing this program in which I open up a file and update that information but to a new file.  I already have a global variable for it but how do I go about creating an openable file in the source code?  If it helps here is what I

Re: Overloading operators

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 7:34 am, Mr.SpOOn [EMAIL PROTECTED] wrote: Hi, in a project I'm overloading a lot of comparison and arithmetic operators to make them working with more complex classes that I defined. Sometimes I need a different behavior of the operator depending on the argument. For example, if

Re: IDE Question

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 1:07 pm, Stef Mientki [EMAIL PROTECTED] wrote: Steve Phillips wrote: Hi All, I am just wondering what seems to be the most popular IDE. The reason I ask is I am currently at war with myself when it comes to IDE's. It seems like every one I find and try out has something in it

Re: How to transfer data structure or class from Python to C/C++?

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 8:08 pm, Hongtian [EMAIL PROTECTED] wrote: Hi friends, I am a newer of Python. I want to ask below question: I have a C/C++ application and I want to use Python as its extension. To do that, I have to transfer some data structure from C/C++ application to Python and get some data

Re: default value in __init__

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 11:05 pm, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED], Steven D'Aprano wrote: On Thu, 09 Oct 2008 01:39:30 -0700, kenneth (a.k.a. Paolo) wrote: On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: No, it always

Re: default value in __init__

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 11:33 pm, Steve Holden [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: [about how default argument behavior should, in his opinion, be changed] Say what you like. The language is as it is by choice. Were it, for some reason, to change we would then be receiving posts every

Re: inspect feature

2008-10-14 Thread Aaron Castironpi Brady
On Oct 14, 9:42 am, George Sakkis [EMAIL PROTECTED] wrote: On Oct 14, 3:06 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 10 Oct 2008 14:18:53 -0300, Aaron Castironpi Brady [EMAIL PROTECTED] escribió: On Oct 10, 3:36 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote

Re: inspect feature

2008-10-14 Thread Aaron Castironpi Brady
On Oct 14, 2:32 pm, George Sakkis [EMAIL PROTECTED] wrote: On Oct 14, 2:35 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 14, 9:42 am, George Sakkis [EMAIL PROTECTED] wrote: On Oct 14, 3:06 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 10 Oct 2008 14:18:53

Re: default value in __init__

2008-10-14 Thread Aaron Castironpi Brady
On Oct 14, 1:50 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: David C. Ullrich a écrit : In article [EMAIL PROTECTED],  Bruno Desthuilliers [EMAIL PROTECTED]  wrote: snip (snip) snip In particular default parameters should work the way the user expects! The fact that different

Re: inspect feature

2008-10-14 Thread Aaron Castironpi Brady
On Oct 14, 4:16 pm, George Sakkis [EMAIL PROTECTED] wrote: On Oct 14, 5:00 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: (snip Here's some more info. Ver 2.5: f( c= 0, c= 0 ) Traceback (most recent call last):   File stdin, line 1, in module TypeError: f() got multiple

Re: docpicture

2008-10-14 Thread Aaron Castironpi Brady
On Oct 14, 11:56 am, [EMAIL PROTECTED] wrote: André: Ok, the following is my first attempt at implementing this idea. I suggest you to change the program you use to encode your images, because it's 1000 bytes, while with my program the same 256 colors image needs just 278 bytes:

Mail reader spam

2008-10-12 Thread Aaron Castironpi Brady
Hello all, I'm hesitating to change news readers because I like Google's interface. In the interests of discussion, I'd make better contributions without it, if only because it's a known spam source, but its reader format beats the alternatives I've seen. I checked out the 'nntplib' module to

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

2008-10-11 Thread Aaron Castironpi Brady
On Oct 11, 2:23 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: snip I am talking about a clash between *conventions*, where there could be many argument names of the form a_b which are not intended to be two item tuples. In Python 2.x, when you see the function signature

Re: extracting null pointer address from PyCObject with ctypes

2008-10-11 Thread Aaron Castironpi Brady
On Oct 11, 9:45 am, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: My pygame install just returns an integer in get_wm_info.  Take a look: pygame.display.get_wm_info() {'window': 1180066, 'hglrc': 0} pygame.display.get_wm_info()['window'] 1180066

Re: extracting null pointer address from PyCObject with ctypes

2008-10-11 Thread Aaron Castironpi Brady
On Oct 11, 1:59 pm, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: What does print pythonapi.PyCObject_AsVoidPtr(display) give you? -- http://mail.python.org/mailman/listinfo/python-list Traceback (most recent call last):   File pygametest.py, line 125, in module

Re: default value in __init__

2008-10-11 Thread Aaron Castironpi Brady
On Oct 10, 12:30 pm, Duncan Booth [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I don't think simply re-executing the default argument expression on each call works either: that would confuse at least as many people as the current system. May I ask you why? I think I don't agree, but

Re: default value in __init__

2008-10-11 Thread Aaron Castironpi Brady
On Oct 11, 4:41 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 10 Oct 2008 06:20:35 -0700, bearophileHUGS wrote: snip I have seen professional programmers too use class attributes instead of instance ones... That's only a mistake if you don't mean to use class

Re: Most compact X if X else Y idiom

2008-10-11 Thread Aaron Castironpi Brady
On Oct 12, 12:01 am, [EMAIL PROTECTED] wrote: I find myself having to do the following:   x = (some complex expression)   y = x if x else blah and I was wondering if there is any built-in idiom that can remove the need to put (some complex expression) in the temporary variable x. e.g.

Re: extracting null pointer address from PyCObject with ctypes

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 5:24 am, Gordon Allott [EMAIL PROTECTED] wrote: Hello :) The result of various incompatibilities has left me needing to somehow extract the address that a null pointer is pointing to with the null pointer being exposed to python via PyCObject_FromVoidPtr the code that creates the

Re: inspect feature

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 3:36 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Aaron Castironpi Brady a écrit : On Oct 9, 3:48 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Aaron Castironpi Brady a écrit : Hello, The 'inspect' module has this method: inspect.getargvalues(frame

Re: extracting null pointer address from PyCObject with ctypes

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 12:04 pm, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: Did you try: tmp= PyLong_FromLong( ( long ) info.info.x11.display ); PyDict_SetItemString (dict, display, tmp); Py_DECREF (tmp); Or also try: PyCObject_AsVoidPtr( tmp ); -- http

Re: extracting null pointer address from PyCObject with ctypes

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 4:16 pm, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: I see.  If I understand, you have a PyCObject in a dictionary. Look at the 'ctypes' module and try calling PyCObject_AsVoidPtr.  Its return type should be 'c_void_p', and you can use 'result.value

Re: Porn Addiction Solutions?

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 10:33 am, Aspersieman [EMAIL PROTECTED] wrote: On Fri, 10 Oct 2008 16:11:07 +0200, [EMAIL PROTECTED] wrote: On Oct 10, 7:03 am, Um Jammer NATTY [EMAIL PROTECTED] wrote: On Oct 10, 5:37 am, [EMAIL PROTECTED] wrote: It's very simple. You need to know the world is much more than

Re: Where/how to propose an addition to a standard module?

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 2:10 pm, Joe Strout [EMAIL PROTECTED] wrote: I would like to propose a new method for the string.Template class.   What's the proper procedure for doing this?  I've joined the python- ideas list, but that seems to be only for proposed language changes,   and my idea doesn't require

Re: extracting null pointer address from PyCObject with ctypes

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 7:59 pm, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: Yes, well said.  But no, not true, not necessarily.  You can choose/ change return types with your code.  If the call is defined already and you can't change the return, just define a new one

Re: Using multiprocessing

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 3:32 pm, nhwarriors [EMAIL PROTECTED] wrote: I am attempting to use the (new in 2.6) multiprocessing package to process 2 items in a large queue of items simultaneously. I'd like to be able to print to the screen the results of each item before starting the next one. I'm having

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Aaron Castironpi Brady
On Oct 9, 5:30 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 10:37 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 9, 5:30 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight

Re: Using multiprocessing

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 10:48 pm, nhwarriors [EMAIL PROTECTED] wrote: On Oct 10, 10:52 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 10, 3:32 pm, nhwarriors [EMAIL PROTECTED] wrote: I am attempting to use the (new in 2.6) multiprocessing package to process 2 items in a large queue

Re: extracting null pointer address from PyCObject with ctypes

2008-10-10 Thread Aaron Castironpi Brady
On Oct 10, 10:54 pm, Gordon Allott [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: snip  Last, you haven't mentioned an attempt with PyCObject_AsVoidPtr yet: void* PyCObject_AsVoidPtr(PyObject* self)     Return the object void * that the PyCObject self was created with. Where

Re: inspect bug

2008-10-09 Thread Aaron Castironpi Brady
On Oct 9, 9:47 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 09 Oct 2008 00:24:20 -0300, Aaron Castironpi Brady   [EMAIL PROTECTED] escribió: Found this bug.  It's in 2.6, too bad. Posting here is not going to help much, it just will be lost. Would be   better to file a bug report

Re: inspect feature

2008-10-09 Thread Aaron Castironpi Brady
On Oct 9, 3:48 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Aaron Castironpi Brady a écrit : Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, including the locals as defined

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Aaron Castironpi Brady
On Oct 9, 1:44 pm, Jason Scheirer [EMAIL PROTECTED] wrote: On Oct 9, 9:01 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Lie Ryan [EMAIL PROTECTED] writes: in python 2.6, ast.literal_eval may be used to replace eval() for literals. What happens on literal_eval('[1]*9') ? The

Re: Traceback not going all the way to the exception?

2008-10-09 Thread Aaron Castironpi Brady
On Oct 9, 3:27 am, sert [EMAIL PROTECTED] wrote: I just got an exception and the traceback wouldn't go all the way to the statement that threw the exception. I found that out by using the debugger. Contrast the traceback: http://tinyurl.com/5xglde with the debugger output (notice the

inspect bug

2008-10-08 Thread Aaron Castironpi Brady
Hi all, Found this bug. It's in 2.6, too bad. Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. import inspect type( inspect.getargvalues( inspect.currentframe() ) ) type 'tuple' Docs say:

inspect feature

2008-10-08 Thread Aaron Castironpi Brady
Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, including the locals as defined in the frame, as shown. def f( a, b, d= None, *c, **e ): ... import inspect ... return inspect.getargvalues(

Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Aaron Castironpi Brady
On Oct 8, 7:34 pm, Warren DeLano [EMAIL PROTECTED] wrote: I would like to parse arbitrary insecure text string containing nested Python data structures in eval-compatible form:   ... # But I know for certain that the above approach is NOT secure since object attributes can still be

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

2008-10-08 Thread Aaron Castironpi Brady
On Oct 8, 7:21 pm, greg [EMAIL PROTECTED] wrote: Terry Reedy wrote: str.find is an historical anomaly that should not be copied.  It was(is?) a wrapper for C's string find function.  C routinely uses -1 to mean None for functions statically typed to return ints.  The Python version

Re: Porn Addiction Solutions?

2008-10-08 Thread Aaron Castironpi Brady
On Oct 8, 2:07 pm, [EMAIL PROTECTED] wrote: Help, I'm addicted to porn. I've been spending a lot of time downloading hardcore porn and masturbating to it. It's ruining my life. I just found out that one of these sites somehow hacked my card and rang up $5K in charges which they won't even

Re: Array of dict or lists or ....?

2008-10-07 Thread Aaron Castironpi Brady
On Oct 7, 10:16 am, Barak, Ron [EMAIL PROTECTED] wrote: Would the following be suitable data structure: ... struct = {} struct[Nebraska] = Wabash struct[Nebraska][Wabash] = Newville struct[Nebraska][Wabash][Newville][topics] = Math struct[Nebraska][Wabash][Newville][Math][Max Allowed

Re: Race condition when generating .pyc files

2008-10-07 Thread Aaron Castironpi Brady
On Oct 7, 10:21 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have a large body of Python code which runs on many different (Unix) machines concurrently.  Part of the code lives in one place, but most of it lives in directories which I find at runtime.  I only have one copy of each Python

Re: type-checking support in Python?

2008-10-07 Thread Aaron Castironpi Brady
On Oct 7, 5:24 am, Bas [EMAIL PROTECTED] wrote: On Oct 7, 8:36 am, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED], Gabriel Genellina wrote: As an example, in the oil industry here in my country there is a mix of measurement units in

Re: type-checking support in Python?

2008-10-07 Thread Aaron Castironpi Brady
On Oct 7, 3:52 pm, Erik Max Francis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: (e.g., man-day-widgets for questions like, If it takes one man three days to make two widgets, how many widgets can five men make in two weeks?). Wouldn't that be 'widgets per man-day'? --

Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Aaron Castironpi Brady
On Oct 6, 4:30 am, Fuzzyman [EMAIL PROTECTED] wrote: On Oct 6, 1:13 am, MRAB [EMAIL PROTECTED] wrote: 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

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

2008-10-06 Thread Aaron Castironpi Brady
On Oct 6, 3:37 am, Mark Dickinson [EMAIL PROTECTED] wrote: On Oct 5, 11:40 pm, Terry Reedy [EMAIL PROTECTED] wrote: Your point, that taking floor(log2(x)) is redundant, is a good catch. However, you should have added 'untested' ;-).  When value has more significant bits than the fp

Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Aaron Castironpi Brady
On Oct 6, 1:17 pm, Fuzzyman [EMAIL PROTECTED] wrote: On Oct 6, 7:01 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: It's a very object oriented solution.  Essentially you're inheriting all the classes that you want to fail, from a class that does. But not a very good solution

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

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

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,

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

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

2008-10-05 Thread Aaron Castironpi Brady
On Oct 5, 2:12 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: Duncan Booth wrote: [EMAIL PROTECTED] wrote: OFFSET = dict((%x%i, int(c)) for i,c in enumerate(5433)) def get_highest_bit_num(r): s = %x%r return len(s) * 4 - OFFSET[s[0]] OFFSET= tuple( int(x

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

2008-10-05 Thread Aaron Castironpi Brady
On Oct 5, 7:02 pm, Rich Healey [EMAIL PROTECTED] wrote: P.S.  Back home, this sort of 'nitpicking' would be judged unconstructive.  Worth pointing out, or not worth saying? P.S.S.  'Thighest' bit?  I thought the spam filters would catch that. That should be P.P.S. PS: This is also

Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-05 Thread Aaron Castironpi Brady
On Oct 5, 7:13 pm, MRAB [EMAIL PROTECTED] wrote: 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__'):

Re: When Python should not be used?

2008-10-05 Thread Aaron Castironpi Brady
On Oct 5, 7:08 pm, Andrea Francia [EMAIL PROTECTED] HERE.ohoihihoihoih.TO-HERE.gmx.it wrote: The right tool depends on the current problem. While some python users prefer to talk about when Python is the right tool I think that it is more instructive to know when it is not. Please, could you

Re: lint for Python?

2008-10-05 Thread Aaron Castironpi Brady
On Oct 5, 8:53 am, Pat [EMAIL PROTECTED] wrote: Miki wrote: Hello, In module one, I have a function: def foo( host, userid, password ):      pass In module two, I call that function: foo( userid, password) lint doesn't find that error and it won't be caught until it's called

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

2008-10-04 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 field z.name with

Re: closures and dynamic binding

2008-10-04 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 well, possibly

Re: One class per file?

2008-10-04 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 compiler

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. It doesn't

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 linguist-- not even

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 a

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 [EMAIL PROTECTED], Aaron Castironpi Brady wrote: Do you ever want

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 generators and consume the

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, James Mills [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote

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

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 call

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,

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]() print

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 natural way of

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 b =

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 iterator from

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 stdin, line 1, in module   File C:\Python25\lib\pickle.py, line 1366, in dumps     Pickler(file, protocol).dump(obj)   File

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 -- where is is

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 it works. There

Re: closures and dynamic binding

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 1:14 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 27 Sep 2008 21:43:15 -0700, Aaron \Castironpi\ Brady wrote: To me, this is a somewhat unintuitive behavior.  I want to discuss the parts of it I don't understand. f= [ None ]* 10 for n in range( 10

Re: closures and dynamic binding

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 2:52 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sat, 27 Sep 2008 21:43:15 -0700, Aaron \Castironpi\ Brady wrote: Hello all, To me, this is a somewhat unintuitive behavior.  I want to discuss the parts of it I don't understand. f= [ None ]* 10 for n

Re: Music knowledge representation

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 9:37 am, Mr.SpOOn [EMAIL PROTECTED] wrote: Hi, I'm working on an application to analyse music (melodies, chord sequences etc.) I need classes to represent different musical entities. I'm using a class Note to represent all the notes. Inside it stores the name of the natural

Re: Music knowledge representation

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 2:08 pm, Mr.SpOOn [EMAIL PROTECTED] wrote: On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady [EMAIL PROTECTED] wrote: Here is a link to someone else's design they asked about on the newsgroup a couple weeks ago. http://groups.google.com/group/comp.lang.python

Re: generate random digits with length of 5

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 2:59 pm, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. pre  random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 elements  code = 'this is a

Re: generate random digits with length of 5

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 3:44 pm, Mensanator [EMAIL PROTECTED] wrote: On Sep 28, 3:11 pm, Gary M. Josack [EMAIL PROTECTED] wrote: Chris Rebert wrote: On Sun, Sep 28, 2008 at 12:59 PM, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length

Re: generate random digits with length of 5

2008-09-28 Thread Aaron Castironpi Brady
On Sep 28, 4:08 pm, Michael Ströder [EMAIL PROTECTED] wrote: Gary M. Josack wrote: Aaron Castironpi Brady wrote: On Sep 28, 2:59 pm, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front

  1   2   3   4   5   6   7   8   9   10   >