Re: python newbie

2007-11-02 Thread Steven D'Aprano
On Sat, 03 Nov 2007 08:36:24 +0200, Hendrik van Rooyen wrote: > "Bruno Desthuilliers" wrote: > >>functions are *not* methods of their module. > > Now I am confused - if I write: > > result = foo.bar(param) > > Then if foo is a class, we probably all agree that bar is a method of > foo. There

Re: Can local function access local variables in main program?

2007-11-02 Thread Stargaming
On Sat, 03 Nov 2007 07:18:17 +, Sullivan WxPyQtKinter wrote: > I am confused by the following program: > > def f(): > print x > x=12345 > f() > > result is: > 12345 If python can't discover x in your current scope and you do not bind to it there, it will automatically access that

Re: Can local function access local variables in main program?

2007-11-02 Thread Steven D'Aprano
On Sat, 03 Nov 2007 07:18:17 +, Sullivan WxPyQtKinter wrote: > def f(): > print x > x=0 > > x=12345 > f() > > result is: > Traceback (most recent call last): > File "...\test.py", line 5, in ? > f() > File "...\test.py", line 2, in f > print x > UnboundLocalError: local v

Re: count increment...

2007-11-02 Thread Hendrik van Rooyen
Beema shafreen wrote: 8< --- file >my script: > >#!/usr/bin/env python > > >fh = open('complete_span','r') >line = fh.readline().split('#') >old_probe = line[0].strip() >old_value = line[1].strip() >print old_probe, old_value >count = 1 Better to start the c

Can local function access local variables in main program?

2007-11-02 Thread Sullivan WxPyQtKinter
I am confused by the following program: def f(): print x x=12345 f() result is: >>> 12345 however: def f(): print x x=0 x=12345 f() result is: Traceback (most recent call last): File "...\test.py", line 5, in ? f() File "...\test.py", line 2, in f print x UnboundLocalEr

Re: how to do the mapping btw numpy arrayvalues and matrix columns

