Re: why doesn't pop/clear call __delitem__ on a dict?

2008-12-11 Thread Chris Rebert
On Wed, Dec 10, 2008 at 11:53 PM, Daniel Fetchinson <[EMAIL PROTECTED]> wrote: > I just found out that if I want to have a custom dict it's not enough > to overload __getitem__, __setitem__ and __delitem__ because, for > example, pop and clear don't call __delitem__. I.e. an instance of the > follo

Re: Rich Comparisons Gotcha

2008-12-11 Thread Steven D'Aprano
On Wed, 10 Dec 2008 17:58:49 -0500, Luis Zarrabeitia wrote: > On Sunday 07 December 2008 09:21:18 pm Robert Kern wrote: >> The deficiency is in the feature of rich comparisons, not numpy's >> implementation of it. __eq__() is allowed to return non-booleans; >> however, there are some parts of Pyth

Re: if expression source format

2008-12-11 Thread Duncan Booth
"Lambert, David W (S&T)" <[EMAIL PROTECTED]> wrote: > > The "if" expression leads to long statements. Please offer suggestions > to beautify this function. For this example use maximum line length > marked by the 's. > > Thank you. > > > ##

Re: if expression source format

2008-12-11 Thread Steven D'Aprano
On Thu, 11 Dec 2008 02:07:54 -0500, Lambert, David W (S&T) wrote: > The "if" expression leads to long statements. Please offer suggestions > to beautify this function. For this example use maximum line length > marked by the 's. > > Thank you. > > > ###

Why optimization mode is slower than normal mode?

2008-12-11 Thread Leo Jay
Hi all, I'm using python 2.6 in a windows xp box, when I try pystone, I get: C:\Python26\Lib\test>python pystone.py 50 Pystone(1.1) time for 50 passes = 5.93632 This machine benchmarks at 84227.3 pystones/second C:\Python26\Lib\test>python -OO pystone.py 50 Pystone(1.1) time for 5

Re: why doesn't pop/clear call __delitem__ on a dict?

2008-12-11 Thread Daniel Fetchinson
>> I just found out that if I want to have a custom dict it's not enough >> to overload __getitem__, __setitem__ and __delitem__ because, for >> example, pop and clear don't call __delitem__. I.e. an instance of the >> following will not print 'deleted' upon instance.pop( 'key' ): >> >> class mydic

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Gerard flanagan
Xah Lee wrote: On Dec 10, 2:47 pm, John W Kennedy <[EMAIL PROTECTED]> wrote: Xah Lee wrote: In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java, you'll have 50 or hundreds lines. [...] Thanks to various replies. I've now gather code solutions in ruby, python, C, Java, here:

Re: SequenceMatcher bug ?

2008-12-11 Thread Tim Roberts
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >En Wed, 10 Dec 2008 15:14:20 -0200, eliben <[EMAIL PROTECTED]> escribió: > >> What ? This can't be. >> >> 1. Go to http://try-python.mired.org/ >> 2. Type >> import difflib >> 3. Type >> difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio

Re: Memory leak when using a C++ module for Python

2008-12-11 Thread Ulrich Eckhardt
Jaume Bonet wrote: > When I test the code from C++ each time I delete a vector the consumed > memory decreases, but it does not happen when the module is called > from python. What is a "vector" for you? Do you mean std::vector? A vector allocated using malloc()? A vector allocated using new? Just

if expression source format

2008-12-11 Thread
The "if" expression leads to long statements. Please offer suggestions to beautify this function. For this example use maximum line length marked by the 's. Thank you. ## def compute_wind_chill_temperture(T:'Temperature, dF',s:'W

Re: trace module and doctest

2008-12-11 Thread R. Bernstein
On Nov 22 2007, 4:31 pm, [EMAIL PROTECTED] (John J. Lee) wrote: > [EMAIL PROTECTED] writes: > > I am trying to use thetracemodulewith the --count flag to test for > > statement coverage in my doctests. Thetracecoverage listing is very > > weird, marking many statements as unexecuted which were cle

Re: Equivalent of 'wget' for python?

2008-12-11 Thread hrishy
Hi Please excuse my OOP but is my understanding correct urllib.urlretrieve(url_of_zip_file,destination_on_local_filesystem) is urllib --->Static Class on which the method urlretrieve method is invoked ? In that case what does the python 3.0 version mean import urllib.request urllib.request.ur

Re: Deeper tracebacks?

