How to have a subprogramm in another programming language [duplicate] - python

This question already has answers here:
How do I run a Python script from C#?
(8 answers)
Run a python script from unity, to use its output (text file) in my game later
(4 answers)
Closed 1 year ago.
I want to make a Unity game that gives data to a subprogram written in Python and this subprogram gives back an answer, that is then processed in the C# game.
I don't really know how to approach this.
Can I run python code from C# somehow or do I let two separate programs running, that exchange data somehow?
Both programs also need access to the same database.

You can make a python server using flask or fastAPI and then access it from C#. I am not sure how to get that done with C#(I dont know C# :( ), but there must be some libraries to call servers. Also, you could save the database on the cloud such as mongoDB.

Related

Print annotations of kubernetes deployment in Python [duplicate]

This question already has answers here:
How to read a Kubernetes Deployment with python kubernetes client
(2 answers)
Closed last year.
I'm writing a python program that prints some kind of data of an existing kubernetes cluster as a first step.
I need to print the annotations of a given deployment. I tried a read the documentation and unfortunately got some lost. Anyone can show me an example?
Here is the example python script,
https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md#read_namespaced_deployment
Once you get the api_response, you may have to do,
print(api_response.metadata.annotations)

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.

Triggers in Python/SQL [duplicate]

This question already has answers here:
Run python script on Database event
(3 answers)
Closed 1 year ago.
I have created a python Code that is supposed to run on some data(to generate data points) as soon as the data is filled into the SQL database.
Is it possible to have a MySQL send a trigger event when a data is added into a table that can be detected by a python script so that action A be taken by the python script?
Appreciate any help on this. Thanks in advance!
Is it possible to have a MySQL send a trigger event when a data is added into a table that can be detected by a python script so that action A be taken by the python script?
No, not directly. Triggers call Stored Procedures, etc. which are written in SQL in that DB engine's specific syntax. They don't call external programs. I'm not aware of any Databases which do.
Wrt not-external programs, MySQL let's you create UDF's in C/C++ which can be used in triggers.
The only way to use your Python code as if it was a trigger is in the same code which executes the insert/update, etc. For example something like:
def insert_into_table(x, y, z):
cursor.execute('INSERT INTO ...')
exec_insert_trigger(cursor)
def exec_insert_trigger(cursor_obj):
"""your trigger code here"""
cursor.execute(...)
Or you can try to convert your Python code to C using Cython and then use that in a MySQL trigger.

Communication from QML --> to Python --> back to QML [duplicate]

This question already has answers here:
How to connect Python and QML with PySide2?
(1 answer)
How Can I Update a Qml Object's Property from my Python file?
(3 answers)
Closed 1 year ago.
I am looking for the best way to communicate from QML to Python and then back to python again.
I am struggling to find the 'correct' way to do this as many resources briefly explain the topic but in different ways and seem to require large amounts of boiler plate code.
For context I am currently using PySide2.
This is the kind of workflow that I am looking to use this in:
QML on button click send input to python --> receive in python --> do some processing on this input --> pass back to QML.
Please provide the best way to do this and with as much explanation as possible, thanks!

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.

Categories

Resources