2007-11-02 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: > hi > i am looking for some info about mapping btw values in an array and > corresponding columns of a matrix > > i have an numpy array=[11.0,33.0,22.0,55.0,44.0] > and a numpy matrix object= >matrix(([1.3,2.5,3.2,6.7,3.1], >

Re: python newbie

2007-11-02 Thread Hendrik van Rooyen
"Bruno Desthuilliers" wrote: >functions are *not* methods of their module. Now I am confused - if I write: result = foo.bar(param) Then if foo is a class, we probably all agree that bar is a method of foo. But the same syntax would work if I had imported some module as foo. So what's the dif

how to do the mapping btw numpy arrayvalues and matrix columns

2007-11-02 Thread [EMAIL PROTECTED]
hi i am looking for some info about mapping btw values in an array and corresponding columns of a matrix i have an numpy array=[11.0,33.0,22.0,55.0,44.0] and a numpy matrix object= matrix(([1.3,2.5,3.2,6.7,3.1], [9.7,5.6,4.8,2.5,2.2],

count increment...

2007-11-02 Thread Beema shafreen
hi, evrybody I have file A_16_P21360207304 A_14_P136880783 A_16_P21360209795 A_16_P21360210173 A_16_P036419591177 A_16_P036419601944 A_16_P03641962999 A_16_P41563648-31 A_16_P036419633391 A_16_P415636493626 A_16_P03641964180 A_16_P415636551216 A_1

Re: difference between IDLE and command line

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 13:38:07 -0300, Jim Hendricks <[EMAIL PROTECTED]> escribió: > New to Python, and just had something strange happen. > > I've been running my new code in IDLE running in windows. My IDLE > version shows as 1.2.1, Python version displaying in IDLE is 2.5.1. > > I have been edi

Re: Instances of BaseException and family don't provide __module__?

2007-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2007 19:36:05 -0700, Scott Dial wrote: > I have started working on a new project using ZSI and perhaps one can > argue this is a bug in ZSI, but I found it odd. The ZSI dispatcher needs > to catch all exceptions and pass that over to the client; in doing so, > it passes along the na

Re: Is pyparsing really a recursive descent parser?

2007-11-02 Thread Just Another Victim of the Ambient Morality
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Nov 2, 5:47 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> >> Pyparsing is no recursive descent parser. It doesn't go back in the >> input >> stream. The ``OneOrMore(Word(alphas))`` part "eats" the 'end

Re: AOP and pep 246

2007-11-02 Thread Michele Simionato
On Nov 3, 12:17 am, "Rustom Mody" <[EMAIL PROTECTED]> wrote: > My own feeling: Python is more AOP ready than java. So lighter-weight > techniques like Michele's decorator should go further. But > methodology not yet formulated. To clarify: my view is that lightweight techniques are enough and tha

MP3 and ID3 library/module recommendations

2007-11-02 Thread p.
Wondering what experiences people have had using various packages for extracting data from and manipulating mp3 files. Specifically, i need to get a song duration, which as i understand it, you extract from the framesets, as well as the typical id3 stuff like artist, album, song, year, etc. Ideally

Re: new style class

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 08:58:32 -0300, gert <[EMAIL PROTECTED]> escribió: > Could not one of you just say "@staticmethod" for once damnit :) Do we have to read your mind now? You miss-typed the method names the first time. You could equally have forgotten to type the 'self' parameter. Don't you

Re: Assertion for python scripts

2007-11-02 Thread Carl Banks
On Nov 2, 2:14 pm, matthias <[EMAIL PROTECTED]> wrote: > Here is my question: How do I maintain debug / release builds that > allow me to switch > debug stmts, like assert, on / off ? If you want to distribute a single-file optimized version, perhaps embedding the Python code as a here-file in a

Re: AOP and pep 246

2007-11-02 Thread Rustom Mody
I find these viewpoints interesting in their divergence. At the risk of being simplistic: Kay: AOP == AspectJ or thereabouts. A failure in itself and uninteresting to pythonistas Michele: AOP not very interesting though does good work himself in decorators, metaclasses and other such AOPish stuf

Re: Bizarre additional calling overhead.

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 21:07:19 -0300, Matimus <[EMAIL PROTECTED]> escribió: > On Nov 2, 3:08 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: >> >>> def test_func(): >> >> ... pass >> ...>>> import new >> >>> test_func2 = new.function(test_func.func_code, {}, "test_func2") >> >>> test_func2 >> >> >

Re: __file__ vs __FILE__

2007-11-02 Thread Jeff McNeil
The __file__ attribute is present when you run a script from a file. If you run from the interactive interpreter, it will raise a NameError. Likewise, I believe that in earlier versions of Python (2.1? Pre 2.2?) it was only set within imported modules. I've used the 'os.path.realpath(os.pat

__file__ vs __FILE__

2007-11-02 Thread klenwell
I apologize in advance for coming at this from this angle but... In PHP you have the __FILE__ constant which gives you the value of the absolute path of the file you're in (as opposed to the main script file.) With the function dirname, this makes it easy to get the parent dir of a particular fil

Instances of BaseException and family don't provide __module__?

2007-11-02 Thread Scott Dial
I have started working on a new project using ZSI and perhaps one can argue this is a bug in ZSI, but I found it odd. The ZSI dispatcher needs to catch all exceptions and pass that over to the client; in doing so, it passes along the name of the exception that occurred so that the client can know m

how to pass a function name and its arguments inside the arguments of other function?

2007-11-02 Thread jmborr
I need something like this: 1: superfoo( non-keyword-args, keyword-args, methodname, *kargs, *kwargs): 2: """non-keyword-args and keyword-args are arguments that 3: apply to superfoo, while *kargs and **kwargs are arguments 4: that apply to methodname. See below""" 5:

Re: python tutorial on a single html page?

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 19:43:23 -0300, BartlebyScrivener <[EMAIL PROTECTED]> escribió: > Is the main Python tutorial posted on single searchable page > somewhere? As opposed to browsing the index and clicking NEXT etc. The next release will use a different doc format (and different layout too),

Re: IDLE

2007-11-02 Thread annonymous
on 11/03/2007 06:44 AM Russ P. wrote : > I've been programming in python for a few years using XEmacs on > Solaris and Linux. I've been thinking about trying IDLE for a long > time, but either it wasn't available on my system or I procrastinated. > I finally have it available, and I gave it a try.

Re: os.readlink returning value

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 13:44:37 -0300, Giampaolo Rodola' <[EMAIL PROTECTED]> escribió: > On 2 Nov, 05:30, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >> En Thu, 01 Nov 2007 22:51:14 -0300, Giampaolo Rodola' <[EMAIL PROTECTED]> >> escribió: >> >> > readlink( path) >> >> > ...It's not clear to me

Re: PyQt with embedded python in Qt App

2007-11-02 Thread cgrebeld
On Nov 2, 7:59 am, "Bart." <[EMAIL PROTECTED]> wrote: > Friday 02 of November 2007 12:21:06 BlueBird napisa (a): > > > > > On Nov 2, 8:03 am, "Bart." <[EMAIL PROTECTED]> wrote: > > > Friday 02 of November 2007 01:06:58 Diez B. Roggisch napisa (a): > > > > > So how to pass this object into embeded p

Re: Assertion for python scripts

2007-11-02 Thread Gabriel Genellina
En Fri, 02 Nov 2007 16:53:12 -0300, matthias <[EMAIL PROTECTED]> escribió: > On Nov 2, 12:12 pm, "Matt McCredie" <[EMAIL PROTECTED]> wrote: >> On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: >> >> > I know that "-O" turns off assertions in general. However, how do I >> > pass thus parameter to

MP3 and ID3 library/module recommendations

2007-11-02 Thread paul petrick
Wondering what experiences people have had using various packages for extracting data from and manipulating mp3 files. Specifically, i need to get a song duration, which as i understand it, you extract from the framesets, as well as the typical id3 stuff like artist, album, song, year, etc. Idea

Re: Bizarre additional calling overhead.

2007-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2007 17:08:06 -0500, Chris Mellon wrote: def test_func(): > ... pass > ... import new test_func2 = new.function(test_func.func_code, {}, "test_func2") [snip results of timeit] > Why almost twice the calling overhead for a dynamic function? When I time the funct

Re: Bizarre additional calling overhead.

2007-11-02 Thread Matimus
On Nov 2, 3:08 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > >>> def test_func(): > > ... pass > ...>>> import new > >>> test_func2 = new.function(test_func.func_code, {}, "test_func2") > >>> test_func2 > > >>> test_func > > >>> import timeit > >>> tf = timeit.Timer("test_func()", "from __mai

Re: Sub-sort after sort

2007-11-02 Thread Paul Hankin
On Nov 2, 9:45 pm, [EMAIL PROTECTED] wrote: > Hello, I have been sorting a list of dicts using the following > function: > > result_rs = sorted(unsort_rs, key=itemgetter(orderby)) > > and this works fine. Now I am looking to perform a subsort as well. > For example, I have this: > > test = [{'name'

Re: IDLE

2007-11-02 Thread Larry Bates
Russ P. wrote: > I've been programming in python for a few years using XEmacs on > Solaris and Linux. I've been thinking about trying IDLE for a long > time, but either it wasn't available on my system or I procrastinated. > I finally have it available, and I gave it a try. > > I immediately encou

Re: Sub-sort after sort

2007-11-02 Thread KeefTM
On Nov 2, 3:36 pm, "Andrew Koenig" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I would want to sort by name first, then sub sort by location. Any > > ideas? Thanks! > > In Python 2.3 and later, sorting is stable -- so you can sort successively

Re: Sub-sort after sort

2007-11-02 Thread KeefTM
On Nov 2, 3:36 pm, "Andrew Koenig" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I would want to sort by name first, then sub sort by location. Any > > ideas? Thanks! > > In Python 2.3 and later, sorting is stable -- so you can sort successively

IDLE

2007-11-02 Thread Russ P.
I've been programming in python for a few years using XEmacs on Solaris and Linux. I've been thinking about trying IDLE for a long time, but either it wasn't available on my system or I procrastinated. I finally have it available, and I gave it a try. I immediately encountered a basic problem for

python tutorial on a single html page?

2007-11-02 Thread BartlebyScrivener
Is the main Python tutorial posted on single searchable page somewhere? As opposed to browsing the index and clicking NEXT etc. Thank you, rd -- http://mail.python.org/mailman/listinfo/python-list

Re: Sub-sort after sort

2007-11-02 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would want to sort by name first, then sub sort by location. Any > ideas? Thanks! In Python 2.3 and later, sorting is stable -- so you can sort successively in reverse order. In other words, sort the list by location, then sort th

Re: AOP and pep 246

2007-11-02 Thread Yu-Xi Lim
Carl Banks wrote: > > AOP is a programming paradigm in the same way indie is a genre of > film. I like your explanation! Heck, if it were more directly Python-related, I'd nominate this line for QOTW. -- http://mail.python.org/mailman/listinfo/python-list

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Jim Hendricks wrote: > This sounds like an issue of terminology. I understand that I > don't declare variables like I would in C or Java, but that they > are implicitly declared via the first assignment. I think yes, it's an issue of terminology. As mentioned I used the terms I know from C/C++,

Re: error ...1 value to unpack

2007-11-02 Thread matthias
On Nov 2, 2:32 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Nov 2, 2007 3:04 PM, Beema shafreen <[EMAIL PROTECTED]> wrote: > > > > > hi everybody, > > i have a file: > > > A_16_P21360207#304 > > A_14_P136880#783 > > A_16_P21360209#795 > > A_16_P21360210#173 > > A_16_P03641959#1177 > > A_16_P0

Re: Sub-sort after sort

2007-11-02 Thread KeefTM
On Nov 2, 2:45 pm, [EMAIL PROTECTED] wrote: > Hello, I have been sorting a list of dicts using the following > function: > > result_rs = sorted(unsort_rs, key=itemgetter(orderby)) > > and this works fine. Now I am looking to perform a subsort as well. > For example, I have this: > > test = [{'name'

Bizarre additional calling overhead.

2007-11-02 Thread Chris Mellon
>>> def test_func(): ... pass ... >>> import new >>> test_func2 = new.function(test_func.func_code, {}, "test_func2") >>> test_func2 >>> test_func >>> import timeit >>> tf = timeit.Timer("test_func()", "from __main__ import test_func") >>> tf.repeat() [0.2183461704377247, 0.18068215314489791,

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Bruno Desthuilliers wrote: > Bjoern Schliessmann a écrit : >> You can't just declare in Python, you always define objects (and >> bind a name to them). > > def toto(): >global p >p = 42 > > Here I declared 'x' as global without defining it. Ah well, someone had to notice it ... BTW, wh

Sub-sort after sort

2007-11-02 Thread keeftm
Hello, I have been sorting a list of dicts using the following function: result_rs = sorted(unsort_rs, key=itemgetter(orderby)) and this works fine. Now I am looking to perform a subsort as well. For example, I have this: test = [{'name': 'John Smith', 'location': 'CA',},{'name': 'John Smith', '

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Duncan Booth wrote: > Why not try it out for yourself (both of you). Globals do not need > to be defined in the global scope so long as the first 'access' is > to bind a value to the variable: Well, I did. I (mis)understood the OP to mean "read" by "access". I didn't consider rebinding another obj

Re: error ...1 value to unpack

2007-11-02 Thread Chris Mellon
On Nov 2, 2007 3:04 PM, Beema shafreen <[EMAIL PROTECTED]> wrote: > hi everybody, > i have a file: > > A_16_P21360207#304 > A_14_P136880#783 > A_16_P21360209#795 > A_16_P21360210#173 > A_16_P03641959#1177 > A_16_P03641960#1944 > A_16_P03641962#999 > A_16_P41563648#-31 > A_16_P03641963#3391 > A_16_P

Re: Assertion for python scripts

2007-11-02 Thread Bart.
Friday 02 of November 2007 22:07:42 matthias napisał(a): > > check this: > > > > python ./assert.pyo > > Yes, I know that this works. Thanx. However, that's not what I was > going for. > > Essentially, I am targeting a build system that allows me to build > debug / release versions > of my Pytho

Re: Assertion for python scripts

2007-11-02 Thread matthias
On Nov 2, 1:29 pm, "Bart." <[EMAIL PROTECTED]> wrote: > Friday 02 of November 2007 20:53:12 matthias napisa (a): > > > > > On Nov 2, 12:12 pm, "Matt McCredie" <[EMAIL PROTECTED]> wrote: > > > On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: > > > > Howdy ! > > > > > I started using the assert() stmt

Re: Assertion for python scripts

2007-11-02 Thread Bart.
Friday 02 of November 2007 20:53:12 matthias napisał(a): > On Nov 2, 12:12 pm, "Matt McCredie" <[EMAIL PROTECTED]> wrote: > > On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: > > > Howdy ! > > > > > > I started using the assert() stmt and found it quite useful :-) I > > > have only one problem: I

Re: 3 number and dot..

2007-11-02 Thread Roberto Bonvallet
On 2 nov, 14:54, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Not necessarily. Something duck typing is too liberal in what it accepts. > You might want convert(math.pi) to raise an exception What I meant was that the function should not reject unnecessarily non- numeric things

Re: Iterable Flattener with Depth.

2007-11-02 Thread Pradeep Jindal
On Friday 02 Nov 2007 10:43:45 pm Ian Clark wrote: > thebjorn wrote: > > On Nov 2, 6:32 am, praddy <[EMAIL PROTECTED]> wrote: > >> On Nov 1, 5:03 pm, [EMAIL PROTECTED] wrote: > >>> Pradeep Jindal: > Any comments? > >>> > >>> Something with similar functionality (plus another 20 utility > >>> f

error ...1 value to unpack

2007-11-02 Thread Beema shafreen
hi everybody, i have a file: A_16_P21360207#304 A_14_P136880#783 A_16_P21360209#795 A_16_P21360210#173 A_16_P03641959#1177 A_16_P03641960#1944 A_16_P03641962#999 A_16_P41563648#-31 A_16_P03641963#3391 A_16_P41563649#3626 A_16_P03641964#180 A_16_P41563655#1216 A_16_P03641965#1170 A_16_P03641966#194

Re: Assertion for python scripts

2007-11-02 Thread matthias
On Nov 2, 12:12 pm, "Matt McCredie" <[EMAIL PROTECTED]> wrote: > On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: > > > > > Howdy ! > > > I started using the assert() stmt and found it quite useful :-) I > > have only one problem: I don't > > know how to turn them off again. > > > I know that "-O"

Re: marshal vs pickle

2007-11-02 Thread Aaron Watters
On Nov 1, 10:12 am, Aaron Watters <[EMAIL PROTECTED]> wrote: > On Oct 31, 6:10 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > Alright already. Here is the patched file you want > > http://nucular.sourceforge.net/kisstree_pickle.py This file has been removed. After consideration, I don't wa

Re: Assertion for python scripts

2007-11-02 Thread Matt McCredie
On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: > Howdy ! > > I started using the assert() stmt and found it quite useful :-) I > have only one problem: I don't > know how to turn them off again. > > I know that "-O" turns off assertions in general. However, how do I > pass thus parameter to > p

Re: (MAC) CoreGraphics module???

2007-11-02 Thread Robert Kern
David C. Ullrich wrote: > On Thu, 01 Nov 2007 19:39:20 -0500, Robert Kern > <[EMAIL PROTECTED]> wrote: > >> David C. Ullrich wrote: >>> [why doesn't CoreGraphics work?] >> That's different than the one that is referenced. The one those articles >> reference is only available in the Python that cam

Re: using the filter function within class return error

2007-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2007 09:42:17 -0700, david.katkowski wrote: > I'm trying to use the __builtin__ filter function within a class; > however, I receive the following error: > > NameError: global name 'MajEthnic' is not defined > > The line of code is: EthMaj = filter(self.MajEthnic,flist) > > So, I

Assertion for python scripts

2007-11-02 Thread matthias
Howdy ! I started using the assert() stmt and found it quite useful :-) I have only one problem: I don't know how to turn them off again. I know that "-O" turns off assertions in general. However, how do I pass thus parameter to python to an executable script ? I have tried the following: 1.

Re: new style class

2007-11-02 Thread Aahz
In article <[EMAIL PROTECTED]>, Nigel Rantor <[EMAIL PROTECTED]> wrote: > >I think what Boris was being exceedingly unhelpful in saying was "why >should it work when you're calling methods that do not exist" http://www.catb.org/~esr/faqs/smart-questions.html -- Aahz ([EMAIL PROTECTED])

Re: 3 number and dot..

2007-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2007 16:39:12 +, Roberto Bonvallet wrote: > On 31 oct, 22:21, Paul Rubin wrote: >> def convert(n): >>assert type(n) in (int,long) > > I'd replace this line with n = int(n), more in the spirit of duck > typing. Not necessarily. Something duck typ

Re: Iterable Flattener with Depth.

2007-11-02 Thread Ian Clark
thebjorn wrote: > On Nov 2, 6:32 am, praddy <[EMAIL PROTECTED]> wrote: >> On Nov 1, 5:03 pm, [EMAIL PROTECTED] wrote: >> >>> Pradeep Jindal: Any comments? >>> Something with similar functionality (plus another 20 utility >>> functions/classes or so) has probably to go into the std lib... :-) >

Re: python newbie

2007-11-02 Thread tasjaevan
On Nov 2, 3:35 pm, Jim Hendricks <[EMAIL PROTECTED]> wrote: > > This sounds like an issue of terminology. I understand that I don't > declare variables like I would in C or Java, but that they are > implicitly declared via the first assignment. And the define objects > and bind a name to them mak

Re: Copy database with python..

2007-11-02 Thread Diez B. Roggisch
Abandoned wrote: > On Nov 2, 4:19 pm, Paul McNett <[EMAIL PROTECTED]> wrote: >> Abandoned wrote: >> > Hi. >> > I want to copy my database but python give me error when i use this >> > command. >> > cursor.execute("pg_dump mydata > old.dump") >> > What is the problem ? And how can i copy the databa

Re: os.readlink returning value

2007-11-02 Thread Giampaolo Rodola'
On 2 Nov, 05:30, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 01 Nov 2007 22:51:14 -0300, Giampaolo Rodola' <[EMAIL PROTECTED]> > escribió: > > > I was reading os.readlink doc which says: > > > readlink( path) > > > Return a string representing the path to which the symbolic link > >

using the filter function within class return error

2007-11-02 Thread david . katkowski
I'm trying to use the __builtin__ filter function within a class; however, I receive the following error: NameError: global name 'MajEthnic' is not defined The line of code is: EthMaj = filter(self.MajEthnic,flist) So, I'm trying to use the MajEthnic function to filter the list flist. Any ideas?

Re: 3 number and dot..

2007-11-02 Thread Roberto Bonvallet
On 31 oct, 22:21, Paul Rubin wrote: > def convert(n): >assert type(n) in (int,long) I'd replace this line with n = int(n), more in the spirit of duck typing. -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list

difference between IDLE and command line

2007-11-02 Thread Jim Hendricks
New to Python, and just had something strange happen. I've been running my new code in IDLE running in windows. My IDLE version shows as 1.2.1, Python version displaying in IDLE is 2.5.1. I have been editing my code in UltraEdit then testing in IDLE by choosing open, then F5. I didn't see an

Re: python newbie

2007-11-02 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Jim Hendricks wrote: (snip) >> I see the global keyword that allows access to global vars in a >> function, what I'm not clear on is does that global need to be >> declared in the global scope, > > You can't just declare in Python, you always define objects (and > b

Re: python newbie

2007-11-02 Thread Bruno Desthuilliers
Jim Hendricks a écrit : > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: > > 1) global vars - python sets scope to the block a var is declared (1st > set), I see the global keyword that allows access to global vars in a

Re: new style class

2007-11-02 Thread gert
On Nov 2, 4:04 pm, Boris Borcic <[EMAIL PROTECTED]> wrote: > gert wrote: > > Could not one of you just say "@staticmethod" for once damnit :) > > I did, did I not ? i am sorry, yes you did :) -- http://mail.python.org/mailman/listinfo/python-list

Re: new style class

2007-11-02 Thread Nigel Rantor
gert wrote: > Could not one of you just say "@staticmethod" for once damnit :) > why were you asking if you knew the answer? yeesh -- http://mail.python.org/mailman/listinfo/python-list

Re: python newbie

2007-11-02 Thread Jim Hendricks
J. Clifford Dyer wrote: >> before calling my_function, x does not exist in my program. So, my >> question is in my_function, the combination of using the global >> statement, then implicitly creating x via assignment to the result of >> the open function, is x created in the global namespace? >

Re: python newbie

2007-11-02 Thread BartlebyScrivener
On Nov 2, 10:13 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > Here's an example of what I am asking: Try this example from Beazley (pg 82) a = 42 def foo(): a = 13 foo() print a 42 By contrast: a = 42 b = 13 def foo(): global a, b a = 13 b = 0 foo() print a 13 print b 0 -- h

Re: compiling python 3000 on debian etch

2007-11-02 Thread rustompmody
On Nov 2, 6:56 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > Here is the home page for the Debian source package for Python 2.5--it > lists the build dependencies. > > http://packages.debian.org/source/etch/python2.5 > Ok Thanks With that help Ive got it down to this (output of (end of) make) Fai

Re: python newbie

2007-11-02 Thread J. Clifford Dyer
On Fri, Nov 02, 2007 at 11:13:00AM -0400, Jim Hendricks wrote regarding Re: python newbie: > > BartlebyScrivener wrote: > > On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > >> New to python, programming in 15 or so langs for 24 years. > >> > >> Couple of questions the tuts I've looke

Re: python newbie

2007-11-02 Thread Jim Hendricks
Bjoern Schliessmann wrote: > Please use a more informative subject next time. > > Jim Hendricks wrote: >> 1) global vars - python sets scope to the block a var is declared >> (1st set), > > http://docs.python.org/ref/global.html > > I'm afraid not. Python only interprets the listed name(s) as >

Re: python newbie

2007-11-02 Thread Duncan Booth
Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > Jim Hendricks wrote: >> I see the global keyword that allows access to global vars in a >> function, what I'm not clear on is does that global need to be >> declared in the global scope, > > You can't just declare in Python, you always define obje

Re: python newbie

2007-11-02 Thread Jim Hendricks
BartlebyScrivener wrote: > On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: >> New to python, programming in 15 or so langs for 24 years. >> >> Couple of questions the tuts I've looked at don't explain: > > Did you look at THE tut? You would seem to be the perfect reader for > it, beca

Re: python newbie

2007-11-02 Thread Neil Cerutti
On 2007-11-02, Jim Hendricks <[EMAIL PROTECTED]> wrote: > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: > > 1) global vars - python sets scope to the block a var is > declared (1st set), I see the global keyword that allows

Re: new style class

2007-11-02 Thread Boris Borcic
gert wrote: > Could not one of you just say "@staticmethod" for once damnit :) > I did, did I not ? -- http://mail.python.org/mailman/listinfo/python-list

http client using ssh -D

2007-11-02 Thread Nikola Skoric
Is there a python library which supports using SOCKS proxy which I create by "ssh -D port remote-host"? I was trying to use that socket by SocksiPy, but I get "channel 3: open failed: administratively prohibited: open failed" on the server side. And I can use that channel freely with firefox. Any o

Re: new style class

2007-11-02 Thread Bjoern Schliessmann
Wildemar Wildenburger wrote: > Bjoern Schliessmann wrote: >> No, since everyone's crystal balls are in repair. > > I don't even have crystal balls! Not many are rich *and* impotent. :) Regards, Björn -- BOFH excuse #14: sounds like a Windows problem, try calling Microsoft support -- http

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Please use a more informative subject next time. Jim Hendricks wrote: > 1) global vars - python sets scope to the block a var is declared > (1st set), http://docs.python.org/ref/global.html I'm afraid not. Python only interprets the listed name(s) as globals. > I see the global keyword that al

Re: python newbie

2007-11-02 Thread BartlebyScrivener
On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: Did you look at THE tut? You would seem to be the perfect reader for it, because you are already a programmer. h

PyQt with embedded python in Qt App

2007-11-02 Thread David Boddie
On Fri Nov 2 12:59:48 CET 2007, Bart. wrote: > Or I want to use PyQt in scripts to have similar gui for plugins written in > python > Or I want to extend application by scripts with PyQt. > > Or better question: > How to easy add python scripting in Qt application and have almast all > objects o

Re: Is there a usenet library for Python?

2007-11-02 Thread Grant Edwards
On 2007-11-02, Just Another Victim of the Ambient Morality <[EMAIL PROTECTED]> wrote: > I'm interested in the former, an NNTP client. Thank you Grant > and Jean-Paul (who answered this question in another post). I > should have guessed at searching for "NNTP" instead of > "usenet..." What to

Re: Copy database with python..

2007-11-02 Thread Martin Sand Christensen
> "Abandoned" == Abandoned <[EMAIL PROTECTED]> writes: Abandoned> Yes i understand thank you. Now i find that maybe help the Abandoned> other users. Abandoned> import os Abandoned> os.system("su postgres") Abandoned> ... I get the distinct impression that you're trying to replace simple shel

Re: Copy database with python..

2007-11-02 Thread Abandoned
On Nov 2, 4:19 pm, Paul McNett <[EMAIL PROTECTED]> wrote: > Abandoned wrote: > > Hi. > > I want to copy my database but python give me error when i use this > > command. > > cursor.execute("pg_dump mydata > old.dump") > > What is the problem ? And how can i copy the database with python ? > > You a

Re: Copy database with python..

2007-11-02 Thread Abandoned
On Nov 2, 4:11 pm, Martin Sand Christensen <[EMAIL PROTECTED]> wrote: > > "Abandoned" == Abandoned <[EMAIL PROTECTED]> writes: > > Abandoned> I want to copy my database but python give me error when i > Abandoned> use this command. cursor.execute("pg_dump mydata > old.dump") > Abandoned> What

[ANN] Leo 4.4.4 Final released

2007-11-02 Thread Edward K Ream
Leo 4.4.4 Final is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html Leo 4.4.4 contains many important features originally planned

Re: Copy database with python..

2007-11-02 Thread Paul McNett
Abandoned wrote: > Hi. > I want to copy my database but python give me error when i use this > command. > cursor.execute("pg_dump mydata > old.dump") > What is the problem ? And how can i copy the database with python ? You are just going to have to give us more to go on. Please post the entire

Re: Copy database with python..

2007-11-02 Thread Martin Sand Christensen
> "Abandoned" == Abandoned <[EMAIL PROTECTED]> writes: Abandoned> I want to copy my database but python give me error when i Abandoned> use this command. cursor.execute("pg_dump mydata > old.dump") Abandoned> What is the problem ? cursor.execute() is for executing SQL commands, and this is no

Re: Copy database with python..

2007-11-02 Thread Carsten Haese
On Fri, 2007-11-02 at 06:51 -0700, Abandoned wrote: > Hi. > I want to copy my database but python give me error when i use this > command. > cursor.execute("pg_dump mydata > old.dump") cursor.execute executes SQL queries. pg_dump is not an SQL query, it is an operating system command. To execute O

Re: compiling python 3000 on debian etch

2007-11-02 Thread Carl Banks
On Nov 2, 8:24 am, "Rustom Mody" <[EMAIL PROTECTED]> wrote: > Ive been trying to compile python 3000 on debian etch > And on running test I get: > > 4 skips unexpected on linux2: > test_tcl test_dbm test_ssl test_bsddb > > Can someone tell me what packages I am missing? Here is the home page f

Copy database with python..

2007-11-02 Thread Abandoned
Hi. I want to copy my database but python give me error when i use this command. cursor.execute("pg_dump mydata > old.dump") What is the problem ? And how can i copy the database with python ? Note: The database's size is 200 GB -- http://mail.python.org/mailman/listinfo/python-list

python newbie

2007-11-02 Thread Jim Hendricks
New to python, programming in 15 or so langs for 24 years. Couple of questions the tuts I've looked at don't explain: 1) global vars - python sets scope to the block a var is declared (1st set), I see the global keyword that allows access to global vars in a function, what I'm not clear on is d

