Re: Default function arguments, KURL::cleanPath() -- a bindings bug?

2005-03-08 Thread Frans Englich
Ups, that was meant to go to the pykde list. Sorry, Frans -- http://mail.python.org/mailman/listinfo/python-list

Default function arguments, KURL::cleanPath() -- a bindings bug?

2005-03-07 Thread Frans Englich
Hello, I've stumbled over a behavior related to default function arguments which appears to be a bug, from what I can tell. See this snippet: >>> from kdecore import KURL >>> u = KURL( "http://www.example.org/test/../"; ) >>> u.cleanPath() Traceback (most recent call last): File "", line 1,

Accessing files installed with distutils

2005-02-21 Thread Frans Englich
This is silly. How do I access data files I've installed with distutils? In a portable, generic way, I want to find out what is the following path on most systems: /usr/local/lib/python2.4/lib/site-packages/foo/bar.txt How do I figure out the rest, if I know foo/bar.txt? sys.prefix doesn't get

Distutils: relative paths

2005-02-19 Thread Frans Englich
Hello, I have trouble installing a data directory which is not a child of my package directory in the source directory. My source directory looks like this: ./setup.py schemas/*.xsd foo/*.py And when it's installed, it should look like: site-packages/foo/*.py site-packages/foo/schemas/*.xsd

Re: Kill GIL

2005-02-13 Thread Frans Englich
On Monday 14 February 2005 00:53, Aahz wrote: > In article <[EMAIL PROTECTED]>, Mike Meyer <[EMAIL PROTECTED]> wrote: > >[EMAIL PROTECTED] (Aahz) writes: > >> In article <[EMAIL PROTECTED]>, Mike Meyer <[EMAIL PROTECTED]> wrote: > >>>Here here. I find that threading typically introduces worse p

Hack with os.walk()

2005-02-12 Thread Frans Englich
Hello, Have a look at this recursive function: def walkDirectory( directory, element ): element = element.newChild( None, "directory", None ) # automatically appends to parent element.setProp( "name", os.path.basename(directory)) for root, dirs, files in os.walk( directory ):

What's wrong with `is not None`?

2005-02-08 Thread Frans Englich
That's what PyChecker tells me, at least. A line of: if testReport is not None: results in: runner.py:587: Using is not None, may not always work In what circumstances can `is not None` fail? How and why does it fail? What is the equivalent expression which is more secure; `!= None`? Chee

Re: Python's idiom for function overloads

2005-02-01 Thread Frans Englich
On Tuesday 01 February 2005 05:02, Steven Bethard wrote: > Frans Englich wrote: > > But in Python, when one wants to be able to pass different data types > > into a single "entry point" for functionality, how is that best done? To > > in a function do an if sta

Re: variable declaration

2005-01-31 Thread Frans Englich
On Tuesday 01 February 2005 05:08, Cameron Laird wrote: > We learned long ago to treat you, Alex, as an exception. > While it's rather unpythonic to have implicit rules, let's > forgive Robert for failing to mention the one that regards > you as an outlier for inferential purposes. Excellent timi

Python's idiom for function overloads

2005-01-31 Thread Frans Englich
Hello, Since Python doesn't have static typing, how is the same result as traditional function overloads results in acheived? With function overloads the "selection of code path depending on data type" is transparent and automatic since the typing system figure out what goes to what. But in P

Re: Inherting from object. Or not.

2005-01-26 Thread Frans Englich
On Wednesday 26 January 2005 21:24, M.E.Farmer wrote: > Hello Frans, > What you are seeing is a step on the path to unification of types and > classes. I changed all base classes in my project to inherit object. There appears to be no reason to not do it, AFAICT. Thanks, Frans

Inherting from object. Or not.

2005-01-26 Thread Frans Englich
(Picking up a side track of the "python without OO" thread.) On Wednesday 26 January 2005 11:01, Neil Benn wrote: > I say this because you do need to be aware of the > 'mythical python wand' which will turn you from a bad programmer into a > good programmer simply by typing 'class Klass(object):

Re: python without OO

2005-01-26 Thread Frans Englich
On Wednesday 26 January 2005 18:55, Terry Reedy wrote: > Your Four Steps to Python Object Oriented Programming - vars, lists, dicts, > and finally classes is great. It makes this thread worthwhile. I saved it > and perhaps will use it sometime (with credit to you) to explain same to > others. I

Re: Distutils: blurring the file==module borders

2005-01-24 Thread Frans Englich
On Tuesday 25 January 2005 02:17, Bill Mill wrote: > read this thread, it should help you: > > http://mail.python.org/pipermail/tutor/2005-January/035124.html Thanks, it did. Not optimally, but in the way I suspected it would be solved. In short, the solution, when translated to my case, is to in

Distutils: blurring the file==module borders

2005-01-24 Thread Frans Englich
Hello all, Due to the size of my source, I want to split it up into multiple files(basically one class in each file), but then I have difficulties with the directory layout when the modules are installed with distutils. This is my file layout: in ./ I have a setup.py which has 'packages="foo"

Re: What is print? A function?

2005-01-23 Thread Frans Englich
On Sunday 23 January 2005 18:04, Michael Hoffman wrote: > Frans Englich wrote: [...] > if command_line_debug_option: > debug = _debug_true > else > debug = _debug_false I find this a nice solution. The most practical would be if it was possible to do this with print,

What is print? A function?

2005-01-23 Thread Frans Englich
Nah, I don't think it's a function, but rather a builtin "statement". But it's possible to invoke it as an function; print( "test" ) works fine. So I wonder, what _is_ exactly the print statement? The untraditional way of invoking it(without paranteses) makes me wonder. The reason I thinks abo

Re: Assigning to self

2005-01-17 Thread Frans Englich
On Monday 17 January 2005 21:24, Peter Otten wrote: > Frans Englich wrote: > > On Monday 17 January 2005 20:03, John Roth wrote: > >> "Frans Englich" <[EMAIL PROTECTED]> wrote in message > > > > > > > >> In other words, you're try

Re: Assigning to self

2005-01-17 Thread Frans Englich
On Monday 17 January 2005 20:03, John Roth wrote: > "Frans Englich" <[EMAIL PROTECTED]> wrote in message > In other words, you're trying to create a singleton. In general, > singletons are frowned on these days for a number of reasons, > not least because

Re: Assigning to self

2005-01-17 Thread Frans Englich
On Monday 17 January 2005 20:55, Frans Englich wrote: > On Monday 17 January 2005 19:02, Peter Otten wrote: > > Frans Englich wrote: > > > What the code attempts to do is implementing a, to the API user, > > > transparent memory-saver by ensuring that no more than one

Re: Assigning to self

2005-01-17 Thread Frans Englich
On Monday 17 January 2005 19:02, Peter Otten wrote: > Frans Englich wrote: > > What the code attempts to do is implementing a, to the API user, > > transparent memory-saver by ensuring that no more than one instance of > > the class foo exists for a particular id. E.g

Re: Assigning to self

2005-01-17 Thread Frans Englich
On Monday 17 January 2005 18:45, Frans Englich wrote: > The line 'self = me'(scary..) doesn't really > work for the attribute attr; the attribute exists on line 21, but it fails > when yo() tries to access it. Typo; line 21 is yo(). I ment line 18, the print stateme

Assigning to self

2005-01-17 Thread Frans Englich
Hello, I am having trouble with throwing class instances around. Perhaps I'm approaching my goals with the wrong solution, but here's nevertheless a stripped down example which demonstrates my scenario: #--

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread Frans Englich
On Wednesday 12 January 2005 18:56, [EMAIL PROTECTED] wrote: > I can not break the original code in 2.4, if I try this: [...] > > So although the dictionary solution is much nicer nothing seems wrong > with your code as it is - or am I missing something? Nope, the current code works. I'm just lo

Refactoring; arbitrary expression in lists

2005-01-12 Thread Frans Englich
As continuation to a previous thread, "PyChecker messages", I have a question regarding code refactoring which the following snippet leads to: > > runner.py:200: Function (detectMimeType) has too many returns (11) > > > > The function is simply a long "else-if" clause, branching out to > > diffe

PyChecker messages

2005-01-10 Thread Frans Englich
Hello, I take PyChecker partly as an recommender of good coding practice, but I cannot make sense of some of the messages. For example: runner.py:878: Function (main) has too many lines (201) What does this mean? Cannot functions be large? Or is it simply an advice that functions should be sm

Documenting data members

2005-01-08 Thread Frans Englich
Hello, I have a custom module which among others contains a dictionary, acting as a "constant". I want to document it, but no matter what I do, it doesn't show up in `pydoc`. For example, the following doesn't work: """ A dictionary of the namespaces. """ xmlns = { ... } or xmlns = { """ A d

Re: A completely silly question

2004-12-17 Thread Frans Englich
On Friday 17 December 2004 16:40, Amir Dekel wrote: > This must be the silliest question ever: > > What about user input in Python? (like stdin) > Where can I find it? I can't find any references to it in the > documentation. See sys.stdin Cheers, Frans -- http://mail.python.or

Re: Time Difference

2004-12-17 Thread Frans Englich
On Friday 17 December 2004 15:40, Fredrik Lundh wrote: > "GMane Python" <[EMAIL PROTECTED]> wrote: > > I was wondering if there is an existing function that would let me > > determine the difference in time. To explain: > > > > Upon starting a program: > > > > startup = time.time() > > > > After

Re: getopt: Make argument mandatory

2004-12-16 Thread Frans Englich
On Wednesday 15 December 2004 14:07, Diez B. Roggisch wrote: > > In my use of getopt.getopt, I would like to make a certain parameter > > mandatory. I know how to specify such that a parameter must have a value > > if it's specified, but I also want to make the parameter itself > > mandatory(combin

Re: libxml2/xpath

2004-12-16 Thread Frans Englich
On Thursday 16 December 2004 14:46, [EMAIL PROTECTED] wrote: > > # confDocument is a libxml2 document, from parseFile() etc > > xp = confDocument.xpathNewContext() > > xp.xpathRegisterNs("xhtml", "http://www.w3.org/1999/xhtml";) > > dirElement = xp.xpathEval( "/xhtml:html" ) > > Stu

Re: libxml2/xpath

2004-12-16 Thread Frans Englich
On Thursday 16 December 2004 12:29, Maxim Khesin wrote: > I do not believe it is... You can see the doc by clicking on the link. > Does it have to be? No, but your XPath statements must match the namespace, no matter what it is. The document do have a namespace -- as XHTML should: http://www.w3

Re: getopt: Make argument mandatory

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 20:12, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Frans Englich > > wrote: > > Hello, > > > > In my use of getopt.getopt, I would like to make a certain parameter > > mandatory. > > Isn't a *ma

Import trouble

2004-12-15 Thread Frans Englich
Hello all, I have a couple of questions related to module importing. 1) When I start my Python program with `python foo.py` instead of simply adding a interpreter comment on the first line and do `./foo.py`, some "local" imports fails, I guess because current working directory is different. I

Re: Python IDE

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 13:59, Chris wrote: > > Try WingIDE if you have some money (about 35 E/$ for the personal > > version) to spend, it's worth every (euro)cent. But please try SPE > > first, maybe that's enough for you. > > SPE? After googling for "python spe", my guess is "SPE - Stani'

Re: Import trouble

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 13:44, Craig Ringer wrote: > On Wed, 2004-12-15 at 21:45, Frans Englich wrote: > > 2) I use Python modules which are not usually installed(libxml2/libxslt) > > and want to fail gracefully in case the modules aren't available; print > > an

getopt: Make argument mandatory

2004-12-15 Thread Frans Englich
Hello, In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make the parameter itself mandatory(combined with a mandatory value, the result is that the user must spec

Re: KeyError

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 13:33, [EMAIL PROTECTED] wrote: > Hello. > Maybe someone will help me with this KeyError: > > > Traceback (most recent call last): > File "C:\Python\tabla.py", line 929, in -toplevel- > tablesDirectory = tablesDirectoryPrefix + os.env