Re: Newbie question about numpy

2006-08-25 Thread Paul Johnston
On Thu, 24 Aug 2006 17:23:49 GMT, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >On Thu, 24 Aug 2006 16:38:45 +0100, Paul Johnston ><[EMAIL PROTECTED]> declaimed the following in >comp.lang.python: > >> I know its a long time since my degree but that's not matrix >> multiplication is it ? > >

Re: callable to disappear?

2006-08-25 Thread Antoon Pardon
On 2006-08-23, Terry Reedy <[EMAIL PROTECTED]> wrote: > > "faulkner" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> what's wrong with hasattr(obj, '__call__')? > > I have the impression that this is not currently true for all callables . > If not, this may be improved in the fut

Re: sum and strings

2006-08-25 Thread Hendrik van Rooyen
"Fredrik Lundh" <[EMAIL PROTECTED]> Wrote: 8< | (I still think a "join" built-in would be nice, though. but anyone who | argues that "join" should support numbers too will be whacked with a | great big halibut.) | | Strange this - you don't *LOOK* lik

Re: lazy arithmetic

2006-08-25 Thread Peter Otten
[EMAIL PROTECTED] wrote: > # This is what I have in mind: > > class Item(object): > def __add__(self, other): > return Add(self, other) > > class Add(Item): > def __init__(self, a, b): > self.a = a > self.b = b > > a = Item() > b = Item() > > c = a+b > > # Now, I am going abso

smtpd and custom MAIL_FROM/RCPT_TO validation

2006-08-25 Thread alf
Hi, I use smtpd for the SMTP server in my app, but I need a little bit more as far as immediate MAIL_FROM/RCPT_TO validation. Returning from process_message is too late SMTP protocol-wise. The ad hoc solution is to create own SMTPServer2 by deriving from and own SMTPChannel2 by deriving SMTP

M$ windows python libs installed in arbitrary directories for customized python distributions

2006-08-25 Thread alf
Hi, for some reason I have to deal with custom python distributions. It turned out it is quite simple - I just install the python from python.org and all the libs needed. Then I take python2n.dll from c:\win*\system32 and move directly to PYTHONDIR. Then I can just tar/zip the PYTHON dir and d

Re: how do you get the name of a dictionary?

2006-08-25 Thread Duncan Booth
Steven D'Aprano wrote: >> a, b, c, d = range(4) >> spam(a, b, c, d) >>> Traceback (most recent call last): >>> File "", line 1, in ? >>> File "", line 6, in spam >>> File "", line 5, in eggs >>> File "", line 4, in beans >>> ValueError: x is too small >>> >>> Of course you can't. x cou

performance of dictionary lookup vs. object attributes

2006-08-25 Thread Andre Meyer
Hi all I was wondering about the performance comparison of either using a dictionary or an object for a large collection of "things". Therefore I have run the attached test. I create a dictionary and an object. Both get the same number of items/attributes, respectively. Then, for both the values

IVI-COM (Interchangeable Virtual Instrument)

2006-08-25 Thread rubbishemail
Hello, has anyone experience using IVI-COM drivers from python? http://adn.tm.agilent.com/index.cgi?CONTENT_ID=1919 http://ivifoundation.org/ Many thanks Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good idea or a waste of time?

2006-08-25 Thread Hendrik van Rooyen
"Simon Forman" <[EMAIL PROTECTED]> wrote: 8<- | BTW, speaking of "strictness", "more stricter" is invalid English, | just "stricter" is the "correct" form. ;-) or alternatively the construct "more strict" is also acceptable - Hendri

Consistency in Python

