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 the database.
Several people should work on it and NEED to have different
access rights.


Can anybody give me some recommendations on what to use?


Thanks for any hints,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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
some SQL database and tell it to store all its tables in
ONE FILE it would be quite easy to do.

I want to write that application cross-platform, at least
Win32 AND Linux.


Best regards,
Torsten.


> Torsten,
> 
> Please explain the environment you are planning to use - Operating
> System, whether you have full control of the machine that runs the
> database, how many users?.
> 
> If you are using Windows and if your needs are simple, you can use
> Access as it has some simple access control that  can be setup.
> 
> Also, the part about "database would store all its data in a file" is
> not very clear. Are you wanting to use a flat-file database and also
> have security implemented in it?  If you are on linux/*BSD machine,
> consider using a real database.
> 
> Fine access control can be implemented in your application (e.g. only
> the creator of a record and his/her superiors can edit it, all others
> view it)
> 
> Please send more details to receive useful recommendations.
> Thanks,
> --Kartic

-- 
http://mail.python.org/mailman/listinfo/python-list


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/mailman/listinfo/python-list


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, das scheint dem was ich suche am
nÃchsten zu kommen, allerdings trifft es das Problem auch nicht,
da ich von einer Unterfunktion aus eine Unterfunktion aufrufen
mÃchte, also tief verschachtelt.  Und global greift nach meinem
VerstÃndnis auf den ganz globalen Namensraum zu und nicht auf den
der aufrufenden Funktion.

Geht sowas vielleicht mit weakref?


Danke fÃr Tipps,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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 something like this possible in python?

The keyword "global" does NOT fit this purpose to
my understanding as it only makes the variables of
the UPPERMOST level visible, not the ones of ONE
calling level above.

Is this somehow possible with weakref?

I don't want to pass the parameter to a function and
then return a changed value.

Is there some other mechanism in python available to
achieve a behaviour like this?


Thanks for any hints,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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 regarded as necessary?


Thanks for any hints,
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 more explicit: I'm quite new to python and i wrote
a small function that does a hexdump of a string.  That string
can be quite large, so i suspected a large overhead when the
string would be copied and handed over to the function.

But i think my understanding was wrong (though it is not yet
clear).  If i hand over a large string to a function and the
function had the possibility to change it, wouldn't that mean
that it is necessary to hand over a _copy_ of the string?
Else, how could it be immutable?

Thinking about all this i came to the idea "How would i write
a function that changes a string with not much overhead?".

def func(s):
  change s in some way, remove all newlines, replace some
charaters by others, ...
  return s

s = func(s)

This seems to be a way to go, but it becomes messy if i hand over
lots of parameters and expect some more return functions.

Maybe it is because i did lots of perl programming, but

func(\$s) looks easier to me.

> In my case, rather than your original example, which you want to look
> something like:
> 
>  def func(x):
>  x += 123
> 
>  x = 5
>  func(x)
> 
> I'd just write:
> 
>  x = 5
>  x += 123

You're right, of course.  I'm sorry the second example is still
a bit constructed, but i came across it by writing the hexdump
utility and wanted to reduce overhead.


Best regards,
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


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


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://mail.python.org/mailman/listinfo/python-list


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 types,
are the C functions by themselves are "atomic" or can they
be interrupted be the perl interpreter and then (data types
are in some inconsistent half-changed state) another function
that works on these data is called?


Thanks for hints,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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
provides this and when linking with python.lib the function
is overwritten?

Or is there some extension hook?

Does this also handle "from module import *" not only the normal
"import module"?


Thanks for any hints,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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


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 implemented.  Can anybody give
>> me some hint on this?
> 
> Well, there are several levels, depending on what you are looking for.
> The literal "import" syntax in a source module is translated by the
> Python compiler to various IMPORT_* bytecodes, which are processed in
> the main interpreter loop (see ceval.c).
> 
> They all basically bubble down to making use of the builtin __import__
> method, which is obtained from the builtin module defined in
> bltinmodule.c.
> 
> That in turn makes use of the import processing module whose code can
> be found in import.c - which is the same source that also implements
> the "imp" module to provide lower layer access to to the import
> internals.
> 
> Now, when it comes to physically loading in a module, Python source
> and compiled modules are handled by import (well, not the compiling
> part), but dynamically loaded extension modules are OS specific.  You
> can find the handling of such extension modules in OS-specific source
> files dynload_*.c (e.g., dynload_win.c for Windows).
> 
> All of these files can be found in the dist/src/Python directory in
> the Python source tree.
> 
> -- David

-- 
http://mail.python.org/mailman/listinfo/python-list


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 think it can't do all
that.

Is there a way for Tkinter to handle this?

If not, what other GUI can do that? (wxPython?)


Thanks for hints,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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 static lib, link them together with my program and
call their init function?


What about python modules, can i just use a tool like
"freeze" or "py2exe" to break up the import hierarchy
and call them before my script?


Is there some more information about building a static
executable available?


Thanks for any hints,
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 columns tho easily display a list of objects.

I did not find any help searching for this with google, but i'd really
rather like to use Tkinter over wxPython, that's the background of the
question.

Thanks for your help anyway, sorry if my question was unclear.


Best regards,
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: 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


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 here works but gives a warning:
RuntimeWarning: Parent module 'ext_abc' not found while handling absolute import

Below are the files, i wonder what is wrong.

It would be great if anybody could give me a hint, what provokes that
warning?


Best regards,
Torsten.



FILE psys.py:
import mymodule.ext_loader
import sys
import os.path

here = os.path.abspath('.')
mpath = os.path.abspath('mymodule')
epath = os.path.abspath('extension')

sys.path.append(here)
sys.path.append(mpath)

mymodule.ext_loader.load('ext_abc')


FILE mymodule/__init__.py:
__all__ = ['base', 'ext_loader']


FILE mymodule/ext_loader.py:
import imp
import os.path


def search_file(fname):
for e in ['extension']:
candidate = os.path.join(os.path.expanduser(e), fname)

if os.path.exists(candidate):
return candidate

return None


def load(modname):
fname = modname + ".py"
abname = search_file(fname)
fd = open(abname, "rb")
mod = imp.load_module(fname, fd, abname, ['py', 'r', imp.PY_SOURCE])
fd.close()


FILE mymodule/base.py:
def func1():
print "func1 called !"


FILE extension/ext_abc.py:
import base

base.func1()

--
http://mail.python.org/mailman/listinfo/python-list


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__)) instead - the above just
> returns the current directory, which might not be the directory containing
> the module)

Thanks, i'll try that.

>> mpath = os.path.abspath('mymodule')
>> epath = os.path.abspath('extension')
>>
>> sys.path.append(here)
>> sys.path.append(mpath)
>>
>> FILE mymodule/__init__.py:
> 
> So mymodule is actually a package. Packages should *not* appear in
> sys.path.

Oh, how does it find modules then?  I thought that would be PYTHONPATH or
sys.path ?


Best regards,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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?


Thanks for any hints,
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:

import mod.smod1.abc
import mod.smod1


But functions/classes in smod1.py are not found:

a = mod.smod1.AClass()

I know this is somehow ambiguous, but i wonder how else i can make
"mod" have subpackages and modules.

I wonder how i can make AClass() known in that package.


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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


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 preferred would be just standard modules.  Is there something
available that is maybe based on shlex?


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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 is in the same directory as qwe.py ?

I'd like to keep the tests for qwe.py within qwe.py, the code that i want to
execute when i directly execute qwe.py and then:

if __name__ == '__main__':
some_test_code()


Or do i need to write an external test code?


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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 graphic
import graphic.square
import graphic.circle

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?

Are there better ways to structure things in Python?

One thing that bothers me is that when i write in circly.py something like
"import graphic", then i can't have the test code for the Circle within
circle.py, at least it looks to me like this.


The closest thing that handles this issue that i could find was PEP 328, but
it doesn't cover this problem.


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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 in circle.py:

circle.py:

import graphic

class Circle(graphic.GraphicObject):
.

if __name__ == '__main__':
abc = Circle()
abc.some_test_code()


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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 *) PyString_FromStringAndSize(const char *, Py_ssize_t);

But my extension module does not have the data consecutively in memory.

If i'd use this function i'd first have to allocate the data, construct the
string and then let python _again_ allocate the same amount of memory
and copy my data.


Is there a way to tell python to:
1. let python create a PyString with an allocated buffer
2. let my extension module fill the buffer
3. let python validate the strings hash value and whatever else is
necessary?


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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__ is not
called.

So i can use __new__ only for classes whose constructors don't
have parameters?


class C2:
def __new__(self):
print "new called"
self.a = 8

def __init__(self, a):
print "init called"
self.a = a

def fct(self):
print self.a


a = C2(7)
a.fct()


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.


Thanks for any hints,
Torsten.

--
http://mail.python.org/mailman/listinfo/python-list


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 __new__(cls, a):
obj = object.__new__(cls)
print "new called"
obj.a = 8

return obj

__new__ = staticmethod(__new__)


def __init__(self, a):
print "init called"
self.a = a

def fct(self):
print self.a


a = C2(7)
a.fct()


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',
  default = 'store_false')

(opts, args) = parser.parse_args()

print "opts", opts
print "args", args
--example

If i call it without any parameters i get:

opts {'verb': 'store_false'}
args []


I would rather like to see the actual value False in "opts",
did i use some wrong parameters somewhere?  I can't imagine
that this is the wanted behaviour of optparse.


Thanks for any hints,
Torsten.


--
http://mail.python.org/mailman/listinfo/python-list


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


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.


Background is that i want to embed some python expressions in a text
and i want to evaluate them later.
It is possible that the embedded expressions span several lines.

Alternatively, is it possible to define a start- and an end-marker
that define the embedded expression and find the expression using
a regular expression?
If the expression contains strings, these strings could contain
the end-marker which should not be found inside strings.

Example:

start: <
end:   >

< some_func(r">")>


Can anybody tell me how to do this best?

Can i do this using just modules from the python library?


Thanks for any hints,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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
forwarded to array's __init__ as they are.  Though i explicitly
call __init__() for array.

I'd like to use array and make sure it's type is always 'B'.
I'd like to derive because i don't want to rewrite all the methods like 
__getiem__ for my class and then call array's __getitem__.

How do i best derive from array.array?


Thanks for any hints,
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 wxpython widgets) i always call the bases __init__ .

>>  Though i explicitly
>> call __init__() for array.
> 
> That's the constructor inherited from 'object', it takes no args (except
> the self arg).

Is there a way to find out what i need to call?  I haven't found much in
the documentation.  From writing C extensions i knew about the "new" entry
in the PyTypeObject struct but it seems there's more behind it.
In docs.python.org i did not find much, is there an URL where i can read 
more?


Best regards,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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: 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 for your hint.  I was aware of that, OO files are a bunch of zipped 
XML files.  But, i searh for something more comfortable/highlevel that lets 
me just do things like doc.Cell(1, 3) = 'abc' or so.

> If that doesn't suit you, you can manipulate them using OO.org through its
> UNO interface; but, I find that much more involved then simply accessing
> the files directly.

Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and 
i'd like to base on something actual.


Best regards,
Torsten.

-- 
http://mail.python.org/mailman/listinfo/python-list


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.adc
import measurement.adc.channels
import measurement.pwm

What do i need to do to create submodules within the initialisation code
of a python module written in C?

Maybe there is an example based on "noddy"?


Thanks for any hints,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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 for any hints,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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 not happening
in the example above.
The conditions in the example are not real but much more complex
in reality.

Can anybody tell me how to do this?


Thanks for any hints,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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 verwenden, ich
muß aber auch Referenzen auf die anderen Einträge eintragen können,
die vom Programm anders behandelt werden müssen.

Die Schlüssel der dict()s werden sich vermutlich nicht mehr ändern
wenn sie einmal zugewiesen sind.
Die Indizes der list()s können sich zur Laufzeit allerdings schon ändern,
wenn z.B. aus einer list() ein Eintrag gelöscht wird.
Der nachfolgende Eintrag würde dann nachrücken und sich damit sein
Index ändern.

Wie könnte ich in so einer verschachtelten Struktur Referenzen abbilden?


Viele Grüße,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list


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, ...

But i'd also like to have something like a "reference" to another
entry.
I'd like to refer to another entry and not copy that entry, i need to
know later that this is a reference to another entry, i need to find
also access that entry then.

Is something like this possible in Python?

The references only need to refer to entries in this structure.
The lists may change at runtime (entries removed / added), so
storing the index may not help.


Thanks for any hints,
Torsten.


-- 
http://mail.python.org/mailman/listinfo/python-list