Questions tagged as 'python'

1
answer

On large scrapes how to avoid ConnectionError?

In Python 3, I have a program to do web-scraping of tables on websites. There are 5,299 pages, on each page there is a table With XHR I found the generated JSON on each page. But always have a connection error after the program scour a few pa...
asked by 13.04.2018 / 12:02
1
answer

Create a function in python that returns a number that is the number of equal values of two columns

I'm trying to create a function that returns me a number that is the amount of equal values in two columns. (I'm new to programming) I tried the following (I do not know how wrong it is): e = 0 df_08['cmb_mpg'] = A df_18['cmb_mpg'] = B def...
asked by 29.01.2018 / 23:25
1
answer

Why this method returns me 2?

I have a code to parse and I can not really understand why this method in my Binary Tree returns me 2. Code: class No: def __init__(self, dado): self.esq = None self.dir = None self.dado = dado class Arvore: def __init__(self)...
asked by 05.01.2018 / 23:00
1
answer

Multiprocessing with infinite loop functions python [closed]

I'm doing a graphical interface with Gtk in python, and I have a serial script that keeps sending and receiving data from a microcontrolled system. The script of the serial is in an infinite loop (while True :), since the interface enters Gtk.ma...
asked by 08.12.2017 / 12:44
1
answer

Python - Split words delimited by white space or bracket

I have a string with several words inside, some words are separated by space, but some are compound words and are protected by brackets. EX: string="Goiânia Vitória Brasília [Campo Grande] Fortaleza [São Paulo] Manaus" I need to separat...
asked by 10.12.2017 / 21:36
1
answer

Using "from x import y" in python reduces the size of the application?

If I do an imposition in the form "from X import Y" instead of "import Y" am I saving on the size of the final application or does it make no difference? Let's say that inside Y has thousands of functions but I want to use only X in my code, w...
asked by 28.02.2018 / 04:58
2
answers

What is the logic of for i 'in' in python

I'd like to know the logic of for i in vogais , as in the example. Doubt, does it load the entire typed word into a list in memory and already sorts according to our rankings, or does it read character by character? For example, if y...
asked by 01.03.2018 / 12:32
1
answer

How to check if a list is inside the other?

My code: n = [int(input()) for c in range(0, 5)] lista = list(range(0, 10)) if n not in lista: print('1') else: print('2') I type 1, 2, 3, 4, 5 and the answer is "1", the numbers 1 through 5 are within the "list" that includes the n...
asked by 23.12.2017 / 19:50
1
answer

Python - How to merge row and column values into ndarray

Hello, I'm having the following difficulty, because I'm working with numpy now, I'm inexperienced ... Well, my problem is this: I have a tuple (w, t), where t repeats, so I want to add t as lines, but specifically in the first row of the...
asked by 04.11.2017 / 04:00
1
answer

How to organize the pygame code correctly?

I came from JavaScript which is a bit simpler than Python, so I did not have to worry about scoping (almost everything was global) or code organization. But in Python even though it is a language that has a better syntax I can not organize the c...
asked by 01.11.2017 / 01:29