2006-08-25 Thread Hendrik van Rooyen
Hi, for S where S is a Standard Python type: The slice notation S[n] returns either: The n'th element of S, or The value of the dictionary entry whose key is n. This is beautiful because as a programmer you don't have to worry what S is... (and as an aside - This consistency h

Re: OS X and Python - what is your install strategy?

2006-08-25 Thread Diez B. Roggisch
> These days, I install the OS X universal binary provided on the Python > language web site. You can find it at > http://www.python.org/download/releases/2.4.3. It's more comprehensive > and much more up-to-date than the version included in OS X. It is. But don't fall for the temptation to remove

Fw: Is this a good idea or a waste of time?

2006-08-25 Thread Hendrik van Rooyen
"Simon Forman" <[EMAIL PROTECTED]> wrote: 8<- | BTW, speaking of "strictness", "more stricter" is invalid English, | just "stricter" is the "correct" form. ;-) or alternatively the construct "more strict" is also acceptabl

Re: Consistency in Python

2006-08-25 Thread Diez B. Roggisch
Hendrik van Rooyen schrieb: > Hi, > > for S where S is a Standard Python type: > The slice notation S[n] returns either: > The n'th element of S, or > The value of the dictionary entry whose key is n. > > This is beautiful because as a programmer you don't have to worry what S

Re: callable to disappear?

2006-08-25 Thread Georg Brandl
Antoon Pardon wrote: > I have been reading http://www.python.org/dev/peps/pep-3100/ > en there is written: > > To be removed: > ... > > callable(): just call the object and catch the exception > > ... > Is there a chance this will be reconsidered? > There was some discus

Re: List problem

2006-08-25 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > For example i write the following code in the Python command line; > list = ['One,Two,Three,Four'] > > Then enter this command, which will then return the following; > > ['One,Two,Three,Four'] This is already wrong. Assignments do not return anything. Georg -- h

Re: sum and strings

2006-08-25 Thread Bryan Olson
Fredrik Lundh wrote: > [...] besides, in all dictionaries I've consulted, the word "sum" > means "adding numbers". That's a result of not looking deeply enough. Fredrik Lundh is partially right, in that "Sum" usually refers to addition of numbers. Nevertheless, the idea that "sum" must refer to n

Re: Consistency in Python

2006-08-25 Thread Paul Boddie
Hendrik van Rooyen wrote: > > There seems to be no common methods such as- > "prepend" - for adding something to the beginning > "append" - for adding something to the end > "insert[j]" - for adding something somewhere in the middle > > Or have I missed something ? [...] > BTW - I und

Re: how do you get the name of a dictionary?

2006-08-25 Thread Giles Brown
jojoba wrote: > Does anyone know how to find the name of a python data type. > Conside a dictionary: > Banana = {} > > Then, how do i ask python for a string representing the name of the > above dictionary (i.e. 'Banana')? As many people have already said this question doesn't really make sense, b

Re: lazy arithmetic

2006-08-25 Thread pianomaestro
Simon Forman wrote: > But that's a function, not a class. When you assign add to an > attribute of Item it "magically" becomes a method of Item: > Yes, I am looking to understand this magic. Sounds like I need to dig into these descriptor thingies (again). (sound of brain exploding).. Simon.

Is this a bug of module struct?

2006-08-25 Thread rong . xian
Before I was bitten by the difference below, I think these two ways are the same. However, they are not. Is there any geek who can tell me if this is a bug? (some weird '\x00\x00' was inserted between '0123456789abcd' and 6 ) >>> struct.pack('3I14sI',1,19960101,14,'0123456789abcd',6) '\x01\x00\x0

Re: Is this a bug of module struct?

2006-08-25 Thread rong . xian
I got it, alignment issue... > >>> struct.pack('!3I14sI',1,19960101,14,'0123456789abcd',6) > '\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456789abcd\x06\x00\x00\x00' > >>> struct.pack('!3I14s',1,19960101,14,'0123456789abcd')+struct.pack('!I',6) > '\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456

Re: Pygame, mouse events and threads

2006-08-25 Thread Ben Sizer
[EMAIL PROTECTED] wrote: > Ben Sizer wrote: > > [EMAIL PROTECTED] wrote: > > > > > When I put the content of the run and input functions in the main > > > thread, it's working, why not in the thread? > > > > Because event handling needs to be done in the main thread. So does > > rendering. This is

Re: Modules... paths... newbie confusion

