Generate UML from Python source [duplicate] - python

This question already has answers here:
What's the best way to generate a UML diagram from Python source code? [closed]
(9 answers)
Closed 8 years ago.
I have a Python program and I would like to generate an UML diagram from from.
Which programs can do that?
edit: I would like to have an option of editing the generated diagram

I'm not sure what kind of quality you want your diagrams to be, but there is a tool called PyNSource that is still maintained (last update August) and does what you are after. You can find it here. I should clarify that this program is for Windows.

Here you can find a list of UML-Python tools. If you need to edit the diagram, then probably you should start by taking a look at PyUML

And there's Stani's Python Editor (SPE) which draws simple UML diagrams on-the-fly.

My tool Pynsource will reverse engineer Python 3 / Python 2 source code into UML class diagrams. You can drag to re-arrange the classes on the screen or let the auto-layout do it.
You can edit/add/delete classes and associations - yellow comment notes are supported. It can even generate ASCII UML to paste into your code.
There's an open source community edition, as well as a pro version if you want zoom functionality.

Related

For what we need python cosole in pycharm (or any IDE) if we have the editor? and vice versa [duplicate]

This question already has answers here:
Is there a Variable Explorer for PyCharm
(11 answers)
Closed 1 year ago.
Im new to pycharm and coding, and can't really understand why i need two places to write my code in.
And also in pycharm there is the run window where I can see the output of my code, but on spyder for example I see the output in the console window.
Why every thing in coding is so messy and complex?
Python Console is used to test and debug programs
Coding is so Complex because computers are complex too, for exemple if we say a bit, the computer doesn't know that. he needs a numeric value for a bit(exept machine learning)
I know it's hard to get started at coding, but for example what I found good when I started was coding a game to learn many things. Maybe just look up ursina, it's an cool engine in which you could code games pretty fast and easy.

Is it a good idea to directly write function on pyuic5 generated py file? [duplicate]

This question already has answers here:
QtDesigner changes will be lost after redesign User Interface
(2 answers)
Closed 2 years ago.
I recently learn about Pyqt5 and have some confusion about it. I have finished designing my GUI using Designer and I convert it using the pyuic5 command to start writing function for it, lets say it generate a mainwindow.py. So my question is, is it a best practice to directly write a code on mainwindow.py or should I create a new python file that import it? I want to avoid problem of fixing this in the future. Thank you
It is generally better to import it and extend it, since you can iterate design process and generate new file when design changes.

graphically (GUI) test Python scripts like jsfiddle

I'm exploring 2D interpolations for the purpose of writing a script in Python. I've been using the PIL (Pillow) modules to quickly display the results of the algorithms - this is best for cases when interactive input isn't necessary (i.e. testing on a random set of points).
For interactive testing I've found jsfiddle to be the most lightweight solution, but I admit it isn't ideal to rewrite functions in another language merely to be able to move points around, and input specific shapes of quads.
simple example, 4 verts drawn at random (JavaScript in JS fiddle; would like to do the same in Python)
What would be a fastest way to play around with a Python script graphically? Is there a Python counterpart of jsfiddle? I googled 'Python fiddle', of course, but it's not what I'm looking for. What I need is a simple canvas implementation and click events support.
Thanks in advance,
Well, there is Python Fiddle, but I think this question is going to be closed by admins as being off-topic on Stack Overflow; see this thread here.
I'd also come to think of Jupyter and Anaconda. The latter includes the former. These will harness matplotlib, amongst others, and Jupyter gives you a Matlab-like interpreter that shows you variable values for each line and you're able to step by step look at those variables and any graphs you are making.
As mentioned in previous answer, there is Jupyter notebook – a software for interactive Python programming including graphical output.
You can run Jupyter locally or on your own server, but there are free cloud versions:
https://colab.research.google.com/
https://notebooks.azure.com/

Python: Create a polyhedron and get its section

I want to create a polyhedron by giving its coordinates, and then get a specific section. Maybe something like:
Points = [A(0,0,0),B(1,0,0),C(1,1,0),D(0,1,0),A"(0,0,1),B"(1,0,1),C"(1,1,1),D"(0,1,1)]
Body = BodyGenerate(Points)
section1 = Body.section(z = 0.5)
section2 = Body.section(x+y= 1)
#And then I can get properties like `area`, `width` of these sections.
How can I do that? Is there any lib for that?
Here is what I find so far:
Vpython is pretty what I need, but it seems too basic, and cannot create a polyhedron
Blender and Rhino are good tools. But they focus more on modelling rather than programming. Python is more like a interactive commandline rather than a program itself.
Three.js seems what I need, but js cannot perform scientific computation.
As a blender user my opinion is biased that way. Yes it focuses on being a gui tool for end users, but it deeply integrates python for defining the user interface all the way to adding features through python addons. It also includes a python console that lets you type in commands that alter data directly, allowing you to see changes in the 3dview. It is also possible to add extra python modules that can then be used within blender.
Blender's python api can be read and searched online.
You should find some examples to help create a polyhedron in the extra objects addon. It is included with blender so you can also find the scripts in your blender install.
Maybe look into how the intersect tool works, you can call the intersect operator yourself, there is also a boolean modifier that may be better to get a closed mesh to calculate the volume.
For calculating the volume there is BMesh.calc_volume, it is used by the 3d printing toolbox.
You might want to add blender.stackexchange.com to your list to get blender specific python help.

Sublime Text 2 :: Python code completion [duplicate]

This question already has answers here:
Sublime Text 2 auto completion popup does not work properly
(4 answers)
Closed 9 years ago.
I'm trying to get Code suggestion (the drop-down box) to suggest properly.
Right now it does not. It only suggests, more or less, identifiers and modules
that are already in the file being edited (meaning in-file scope). If, for example, I try this:
import numpy <--- numpy is not suggested as I type it.
numpy.a <--- And here, nothing that begins with 'a' is suggested.
I've implemented a raft of things suggested at various sites, including the following, but
with no success in getting correct code-complete suggestions to appear,
or sometimes to appear at all:
- Installed SublimeRope
- "use_simple_completion": true (in SublimeRope.sublime-settings)
- "auto_complete_triggers": [ {"selector": "source.python - string - comment - constant.numeroc", "characters": "."} ] (in Pyhon.sublime-settings)
- etc.
Am I missing something (of course I am :)). Appreciate the suggestions.
Sublime's autocomplete is intended to match within the current file.
If you want to have code completion based on syntactic features of the language, you have many options, but I would suggest some combination of the following:
Install the CodeIntel package (package control instructions here)
Use snippets
Install Python snippets through package control (I like sublime-unittest).
Instructions for creating your own snippets.
Hope that helps.

Categories

Resources