dict.has_key(x) versus 'x in dict'

2006-12-06 Thread Paul Melis
Hello, I've always been using the has_key() method to test if a dictionary contains a certain key. Recently I tried the same using 'in', e.g. d = { ... } if k in d: ... and found that it seems to perform a lot better when lots of key-tests are to be performed. I also noticed that has_key() i

Re: dict.has_key(x) versus 'x in dict'

2006-12-06 Thread Paul Melis
Bjoern Schliessmann wrote: > Peter Otten wrote: > >> No, 'k in d' is equivalent to 'd.has_key(k)', only with less >> (constant) overhead for the function call. > > Ah, thx. Thought the "x in d" syntax might search in d.values() too. I don't think it does Python 2.4.3 (#1, Nov 19 2006, 13:16:36

Re: Python memory handling

2007-05-31 Thread Paul Melis
[EMAIL PROTECTED] wrote: > I will try later with python 2.5 under linux, but as far as I can see, > it's the same problem under my windows python 2.5 > After reading this document : > http://evanjones.ca/memoryallocator/python-memory.pdf > > I think it's because list or dictionnaries are used by t

Re: Help a C++ escapee!

2007-06-07 Thread Paul Melis
Hello, Simon Pickles wrote: > Can someone help me leave the murky c++ world and enter shiny pythonland? Welcome! > I have a problem with importing and global variables, here's my code: > > [...] > > When run, I come unstuck here: > >self.clientSocket, self.clientAddress = network.

Properties on old-style classes actually work?