2006-08-25 Thread Steve Holden
Dennis Lee Bieber wrote: > On Tue, 22 Aug 2006 14:32:36 +0100, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>You won;t get MySQLdb to run without running the setup.py since IIRC >>there's a compile step for a C library (and it's that compile step that

Re: how do you get the name of a dictionary?

2006-08-25 Thread Steve Holden
Fredrik Lundh wrote: > Steve Holden wrote: > > >>Right. Plus it's fun to imagine the effbot hitting itself as hard as >>some people would obviously have liked to hit it in the past :-) > > > you mean the guy who's spent the last six months downrating every single > post I've made on this list

Re: Python and STL efficiency

2006-08-25 Thread Ben Sizer
Neil Cerutti wrote: > On 2006-08-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > It will run a lot faster if it doesn't have to keep resizing > > the array. > > I don't see why it should run a lot faster that way. > > Appending elements to a vector with push_back takes amortized > constant t

Re: RE Module

2006-08-25 Thread Anthra Norell
Roman, Your re works for me. I suspect you have tags spanning lines, a thing you get more often than not. If so, processing linewise doesn't work. You need to catch the tags like this: >>> text = re.sub ('<(.|\n)*?>', '', text) If your text is reasonably small I would recommend this solution. E

prevent unauthorized call to script

2006-08-25 Thread kudincendol
Hello everyone.I just learn Python this week. So I don't know if this question may have been asked by someone else.I have copy-paste a script called  "form.py"  from somewhere else. This script is called from " form.html". Both are running in my Apache server. How do I prevent other html files from

Re: M$ windows python libs installed in arbitrary directories forcustomized python distributions

2006-08-25 Thread Fredrik Lundh
"alf" <[EMAIL PROTECTED]> wrote: > It turned out it is quite simple - I just install the python from > python.org and all the libs needed. Then I take python2n.dll from > c:\win*\system32 and move directly to PYTHONDIR. Then I can just tar/zip > the PYTHON dir and distribute around so users do not

Re: Best Editor

2006-08-25 Thread mystilleef
I recommend Scribes on Linux. It's simple, fast and powerful. Website: http://scribes.sf.net/ Flash Demo: http://scribes.sf.net/snippets.htm GIF Demo: http://www.minds.may.ie/~dez/images/blog/scribes.html JAG CHAN wrote: > Friends, I am trying to learn Python. > It will be of great help to me if

Re: Consistency in Python

2006-08-25 Thread Paul McGuire
"Paul Boddie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Moreover, append and insert return > no result because the change occurs within an existing object - if you > were to return a reference to the changed object, it would be the same > reference as the one you already had.

Re: Consistency in Python

2006-08-25 Thread Paul Boddie
Paul McGuire wrote: > > There's nothing wrong with returning self from a mutator. This was a common > idiom in Smalltalk (the syntax for this was "^self", which was probably the > most common statement in any Smalltalk program), and permitted the chaining > of property mutators into a single line,

Re: Best Practices for Python Script Development?

