Re: python class methods identity?

2007-11-23 Thread Roc Zhou
t;> id(y.var) 11228488 >>> id(x.func) 14430976 >>> id(y.func) 14433656 >>> On Nov 23, 2007 3:29 PM, Roc Zhou <[EMAIL PROTECTED]> wrote: > Hello, > > I'm now being confused by this segment of code: > >>> class Test: > ... var = 1 >

python class methods identity?

2007-11-22 Thread Roc Zhou
Hello, I'm now being confused by this segment of code: >>> class Test: ... var = 1 ... def func(self): pass ... >>> x = Test() >>> y = Test() >>> x.var is y.var True >>> x.func is y.func False >>> id(x.var); id(y.var) 146132400 146132400 >>> id(x.func); id(y.func) -1208243388 -1208243388

What about a Python Tree container?

2007-11-06 Thread Roc Zhou
Hello, Recently I'm working on a new data structure written in python: Tree, by operator overloading. I want it can act as a builtin type, such as list and dict, but do something like a tree, to make those things need trees can be more convenient. For example, 1. to create a Tree, there are sever

Re: A near realtime fs mirror application (for backup, written in Python, by Linux inotify)

2007-10-30 Thread Roc Zhou
Now I meet a strange problem. After the first sync init, it enters to the realtime replication state. I deployed them on 3 machines, and have run near half month. Suddenly one day, a host, I don't know what's wrong, I found fs_mirror get the empty records from its mirrord agent. In normal conditio

"realtime" fs mirror application (backup, Python and Linux inotify)

2007-10-24 Thread Roc Zhou
Recently I started an open source project "cutils" on the sourceforge: http://sourceforge.net/projects/crablfs/ The document can be found at: http://crablfs.sourceforge.net/#ru_data_man This project's mirrord/fs_mirror tool is a near realtime file system mirroring application across 2 or more

A near realtime fs mirror application (for backup, written in Python, by Linux inotify)

2007-10-21 Thread Roc Zhou
Hello: Recently I started an open source project "cutils" on the sourceforge: http://sourceforge.net/projects/crablfs/ The document can be found at: http://crablfs.sourceforge.net/#ru_data_man This project's mirrord/fs_mirror tool is a near realtime file system mirroring application across 2

Fwd: Pyinotify : which user ?

2007-10-18 Thread Roc Zhou
-- Forwarded message -- From: Roc Zhou <[EMAIL PROTECTED]> Date: Oct 19, 2007 12:48 AM Subject: Re: Pyinotify : which user ? To: Sébastien Weber <[EMAIL PROTECTED]> The command lsof or fuser can report who is using the file, maybe you can have a look at their source co

Re: A near realtime file system mirror application written in Python

2007-10-18 Thread Roc Zhou
mirrord/fs_mirror makes use of inotify, which is a functionality afforded by the recent Linux (from 2.6.12). It is a counterpart of FAM, since Linux FAM has stopped so long. On 10/17/07, Roc Zhou <[EMAIL PROTECTED]> wrote: > > Hello: > > Recently I started an open source proje

A near realtime file system mirror application written in Python

2007-10-16 Thread Roc Zhou
Hello: Recently I started an open source project "cutils" on the sourceforge: https://sourceforge.net/projects/crablfs/ The document can be found at: http://crablfs.sourceforge.net/#ru_data_man This project's mirrord/fs_mirror is a near realtime file system mirroring application across 2 or more

A new data structrue in python: Tree

2007-07-03 Thread Roc Zhou
Recently I tried to create a new data structure in python: Tree, by operator overloading. I want it can act as a builtin type, such as list and dict. Luckily the basic definition has been finished now, the document is in the code and unittest. And I have put the HTML doc at: http://crablfs.source

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
I'm sorry but I still have a question, look at this example: >>> class test: ... def __init__(self): ... self.x = 1 ... def __getattr__(self, attr_name): ... print attr_name ... if attr_name == 'y': ... return 2 ... else: ... raise Att

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
return hex(id(self)) On 6 22 , 1 48 , Roc Zhou <[EMAIL PROTECTED]> wrote: > I know what's wrong. Thank you. And I think > try: > return self.__dict__[attr_name] > is unnecessary, because python will do it itself for us. > > So now I have to overload __str__, bu

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
12 55 , "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 22 Jun 2007 00:30:43 -0300, Roc Zhou <[EMAIL PROTECTED]> > escribió: > > > Now I have to design a class that overload __getattr__, but after > > that, I found the __repr__ have been affected.

gettext and __doc__ for class methods?

2007-06-21 Thread Roc Zhou
from gettext import gettext as _ __doc__ = _("""module docstrings""") class test: __doc__ = _("""class docstrings""") def __setattr__(self, attr_name, value): _("""class method docstrings""") But I found when the module and class docstrings take effect(must use __doc__ to specify i

why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
Now I have to design a class that overload __getattr__, but after that, I found the __repr__ have been affected. This is a simple example model: #!/usr/bin/env python class test: def __init__(self): self.x = 1 def __getattr__(self, attr_name): try: return self.__dic

why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
Now I have to design a class that overload __getattr__, but after that, I found the __repr__ have been affected. This is a simple example model: #!/usr/bin/env python class test: def __init__(self): self.x = 1 def __getattr__(self, attr_name): try: return self._

why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
Now I have to design a class that overload __getattr__, but after that, I found the __repr__ have been affected. This is a simple example model: #!/usr/bin/env python class test: def __init__(self): self.x = 1 def __getattr__(self, attr_name): try: return self._

__repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Roc Zhou
Now I have to design a class that overload __getattr__, but after that, I found the __repr__ have been affected. This is a simple example model: #!/usr/bin/env python class test: def __init__(self): self.x = 1 def __getattr__(self, attr_name): try: return self.