2007-05-07 Thread Paul Melis
Hello, The python library docs read in section 2.1 (http://docs.python.org/lib/built-in-funcs.html): " ... property( [fget[, fset[, fdel[, doc) Return a property attribute for new-style classes (classes that derive from object). ... " But in 2.4 at least properties also seem

Re: Trying to choose between python and java

2007-05-15 Thread Paul Melis
Anthony Irwin wrote: > Hi All, > > I am currently trying to decide between using python or java and have a > few quick questions about python that you may be able to help with. > > #1 Does python have something like javas .jar packages. A jar file > contains all the program files and you can ex

Re: Splitting a quoted string.

2007-05-16 Thread Paul Melis
Paul Melis wrote: > Hi, > > mosscliffe wrote: > >> I am looking for a simple split function to create a list of entries >> from a string which contains quoted elements. Like in 'google' >> search. >> >> eg string = 'bob john "j

Re: Splitting a quoted string.

2007-05-16 Thread Paul Melis
Hi, mosscliffe wrote: > I am looking for a simple split function to create a list of entries > from a string which contains quoted elements. Like in 'google' > search. > > eg string = 'bob john "johnny cash" 234 june' > > and I want to have a list of ['bob', 'john, 'johnny cash', '234', > 'jun

Re: Python memory handling

2007-05-31 Thread Paul Melis
Hello, [EMAIL PROTECTED] wrote: > I've some troubles getting my memory freed by python, how can I force > it to release the memory ? > I've tried del and gc.collect() with no success. [...] > The same problem here with a simple file.readlines() > #Python interpreter memory usage : 1.1 Mb private

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 10, 8:23 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > However, it is not true that += "always leads to a rebinding of a to the > > result of the operation +". The + operator for lists creates a new list. > > += for lists does an in-place modification: > > It still is true. > > a +=

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 17, 10:00 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Oct 10, 8:23 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > >> rebinds a. Period. Which is the _essential_ thing in my post, because > >> this rebinding semantics are what confused the OP. > > > D

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 17, 11:08 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Curious, do you have the relevant section in the docs that describes > > this behaviour? > > Yes, but mostly by implication. In section 3.4.7 of the docs, the sentence > before the one you quoted says: > >

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 2:39 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > Simply not to introduce special cases I guess. If you write ``x.a += > > b`` then `x.a` will be rebound whether an `a.__iadd__()` exists or > > not. Otherwise one would get inter

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 3:20 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 17 Oct 2007 05:57:50 -0700, Paul Melis wrote: > > On Oct 17, 2:39 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > >> >>> class C(object): > > >>

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 3:41 pm, Paul Melis <[EMAIL PROTECTED]> wrote: > On Oct 17, 3:20 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > > > On Wed, 17 Oct 2007 05:57:50 -0700, Paul Melis wrote: > > > On Oct 17, 2:39 pm, Duncan Booth <

Re: Backslash frowned upon?

2008-05-13 Thread Paul Melis
[EMAIL PROTECTED] wrote: Why is the \ backslash character frowned upon? Can I still use it in Python 3.0 to achieve the same thing it was designed to do? Yes, it's still valid to use in a script. See http://docs.python.org/dev/3.0/whatsnew/3.0.html for the big changes coming with 3.0 Paul

Re: Shed my a light :)

2008-06-02 Thread Paul Melis
TheSaint wrote: On 19:06, lunedì 02 giugno 2008 Chris wrote: actions= ('print', 'sum', 'divide', 'myfunction') parameters=(5, 'nothing',5.63, object) 8< 8< getattr(...) getattr(object, name[, default]) -> value 8< 8< for nn in actions: func = getattr(cp, nn) if callable(func)

Re: SWIG (Python) - "no constructor defined" for concrete class

2008-04-21 Thread Paul Melis
Stodge wrote: > Yet another SWIG question (YASQ!). > > I'm having a problem with using an abstract base class. When > generating the Python bindings, SWIG thinks that all the concrete > classes that derive from this abstract class are abstract too and > won't create the correct constructor. > > A

Re: Does Python 2.5 include or not include SQLite engine?

2008-04-22 Thread Paul Melis
Hi, Diez B. Roggisch wrote: Dennis Lee Bieber schrieb: On Mon, 21 Apr 2008 19:05:46 -0400, [EMAIL PROTECTED] declaimed the following in comp.lang.python: I thought one of the major features of Python 2.5 was its embedded SQLite engine. No, just the inclusion of the adapter became stand

Re: Python Success stories

2008-04-22 Thread Paul Melis
azrael wrote: Which big aplications are written in python. I see its development, But i can't come up with a big name. I know that there are a lot of companys using python, but is there anythong big written only in python. I want him to fuck of with his perl once and for all time Not really "bi

Re: Problem building python in virtual machine running centos

2008-04-25 Thread Paul Melis
Paul Boddie wrote: On 25 Apr, 03:05, Alexandre Gillet <[EMAIL PROTECTED]> wrote: I am trying to build python-2.4.5 on Centos 5.1, which is a virtual machine running with xen. I am not able to build python. The compilation crash with the following: gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstric

Re: SWIG Python undefined reference

2008-04-29 Thread Paul Melis
Instead of manually trying to get all the options to gcc correct you might want to look at using distutils for compiling your extension. See the SWIG documentation, section 30.2.2 (http://www.swig.org/Doc1.3/Python.html#Python_nn6) Paul Soren wrote: Hi, I went through the SWIG tutorial for t

Re: Issue with regular expressions

2008-04-29 Thread Paul Melis
Julien wrote: Hi, I'm fairly new in Python and I haven't used the regular expressions enough to be able to achieve what I want. I'd like to select terms in a string, so I can then do a search in my database. query = ' " some words" with and "withoutquotes " ' p = re.compile(magic_reg

Re: Getting started with pyvtk

2008-05-01 Thread Paul Melis
On 1 mei, 22:54, Peter Pearson <[EMAIL PROTECTED]> wrote: > I'm trying to get started with pyvtk, the Python interface > to the Visualization Toolkit, It looks like you're using this package: http://cens.ioc.ee/projects/pyvtk/ These are not the official Python bindings to VTK, but seem to be an a

Re: Getting started with pyvtk

2008-05-02 Thread Paul Melis
Peter Pearson wrote: On Thu, 01 May 2008 16:45:51 -0500, Robert Kern <[EMAIL PROTECTED]> wrote: pyvtk is not the Python interface to VTK. It is for the creation of VTK files. The vtk(1) command is a Tcl shell with the VTK libraries loaded (I believe). Read the VTK documentation for information

PEP 370 question

2008-05-07 Thread Paul Melis
In (the recently accepted) PEP 370 it says "Current Python versions don't have a unified way to install packages into the home directory of a user (except for Mac Framework builds). Users are either forced to ask the system administrator to install or update a package for them or to use one of

Re: letter frequency counter / your thoughts..

2008-05-07 Thread Paul Melis
[EMAIL PROTECTED] wrote: Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated.. Not bad for a beginner I think :) def valsort(x): res = [] for key