2006-08-25 Thread Nick Craig-Wood
metaperl <[EMAIL PROTECTED]> wrote: > high-quality scripts. I know about object-oriented programming and > application configuration and have spent 6 years doing professional > Perl but have decided that Python is the new choice of serious agile > developers. I was where you are a couple of ye

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread bearophileHUGS
Andre Meyer: > Is the test meaningful and are you surprised by the results? > I am, actually, because I would have assumed that attribute access > with an object should be faster because lookup can be precompiled. The results seem okay. Python is a dynamic language, object attributes (and methods,

Open Office and Python

2006-08-25 Thread F
Hello there! I'd like to load a .csv file to the Open Office spreadsheet from the command line using an arbitrary delimiter through Python. I don't need any fancy formatting and stuff like that, just putting the values in the spreadsheet will do. Is there a relatively simple way to do that? S

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Peter Otten
Andre Meyer wrote: > Hi all > > I was wondering about the performance comparison of either using a > dictionary or an object for a large collection of "things". Therefore > I have run the attached test. I create a dictionary and an object. > Both get the same number of items/attributes, respectiv

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Fredrik Lundh
Andre Meyer wrote: > Is the test meaningful and are you surprised by the results? surprised by the amount of code you needed to test this, at least. and you might wish to use the proper spelling for v = self.obj.__getattribute__(a) which is v = getattr(obj, a)

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Andre Meyer
Good points! It's always good to learn from the pros! So, what it means is that the test is not meaningful, because of the different way that object attributes are accessed (not as o.x, which could be compiled). Nevertheless, the general impression remains that dicts *are* faster than objects, be

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Fredrik Lundh
Peter Otten wrote: > $ python -m timeit -s'class A(object): pass' -s 'a = A(); a.alpha = 42' > 'a.__getattribute__("alpha")' > 100 loops, best of 3: 0.674 usec per loop also: timeit -s "class A(object): pass" -s "a = A(); a.alpha = 42" "a.__getattribute__('alpha')" 100 loops,

Re: Consistency in Python

2006-08-25 Thread Brendon Towle
Date: 25 Aug 2006 04:22:37 -0700From: "Paul Boddie" <[EMAIL PROTECTED]>Subject: Re: Consistency in PythonTo: python-list@python.orgMessage-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset="iso-8859-1"Paul McGuire wrote: But with mutators that return self, a client could write any of these:b

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Fredrik Lundh
Andre Meyer wrote: > So, what it means is that the test is not meaningful, because of the > different way that object attributes are accessed (not as o.x, which > could be compiled). correct, but you may be overestimating what the compiler can do. here's the byte code for the various cases: #

django's view.py as class not just methods

2006-08-25 Thread Skink
Hi, I'm relatively new to django and maybe my question is stupid, but... Is it possible to map in urls.py some url not to function in views.py (which has first argument with HttpRequest) but to some class method? In that case each instance of such class would be created when session starts and fo

Re: Consistency in Python

2006-08-25 Thread Fredrik Lundh
Brendon Towle wrote: > So, my question is: Someone obviously thought that it was wise and > proper to require the longer versions that I write above. Why? a) maybe they had a working carriage return key ? b) http://pyfaq.infogami.com/why-doesn-t-list-sort-return-the-sorted-list (this also exp

Re: Open Office and Python

2006-08-25 Thread Simon Brunning
On 8/25/06, F <[EMAIL PROTECTED]> wrote: > I'd like to load a .csv file to the Open Office spreadsheet from the command > line using an arbitrary delimiter through Python. I don't need any fancy > formatting and stuff like that, just putting the values in the spreadsheet > will do. Have you looked

Re: Open Office and Python

2006-08-25 Thread Ben Sizer
F wrote: > I'd like to load a .csv file to the Open Office spreadsheet from the command > line using an arbitrary delimiter through Python. I don't need any fancy > formatting and stuff like that, just putting the values in the spreadsheet > will do. > > Is there a relatively simple way to do that?

Re: Python-like C++ library

2006-08-25 Thread catalin . marinas
Will McGugan wrote: > I'm forced to use C++ and STL at work, and consequently miss the ease > of use of Python. I was wondering if there was a C++ library that > implemented the fundamental objects of Python as close as possible, > perhaps using STL underneath the hood. Not copying Python but it h

random writing access to a file in Python

2006-08-25 Thread Claudio Grondi
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain unchanged). How can I do that in Python? Claudio Grondi -- http://mail.python.org/mailman/listinfo/pyt

Re: Is this a bug of module struct?

2006-08-25 Thread Grant Edwards
On 2006-08-25, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Before I was bitten by the difference below, I think these two > ways are the same. However, they are not. As is explained here: http://www.python.org/doc/current/lib/module-struct.html > Is there any geek who can tell me if this is

Re: random writing access to a file in Python

2006-08-25 Thread Tim Peters
[Claudio Grondi] > I have a 250 Gbyte file (occupies the whole hard drive space) Then where is Python stored ;-)? > and want to change only eight bytes in this file at a given offset of appr. > 200 > Gbyte (all other data in that file should remain unchanged). > > How can I do that in Python? S

