Getting python to type - python-3.x

How would I get python to type for me. The only thing I've found was on SendKeys but I can't find the version for python 3.5. Is there any built in module I can use to get python to type for me?

The win32api, assuming windows, has what you need in the keybd_event() function. Documentation here. As for built-ins, not aware of anything like that. Also, see this page.

Related

Is there a python module in linux similar to win32gui for sending input to inactive windows

Basically title, is there anything like this? I googled around a bit but couldn't find anything relevant to Linux only... win32gui postcommand is what I'm looking for an equivalent on Linux
The module python-libxdo should be able to achieve what you wanted to do.
In particular, you can hardcode window id.

python 3.4 shell, why need to reimport same module (never restart shell)

Today it happened to me multiple times. I was using Python 3.4.4 shell on win32. I imported datetime, and did some input like 'print(datetime.datetime.now().date())' and got output right. After a while, I had to type "import datetime" again in order to do similar work (like 'datetime.datetime.now(datetime.timezone.utc)')
I think the similar problem happened to me before with other module?
Can anyone explain? I was looking for answers here and google but with no luck.

How to syntax check Python?

I'm writing just a simple Python 3 program (beginner here) and I want to syntax check the code rather than just run it and see errors. How can I do this?
I've done python3 -m py_compile sender.py but nothing changes or is displayed. I'm using version 3.5.2 in Ubuntu, and sender.py is in the directory that I'm currently in.
There are some Python editors than can do this.
For example, Spyder and PyCharm.
They highlight the code segments that have problems.
If you are looking for tools similar to regular compilers, then you can have a look at this stackoverflow question and this with good answers.

Novice with Python

I have just downloaded Python 3.3.2 to use on windows7 and run the msi file to install. After installation I have tried using the prog only to find that every time I run my initial print 'hello world' it keeps reporting a syntax error.
I have tried both single and double quotes but each time reports a syntax. It will add say 8 + 9 and return the answer but no joy with using a print statement.
I have tried both the shell and a new window but without success.
Any advice please much appreciated.
If you are using Python 3.x, you have to do print('hello world').
In Python 2.x, print was a statement, like if, for, etc. Now it is a function, thus the ().
You're probably using instructions for a python-2 program, where print was a statement, rather than a function. In python >= 3, you have to do print(something), rather than just print something.

Parsing Excel files with Python 3.x

I have found very few libraries in Python able to parse excel files, and none of them were in Python 3.x nor passed with success the 2to3 step.
What would be your suggestions ?
Have a look at Python Package Index (Pypi), section Python 3 .
xlrd3 is a port of xlrd, a python 2.x lib to parse Excel files.
My suggestion would be to contact the authors of the libraries and help port them. It's not horribly hard and quite fun! Your only other option is to use Python 2, and that is obviously not as fun. :)
Possibly you could export to CSV as well, but I guess you would have if that was an option.
xlsxwriter is a good tool I've found, and practically the only one for Python 3 that hasn't been discontinued.
I know it works well with both Linux and Windows--LibreOffice in both Linux and Windows, and Excel in Windows.

Resources