Re: Python UML Metamodel

2008-01-30 Thread gagsl-py2
--- sccs cscs <[EMAIL PROTECTED]> escribió:
> Gabriel Genellina <[EMAIL PROTECTED]> a écrit :
> En Tue, 29 Jan 2008 21:25:26 -0200, sccs cscs 
> escribió:
> 
> > I find an OPEN SOURCE tool 
> (http://bouml.free.fr/) that Recently  
> > generates Python code from UML model.
> 
> Does it keep the model synchronized when you modify
> the Python code?
> 
> =>No, not for the moment because the Python code
> generator is  brand new, but  the tool's author and
> i are specifying the reverse tool for a next
> version. I do not have found another Open Source
> Tool that generates Python code from UML better like
> that.

Ok, that's important. If the model cannot reflect
changes in the code it becomes less and less useful.

> > I like to model the Python language metamodel
> himself, with it, e.g  the  
> > model of the language: I need that to better
> understand the language  
> > constraint of  the language.
> > [...]
> > -a class  "class" has 0..n attributes and 0..n
> method
> 
> Just attributes. Methods are created on-the-fly when
> the corresponding  
> function attribute is retrieved from the instance.
> And remember that instances are not restricted to
> what their class define.  
> You can add or remove any attribute (even methods!)
> to any instance of a  
> user-defined class at any time. (This doesn't apply
> to most builtin types,  
> but *does* apply if you inherit from it)
> 
> 
> =>You're Right but I will also model that dynamic
> aspect . However i think it is possible and the
> relevant to make a static metamodel of Python, as 
> if there was no possibility of changing dynamic an
> instance.

But Python *is* a dynamic language. You have to
capture that into the model somehow.

> A lot of person  do not understand nothing
> to Python on many aspects, because there is no
> graphical representation of the relation of concepts
> : may a module have  more than on class definition ?
> a mix of class and global fonction? etc... 

A graphical representation may be useful, but it must
be acurate too - else people may incorrectly deduce
that something can't be done because it's not
expressed in the graph.

> > Does anyone know a document that describes it
> already, because I think  
> > it is complicated to find this information in the
> documentation of  
> > Python.
> 
> See section 2 "Data Model" and section 3 "Execution
> Model" in the Python  
> Language Reference http://docs.python.org/ref/
> 
> =>
> Thank you, it's pretty standard but somewhat
> indigestible. However, by studying line by line, I
> would have to be filled into a UML model

Yes, sure, it's hard to follow. As the subtitle says,
it's "for language lawyers" :)

> > - a class "method" can contains nested "method",
> but what is the way to  
> > get a list of internal methods, without use ? Can
> i just write:
> > "myNestedMethodList = method.nestedMethodList"
> 
> Are you talking about nested functions?
> => Yes
> 
> You can't enumerate them from outside the container
> function: Python is a  
> dynamic language, those inner functions are created
> when the def statement  
> is *executed*. If you have an if statement around
> the def, the function  
> may not even exist.
> 
>  => OK, it is diffcult to model: but possible: for
> example, by using a composition (a method may have
> 0..n   inner function). The dynamic aspect may be
> described into a UML note or constraints for example

Anyway it doesn't look right. Inner functions are not
attributes of the enclosing one, like local variables
are not attributes of the enclosing function.

-- 
Gabriel Genellina


  Los referentes más importantes en compra/ venta de autos se juntaron:
Demotores y Yahoo!
Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python UML Metamodel

2008-01-30 Thread Gabriel Genellina
En Tue, 29 Jan 2008 21:25:26 -0200, sccs cscs <[EMAIL PROTECTED]> escribió:

> I find an OPEN SOURCE tool  (http://bouml.free.fr/) that Recently  
> generates Python code from UML model.

Does it keep the model synchronized when you modify the Python code?

> I like to model the Python language metamodel himself, with it, e.g  the  
> model of the language: I need that to better understand the language  
> constraint of  the language.
>
> for example, i like to model that :
> -a  class "class" may inherit from 0..* class

1..* classes if you model new-style classes only. Classic classes  
disappear completely in Python 3.0

> -a class "class" is create from a class that is its "metaclass"
> -a class  "class" has 0..n attributes and 0..n method

Just attributes. Methods are created on-the-fly when the corresponding  
function attribute is retrieved from the instance.
And remember that instances are not restricted to what their class define.  
You can add or remove any attribute (even methods!) to any instance of a  
user-defined class at any time. (This doesn't apply to most builtin types,  
but *does* apply if you inherit from it)

> -a class "module" has 0..n class "class"

Not true. A module instance can contain any number of attributes of any  
type; classes are just an example.

> Does anyone know a document that describes it already, because I think  
> it is complicated to find this information in the documentation of  
> Python.

See section 2 "Data Model" and section 3 "Execution Model" in the Python  
Language Reference http://docs.python.org/ref/

> For example, can i say that:
>
> -a class  "class" has 0..n properties ?
> It seems that the Python metamodel is not perfect, because I do not find  
> attribute which give me the property list with a code like:
> "myPropertyList = myclass.properties"

dir(obj) retrieves most of the obj attributes. Some are hard to enumerate  
(if they are simulated in code, using __getattr__ by example), and some  
internal fields are not shown in dir() yet (the __dir__ method in 2.6  
would help in this case).

> - a class "method" can contains nested "method", but what is the way to  
> get a list of internal methods, without use ? Can i just write:
> "myNestedMethodList = method.nestedMethodList"

Are you talking about nested functions?
You can't enumerate them from outside the container function: Python is a  
dynamic language, those inner functions are created when the def statement  
is *executed*. If you have an if statement around the def, the function  
may not even exist.

> I think a metamodel Python would be welcome to complement the BNF  
> (http://docs.python.org/ref/grammar.txt), so as to know fully understand  
> the relationships between the various elements of language.

Maybe, but I think it's a lot simpler than you imagine. For the builtin  
types, see section 3.2 on the reference above; more info in the Library  
Reference.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Python UML Metamodel

2008-01-29 Thread sccs cscs
Hello,
I find an OPEN SOURCE tool  (http://bouml.free.fr/) that Recently generates 
Python code from UML model.

I like to model the Python language metamodel himself, with it, e.g  the model 
of the language: I need that to better understand the language constraint of  
the language.

for example, i like to model that :
-a  class "class" may inherit from 0..* class
-a class "class" is create from a class that is its "metaclass"
-a class  "class" has 0..n attributes and 0..n method
-a class "module" has 0..n class "class"

Does anyone know a document that describes it already, because I think it is 
complicated to find this information in the documentation of Python.
For example, can i say that:

-a class  "class" has 0..n properties ?
It seems that the Python metamodel is not perfect, because I do not find 
attribute which give me the property list with a code like:
"myPropertyList = myclass.properties"

- a class "method" can contains nested "method", but what is the way to get a 
list of internal methods, without use ? Can i just write:
"myNestedMethodList = method.nestedMethodList"


I think a metamodel Python would be welcome to complement the BNF 
(http://docs.python.org/ref/grammar.txt), so as to know fully understand the 
relationships between the various elements of language.

Thank you








   
-
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail -- 
http://mail.python.org/mailman/listinfo/python-list