Re: Best Practices for Python Script Development?

2006-08-25 Thread Ant
> `Pydoc `_ seems to be > built around modules and I want to document scripts. Any python script *is* a python module. So pydoc is what you are after here. > Version Control > === Subversion and Trac are a very good combination - Trac is

Re: Python and STL efficiency

2006-08-25 Thread Ray
Neil Cerutti wrote: > I don't see why it should run a lot faster that way. > > Appending elements to a vector with push_back takes amortized > constant time. In the example above, preallocating 4 strings > saves (probably) math.log(4, 2) reallocations of the vector's > storage along with t

How to handle wrong input in getopt package in Python?

2006-08-25 Thread Daniel Mark
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect input D:\>python AddArrowOnImage.py --imageDi Traceback (most recent call last): File "AddArrowOnImage.py", li

Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread Aahz
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >Andre Meyer: >> >> Is the test meaningful and are you surprised by the results? >> I am, actually, because I would have assumed that attribute access >> with an object should be faster because lookup can be precompiled. > >The results see

Re: Best Practices for Python Script Development?

2006-08-25 Thread skip
>> `Pydoc `_ seems to be >> built around modules and I want to document scripts. Ant> Any python script *is* a python module. So pydoc is what you are Ant> after here. Assuming you name your scripts so that they are importable (e.g. "

Re: all ip addresses of machines in the local network

2006-08-25 Thread Ognjen B
Amit Khemka wrote: > On 23 Aug 2006 21:46:21 -0700, damacy <[EMAIL PROTECTED]> wrote: > >> hi, sandra. >> >> no, it's not as complicated as that. all i want to do is to load a >> database onto different machines residing in the same network. i hope >> there is a way doing it. or perhaps i have a

Re: random writing access to a file in Python

2006-08-25 Thread Claudio Grondi
Tim Peters wrote: > [Claudio Grondi] > >> I have a 250 Gbyte file (occupies the whole hard drive space) > > > Then where is Python stored ;-)? > >> and want to change only eight bytes in this file at a given offset of >> appr. 200 >> Gbyte (all other data in that file should remain unchanged).

Re: sum and strings

2006-08-25 Thread Paul Rubin
Bryan Olson <[EMAIL PROTECTED]> writes: > And herein is the problem: A class may implement "__add__" any > way the programmer chooses. Python should require, or at least > document requirements, on further properties of addition. Python > should insist that addition be symmetric an transitive, and

Re: Python and STL efficiency

2006-08-25 Thread Neil Cerutti
On 2006-08-25, Ben Sizer <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-08-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > It will run a lot faster if it doesn't have to keep resizing >> > the array. >> >> I don't see why it should run a lot faster that way. >> >> Appending eleme

Re: lazy arithmetic

2006-08-25 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Simon Forman wrote: > > But that's a function, not a class. When you assign add to an > > attribute of Item it "magically" becomes a method of Item: > > Yes, I am looking to understand this magic. > Sounds like I need to dig into these descriptor thingies (again). >

Re: How to handle wrong input in getopt package in Python?

2006-08-25 Thread skip
Daniel> getopt.GetoptError: option --imageDir requires argument Which is precisely what the getopt module should do. Daniel> Is there any method in getopt or Python that I could easily Daniel> check the validity of each command line input parameter? Getopt already did the validity c

Re: performance of dictionary lookup vs. object attributes

2006-08-25 Thread Duncan Booth
Fredrik Lundh wrote: >> I am, actually, because I would have assumed that attribute access >> with an object should be faster because lookup can be precompiled. > > huh? you're using a reflection API; there's no way the compiler can > figure out in advance what you're going to pass to getattr().

Re: sum and strings

2006-08-25 Thread Neil Cerutti
On 2006-08-25, Paul Rubin wrote: > Bryan Olson <[EMAIL PROTECTED]> writes: >> And herein is the problem: A class may implement "__add__" any >> way the programmer chooses. Python should require, or at least >> document requirements, on further properties of addition. >> Python should insist that a

