naveen wrote:
Is it possible to split up a class definition over multiple files?
Not exactly, but you can do variations of this:
... [subclass a class]
Multiple inheritance can also be useful:
# A_Part1.py
class A_Part1:
...
# A_Part2.py
class A_Part2:
...
# A.py
from A_Part1 impo
18-08-2009 o 06:58:58 Xavier Ho wrote:
On Tue, Aug 18, 2009 at 2:45 PM, naveen wrote:
Is it possible to split up a class definition over multiple files?
-
Answer in short, I don't think so.
Why not?
-
File a.py:
class MyClass:
def foo(self, x):
return x * 6
-
On Tue, Aug 18, 2009 at 1:57 AM, Steven
D'Aprano wrote:
> On Mon, 17 Aug 2009 21:45:57 -0700, naveen wrote:
>
>> Is it possible to split up a class definition over multiple files?
>
> Not exactly, but you can do variations of this:
>
>
> In file A.py, create:
>
> class Parent:
> def method(self)
> indicator of bad practice. What is the problem you're trying to solve?
> Ben Finney
No major problem.
I was just trying to make some experimental changes to autokey. My
repo: http://github.com/tinku99/autokey.git/
Didn't want to subclass or reorganize a class just yet.
--
http://mail.python.or
naveen writes:
> I guess I will just preprocess the script:
>
> cat partA.py > class.py
> cat partB >> class.py
> python class.py
>
This, to me, is a programming smell; not necessarily bad, but an
indicator of bad practice. What is the problem you're trying to solve?
I'll wager there are bette
> > Is it possible to split up a class definition over multiple files?
>
> Not exactly, but you can do variations of this:
... [subclass a class]
> Steven
Thanks Steven.
I guess I will just preprocess the script:
cat partA.py > class.py
cat partB >> class.py
python class.py
--
http://mail.pyth
On Mon, 17 Aug 2009 21:45:57 -0700, naveen wrote:
> Is it possible to split up a class definition over multiple files?
Not exactly, but you can do variations of this:
In file A.py, create:
class Parent:
def method(self):
return "Method"
In file B.py, do this:
import A
class Chil
On Tue, Aug 18, 2009 at 2:45 PM, naveen wrote:
> Is it possible to split up a class definition over multiple files?
> -
Answer in short, I don't think so.
Now why would you want to do that?
There is another solution - have a main class for shared methods, and have
other classes [in different