Questions tagged as 'python'

3
answers

How to convert a string variable to int?

As I correctly declare an integer value, it is returning that my variables are strings . n1 = input("informe um número ") n2 = input("informe um número ") soma = n1 + n2 print ("O resultado da soma de ", soma)    report a number 25   r...
asked by 17.09.2015 / 22:52
2
answers

In Python, how do I get the default temporary directory?

I'm doing a program that uses a temporary file to save a serialized (pickled) object. Currently, the program is generating in /tmp , but this path is specific to Unix / Linux; wanted to take the path of the default operating system tempora...
asked by 12.12.2013 / 19:58
5
answers

Refactoring: When is a method "too big"?

I have a project that "retrieves" certain information from an HTML page, parses with the help of Beautiful Soup, and returns values in the form of dictionary , to that in another method I generate a JSON object. The problem is that because...
asked by 10.02.2014 / 01:58
1
answer

Why use static methods in python

I am studying on the subject of the title and I can not get the idea with the explanation video and Stk I found, then when and why you use static method @staticmethod in python, there is a positive addition to just do not reference the ob...
asked by 12.06.2017 / 21:11
1
answer

How do you know if a dot (x, y) is within the filled percentage of a pie chart?

I came up with this code that shows whether a point (x, y) is inside or outside a circle on a Cartesian plane. def dentro_fora(p, x = 0, y = 0): r = cx = cy = 50 if (x - cx)**2 + (y - cy)**2 < r**2: return 'dentro' els...
asked by 07.01.2017 / 16:55
1
answer

When you finish the script with "Ctrl + C" (KeyboardInterrupt) it does not close Selenium or Firefox

I'm using selenium to handle a page, while running the script it opens firefox, but what I wanted to do is the following, if any problem occurs in the script or if the user terminates, I want the firefox to close as well. I tried several thin...
asked by 28.09.2017 / 18:27
2
answers

How to play audio with PyQt?

Is there any way to run an audio file with PyQt? Is it possible to do this only with PyQt or do you need to install another library?     
asked by 11.11.2016 / 13:48
3
answers

Installing with PIP through the requirements.txt file inside VirtualEnv?

I've learned these days that through the pip freeze > requirements.txt command, I can generate a dependency list for a specific project where I'm using VirtualEnv . How do I install all the libraries contained within this r...
asked by 01.06.2017 / 17:16
2
answers

Difference of class properties vs Instance

What is the purpose of creating attributes in the class if I can create in the instance itself?     
asked by 23.05.2017 / 05:53
3
answers

TypeError: not all arguments converted during string formatting (Python 3.4)

I'm new to programming and trying to make a simple exercise code to calculate a phone bill: t = float(input('Digite a quantidade de minutos gasta: ')) if t < 200: p = t * 0,2 if t >= 200 and t < 400: p = t * 0,18 if t >= 4...
asked by 22.02.2015 / 13:23