Re: Consistency in Python

2006-08-25 Thread Brendon Towle
Message: 3 Date: Fri, 25 Aug 2006 15:28:46 +0200 From: "Fredrik Lundh" <[EMAIL PROTECTED]> Subject: Re: Consistency in Python Brendon Towle wrote: So, my question is: Someone obviously thought that it was wise and proper to require the longer versions that I write above. Why? a) maybe they had a

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread Gabriel Genellina
At Friday 25/8/2006 11:34, Aahz wrote: >The results seem okay. Python is a dynamic language, object attributes >(and methods, etc) are kept inside a dict, where you can add and remove >them when you like. So using a dict is faster. >You can also take a look at __slots__ Taking a look at __slots_

Re: sum and strings

2006-08-25 Thread Paul Rubin
Neil Cerutti <[EMAIL PROTECTED]> writes: > So there isn't, it seems, a practical way of implementing the > sum(list of strings) -> ''.join(list of strings optimization. ''.join may not be the right way to do it, but obviously there are other ways. This isn't rocket science. -- http://mail.python

Re: soap comlex data to plain xml

2006-08-25 Thread Chris Lambacher
You would probably get more responses on the pywebsvcs mailing list http://pywebsvcs.sf.net SOAP goes over HTML, so you can use httplib to do what you want. Just go look up the protocol details (hint use Google). You will probably want to use ZSI or SOAPpy to serialize the request body to xml f

Creating an executable installer on Windows

2006-08-25 Thread Bernard Lebel
Hello, I'd like to know how one can create a Windows installer executable. I have this bunch modules, html files, pictures and directories that I'd like to install in various places on a disk drive. When the executable is run, it's like pretty much any standard installation: user answers a few que

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread skip
Aahz> Taking a look at __slots__ is fine as long as you don't actually Aahz> use them. Gabriel> Why? http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=st&q=Python+__slots__+aahz&rnum=2#f4ac2dfde32b16fd Skip -- http://mail.pyt

Re: sum and strings

2006-08-25 Thread Bryan Olson
Paul Rubin wrote: > Are you saying "abc"+"def" should not be concatenation? I guess > that's reasonable. No, I'm definitely not saying that, or at least I didn't mean that. > As long as + is string concatenation though, the > principle of least astonishment suggests that "sum" should > conconca

Re: Creating an executable installer on Windows

2006-08-25 Thread Larry Bates
Bernard Lebel wrote: > Hello, > > I'd like to know how one can create a Windows installer executable. I > have this bunch modules, html files, pictures and directories that I'd > like to install in various places on a disk drive. When the executable > is run, it's like pretty much any standard ins

Re: Consistency in Python

2006-08-25 Thread Terry Reedy
  "Brendon Towle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... Message: 3 Date: Fri, 25 Aug 2006 15:28:46 +0200 From: "Fredrik Lundh" <[EMAIL PROTECTED]> Subject: Re: Consistency in Python Brendon Towle wrote: [snip]   Please pos

time.clock() going backwards??

2006-08-25 Thread Giovanni Bajo
Hello, I experimented something very strange, a few days ago. I was debugging an application at a customer's site, and the problem turned out to be that time.clock() was going "backwards", that is it was sometimes (randomically) returning a floating point value which was "less than" the value retu

Re: RE Module

