Re: question about xmlrpc server: returning a list of lists to a Java client?

2006-10-22 Thread fortepianissimo
fortepianissimo wrote: > I have a simple xmlrpc server/client written in Python, and the client > throws a list of lists to the server and gets back a list of lists. > This runs without a problem. > > I then wrote a simple Java xmlrpc client and it calls the python > server.

question about xmlrpc server: returning a list of lists to a Java client?

2006-10-22 Thread fortepianissimo
I have a simple xmlrpc server/client written in Python, and the client throws a list of lists to the server and gets back a list of lists. This runs without a problem. I then wrote a simple Java xmlrpc client and it calls the python server. But I can't figure out what type to cast the result (of t

Re: Using python code from Java?

2006-07-20 Thread fortepianissimo
Diez B. Roggisch wrote: > fortepianissimo schrieb: > > Is there a solution to enable Java programmers to call functions > > written in Python? Any wrapper generator that wraps Python code into > > some Java-callable form? > > > > I briefly looked at Jython, but if

Using python code from Java?

2006-07-20 Thread fortepianissimo
Is there a solution to enable Java programmers to call functions written in Python? Any wrapper generator that wraps Python code into some Java-callable form? I briefly looked at Jython, but if I understand it right, it didn't support full power of Python 2.3.x (which I need). Any suggestion is w

Re: Package organization: where to put 'common' modules?

2006-03-06 Thread fortepianissimo
Kent Johnson wrote: > Paul Boddie wrote: > > Yes, Python does this - it puts the directory of bar.py (B in this > > case) in sys.path, but not the directory in which you're sitting when > > you run the program from the shell (A in this case). > > This seems to be OS dependent. If I put 'print sys.

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread fortepianissimo
Paul Boddie wrote: > fortepianissimo wrote: > > Hm this doesn't work. Say I have the following directory structure: > > > > A > > |--- util > > ||--- foo.py > > | > > |--- B > > |--- bar.py > > > > > > And bar.py

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread fortepianissimo
Interesting - Python seems to act differently under Windows then. Here I'm using Python 2.4 on Mac OS X. With all of the files, directories and command exactly like yours, it's still not working. One thing I noticed is that you have this 'C:\\WUTemp\\A' when you print sys.path in B/bar.py, but min

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread fortepianissimo
Hm this doesn't work. Say I have the following directory structure: A |--- util ||--- foo.py | |--- B |--- bar.py And bar.py has this line from util import foo I then run python B/bar.py in directory A. Still got error ImportError: No module named util A check of sys.path in bar

Re: Package organization: where to put 'common' modules?

2006-03-03 Thread fortepianissimo
Ok I guess a little more "hunch" might be needed to elicit suggestions. If I chose to put foo in A, is there a way for code in B to import foo from A? Namely, is there a way to import stuff from a parent directory/package? If it's not possible without changing sys.path, what's the path of least ef

Package organization: where to put 'common' modules?

2006-03-03 Thread fortepianissimo
Say I have the following package organization in a system I'm developing: A |B |C |D I have a module, say 'foo', that both package D and B require. What is the best practice in terms of creating a 'common' package that hosts 'foo'? I want to be able to - Testing modules in

Re: Komodo IDE: '__file__' is not defined when debugging

2006-01-03 Thread fortepianissimo
Thank you very much for the prompt reply and the patch - I applied it and everything is well now. Looking forward to the update! -- http://mail.python.org/mailman/listinfo/python-list

Komodo IDE: '__file__' is not defined when debugging

2006-01-03 Thread fortepianissimo
This is a question to all of you who use Komodo IDE for development: when I tried to debug my script which uses __file__ to get the absolute path to the file, Komodo complained that the variable is not defined. Anyway to work around this? (without changing the code) Or if I need to change the cod

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
To be complete, the first code snippet, when modified as follows, works fine in Python 2.4.2: --- START --- #!/usr/bin/env python import copy class Foo (object): __slots__ = ('i', ) def __init__ (self): self.i = 10 class Bar (Foo): __slots__ = ('j', ) def __init__ (self): supe

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
Mystery solved - when there's only one slot I should've used __slots__ = ('i', ). Duh! So in short, __slots__ and copy.copy() work fine in Python 2.4.2. -- http://mail.python.org/mailman/listinfo/python-list

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
More weird observations: the following code does not work until you change the name of the member 'longer' to a one-char name, for example, 'j': --- START --- #!/usr/bin/env python import copy class Foo (object): __slots__ = 'i' class Bar (Foo): __slots__ = 'longer' #__slots__ = 'j'

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
I should've mentioned this was tested on Python 2.4.2. fortepianissimo wrote: > I remember from painful experience that copy.copy() won't really copy > __slots__ members. But I have trouble explaning why the following code > works: > > --- START--- > #!/usr/bi

__slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
I remember from painful experience that copy.copy() won't really copy __slots__ members. But I have trouble explaning why the following code works: --- START--- #!/usr/bin/env python import copy class Foo (object): __slots__ = 'i' def __init__ (self): self.i = 10 class Bar (Foo): _

Re: Computing class variable on demand?

2005-02-05 Thread fortepianissimo
Thanks Steve - actually my question was simpler than that. I just wanted to use Daniels' recipe of lazy initialization on objects with __slots__: class Lazy(object): def __init__(self, calculate_function): self._calculate = calculate_function def __get__(self, obj, _=None):

Re: Computing class variable on demand?

2005-02-03 Thread fortepianissimo
Thank you so much about this useful tip! I learned the new decorator feature of 2.4 simply because of your post. Unfortunately I don't have luxury right now to run Python 2.4 (for what I'm doing anyways). You mentioned the way to do decorator in 2.3. Still I have a question here. Here is Scott Dav

Re: Computing class variable on demand?

2005-02-03 Thread fortepianissimo
This seems to be what I need. My use case is to do lengthy intialization as late as possible. In this case this is to initialize class variables. Does this make sense? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Computing class variable on demand?

2005-02-02 Thread fortepianissimo
We all know that using __getattr__() we can compute an instance variable on demand, for example: class Foo: def __getattr__ (self, name): if name == 'bar': self.bar = 'apple' return self.bar else: raise AttributeError() Then we can f = Foo() s1 = f.bar s2 = f.bar # this uses the "cached" resul

Re: Example of resolving an alias using Carbon.File module?

2005-01-21 Thread fortepianissimo
Problem solved: from Carbon.File import * fs, _, _ = ResolveAliasFile('/some/path', 1) print fs.as_pathname() -- http://mail.python.org/mailman/listinfo/python-list

Example of resolving an alias using Carbon.File module?

2005-01-20 Thread fortepianissimo
This is a question only relevant to Mac OS X. Could someone offer a simple example how to use Carbon.File module (perhaps Alias.FSResolveAlias()?) to resolve an alias? Basically I'd like to load in an alias file and find out which file/directory the alias points to. Thanks a lot! -- http://mail.