Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Torsten Mohr
Hello, > There is no package needed to read or write the new open document files. > The files are merely a jar archive containing XML files. You can open > and update them using jar as a subprocess and manipulate the XML files > using your favorite XML libraries DOM/SAX/XPath/Etree/etc. thanks f

Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread Torsten Mohr
Hi, i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? Best regards, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: deriving from array.array

2010-01-26 Thread Torsten Mohr
Hello, thanks a lot for your hint, it works fine. >> I get an error for "a = Abc(4, 5)", seems the parameters are >> forwarded to array's __init__ as they are. > > No, with CPython they're forwarded to __new__. Not sure if i understand this correctly, if i derive from other classes (like wxpyth

deriving from array.array

2010-01-26 Thread Torsten Mohr
Hello, i try to derive a class from array.array: import array class Abc(array.array): def __init__(self, a, b): array.array.__init__(self, 'B') self.a = a self.b = b a = Abc(4, 5) print a print a.a I get an error for "a = Abc(4, 5)", seems the parameters are forw

test if an input string starts with a python expression

2009-12-07 Thread Torsten Mohr
Hi, i'd like to test if an input string starts with a python expression and also where that expression ends. An example: a_func(3*7, '''abc''') +5 pls some more The first part until (inclusive) the 5 should be found as an expression and the length of that string should also be detected. Backg

nested structure with "internal references"

2009-09-25 Thread Torsten Mohr
Hi, sorry for posting in german before, that was a mistake. I'd like to use a nested structure in memory that consists of dict()s and list()s, list entries can be dict()s, other list()s, dict entries can be list()s or other dict()s. The lists and dicts can also contain int, float, string, ... B

Python und Referenzen auf Variablen?

2009-09-25 Thread Torsten Mohr
Hallo, ich möchte im Speicher eine verschachtelte Struktur aufbauen in der dict()s und list()s verwendet werden und tief ineinander verschachtelt sind. D.h. mehrere lists und dicts können jeweils wieder lists und dicts enthalten. Ich möchte als Einträge hauptsächlich int, float und string verwen

iterate over list while changing it

2009-09-24 Thread Torsten Mohr
Hello, a = [1, 2, 3, 4, 5, 6] for i, x in enumerate(a): if x == 3: a.pop(i) continue if x == 4: a.push(88) print "i", i, "x", x I'd like to iterate over a list and change that list while iterating. I'd still like to work on all items in that list, which is n

Windows, CreateThread

2009-09-07 Thread Torsten Mohr
Hi, in a python C module i may need to create a Thread to do some background observations / calculations. Are there any problems with Python doing something like this? Is there some special support on sharing data? I guess i can't call any Python functions from the thread, correct? Thanks fo

Noddy with submodules?

2009-09-07 Thread Torsten Mohr
Hi, i want to write a Python module that interfaces a DLL that we use in the office to do some measurement. So i'd like to write a python module in C (which i did before some times). But i'm not sure how i can create a module in a way that i can later do: import measurement import measurement.

Reference or Value?

2009-02-22 Thread Torsten Mohr
Hi, how is the rule in Python, if i pass objects to a function, when is this done by reference and when is it by value? def f1(a): a = 7 b = 3 f1(b) print b => 3 Integers are obviously passed by value, lists and dicts by reference. Is there a general rule? Some common formulation? Thank

Re: Plugin system, RuntimeWarning: Parent module 'ext_abc' not found while handling absolute import

2009-01-26 Thread Torsten Mohr
Hello, >> Basically, this here works but gives a warning: >> RuntimeWarning: Parent module 'ext_abc' not found while handling >> absolute import > > >> here = os.path.abspath('.') > > (Unrelated to the main question, but you probably want to use > os.path.dirname(os.path.abspath(__file__)) inst

Plugin system, RuntimeWarning: Parent module 'ext_abc' not found while handling absolute import

2009-01-25 Thread Torsten Mohr
Hi, i try to write a plugin system that i want to use to let users extend a module that i write. Within the module there is an extension loader that loads an extension module. This extension module should be able to import modules from my system, which provides some extensions. Basically, this

Re: structuring a package?

2009-01-05 Thread Torsten Mohr
Hello James, >> That way i'd have to structure the code like this: >> >> graphic/ >> __init__,py (GraphicObject) >> square.py (Square) >> circle.py (Circle) >> >> Does that make sense like this? > > This seems perfectly acceptable. Thanks for that hint. Do you see a way that i could write i

structuring a package?

2009-01-04 Thread Torsten Mohr
Hi, i have a question on how to structure a package best, would be great if anybody could give me some hint on this: Assuming i have a base class GraphicObject and derived from that some classes like Square, Circle, ... It looks natural to me to write in a code that uses the package: import gra

Package / Module Hierarchy question

2009-01-04 Thread Torsten Mohr
Hi, in a package i use these files: module (dir) __init__.py submodule __init__.py qwe.py qwe.py defines a class that derives from a class defined in submodule (and by that in submodule/__init__.py. Is it possible somehow to write in qwe.py to import submodule (though __init__.py

parse C expression?

2008-12-15 Thread Torsten Mohr
Hi, i found some examples when googling for the subject but nothing really matched. Is there a standard module available that lets me parse a syntax like "C" with numbers, operators, braces, variables and function calls? I'd like to use this to parse an own kind of configuration language and pre

Re: package structure?

2008-12-14 Thread Torsten Mohr
>> I wonder how i can make AClass() known in that package. >> > > Why don't you put the contents of smod1.py in mod/smod1/__init__.py? > It'll work this way. Of course, thanks for that hint. Best regards, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

package structure?

2008-12-14 Thread Torsten Mohr
Hi, in a package i'd like to have a structure like this: Files end with ".py", others are directories: mod __init__.py # sets __all__ = ['smod1'] smod1.py # contains AClass() smod1 __init__.py # sets __all__ = ['abc', 'def'] abc.py def.py So i can now do: i

Re: optparse

2008-09-16 Thread Torsten Mohr
Hi, > If i call it without any parameters i get: > > opts {'verb': 'store_false'} > args [] If i call it with parameter -v i get: ./script.py -v opts {'verb': True} args [] I wonder what's wrong here. Best regards, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

optparse

2008-09-16 Thread Torsten Mohr
Hi, i use the module optparse to parse the command line: --example #! /usr/bin/python import optparse parser = optparse.OptionParser() parser.add_option("-v", "--verbose", dest = 'verb', help = 'be loud', action = 'store_true',

Re: new style classes, __new__, __init__

2008-09-16 Thread Torsten Mohr
Hello, > This way __new__ is not called, if i remove __init__ then > there are too many parameters to __new__, if i add a parameter > to __new__ then it says that __new__ does not take arguments. I just found an article that describes it better, this example works: class C2(object): def __ne

new style classes, __new__, __init__

2008-09-16 Thread Torsten Mohr
Hi, i have some questions related to new style classes, they look quite useful but i wonder if somebody can give me an example on constructors using __new__ and on using __init__ ? I just see that when using it i can't give parameters to __new__ and when i additionally define __init__ then __new_

create PyString

2008-07-18 Thread Torsten Mohr
Hi, in an extension module i'd like to create a very large PyString. As the string is very large i'd first like to create the string and let Python allocate the space for it and then fill it from my code. But the only interface that i can find in Python/stringobject.h is: PyAPI_FUNC(PyObject *)

import hook, overwrite import?

2005-01-25 Thread Torsten Mohr
Hi, is there some description available to overwrite the import hook? By googling i found out so far that i need to overwrite __builtins__.__import__ with something else. Can i also do this with a C function that is provided when using an embedded python interpreter? So my own C program provide

extension module, thread safety?

2005-01-17 Thread Torsten Mohr
Hi, i write an extension module in C at the moment. This module does some work on some own data types that consist of some values. The functions that can change the data are written in C. The question came up if this is by itself thread safe, if some two or more threads try to change these data

supplying constants in an extension module

2005-01-17 Thread Torsten Mohr
Hi, i write an extension module in C at the moment. I want to define some constants (integer mainly, but maybe also some strings). How do i do that best within this extension module in C? Do i supply them as RO attributes? What's the best way for it? Thanks for hints, Torsten. -- http://ma

Py_Object* Py_BuildValue, Py_INCREF necessary?

2005-01-17 Thread Torsten Mohr
Hi, when i write an extension module in C and return a Py_Object* that i've built with Py_BuildValue, do i need to use Py_INCREF on that before i return it to python from my extension module or not? Thanks for hints, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: reference or pointer to some object?

2005-01-13 Thread Torsten Mohr
Hi, thank you all for your explanations. That's really great and helps me a lot. Thanks, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: reference or pointer to some object?

2005-01-13 Thread Torsten Mohr
Hi, > Could you give us a more concrete use case? My suspicion is that > anything complicated enough to be passed to a method to be modified will > probably be more than a simple int, float, str or tuple... In which > case, it will probably have methods to allow you to update it... yes, to be m

Re: reference or pointer to some object?

2005-01-12 Thread Torsten Mohr
Hi, thank you all for your explanations. I still wonder why a concept like "references" was not implemented in Python. I think it is (even if small) an overhead to wrap an object in a list or a dictionary. Isn't it possible to extend Python in a way to use real references? Or isn't that regard

reference or pointer to some object?

2005-01-10 Thread Torsten Mohr
Hi, i'd like to pass a reference or a pointer to an object to a function. The function should then change the object and the changes should be visible in the calling function. In perl this would be something like: sub func { $ref = shift; $$ref += 123; # change } $a = 1; func(\$a); is so

Referenz auf Variable an Funktion Ãbergeben?

2005-01-10 Thread Torsten Mohr
Hallo, ich mÃchte eine Funktion schreiben, der ich eine Referenz auf einen String Ãbergeben kann und die dann einige Ãnderungen am String vornimmt. In Perl wÃrde ich also ein \$string Ãbergeben und in der Funktion auf $$string zugreifen. Geht sowas auch in Python? Ich habe von "global" gelesen,

SuSE 9.1: updating to python-2.4

2005-01-09 Thread Torsten Mohr
Hi, along with my distribution SuSE 9.1 came python 2.3.3. I'd like to update to 2.4 now, is this an easy thing to do or will lots of installed modules refuse to work then? Is there an easy way to find out what i need to update? Thanks for any hints, Torsten. -- http://mail.python.org/mailma

Re: use a file as a database, access rights

2005-01-09 Thread Torsten Mohr
Hi, sorry for being unclear and thanks for your answers. Yes, i'd like to use a flat-file database AND access rights. One way i thought of would be to handle the access rights in the script that i write. But to let some other module handle it would also be great. If for example i could embed so

use a file as a database, access rights

2005-01-09 Thread Torsten Mohr
Hi, i'd like to write a script that makes use of a database. It would be great if the database would store all its data in a file, that would be great for data exchange. It would also be great if i could use SQL, as i have some experience in that. Also, i NEED access rights to certain parts of

Re: build a static executable program with python

2004-12-30 Thread Torsten Mohr
Hi Adal, can you send me your mail address? I think the one in your posting is a spam stopper. Cheers, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: build a static executable program with python

2004-12-30 Thread Torsten Mohr
Hi, thank you very much for that detailled description. I will try to get as far as i can with this information and get back to you if i have any questions. Thanks a lot, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: GUI with sophisticated Table support

2004-12-30 Thread Torsten Mohr
Hi, > Do a group-google search for *tkinter table*. That shows up quite a few > hits. thanks for that hint, but nearly every hit shows the Table of contents for Tkinter", which is not what i search for. My question here is rather in detail about Tkinters Table and if it can show resizable column

build a static executable program with python

2004-12-30 Thread Torsten Mohr
Hi, i'd like to build an executable file that is linked with a python library and executes a script via PyRun_SimpleString or similar functions. Is there a static library of python available, so the users don't need to install python? What about DLL modules, do i just need to compile them as a

GUI with sophisticated Table support

2004-12-30 Thread Torsten Mohr
Hi, i want to write an application where i need a Table to display some values. The table should display a list of objects, so to say, a column for each attribute of the object. I'd also like the user to be able to change the width of each column, like in Excel. I'd prefer to use Tkinter, but i

Re: where's "import" in the C sources?

2004-12-30 Thread Torsten Mohr
Hi David, thanks for the explanation. That is very helpful to me. Best regards, Torsten. David Bolen wrote: > Torsten Mohr <[EMAIL PROTECTED]> writes: > >> i tried to find the file and line in the C sources of python >> where the command "import" is im

where's "import" in the C sources?

2004-12-29 Thread Torsten Mohr
Hi, i tried to find the file and line in the C sources of python where the command "import" is implemented. Can anybody give me some hint on this? Thanks, Torsten. -- http://mail.python.org/mailman/listinfo/python-list