2006-08-25 Thread Roman
Thanks for your help. A thing I didn't mention is that before the statement row[0] = re.sub(r'<.*?>', '', row[0]), I have row[0]=re.sub(r'[^ 0-9A-Za-z\"\'\.\,[EMAIL PROTECTED](\)\*\&\%\%\\\/\:\;\?\`\~\<\>]', '', row[0]) statement. Hence, the line separators are going to be gone. You mentioned th

Re: sum and strings

2006-08-25 Thread Paddy
Paddy wrote: <> > Why not make sum work for strings too? > > It would remove what seems like an arbitrary restriction and aid > duck-typing. If the answer is that the sum optimisations don't work for > the string datatype, then wouldn't it be better to put a trap in the > sum code diverting stri

Re: time.clock() going backwards??

2006-08-25 Thread Michiel Sikma
Op 25-aug-2006, om 16:13 heeft Giovanni Bajo het volgende geschreven: > Hello, > > Is it possible this to be a bug in Python itself > (maybe, shooting at the moon, in the conversion between the 64bit > performance > counter and the floating point representation returned by time.clock > ()), or

get a line of text from a socket...

2006-08-25 Thread KraftDiner
If you don't know how long your input data is going to be how can you at least treat it a text line at a time... like looking for new line in the data... Right now recv blocks. Yes I could do a select, but the examples seem a bit complicated for a simple line oriented input... -- http://mail.py

Re: time.clock() going backwards??

2006-08-25 Thread K.S.Sreeram
Giovanni Bajo wrote: > Hello, > > I experimented something very strange, a few days ago. I was debugging an > application at a customer's site, and the problem turned out to be that > time.clock() was going "backwards", that is it was sometimes (randomically) > returning a floating point value whi

Re: get a line of text from a socket...

2006-08-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, KraftDiner wrote: > If you don't know how long your input data is going to be how can you > at least treat it a text line at a time... like looking for new line in > the data... Right now recv blocks. Yes I could do a select, but the > examples seem a bit complicated for

namespace problems

2006-08-25 Thread Kiran
Hi all, I am trying to get the following to work, but cant seem to do it the way i want to. ok, so I come into python and do the following: >>> x = 1 then, i have a file called test.py in which i say: print x Now, after having defined x =1 in the python interpreter, i come in and say: import te

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Fuzzyman wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would ke

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Duncan Booth wrote: > lazaridis_com wrote: > > > Are ther alternative constructs/mechanism available, which could be > > used to add this functionality possiby directly to a code-module? > > How about something along these lines: > > -- auto.py - > import sys, atexit > > de

ANN: DMetaph.py An implementation of the Double Metaphone algorithm

2006-08-25 Thread Timothy Grant
Hello everyone, I recently had a need to do some work with fuzzy matches, so I ported Lawrence Philips DMetaph class from C++ to Python. This is currently pretty much a line for line port of his his C++ code. It is not very pythonic at all. Because it is SO ugly, I'm not yet making it available

Re: get a line of text from a socket...

2006-08-25 Thread Jean-Paul Calderone
On 25 Aug 2006 09:37:09 -0700, KraftDiner <[EMAIL PROTECTED]> wrote: >If you don't know how long your input data is going to be how can you >at least treat it a text line at a time... like looking for new line in >the data... Right now recv blocks. Yes I could do a select, but the >examples seem

Re: Best Editor

2006-08-25 Thread crystalattice
JAG CHAN wrote: > Friends, I am trying to learn Python. > It will be of great help to me if you let me know which one would be best > editor for learning Python. > Plese note that I would like to have multiplatform editor which will be > useful for both LInux and Windows XP. > Thanks. My choice i

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread bearophileHUGS
Aahz wrote: > Taking a look at __slots__ is fine as long as you don't actually use them. I remember the recent discussion about such matters... but I don't understand its dangers fully still. I assume __slots__ may be removed in Python 3.0, but maybe "experts" need it now an then. Or maybe a "expe

Re: couple more questions about sqlite

2006-08-25 Thread Preston Hagar
It looks like most of your questions have been answered, but I might also suggest the APress book on SQLite: http://www.amazon.com/gp/product/1590596730/sr=8-2/qid=1142277203/ref=pd_bbs_2/002-3764084-7189633?%5Fencoding=UTF8***MAJOR DISCLAIMER: I was the technical reviewer on this book.***The book

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-25 Thread lazaridis_com
Larry Bates wrote: > lazaridis_com wrote: > > I would like to change the construct: > > > > if __name__ == '__main__': > > > > to something like: > > > > if exec.isMain(): > > > > My (OO thought) is to place a class in an separate code module and to > > instantiate an singleton instance which would

[Q] About an Installer Script for PyWin

2006-08-25 Thread Mr. Roboto
I need PyWin under the covers, that is, to install it as part of an application, but in such a way that it isn't visible to users. I'm concerned about a so-called "power-user", seeing the Python directory and/or the corresponding entry in the 'Add/Remove Programs' list, breaking my app by uninstal

Re: telnetlib thread-safe?

2006-08-25 Thread Jerry
Great, thanks for the info. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Q] About an Installer Script for PyWin

