Skip to content

Tag: python

Python win32com constants

I’m currently wondering how to list the constants in win32com in python, for example using excel win32com.client.Dispatch(‘Excel.Application’) Is there a way to display all constants using win32com.client.Constants ? Or does someone know where i could find win32com’s documentation ? Be…

Getting the name of a variable as a string

I already read How to get a function name as a string?. How can I do the same for a variable? As opposed to functions, Python variables do not have the __name__ attribute. In other words, if I have a variable such as: I am looking for a function/attribute, e.g. retrieve_name() in order to create a DataFrame i…

Print range of numbers on same line

Using python I want to print a range of numbers on the same line. how can I do this using python, I can do it using C by not adding n, but how can I do it using python. I am trying to get this result. Answer Python 2 Python 3

“set session” in a SQLAlchemy session object

I’m using SQLAlchemy for a project, and need to be able to specify a session variable/setting for one specific call for performance reasons: I can of course do this in MySQL directly (on the shell), but how do I set this session variable in a SQLAlchemy session? Answer Use a session event to execute an …

Tkinter importing without *?

In my past programming i used the following code: but someone told me that importing * was not good for many reasons but now when i want to import it says geometry not a module thing (name). and when i do: it says ‘module’ object has no attribute ‘geometry’ Can someone explain me how t…

How to upload a file using an ajax call in flask

Hi I’m quite new to flask and I want to upload a file using an ajax call to the server. As mentioned in the documentation, I added a file upload to the html as folows: and I wrote the ajax handler as this I do not know how to get the uploaded file (not the name) from this and save

Referring to variables of a function outside the function

The result is: NameError: name ‘a’ is not defined Is it possible to use a outside the function? Answer In python the scope is a function, or class body, or module; whenever you have the assignment statement foo = bar, it creates a new variable (name) in the scope where the assignment statement is …