Questions tagged as 'python'

1
answer

How to check the latest file in a folder with Python?

Assuming you have a folder with several TXT files with different names and need to know the latest file, how do I do this using Python?     
asked by 20.04.2018 / 14:13
1
answer

Determine the key of a dictionary that contains the largest amount of values

animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']} animals['d'] = ['donkey'] animals['d'].append('dog') animals['d'].append('dingo') Be the animals dictionary defined above. The function applied to it should return the key...
asked by 22.04.2018 / 01:48
1
answer

How to get a string with the name of the window that is focused on python?

Some time ago I started using pyHook to handle events. However, the original version has errors, so I changed it to an alternate version that corrected the errors of the original version. However, I have found that this alternate version always...
asked by 11.02.2017 / 21:57
1
answer

Exceptions.py file

I've been programming in python for about a year, and I've always seen in some projects that I find on the web, a file called exceptions.py. I know treat exceptions within my codes, this is not my doubt. I would just like to understand the im...
asked by 13.09.2014 / 21:35
1
answer

How to randomly pick an item from a dictionary in Python?

I would like to know how to randomly pick an item from a Python dictionary? For example: I have the dictionary dic = {'Pedro': 99, 'João': 19, 'Rosa': 35, 'Maria': 23} I need to choose an item randomly.     
asked by 28.12.2016 / 17:05
2
answers

How to run a python file as admin?

I'm trying to run a python file, but it asks to be run as admin how do I do that?     
asked by 20.02.2017 / 05:26
1
answer

What is the best way to concatenate strings in Python?

I know I can concatenate strings with += , + , join() and append() . All of them give me the same result when I concatenate two strings. What is the best way to concatenate strings in Python? What is the difference be...
asked by 03.03.2017 / 04:14
1
answer

How to make an input password in PyQt4?

To use a field similar to input of HTML in Pyqt4, I usually use QtGui.QLineEdit . But how do I make a field similar to input password, what is a specific field for entering passwords? Can you define the "asterisks" that...
asked by 26.10.2016 / 21:12
1
answer

Use list as dictionary value using append () method Python

I have some dictionary in python, and I want to assign a list as value for each key of the dictionary, however I need to use the append () method to add elements, but after adding the elements in the list, the value of the key is None. Ex:...
asked by 20.06.2014 / 05:19
1
answer

How to move the mouse in a realistic way using Python?

How to make the mouse move automatically, realistically, using Python? I was able to find and change a code that produces a "V" -shaped movement on the screen. However, I would like to move the mouse using non-linear movements. I found som...
asked by 12.01.2017 / 18:53