2006-08-25 Thread Larry Bates
Mr. Roboto wrote: > I need PyWin under the covers, that is, to install it as part of an > application, but in such a way that it isn't visible to users. I'm > concerned about a so-called "power-user", seeing the Python directory > and/or the corresponding entry in the 'Add/Remove Programs' list, >

Re: django's view.py as class not just methods

2006-08-25 Thread Rob Wolfe
Skink <[EMAIL PROTECTED]> writes: > Hi, > > I'm relatively new to django and maybe my question is stupid, but... > > Is it possible to map in urls.py some url not to function in views.py > (which has first argument with HttpRequest) but to some class method? > In that case each instance of such cl

wxPython and Py2exe crashes in "window" mode but not in "console" mode

2006-08-25 Thread Jerry
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=['myscript.py']) in my setup.py file, the resulting application runs just fine. But when I change it to setup(windows=['myscript.py']) The application crashes without any indication of what hap

Re: When is a subclass not right?

2006-08-25 Thread David Ells
Chaz Ginger wrote: > I was writing some code that used someone else class as a subclass. He > wrote me to tell me that using his class as a subclass was incorrect. I > am wondering under what conditions, if ever, does a class using a > subclass not work. > > Here is an example. For instance the ori

Duck typing alows true polymorfisim

2006-08-25 Thread atbusbook
lets say you want a generic numerical algorithom like sum Ruby def sum lst lst.inject(0){|total,current| total*current} end Java // i dont know if there is a numeric super class for numbers class Sum{ public static int sum(int[] lst){ int total = 0; for(int current : lst){ tot

Re: When is a subclass not right?

2006-08-25 Thread David Ells
Carl Banks wrote: > > I think it's kind of a fine point. In my own code I've had cases where > I've switched from subclass to attribute and back over the development, > and vice versa. I think there are many cases where it's preferable to > use an attribute, but not really wrong to subclass (and

Drag and Drop with PyQt4

2006-08-25 Thread Harshad
Hi, I'm writing a program using Python 2.4 and PyQt4. The aim is to implement drag and drop from filesystem and display a list of files dragged on to the listWidget. This function will later become part of a software for workflow management. When I run the program, DragEnterEvent works as expecte

Re: RE Module

2006-08-25 Thread tobiah
Roman wrote: > I am trying to filter a column in a list of all html tags. > > To do that, I have setup the following statement. > > row[0] = re.sub(r'<.*?>', '', row[0]) The regex will be 'greedy' and match through one tag all the way to the end of another on the same line. There are more comple

Re: Python and STL efficiency

2006-08-25 Thread Pebblestone
I tested in Common Lisp and compared the result with python. My PC is: 3.6GH Pentium4 My OS is: Ubuntu 6.06 i386 My lisp implementation is SBCL 0.9.8 for i386 My python's version is: V2.4.3 Both implementations were installed via apt-get install. Here's my Lisp program: +

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: > lets say you want a generic numerical algorithom like sum > > Ruby > > def sum lst > lst.inject(0){|total,current| total*current} > end > > Java // i dont know if there is a numeric super class for numbers > > class Sum{ > public static int sum(int[] lst){ > int t

Re: List comparison help please

2006-08-25 Thread Simon Forman
Bucco wrote: > Simon Forman wrote: > > > 1) Don't use "dir", "file", and "list" as variable names, those are > > already python built in objects (the dir() function, list type, and > > file type, respectively.) > > Thanks. My own stupidity on this one. > > > > 2) 'r' is the default for open(), omi

  1   2   >