Questions tagged as 'python'

1
answer

How to create an executable from python

I'm doing a service where I have to do a program that reads and creates files with numeric data. The problem I have is that the computers on which the program will be used are not accessible to me. Because of this, I needed to convert my file...
asked by 10.02.2017 / 18:06
2
answers

Why can not f-strings be used as a docstring?

According to PEP 257 , you have:    A docstring is the literal string that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object....
asked by 17.08.2018 / 20:00
1
answer

How to include in Python a function made in C?

I want to use a function made in C . Example: I have a function int swap(){ printf("lista"); } And I want to call it Python ...     
asked by 23.10.2015 / 18:32
2
answers

When is a default argument evaluated in Python?

Consider the following class: class Foo: def __init__(self, values = []): self.values = values Note that we are using an instance attribute and not a class attribute, however, see the following code: a = Foo() b = Foo() Two...
asked by 26.09.2017 / 16:49
2
answers

Handling windows events using Python

I need to develop an application in Python with Pop-up's in Windows (like Avast, for example). In case, my application will be a keylogger that will take a string from a barcode reader. When the keylogger detects the code, a popup will appear wi...
asked by 06.05.2014 / 14:37
4
answers

How to limit the generation of pseudorandom numbers to nonzero and non-repeating numbers?

I wish the numbers did not repeat themselves and were nonzero. import random Sort1 = int(60 * random.random()) Sort2 = int(60 * random.random()) Sort3 = int(60 * random.random()) Sort4 = int(60 * random.random()) Sort5 = int(60 * ra...
asked by 27.12.2016 / 23:32
4
answers

Performance of functions with and without creation of local variables

Despite the simplicity of this question, I could not find an answer for it on the Internet. Is there any structural / performatic difference between the two functions defined below? def F(x): Output = x + 1 return Output def F(x):...
asked by 17.12.2018 / 22:45
4
answers

Draw a square on the screen using a tick (#)

Hello, I'm starting to program in python and I'm having a hard time doing an exercise in which I have to make a rectangle with "#". largura = int(input("Digite a largura: ")) altura = int(input("Digite a altura: ")) while largura >...
asked by 19.01.2017 / 18:00
3
answers

How to check if a variable was defined in Python?

Is there any way to check whether or not a variable was defined in Python?     
asked by 10.02.2015 / 17:56
3
answers

Remove elements from a Python List

I have a problem with lists in python, I have a list in 2 different variables, with the same value .... but if I remove an element from any of the lists, the list that was to remain intact also has its element removed listaUm = [1, 2, 3, 4] li...
asked by 10.07.2015 / 20:33