Re: MySQLdb.string_literal

2007-11-02 Thread gert
On Nov 2, 1:48 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-11-02 at 12:24 +, gert wrote: > > I want to escape binary data so i can insert data into a blob > > No, you don't want to escape binary data. You want to bind it to a > parametrized query: > > http://informixdb.blogspot.

Re: new style class

2007-11-02 Thread gert
On Nov 2, 2:10 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann wrote: > > gert wrote: > >> Could not one of you just say "@staticmethod" for once damnit :) > > > No, since everyone's crystal balls are in repair. > > I don't even have crystal balls! > > /W lol -- http:/

Re: new style class

2007-11-02 Thread Wildemar Wildenburger
Bjoern Schliessmann wrote: > gert wrote: >> Could not one of you just say "@staticmethod" for once damnit :) > > No, since everyone's crystal balls are in repair. > I don't even have crystal balls! /W -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax coloring in Python interpreter

2007-11-02 Thread kyosohma
On Nov 1, 12:45 pm, braver <[EMAIL PROTECTED]> wrote: > Greetings -- as a long time user of both Python and Ruby interpreters, > I got used to the latter's syntax-coloring gem, wirble, which > colorizes Ruby syntax on the fly. Is there anything similar for > Python? What's wrong with IDLE? There'

  1   2   >