Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread Michele Simionato
On Feb 8, 8:15 pm, Thomas Heller <[EMAIL PROTECTED]> wrote: > I agree with most of the posters is this thread that it is confusing to spread > the definition of a class over several places or files. > > But, there are cases where the trick come in handy - when classes are created > not by class sta

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread Thomas Heller
Ziga Seilnacht schrieb: > Thomas Heller wrote: >> >> Do you have a pointer to that post? >> > > I think that he was refering to this post: > http://mail.python.org/pipermail/python-list/2006-December/416241.html > > If you are interested in various implementations there is also this: > http://mai

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread J. Clifford Dyer
Martin v. Löwis wrote: > I'm happy to announce partial 1.0; a module to implement > partial classes in Python. It is available from > > http://cheeseshop.python.org/pypi/partial/1.0 > > A partial class is a fragment of a class definition; > partial classes allow to sp

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread Michele Simionato
On Feb 8, 4:05 pm, [EMAIL PROTECTED] wrote:> > Composition is great when you know how largish classes are going to be > composed ahead of time and/or already have the pieces available in the form > of other classes you want to reuse. I use this fragment-by-multiple- > inheritance (I hesitate to ca

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread skip
Michele> That is a common design, but I don't like it, since it becomes Michele> very easy to get classes with dozens of methods inherited from Michele> everywhere, a modern incarnation of the spaghetti-code Michele> concept. I find it much better to use composition, i.e. to Mi

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread Michele Simionato
On Feb 8, 1:04 pm, [EMAIL PROTECTED] wrote: > greg> When I want to do this, usually I define the parts as ordinary, > greg> separate classes, and then define the main class as inheriting > greg> from all of them. > > Agreed. Maybe it's just my feeble brain, but I find this the most > c

Re: Partial 1.0 - Partial classes for Python

2007-02-08 Thread skip
greg> When I want to do this, usually I define the parts as ordinary, greg> separate classes, and then define the main class as inheriting greg> from all of them. Agreed. Maybe it's just my feeble brain, but I find this the most compelling (and easy to understand) use for multiple in

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread greg
> Martin v. Löwis schrieb: > >>A partial class is a fragment of a class definition; >>partial classes allow to spread the definition of >>a class over several modules. When I want to do this, usually I define the parts as ordinary, separate classes, and then define the

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Ziga Seilnacht
Thomas Heller wrote: > > Do you have a pointer to that post? > I think that he was refering to this post: http://mail.python.org/pipermail/python-list/2006-December/416241.html If you are interested in various implementations there is also this: http://mail.python.org/pipermail/python-list/2006-A

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Thomas Heller
Carl Banks schrieb: > On Feb 7, 10:17 am, "Carl Banks" <[EMAIL PROTECTED]> wrote: >> On Feb 7, 8:51 am, Thomas Heller <[EMAIL PROTECTED]> wrote: >> >> >> >> > Martin v. Löwis schrieb: >> >> > > I'm happy to an

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Carl Banks
On Feb 7, 10:48 am, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > > Martin v. Löwis schrieb: > > > > I'm happy to announce partial 1.0; a module to implement > > > partial classes in Python. It is available from > > > >http://cheeses

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Michele Simionato
> Martin v. Löwis schrieb: > > > > > I'm happy to announce partial 1.0; a module to implement > > partial classes in Python. It is available from > > >http://cheeseshop.python.org/pypi/partial/1.0 > > > A partial class is a fragment of a class defi

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Carl Banks
On Feb 7, 10:17 am, "Carl Banks" <[EMAIL PROTECTED]> wrote: > On Feb 7, 8:51 am, Thomas Heller <[EMAIL PROTECTED]> wrote: > > > > > Martin v. Löwis schrieb: > > > > I'm happy to announce partial 1.0; a module to implement > >

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Carl Banks
On Feb 7, 8:51 am, Thomas Heller <[EMAIL PROTECTED]> wrote: > Martin v. Löwis schrieb: > > > I'm happy to announce partial 1.0; a module to implement > > partial classes in Python. It is available from > > >http://cheeseshop.python.org/pypi/partial/1.0 &g

Re: Partial 1.0 - Partial classes for Python

2007-02-07 Thread Thomas Heller
Martin v. Löwis schrieb: > I'm happy to announce partial 1.0; a module to implement > partial classes in Python. It is available from > > http://cheeseshop.python.org/pypi/partial/1.0 > > A partial class is a fragment of a class definition; > partial classes allow to sp

Partial Classes - Aspects

2006-07-29 Thread Dr. Peer Griebel
anage the complexity I implemented some sort of aspect oriented programming (perhaps aspect oriented programming is not quite right in this context...). That is I implemented a mechanism to dynamically add methods to existing classes. This is similar to the thread "Partial classes" discuss

Re: Partial classes

2006-07-20 Thread Bruno Desthuilliers
Stefan Behnel wrote: > Kay Schluehr wrote: > >>What about letting your teammates editing certain data-structures in >>different files ( physical modules ) but using them in a uniform way >>and enable a single access point. If you have partial classes there is >>

Re: Partial classes

2006-07-19 Thread Stefan Behnel
Kay Schluehr wrote: > What about letting your teammates editing certain data-structures in > different files ( physical modules ) but using them in a uniform way > and enable a single access point. If you have partial classes there is > no reason why your team has to share a large fil

Re: Partial classes

2006-07-19 Thread Sanjay
> Anyway, I would suggest you NOT to use this code in production. Yes, > Python > can imitate Ruby, but using this kind of classes would confuse > everybody and > make your code extremely unpythonic. As always, consider changing your > mindset, > when you switch language. For you problem, you could

Re: Partial classes

2006-07-19 Thread Michele Simionato
Sanjay ha scritto: > Thanks for the code showing how to implement partial classes. Infact, I > was searching for this code pattern. I will have a study on metaclass > and then try it. > > Thanks > Sanjay Anyway, I would suggest you NOT to use this code in production. Yes,

Re: Partial classes

2006-07-19 Thread Rob Williscroft
a meta class? >> >> >> From my experience with C#, the only real use for partial classes is >> when you want to separate your GUI code from the rest of your logic. > > What the ... is GUI code doing in a domain object ??? It doesn't (shouldn't) really wo

Re: Partial classes

2006-07-19 Thread John Salerno
Bruno Desthuilliers wrote: > John Salerno wrote: >> Marc 'BlackJack' Rintsch wrote: >> >>> Can you flesh out your use case a little bit and tell why you can't solve >>> the problem with inheritance or a meta class? >> >> From my experien

Re: Partial classes

2006-07-19 Thread Sanjay
> > Class PersonBO(Person): > > def Block(): > > blocked = True > > > shouldn't it be: > class PersonBO(Person): > def block(self): > self.blocked = True > Yes, it should be as you mentioned. However, I had posted it to elaborate the case. Actually, I tested using the follow

Re: Partial classes

2006-07-19 Thread Kay Schluehr
John Salerno wrote: > Marc 'BlackJack' Rintsch wrote: > > > Can you flesh out your use case a little bit and tell why you can't solve > > the problem with inheritance or a meta class? > > From my experience with C#, the only real use for partial classes

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
Sanjay wrote: >>Can you flesh out your use case a little bit and tell why you can't solve >>the problem with inheritance or a meta class? > > > I have to study about metaclass and see whether this can be handled. It > seemed inheritence is not working. > > PROBLEM: Separating plumbing code and b

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
John Salerno wrote: > Marc 'BlackJack' Rintsch wrote: > >> Can you flesh out your use case a little bit and tell why you can't solve >> the problem with inheritance or a meta class? > > > From my experience with C#, the only real use for partial class

Re: Partial classes

2006-07-19 Thread John Salerno
Marc 'BlackJack' Rintsch wrote: > Can you flesh out your use case a little bit and tell why you can't solve > the problem with inheritance or a meta class? From my experience with C#, the only real use for partial classes is when you want to separate your GUI code from t

Re: Partial classes

2006-07-19 Thread [EMAIL PROTECTED]
Kay Schluehr wrote: > This definition lacks a check for disjointness of the parts. No two > partial classes shall contain a method with the same name. Yes - I mentioned at the bottom that the last one evaluated will overwrite any existing one. You're right that its probably a bet

Re: Partial classes

2006-07-19 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > Sanjay wrote: > > Hi All, > > > > Not being able to figure out how are partial classes coded in Python. > > > > Example: Suppose I have a code generator which generates part of a > > business class, where as the custome part is

Re: Partial classes

2006-07-19 Thread Sanjay
Thanks for the code showing how to implement partial classes. Infact, I was searching for this code pattern. I will have a study on metaclass and then try it. Thanks Sanjay -- http://mail.python.org/mailman/listinfo/python-list

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
Kay Schluehr wrote: > Bruno Desthuilliers wrote: > >>Sanjay wrote: >> >>>Hi Alex, >>> >>>Thanks for the input. >>> >>>Being new to Python, and after having selected Python in comparison to >>>ruby (Turbogears vs Rails) , is jerks me a bit. In my openion it should >>>be an obvious and easy to imple

Re: Partial classes

2006-07-19 Thread [EMAIL PROTECTED]
Sanjay wrote: > Hi All, > > Not being able to figure out how are partial classes coded in Python. > > Example: Suppose I have a code generator which generates part of a > business class, where as the custome part is to be written by me. In > ruby (or C#), I divide the code

Re: Partial classes

2006-07-19 Thread Kay Schluehr
Bruno Desthuilliers wrote: > Sanjay wrote: > > Hi Alex, > > > > Thanks for the input. > > > > Being new to Python, and after having selected Python in comparison to > > ruby (Turbogears vs Rails) , is jerks me a bit. In my openion it should > > be an obvious and easy to implement feature and must

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
Sanjay wrote: > Hi Alex, > > Thanks for the input. > > Being new to Python, and after having selected Python in comparison to > ruby (Turbogears vs Rails) , is jerks me a bit. In my openion it should > be an obvious and easy to implement feature and must be, if not already > have been, planned in

Re: Partial classes

2006-07-19 Thread Sanjay
> Can you flesh out your use case a little bit and tell why you can't solve > the problem with inheritance or a meta class? I have to study about metaclass and see whether this can be handled. It seemed inheritence is not working. PROBLEM: Separating plumbing code and business logic while using S

Re: Partial classes

2006-07-19 Thread Peter Otten
Sanjay wrote: > Hi All, > > Not being able to figure out how are partial classes coded in Python. > > Example: Suppose I have a code generator which generates part of a > business class, where as the custome part is to be written by me. In > ruby (or C#), I divide the code

Re: Partial classes

2006-07-19 Thread Daniel Dittmar
Sanjay wrote: > Hi All, > > Not being able to figure out how are partial classes coded in Python. > > Example: Suppose I have a code generator which generates part of a > business class, where as the custome part is to be written by me. In > ruby (or C#), I divide the code

Re: Partial classes

2006-07-19 Thread Dave Benjamin
On Wed, 18 Jul 2006, Sanjay wrote: > What is the equivalent in Python? Inheriting is a way, but is not > working in all scenerios. Have you tried multiple inheritance? For example: from GeneratedPerson import GeneratedPerson from HandcraftedPerson import HandcraftedPerson class Person(Generated

Re: Partial classes

2006-07-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Sanjay wrote: > Being new to Python, and after having selected Python in comparison to > ruby (Turbogears vs Rails) , is jerks me a bit. In my openion it should > be an obvious and easy to implement feature and must be, if not already > have been, planned in future releases

Re: Partial classes

2006-07-19 Thread Sanjay
Hi Alex, Thanks for the input. Being new to Python, and after having selected Python in comparison to ruby (Turbogears vs Rails) , is jerks me a bit. In my openion it should be an obvious and easy to implement feature and must be, if not already have been, planned in future releases of Python. W

Re: Partial classes

2006-07-18 Thread Kay Schluehr
Sanjay wrote: > Hi All, > > Not being able to figure out how are partial classes coded in Python. > > Example: Suppose I have a code generator which generates part of a > business class, where as the custome part is to be written by me. In > ruby (or C#), I divide the code

Re: Partial classes

2006-07-18 Thread alex23
Sanjay wrote: > Not being able to figure out how are partial classes coded in Python. Hi Sanjay, To the best of my knowledge, Python currently has no support for partial classes. However, BOO (http://boo.codehaus.org/) - which is a Python-like language for the .NET CLI)- _does_ support part

Partial classes

2006-07-18 Thread Sanjay
Hi All, Not being able to figure out how are partial classes coded in Python. Example: Suppose I have a code generator which generates part of a business class, where as the custome part is to be written by me. In ruby (or C#), I divide the code into two source files. Like this