Accessing 'Package Data'

2007-10-09 Thread Stefan Arentz
At http://docs.python.org/dist/node12.html it is described how to add package data to a module. This was pretty easy to do, but now how do I access this data from my module? Is there an API to load a 'package resource' ala Java's classloader? S. --

Mixing Python and C classes in a module

2007-10-09 Thread Stefan Arentz
Is it possible to mix classes defined in both Python and C in the same module? Ideally I would like to be able to do: from some.module import MyPythonClass, MyCClass I guess that would mean that this would look like this on disk: some/ __init__.py module.py (contains

Native class methods

2007-10-09 Thread Stefan Arentz
Is there an easy way to implement a specific method of a Python class in C? Like a native method in Java? I would really like to do the majority of my class code in Python and just do one or two methods in C. S. -- http://mail.python.org/mailman/listinfo/python-list

Re: Native class methods

2007-10-09 Thread Stefan Arentz
Chris Mellon [EMAIL PROTECTED] writes: On 09 Oct 2007 17:20:09 +0200, Stefan Arentz [EMAIL PROTECTED] wrote: Is there an easy way to implement a specific method of a Python class in C? Like a native method in Java? I would really like to do the majority of my class code in Python

Is there a nicer way to do this?

2007-10-04 Thread Stefan Arentz
Is there a better way to do the following? attributes = ['foo', 'bar'] attributeNames = {} n = 1 for attribute in attributes: attributeNames[AttributeName.%d % n] = attribute n = n + 1 It works, but I am wondering if there is a more pythonic way to do this. S. --

Re: Is there a nicer way to do this?

2007-10-04 Thread Stefan Arentz
Stefan Arentz [EMAIL PROTECTED] writes: Is there a better way to do the following? attributes = ['foo', 'bar'] attributeNames = {} n = 1 for attribute in attributes: attributeNames[AttributeName.%d % n] = attribute n = n + 1 It works, but I am wondering if there is a more

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-10 Thread Stefan Arentz
[EMAIL PROTECTED] (Alex Martelli) writes: Stefan Arentz [EMAIL PROTECTED] wrote: Miki [EMAIL PROTECTED] writes: steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ... steps.sort(key=attrgettr

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-09 Thread Stefan Arentz
Miki [EMAIL PROTECTED] writes: steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ... steps.sort(key=attrgettr(time)) Personally I prefer the anonymous function over attrgettr :) S. --

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Stefan Arentz
[EMAIL PROTECTED] writes: Hi there I am fairly new to Python and have not really used regular expressions before (I think this might be needed for my query) and wondered if you could help I have a step class and store in a list step instances A step instance contains variables: name,

Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Bruno Desthuilliers [EMAIL PROTECTED] writes: ... The problem with Java is that it makes it very painfull to bridge two APIs together, while Python usually makes it a breeze (easy delegation, no dumb-ass psycho-rigid type system). So Java's solution (hyper-formalization) isn't necessary

Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: On Thu, 06 Sep 2007 09:00:02 +0200, Stefan Arentz wrote: What I find really frustrating in Python (combined with usually bad documentation) is that many people have different styles. The most frustratinng being getFoo() vs .foo, vs

Re: How to do python and RESTful

2007-09-06 Thread Stefan Arentz
Michele Simionato [EMAIL PROTECTED] writes: On Sep 5, 9:54 pm, MarkyMarc [EMAIL PROTECTED] wrote: Hi all, I want to make a web service application in python and keywords are RESTful, python and nice urls(urls mapped to python objects). I don't want a big framework but a nice small

Queueing in Python (ala JMS)

2005-12-20 Thread Stefan Arentz
Is there a JMS-like API available for Python? I would like to quickly receive messages through the network and then process those slowly in the backgound. In the Java world I would simply create a (persistent) queue and tell the JSM provider to run N messagehandlers parallel. Is something like

Re: PYTHON LOOSING FOR JAVA???????

2005-11-09 Thread Stefan Arentz
Fcamattti [EMAIL PROTECTED] writes: Hello for everybody OH MY GOD!?!?!?!?!?!?! I BETTER FIND A NEW JOB!?!?!?!? S. -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-04 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: ... Ah yes. Well, good luck with that. You seem to have decided that it is not sane and who am I to argue with that. It depends on your state of mind :-) I can just say the opposite, that you seem to have decided that it is sane. I have. I like