2008-12-11 Thread R. Bernstein
brooklineTom <[EMAIL PROTECTED]> writes: > I want my exception handler to report the method that originally > raised an exception, at the deepest level in the call-tree. Let give > an example. > > import sys, traceback > class SomeClass: > def error(self): > """Raises an AttributeError

Py_GetPath() C API in python 3

2008-12-11 Thread stalex
Hi all, I want to build a new, requires total control, python interpreter. So I implement my own version of Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix() and Py_GetProgramFullPath(). When compiling, I always get error messages, for each API function, look like followings: /opt/python-3.0/lib/p

Re: Equivalent of 'wget' for python?

2008-12-11 Thread alex23
On Dec 11, 7:36 pm, hrishy <[EMAIL PROTECTED]> wrote: > urllib -->static class > request -->method > urlretrieve--> what is this then ? The easiest way is to check for yourself, using type(). So 'type(urllib)' should give you '' (assuming the same types as 2.5, I don't have an install of 3.0 hand

Re: sys.settrace 'call' event behavior

2008-12-11 Thread R. Bernstein
On Jun 21, 8:47 am, Michal Kwiatkowski <[EMAIL PROTECTED]> wrote: > I'm building a tool to trace all function calls usingsys.settrace > function from the standard library. One of the awkward behaviors of > this facility is that the class definitions are reported as 'call' > events.[1] Since I don't

Custom debugger trace hooks

2008-12-11 Thread R. Bernstein
A colleague recently asked this: Is there a cleaner way to dump a trace/track of running a python script. With Pydb I made work-around with import pydb pydb.debugger(dbg_cmds=['bt', 'l', 's']*300 + ['c']) So now I have a dump of 300 steps with backtraces, so I can easily compar

Re: Equivalent of 'wget' for python?

2008-12-11 Thread [EMAIL PROTECTED]
On Dec 11, 2:36 pm, hrishy <[EMAIL PROTECTED]> wrote: > Hi > > Please excuse my OOP but is my understanding correct > > urllib.urlretrieve(url_of_zip_file,destination_on_local_filesystem) > > is urllib --->Static Class on which the method urlretrieve method is invoked ? No urllib is a "method". Us

Re: Equivalent of 'wget' for python?

2008-12-11 Thread [EMAIL PROTECTED]
On Dec 11, 3:36 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Dec 11, 2:36 pm, hrishy <[EMAIL PROTECTED]> wrote: > > > Hi > > > Please excuse my OOP but is my understanding correct > > > urllib.urlretrieve(url_of_zip_file,destination_on_local_filesystem) > > > is urllib --->Static Class o

Re: Equivalent of 'wget' for python?

2008-12-11 Thread hrishy
Hi Saju Thanks for helping the oop challenged regards Hrishy --- On Thu, 11/12/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > From: [EMAIL PROTECTED] <[EMAIL PROTECTED]> > Subject: Re: Equivalent of 'wget' for python? > To: python-list@python.org > Date: Thursday, 11 December, 2008, 10:41

Re: Equivalent of 'wget' for python?

2008-12-11 Thread Leo Jay
On Tue, Dec 9, 2008 at 12:22 AM, Robert Dailey <[EMAIL PROTECTED]> wrote: > Hi, > > I'm looking for a portable way to download ZIP files on the internet > through Python. I don't want to do os.system() to invoke 'wget', since > this isn't portable on Windows. I'm hoping the core python library has

Re: Mathematica 7 compares to other languages

2008-12-11 Thread William James
John W Kennedy wrote: > Xah Lee wrote: > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > Java, you'll have 50 or hundreds lines. > > Java: > > static float[] normal(final float[] x) { >float sum = 0.0f; >for (int i = 0; i < x.length; ++i) sum += x[i] * x[i]; >f

Re: Mathematica 7 compares to other languages

2008-12-11 Thread William James
William James wrote: > John W Kennedy wrote: > > > Xah Lee wrote: > > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > > Java, you'll have 50 or hundreds lines. > > > > > Java: > > > > static float[] normal(final float[] x) { > >float sum = 0.0f; > >for (int i = 0;

Re: broken ncurses on python 3.0

2008-12-11 Thread Christian Heimes
icarus wrote: OS: win32, python 3.0 I've been trying to run some curses demos and I get this: C:\Python\Lib\curses>python textpad.py Traceback (most recent call last): File "textpad.py", line 3, in import curses File "C:\Python\lib\curses\__init__.py", line 15, in from _curses imp

Re: Python is slow

2008-12-11 Thread Luis M . González
On Dec 10, 3:42 pm, cm_gui <[EMAIL PROTECTED]> wrote: > http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-... > > I fully agree with Krzysztof Kowalczyk . > Can't they build a faster VM for Python since they love the language > so much? > > Python is SLOW.    And I am not compari

Converting c header file to a python file

2008-12-11 Thread tarun
Hello, I am looking for a tool/utility by which can convert c header file to a python file. A typical header file that I want convert looks like: #ifndef __VAR1 #define __VAR1 #define VAR2 "Rev 2" #define VAR3 2L typedef struct { } #if defined(__cplusplus) || defined(__cplusplus__

ctypes and misaligned doubles

2008-12-11 Thread Jan Roelens
Dear python experts, How can I change the alignment of types in the ctypes package? I have a library that was built with gcc using the -malign-double option. I also have python code that can create ctypes wrapper code from the include files for that library. The problem is that structs that contai

Python, threading

2008-12-11 Thread SMALLp
Hy. I have a problem! I'm making multi thread application (client, server) using wxPython for GUI, and threading.Thread for threding. Clients connect and when they are connected (evry thread handles one connection) threads change main window. I neded tip how to make communication between thre

Re: ctypes and misaligned doubles

2008-12-11 Thread Thomas Heller
Jan Roelens schrieb: > Dear python experts, > > How can I change the alignment of types in the ctypes package? I have > a library that was built with gcc using the -malign-double option. I > also have python code that can create ctypes wrapper code from the > include files for that library. The pr

Re: var or inout parm?

2008-12-11 Thread Bruno Desthuilliers
Joe Strout a écrit : On Dec 10, 2008, at 4:29 PM, J. Clifford Dyer wrote: [EMAIL PROTECTED] wrote: How can I make a "var" parm, where the called function can modify the value of the parameter in the caller? See Also: the earlier heated debate thread over what evaluation strategy Python uses

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-11 Thread Nick Craig-Wood
David Cournapeau <[EMAIL PROTECTED]> wrote: > On Wed, Dec 10, 2008 at 12:04 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > > On Tue, Dec 9, 2008 at 6:49 PM, <[EMAIL PROTECTED]> wrote: > >> On Ubuntu, I accidentally manually installed setuptools > >> http://pypi.python.org/pypi/setuptools/0.6c9 (by

Re: looking up function's doc in emacs

2008-12-11 Thread Andreas Röhler
Xah Lee wrote: > in programing elisp in emacs, i can press “Ctrl+h f” to lookup the doc > for the function under cursor. > > is there such facility when coding in perl, python, php? > > (i'm interested in particular python. In perl, i can work around with > “perldoc -f functionName”, and in php

Re: Python, threading

2008-12-11 Thread Saju Pillai
On Dec 11, 6:06 pm, SMALLp <[EMAIL PROTECTED]> wrote: > Hy. I have a problem! I'm making multi thread application (client, > server) using wxPython for GUI, and threading.Thread for threding. > > Clients connect and when they are connected (evry thread handles one > connection) threads change main

Re: How to convert uint64 in C into Python 32bit Object [ I am using Python2.2 ]

2008-12-11 Thread Explore_Imagination
On Dec 11, 4:45 am, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 11, 9:49 am, Explore_Imagination <[EMAIL PROTECTED]> > wrote: > > > Hi all > > > I am new to C and python ... I want to convert C data type uint64 > > variable into the Python 32bit Object. I am currently using Python 2.2 > > [ It

Re: How to convert uint64 in C into Python 32bit Object [ I am using Python2.2 ]

2008-12-11 Thread Saju Pillai
On Dec 11, 6:45 pm, Explore_Imagination <[EMAIL PROTECTED]> wrote: > On Dec 11, 4:45 am, John Machin <[EMAIL PROTECTED]> wrote: > > > > > On Dec 11, 9:49 am, Explore_Imagination <[EMAIL PROTECTED]> > > wrote: > > > > Hi all > > > > I am new to C and python ... I want to convert C data type uint64 >

just got the g1

2008-12-11 Thread garywood
Hi Just got the G1, is their any way to get python running on the andriod platform ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, threading

2008-12-11 Thread Diez B. Roggisch
SMALLp wrote: > Hy. I have a problem! I'm making multi thread application (client, > server) using wxPython for GUI, and threading.Thread for threding. > > Clients connect and when they are connected (evry thread handles one > connection) threads change main window. > > I neded tip how to make c

How can I understan the "for" here?

2008-12-11 Thread Kermit Mei
Hello all, look at the following sentence: >>>params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"} >>> ["%s=%s" % (k, v) for k, v in params.items()] ['pwd=secret', 'database=master', 'uid=sa', 'server=mpilgrim'] I can't understand the second sentence because of the "

Re: How can I understan the "for" here?

2008-12-11 Thread skip
Kermit> I can't understand the second sentence because of the "for Kermit> ... in". Google for "python list comprehensions". -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I understan the "for" here?

2008-12-11 Thread James Mills
On Fri, Dec 12, 2008 at 12:44 AM, Kermit Mei <[EMAIL PROTECTED]> wrote: > I can't understand the second sentence because of the "for ... in". > I consider that the syntactics of "for" should be: > > for k,v in params.items(): > .. > > But there's no a colon here, why it can work? It's called

Re: Mathematica 7 compares to other languages

2008-12-11 Thread the . brown . dragon . blog
On Dec 11, 4:53 pm, "William James" <[EMAIL PROTECTED]> wrote: > William James wrote: > > John W Kennedy wrote: > > > > Xah Lee wrote: > > > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > > > Java, you'll have 50 or hundreds lines. > > > > Java: > > > > static float[] normal(

Re: How to pass out the result from iterated function

2008-12-11 Thread JD
On Dec 10, 2:25 pm, eric <[EMAIL PROTECTED]> wrote: > On Dec 10, 9:16 pm, JD <[EMAIL PROTECTED]> wrote: > > > > > I got a iterated function like this: > > > def iterSomething(list): > > has_something = False > > for cell in list: > > if something in cell: > > has_somethi

Re: How can I understan the "for" here?

2008-12-11 Thread D'Arcy J.M. Cain
On Thu, 11 Dec 2008 22:44:20 +0800 Kermit Mei <[EMAIL PROTECTED]> wrote: > >>> ["%s=%s" % (k, v) for k, v in params.items()] > ['pwd=secret', 'database=master', 'uid=sa', 'server=mpilgrim'] > > I can't understand the second sentence because of the "for ... in". > I consider that the syntactics of

Re: Mathematica 7 compares to other languages

2008-12-11 Thread the . brown . dragon . blog
On Dec 11, 7:50 pm, [EMAIL PROTECTED] wrote: > On Dec 11, 4:53 pm, "William James" <[EMAIL PROTECTED]> wrote: > > > > > William James wrote: > > > John W Kennedy wrote: > > > > > Xah Lee wrote: > > > > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > > > > Java, you'll have 50

Re: Call by reference in SWIG?

2008-12-11 Thread Joe Strout
On Dec 10, 2008, at 10:19 PM, Nok wrote: I can't get call-by-reference functions to work in SWIG... Python doesn't have any call-by-reference support at all [1], so I'm not surprised that a straight translation of the call-by-reference C function doesn't work. Unfortunately I don't know

Re: Python is slow

2008-12-11 Thread jay....@gmail.com
On Dec 11, 7:06 am, Luis M. González <[EMAIL PROTECTED]> wrote: > On Dec 10, 3:42 pm, cm_gui <[EMAIL PROTECTED]> wrote: > > > > >http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-... > > > I fully agree with Krzysztof Kowalczyk . > > Can't they build a faster VM for Python since

Re: Mathematica 7 compares to other languages

2008-12-11 Thread William James
William James wrote: > John W Kennedy wrote: > > > Xah Lee wrote: > > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or > > > Java, you'll have 50 or hundreds lines. > > > > > Java: > > > > static float[] normal(final float[] x) { > >float sum = 0.0f; > >for (int i = 0;

Re: Rich Comparisons Gotcha

2008-12-11 Thread M.-A. Lemburg
On 2008-12-10 23:21, Luis Zarrabeitia wrote: > On Wednesday 10 December 2008 02:44:45 pm you wrote: >>> Even in statically typed languages, when you override the equality >>> operator/function you can choose not to return a valid answer (raise an >>> exception). And it would break all the cases men

Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
Sorry if I'm a bit thick here... can any of the esteemed participant in this noble newsgroup confirm that is not possible to prevent a python module's code from executing the methods of another module? I.e. if I have a class with two methods, doSomethingSafe() and doSomethingDangerous(), is there

pexpect and inconsistent exit codes

2008-12-11 Thread Heikki Toivonen
I don't seem to be able to figure out how to get the exit values of commands executed with pexpect reliably. Here's first with regular shell: [EMAIL PROTECTED]:~$ true; echo $? 0 Let's try with pexpect. Below is the program: ---CLIP--- import sys, pexpect cmd = "true" print 'cmd=', cmd child

Re: Preventing execution of a method

2008-12-11 Thread alex23
On Dec 12, 2:07 am, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: > I.e. if I have a class with two methods, doSomethingSafe() and > doSomethingDangerous(), is there a way to prevent another module from > executing doSomethingDangerous() but allow the execution of > doSomethingSafe()? > > My under

HGE and Python (again)

2008-12-11 Thread Cro
Good day. I've been trying to port HGE (http://hge.relishgames.com) to Python for more than 4 months now... HGE is a hardware accelerated 2D game engine. It comes with the source and examples. In the folder "include", you can find "hge.h", the file that i am talking about in all the post. # I tri

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-11-29T04:02:11Z, Mel <[EMAIL PROTECTED]> writes: > You could try > > for item in fname: > item = item.strip() This is one case where I really miss Perl's "chomp" function. It removes a trailing newline and nothing else, so you don't have to worry about losing leading or trailing spac

Re: Why optimization mode is slower than normal mode?

2008-12-11 Thread Cro
Not-optimised: Pystone(1.1) time for 100 passes = 12.8366 This machine benchmarks at 77902 pystones/second Optimised: Pystone(1.1) time for 100 passes = 13.0574 This machine benchmarks at 76584.8 pystones/second It is probably the way it should be. :) -- http://mail.python.org/mailman/li

Re: Preventing execution of a method

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 08:16, alex23 wrote: On Dec 12, 2:07?am, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: I.e. if I have a class with two methods, doSomethingSafe() and doSomethingDangerous(), is there a way to prevent another module from executing doSomethingDangerous() but allow the execu

Re: Preventing execution of a method

2008-12-11 Thread MRAB
alex23 wrote: On Dec 12, 2:07 am, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: I.e. if I have a class with two methods, doSomethingSafe() and doSomethingDangerous(), is there a way to prevent another module from executing doSomethingDangerous() but allow the execution of doSomethingSafe()? My

Re: Do more imported objects affect performance

2008-12-11 Thread Kirk Strauser
At 2008-12-01T11:30:44Z, Nick Craig-Wood <[EMAIL PROTECTED]> writes: > Importing the module is actualy slower... If you import the name into > your namespace then there is only one lookup to do. If you import the > module there are two. Note that if you're importing the entire module but want t

Re: pydb 1.24

2008-12-11 Thread J Kenneth King
[EMAIL PROTECTED] (R. Bernstein) writes: > This release is to clear out some old issues. It contains some > bugfixes, document corrections, and enhancements. Tests were > revised for Python 2.6 and Python without readline installed. A bug > involving invoking from ipython was fixed. The "frame" co

Re: Python, threading

2008-12-11 Thread Grant Edwards
On 2008-12-11, SMALLp <[EMAIL PROTECTED]> wrote: > Hy. I have a problem! I'm making multi thread application (client, > server) using wxPython for GUI, and threading.Thread for threding. > > Clients connect and when they are connected (evry thread handles one > connection) threads change main win

Re: if expression source format

2008-12-11 Thread lambertdw
Consider following snippets: # must examine code carefully to see that result has a value if condition: result = expression1 else: result = another_expression return result # result has a value but difficult to understand how it comes about result = expre

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Andreas Waldenburger
On Thu, 11 Dec 2008 05:40:45 + Paul Rudin <[EMAIL PROTECTED]> wrote: > "Dotan Cohen" <[EMAIL PROTECTED]> writes: > > > 2008/12/10 <[EMAIL PROTECTED]>: > >> Ruby: > >> > >> def norm a > >> s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y}) > >> a.map{|x| x/s} > >> end > > > > If someone doesn't

dictionary idiom needed

2008-12-11 Thread Brandon
Hi all, I have a series of lists in format ['word', 'tagA', 'tagB']. I have converted this to a few dicts, such as one in which keys are tuples of ('word', 'tagB'), and the values are the number of times that key was found. I need an dictionary idiom whereby I can find all instances of a given '

Re: newbie question: if var1 == var2:

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 10:24, Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel <[EMAIL PROTECTED]> writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's "chomp" function. It removes a trailing newline and nothing else, so you don't hav

Re: Preventing execution of a method

2008-12-11 Thread alex23
On Dec 12, 2:35 am, [EMAIL PROTECTED] wrote: > There is, however, also the possibility of prefixing the method name > with '__'.  The invokes 'name mangling', which makes it more difficult > (though not impossible, the idea is to avoid accidents) for the method > to be called from outside the class

Re: internal circular class references

2008-12-11 Thread Ethan Furman
Carl Banks wrote: On Dec 10, 5:26 pm, Ethan Furman <[EMAIL PROTECTED]> wrote: Greetings List! I'm writing a wrapper to the datetime.date module to support having no date. Its intended use is to hold a date value from a dbf file, which can be empty. The class is functional at this point, but

Re: Preventing execution of a method

2008-12-11 Thread alex23
On Dec 12, 3:22 am, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 12, 2:35 am, [EMAIL PROTECTED] wrote: > > > There is, however, also the possibility of prefixing the method name > > with '__'.  The invokes 'name mangling', which makes it more difficult > > (though not impossible, the idea is to avoid

Re: Deeper tracebacks?

2008-12-11 Thread brooklineTom
BINGO! Give that man a CIGAR! The specifics don't seem to be quite right (there is no sys.last_traceback), but R.Bernstein put me directly on the correct track. I misunderstood the traceback module documentation. OK, I just plain didn't read it correctly, it's right there ("extract_stack(): Extrac

Re: cx_Oracle issues

2008-12-11 Thread ron.re...@gmail.com
On Dec 10, 9:48 am, huw_at1 <[EMAIL PROTECTED]> wrote: > Hey all. When using cx_Oracle to run a procedure like: > > cursor.execute("select (obj.function(value)) from table where > id=blah") > > I am getting the following error: > > ORA-06502: PL/SQL: numeric or value error: character string buffer

Re: Memory leak when using a C++ module for Python

2008-12-11 Thread Jaume Bonet
Sure, sorry... This is the function that is visible from python and the one that the python code calls: static PyObject * IMFind (PyObject *self, PyObject *args, PyObject *kwargs) { //Array for the detection of the parameters coming from Python static char *kwlist[] = {"shareInt"

Re: Preventing execution of a method

2008-12-11 Thread r
> And of course -now- I realise that the OP was asking for protecting > methods. Please disregard my last post :) Alex23, Are you telling me that you do not know how to YANK your own post? I find that hard to believe. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: get todays files

2008-12-11 Thread Andrew Doades
Tim Chase wrote: This looks very good and I have tested successfully, but is there a way I can set the today to automatically become todays date in that format? Yes...see the python datetime module[1]...particularly the strftime() call on date/datetime objects. -tkc [1] http://docs.python.o

Re: How can I understan the "for" here?

2008-12-11 Thread Kermit Mei
D'Arcy J.M. Cain wrote: On Thu, 11 Dec 2008 22:44:20 +0800 Kermit Mei <[EMAIL PROTECTED]> wrote: >>> ["%s=%s" % (k, v) for k, v in params.items()] ['pwd=secret', 'database=master', 'uid=sa', 'server=mpilgrim'] I can't understand the second sentence because of the "for ... in". I consider th

Python to open command script file

2008-12-11 Thread dave rose
Hello all I would like to know how to do the following. I'd like to have a generic python program that the user will open a command-script file to do actions. So, my python program will get a list of servers, enumerate them within a checklistbox in wxpython. Then I want to open a command-file

How to know when it's possible to bind a socket on an unprivileged port?

2008-12-11 Thread Giampaolo Rodola'
Hi, For a purpose of testing I need a function which could tell me whether it is possible to bind sockets on privileged ports or not. I wrote down this simple function. It seems reasonably working to me but I'd like to hear your opinion first. Thanks in advance. import socket, errno def bind_on

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Stef Mientki
Andreas Waldenburger wrote: On Thu, 11 Dec 2008 05:40:45 + Paul Rudin <[EMAIL PROTECTED]> wrote: "Dotan Cohen" <[EMAIL PROTECTED]> writes: 2008/12/10 <[EMAIL PROTECTED]>: Ruby: def norm a s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y}) a.map{|x| x/s} end If som

Re: Is 3.0 worth breaking backward compatibility?

2008-12-11 Thread walterbyrd
On Dec 7, 12:35 pm, Andreas Waldenburger <[EMAIL PROTECTED]> wrote: > Plze. Python 3 is shipping now, and so is 2.x, where x > 5. Python > 2 is going to be around for quite some time. What is everybody's > problem? A possible, potential, problem, could arise if you were using python 2.x, but

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Xah Lee
On Dec 11, 12:32 am, Gerard flanagan <[EMAIL PROTECTED]> wrote: > Xah Lee wrote: > > On Dec 10, 2:47 pm, John W Kennedy <[EMAIL PROTECTED]> wrote: > >> Xah Lee wrote: > >>> In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java, > >>> you'll have 50 or hundreds lines. > [...] > > > Th

Re: Deeper tracebacks?

2008-12-11 Thread Gabriel Genellina
En Thu, 11 Dec 2008 07:49:42 -0200, R. Bernstein escribió: brooklineTom writes: I want my exception handler to report the method that originally raised an exception, at the deepest level in the call-tree. Let give an example. extract_stack() without any arguments is getting this from the

Re: Is 3.0 worth breaking backward compatibility?

2008-12-11 Thread Chris Mellon
On Thu, Dec 11, 2008 at 12:21 PM, walterbyrd wrote: > On Dec 7, 12:35 pm, Andreas Waldenburger wrote: > >> Plze. Python 3 is shipping now, and so is 2.x, where x > 5. Python >> 2 is going to be around for quite some time. What is everybody's >> problem? > > A possible, potential, problem, cou

Re: dictionary idiom needed

2008-12-11 Thread bearophileHUGS
Brandon: > I need an dictionary idiom whereby I can find all instances of > a given 'word' with any 'tagB', and then subdivide into all instances > of a given 'tagB'.  In both cases I would want the value as a count of > all instances found. If I have understood you well enough, I think you can do

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Xah Lee
Xah Lee wrote: • A Example of Mathematica's Expressiveness http://xahlee.org/UnixResource_dir/writ/Mathematica_expressiveness.html On Dec 11, 3:53 am, "William James" wrote: > function normal( ary ) > { var div = Math.sqrt( > ary.map(function(x) x*x).reduce(function(a,b) a+b) ) > return

Re: dictionary idiom needed

2008-12-11 Thread bearophileHUGS
bearophile: > you can do with a dict > that has the tuple ('word', 'tagB') as key, and as value has a > collections.defaultdict(int) that maps 'tagB' to its count. Where's 'tagA'? Probably I haven't understood your problem well enough. I need a better example of your data and what you need... Sor

Re: Is 3.0 worth breaking backward compatibility?

2008-12-11 Thread Andreas Waldenburger
On Thu, 11 Dec 2008 10:21:55 -0800 (PST) walterbyrd wrote: > On Dec 7, 12:35 pm, Andreas Waldenburger wrote: > > > Plze. Python 3 is shipping now, and so is 2.x, where x > 5. > > Python 2 is going to be around for quite some time. What is > > everybody's problem? > > A possible, potential,

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Xah Lee
On Dec 10, 2:47 pm, John W Kennedy wrote: > Xah Lee wrote: > > In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java, > > you'll have 50 or hundreds lines. > > C: > > #include > #include > > void normal(int dim, float* x, float* a) { >     float sum = 0.0f; >     int i; >     floa

Re: Python to open command script file

2008-12-11 Thread Mike Driscoll
On Dec 11, 12:04 pm, dave rose wrote: > Hello all >  I would like to know how to do the following.  I'd like to have a generic > python program that the user will open a command-script file to do actions. > > So, my python program will get a list of servers, enumerate them within a > checklistbox

Re: How to know when it's possible to bind a socket on an unprivileged port?

2008-12-11 Thread Giampaolo Rodola'
On 11 Dic, 19:09, "Giampaolo Rodola'" wrote: > Hi, > For a purpose of testing I need a function which could tell me whether > it is possible to bind sockets on privileged ports or not. > I wrote down this simple function. It seems reasonably working to me > but I'd like to hear your opinion first.

Re: get todays files

2008-12-11 Thread Tim Chase
I know this will sound like I am being very cheeky, but is there a way you can make this for where the ftp server is actually windows server? For Windows Server, I don't have a Windows FTP server to test with -- I've got the company Linux server, and the previous testing site I used (I think I

Re: internal circular class references

2008-12-11 Thread Carl Banks
On Dec 11, 11:33 am, Ethan Furman wrote: > Good question.  My goal with NullDate is to have a date object that I > can treat the same regardless of whether or not it actually holds a > date.  NullDates with no value should sort before any NullDates with a > value, should be comparable to dates as

Re: get todays files

2008-12-11 Thread Andrew Doades
Tim Chase wrote: I know this will sound like I am being very cheeky, but is there a way you can make this for where the ftp server is actually windows server? For Windows Server, I don't have a Windows FTP server to test with -- I've got the company Linux server, and the previous testing si

Re: Find Files in a Folder Between 2 Dates

2008-12-11 Thread Gregory Plantaine
On Dec 5, 3:14 pm, John Machin wrote: > On Dec 6, 9:41 am, GregoryPlantaine wrote: > > > That worked perfectly! > > > Thanks Tim! > > > Since we can print the files, does that mean the list of files is in a > > tuple, or something?  Would there be a way to further split up the > > file names? > >

Re: Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
Thank you all for the confirmation and the suggestions (including the tangential ones: I didn't know one could remove your his own posts!). As much as I really like Python (which I've been using full-time only for the past two months) I really wish it did have regular private/ protected/public met

Re: internal circular class references

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 09:33, Ethan Furman wrote: Carl Banks wrote: On Dec 10, 5:26 pm, Ethan Furman wrote: First of all, do you even need to wrap the datetime.date class? With Python's duck typing ability, you could have a separate NullDate class to go alongside the datetime.date, and use

Re: Call by reference in SWIG?

2008-12-11 Thread Chris Mellon
On Thu, Dec 11, 2008 at 9:43 AM, Joe Strout wrote: > On Dec 10, 2008, at 10:19 PM, Nok wrote: > >> I can't get call-by-reference functions to work in SWIG... > > Python doesn't have any call-by-reference support at all [1], so I'm not > surprised that a straight translation of the call-by-referenc

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Xah Lee
On Dec 11, 6:50 am, the.brown.dragon.b...@gmail.com wrote: ;; Chicken Scheme. By the.brown.dragon...@gmail.com (require 'srfi-1) (define (normalize vec) (map (cute / <> (sqrt (reduce + 0 (map (cute expt <> 2) vec vec)) Is it possible to make it work in scsh? (i'm running scsh 0.6.4, and don'

Re: just got the g1

2008-12-11 Thread Michael Torrie
garywood wrote: > Hi > > Just got the G1, is their any way to get python running on the andriod > platform ? Nope. But some day when other languages are supported, Python will be high on the list. In the meantime, Android is java only. And no you can't use Jython because Android statically c

Re: Equivalent of 'wget' for python?

2008-12-11 Thread member thudfoo
On Mon, Dec 8, 2008 at 8:22 AM, Robert Dailey wrote: > Hi, > > I'm looking for a portable way to download ZIP files on the internet > through Python. I don't want to do os.system() to invoke 'wget', since > this isn't portable on Windows. I'm hoping the core python library has > a library for this

Re: newbie question: if var1 == var2:

2008-12-11 Thread Steve Holden
Kirk Strauser wrote: > At 2008-11-29T04:02:11Z, Mel writes: > >> You could try >> >> for item in fname: >> item = item.strip() > > This is one case where I really miss Perl's "chomp" function. It removes a > trailing newline and nothing else, so you don't have to worry about losing > leadin

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: > >>> ' ab c \r\n'.rstrip('\r\n') > ' ab c ' > >>> ' ab c \n'.rstrip('\r\n') > ' ab c ' > >>> ' ab c '.rstrip('\r\n') > ' ab c ' I didn't say it couldn't be done. I just like the Perl version better. -- K

Re: Python, threading

2008-12-11 Thread Scott David Daniels
SMALLp wrote: ... I need a tip on how to communicat4 between threads. Typically inter-thread communication is done via Queue.Queue. Look up the Queue module in your docs. a "Simple" example: import Queue shared_work = Queue.Queue() combined_replies = Queue.Queue() ... [distribu

Re: dictionary idiom needed

2008-12-11 Thread Scott David Daniels
Brandon wrote: I have a series of lists in format ['word', 'tagA', 'tagB']. I have converted this to a few dicts, such as one in which keys are tuples of ('word', 'tagB'), and the values are the number of times that key was found. Smells like homework without a particular application. --

  1   2   >