473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Re: Representation of python code ?

Le Sunday 14 September 2008 15:44:03 Barak, Ron, vous avez écrit*:
Hi Guys,
Is there a script/application, which gets as input python code, and
produces a (graphic) representation of the inter-relationships between its
classes/functions ? Bye,
None I know of. Not saying that it would be unfeasible, but it would be a hard
job, given the fact that most of relationships are purely dynamic.

How such an application would find the relationship (composition) between A
and B without executing this code ?

class A :
def __init__(self) :
self._b = B()

class B : pass
--
_____________

Maric Michaud
Sep 15 '08 #1
4 939
On Sep 15, 4:38*am, Maric Michaud <ma...@aristote.infowrote:
Le Sunday 14 September 2008 15:44:03 Barak, Ron, vous avez écrit*:
Hi Guys,
Is there a script/application, which gets as input python code, and
produces a (graphic) representation of the inter-relationships between its
classes/functions ? Bye,
If you can't find anything that's already packaged up and polished,
one possibility is to use the parser and/or compiler.ast modules in
Python to analyze your code, then produce something that graphviz can
consume.

Graphviz is something really nice to have in your bag of tricks,
anyway.

http://www.graphviz.org/
None I know of. Not saying that it would be unfeasible, but it would be ahard
job, given the fact that most of relationships are purely dynamic.

How such an application would find the relationship (composition) betweenA
and B without executing this code ?
I'm not sure this is the best counterexample. You can see statically
that A potentially creates an instance of the B class.
class A :
* * def __init__(self) :
* * * * *self._b = B()

class B : pass
Sep 15 '08 #2
Le Monday 15 September 2008 16:06:19 sh************@gmail.com, vous avez
écrit*:
I'm not sure this is the best counterexample. *You can see statically
that A potentially creates an instance of the B class.
class A :
* * def __init__(self) :
* * * * *self._b = B()

class B : pass
Yes, you can, but are you sure it's obvious that B in A.__init__ is the class
you think of ?

--
_____________

Maric Michaud

Sep 15 '08 #3
On Sep 15, 7:17*am, Maric Michaud <ma...@aristote.infowrote:
Le Monday 15 September 2008 16:06:19 showellshow...@gmail.com, vous avez
écrit*:
I'm not sure this is the best counterexample. *You can see statically
that A potentially creates an instance of the B class.
class A :
* * def __init__(self) :
* * * * *self._b = B()
class B : pass

Yes, you can, but are you sure it's obvious that B in A.__init__ is the class
you think of ?
I'm guessing 99% of the time it will be. It seems to me that if
you're invoking classes in a truly dynamic way, you should be explicit
about it anyway, and give methods some kind of naming convention, like
have "factory" in the name. This would not only make it easy for a
visualization program not to be tricked, but it would help out your
human readers as well.

Sep 15 '08 #4
sh************@gmail.com wrote:
On Sep 15, 4:38 am, Maric Michaud <ma...@aristote.infowrote:
>Le Sunday 14 September 2008 15:44:03 Barak, Ron, vous avez écrit :
>>Hi Guys,
Is there a script/application, which gets as input python code, and
produces a (graphic) representation of the inter-relationships between its
classes/functions ? Bye,

If you can't find anything that's already packaged up and polished,
one possibility is to use the parser and/or compiler.ast modules in
Python to analyze your code, then produce something that graphviz can
consume.

On that note, perhaps have a look at PySmell [1] which
Orestis Lightning-spoke about at PyconUK over the weekend.
It's designed as an autocompletion tool, but he mentioned
that the structure it generates could well be used for
other purposes.

TJG

[1] http://orestis.gr/blog/2008/08/31/announcing-pysmell/
Sep 17 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tonguç Yumruk | last post by:
Hi, I'm looking for a way to represent bit-level data in python. Something like 0xDEADBEEF representation, but not for hex i'm looking for binary. Something like the %00110101 representation I...
6
by: manders2k | last post by:
Hi all -- I'm contemplating the idea of writing a simple emacs-like editor in python (for fun and the experience of doing so). In reading through Craig Finseth's "The Craft of Text Editing": ...
2
by: Ajay | last post by:
hi! i am calculating a digest of some data (using hmac) and printing it to a cookie. the problem is the hash may contain special characters. when these are printed they get converted to...
7
by: Philipp H. Mohr | last post by:
Hello, I am trying to xor the byte representation of every char in a string with its predecessor. But I don't know how to convert a char into its byte representation. This is to calculate the...
4
by: ej | last post by:
I ran into something today I don't quite understand and I don't know all the nitty gritty details about how Python stores and handles data internally. (I think) I understand why, when you type in...
6
by: Ksenia Marasanova | last post by:
Hi, I am looking for a library that will give me very simple text representation of HTML. For example <div><h1>Title</h1><p>This is a <br />test</p></div> will be transformed to: Title
8
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
0
by: limodou | last post by:
---------- Forwarded message ---------- From: limodou <limodou@gmail.com> Date: Oct 27, 2006 11:51 AM Subject: Re: How to Split Chinese Character with backslash representation? To: Wijaya Edward...
0
by: Manuel Ebert | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 AFAIK epydoc can generate pretty graphs with graphviz on the fly, such as class hierarchies or call graphs. On Sep 14, 2008, at 3:44 PM, Barak,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.