Re: Class Variable Access and Assignment

2005-11-04 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: ... Would it be too much to ask that in a line like. x = x + 1. both x's would resolve to the same namespace? This is starting to look more like a nagging contest than a real discussion imo. Consider changing the semantics of what you are

Re: Class Variable Access and Assignment

2005-11-04 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: Op 2005-11-03, Mike Meyer schreef [EMAIL PROTECTED]: Antoon Pardon [EMAIL PROTECTED] writes: What would you expect to get if you wrote b.a = b.a + 2? I would expect a result consistent with the fact that both times b.a would refer to the same

Re: Class Variable Access and Assignment

2005-11-04 Thread Stefan Arentz
Paul Rubin http://[EMAIL PROTECTED] writes: Stefan Arentz [EMAIL PROTECTED] writes: Would it be too much to ask that in a line like. x = x + 1. both x's would resolve to the same namespace? ... Consider changing the semantics of what you are proposing and think about all those

shared library search path

2005-11-03 Thread Stefan Arentz
Hi. I've wrapped a C++ class with Boost.Python and that works great. But, I am now packaging my application so that it can be distributed. The structure is basically this: .../bin/foo.py .../lib/foo.so .../lib/bar.py In foo.py I do the following:

Re: How to read all files in a directory

2005-11-03 Thread Stefan Arentz
hungbichvo [EMAIL PROTECTED] writes: Dear All, My python application is small. It reads data from a file. My code is: fileName = '900128.DAT' dataFile = open(fileName, 'r').readlines() I have to run 100 input files .DAT. Each time I run application, I have to change code fileName

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]: There are two possible fixes, either by prohibiting instance variables with the same name as class variables, which would allow any reference to an instance of the class assign/read the

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Stefan Arentz
Stuart Turner [EMAIL PROTECTED] writes: Hi Everyone, I'm working hard trying to get Python 'accepted' in the organisation I work for. I'm making some good in-roads. One chap sent me the text below on his views of Python. I wondered if anyone from the group could give me some advice on

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Stefan Arentz
Stuart Turner [EMAIL PROTECTED] writes: I'm already using it for a ton of things - I want to try and get broader acceptance in the organisation for it to be made and 'officially supported product'. IMO that is what you need to communicate: 'already using it for a ton of things' and probably

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: ... No matter wat the OO model is, I don't think the following code exhibits sane behaviour: class A: a = 1 b = A() b.a += 2 print b.a print A.a Which results in 3 1 I find it confusing at first, but I do understand

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: Op 2005-11-03, venk schreef [EMAIL PROTECTED]: You see, The seen behavior is due to the result of python's name binding,scoping scheme. I know what causes the behaviour. But I still think it is not sane behaviour. ... the same

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: ... Fine, we have the code: b.a += 2 We found the class variable, because there is no instance variable, then why is the class variable not incremented by two now? Because it really is executed as: b.a = b.a + 2 1. get 't'b.a and store it

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Stefan Arentz [EMAIL PROTECTED] writes: Antoon Pardon [EMAIL PROTECTED] writes: ... Fine, we have the code: b.a += 2 We found the class variable, because there is no instance variable, then why is the class variable not incremented by two now? Because it really

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes: Op 2005-11-03, Stefan Arentz schreef [EMAIL PROTECTED]: Antoon Pardon [EMAIL PROTECTED] writes: ... Fine, we have the code: b.a += 2 We found the class variable, because there is no instance variable, then why is the class variable

Embedding Python in an embedded system

2005-11-01 Thread Stefan Arentz
Howdy. I'm looking at embedding python in a little embedded system. The device (a linksys wrt54g router, popular hack object since it runs linux), has limited resources. Just 4MB flash and 16MB memory. I'm interested in Python because I need to be more agile with developing an application for