I am not sure how to accomplish something that should be straightforward.
I want to define a class. In that class will be subclasses. In those subclasses will be attributes.
Ok, that's easy. But I want the attributes of one subclass to be generated based on the attributes of another of the subclasses. Here is my (wrong) code to try to do that:
class Food(object):
class Fruits(object):
crunchy=['Apples', 'Pears']
juicy=['Limes', 'Lemons']
class Salads(object):
import Fruits
FruitSalad=crunchy+juicy+['Whipped Cream']
Obviously "import Fruits" is wrong here. But how can I accomplish what I need?
-------------edit/addendum--------------------------------------
Ok, so I lose the outer class "Food", that's ok, I never liked it anyway.
I can now instantiate the first class into the second like this:
class Fruits(object):
crunchy=['Apples', 'Pears']
juicy=['Limes', 'Lemons']
class Salads(object):
fruit=Fruits
FruitSalad=fruit.crunchy+fruit.juicy+['Whipped Cream']
Which is closer, but I really want to lose the "fruit." structure.
import Fruitsat all. Only useimportto import structures from another file. These definitions are in the same file.food, then you can doimport foodand create an instance offood.Salads().