Python UML Metamodel

gagsl-py2 at yahoo.com.ar gagsl-py2 at yahoo.com.ar
Thu Jan 31 03:22:37 CET 2008


--- sccs cscs <zorg724 at yahoo.fr> escribió:
> Gabriel Genellina <gagsl-py2 at yahoo.com.ar> 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/



More information about the Python-list mailing list