Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
3
votes1
answer177
viewsHow can I turn an INI file into a Dict?
How can I transform data from a file .ini in a dict in Python? Is there any way to do this in Python? [database] host = localhost password = sabe_nada_de_python port = 3306…
-
3
votes1
answer290
viewsHow to create a Connection Pool using python and sqlAlchemy?
Hello ! Well I am studying python and I started looking for material on Connection pool using sqlalchemy but unfortunately I did not find any example on the internet that shows the process of…
pythonasked 8 years, 6 months ago Programmer goblin 91 -
3
votes1
answer188
viewsReading of csv with Django
Well, I’m working with an open database, and it’s in CSV, I’m using DJANGO to read the CSV and so entering into the database... However is giving a flaw in the insertion of the first year,I’m trying…
-
3
votes3
answers706
viewsvirtualenv with kivy
Using Ubuntu 16.04, I installed virtualenv and created a virtual environment. In this virtual environment I installed Cython using: pip install cython==0.23 I’ll have Kivy installed: pip install…
-
3
votes1
answer36
viewsWhy does "is" not work when comparing the replace of a string?
I tried to do in CLI Python 2.7.6 the following command: 'foo bar'.replace(" ", "") is 'foobar' But returned False Despite 'foo bar'.replace(" ", "") return 'foobar' Does anyone have any logical…
-
3
votes1
answer421
viewsTrigger an event after two clicks on button
I am developing a small interface in Tkinter, but I have the following question: Is there a mouse event that allows an action to be executed after two clicks consecutive on a button?…
-
3
votes2
answers2075
viewsChange color and border size Tkinter Menu
Can someone help me with this question?…
-
3
votes2
answers2340
viewsIterating over nested dictionaries (Pythonic)
I always lag behind when it comes to thinking of nested repeat loops to iterate over some container (typical of C/C++), because I know that python has very particular ways of iterating over…
pythonasked 8 years, 7 months ago Matheus Saraiva 2,157 -
3
votes1
answer498
viewsError with scrapy requests
I have a csv file with some urls that need to be accessed. http://www.icarros.com.br/Audi, Audi http://www.icarros.com.br/Fiat, Fiat http://www.icarros.com.br/Chevrolet, Chevrolet I’ve got an Spider…
-
3
votes1
answer1079
viewsHow to block resizing a widget/window?
I am setting a certain widget according to the size of the secondary monitor. This I managed to do perfectly. However, as I am beginner with Pyqt, I would like to know how to block window resizing.…
-
3
votes1
answer68
viewsPass captured data from a Python code to Shell Script
I would like to know what to do to take this data captured from a DHT11 sensor (Python Code [Temperature and Humidity]) and pass them to a Shell script if umid is not None and temp is not None:…
-
3
votes1
answer8794
viewsNo module named numpy
porco1 = [1,1,0] porco2 = [1,1,0] porco3 = [1,1,0] cachorro1 = [1,1,1] cachorro2 = [0,1,1] cachorro3 = [0,1,1] dados = [porco1, porco2, porco3, cachorro1, cachorro2, cachorro3] marcacoes = [1, 1, 1,…
-
3
votes2
answers767
viewsError in "utf-8" in python 3
I have a problem in python 3 that in the code: #!/usr/bin/env python #-*- coding: utf-8 -*- import urllib.request page = urllib.request.urlopen("http://beans-r-us.biz/prices.html") text =…
-
3
votes1
answer415
viewsHow do I set a Tray Icon (tray icon) in a Pyqt application?
I’m still a beginner in Pyqt and would like to clarify a question: Is there any way to define a Tray Icon (Tray Icon) in a Pyqt application? If so, how can I do it? I need to set some options on…
-
3
votes2
answers978
viewsHow to find the name of a button by source code?
I’m working with a library python calling for Splinter, that simulates a web browser. I’ve read about how to use it, and to click a button, just give a command that involves the name of the button.…
-
3
votes1
answer99
viewsGrab a button on Splinter (python)
For most of the buttons I try to grab using Splinter, the commands that are on this site (https://splinter.readthedocs.io/en/latest/finding.html) is enough. But for this particular button, I can’t…
-
3
votes1
answer340
viewsImport Mysql data to Excel
To want to import data from Mysql to excel using Python, when I try to make it from an error of tuple. Someone with more experience can help me? I followed the code and the error: # coding=utf-8…
-
3
votes0
answers97
viewsDoubt provided to the calculation of the area
I was testing an algorithm that returns to me the area of objects based on a reference, a priori this gave me results quite close to the real, when the reference was the same height of the measured…
-
3
votes3
answers1090
viewsError installing Scrapy package in Python
I’m trying to install Scrapy through Pip, but I’ve been getting errors like: running build_ext buildig 'lxml.etree' Extension error: Microsoft Visual C++ 10.0 is required (Unable to find…
-
3
votes1
answer6899
viewsPython: How to correctly import one method that depends on another?
I’m on the reboot of a project I did in Java, seeking to learn about Python in POO, but I’m stuck on something I haven’t found any solution yet: I have 2 files ("working.py" and ".py files"). The…
-
3
votes2
answers238
viewsWhat happened to Unicode in Python 3?
I’m starting to use the Python3 little by little. I ran a certain code that I used to run with Python2.7 and got the following error: Nameerror: name 'Unicode' is not defined So I understand that…
-
3
votes1
answer244
viewsWhy can’t I pass a parameter to the class?
I’m trying to pass the parameter "ink" to the class "Pen" but I can’t. I’ve tried using boolean expressions instead of index, but still no result. Could someone give me a help? class Caneta(): açao…
-
3
votes2
answers2354
viewsConcatenate arrays using numpy module
One question, for the solution of linear systems: how to concatenate an array (matrix) A, an array (column vector) b, so that one has the "augmented" matrix of the system, A~ = [A b], using numpy?…
-
3
votes1
answer1446
viewsLine exchange in the matrix
Hello. I was programming in python and wanted to change the line (between the second and third lines) of an array using the following code. But I wanted to know why the variable auxLinha changes…
pythonasked 8 years, 4 months ago Victor Henrique 817 -
3
votes1
answer356
viewsHow can I change file attributes in windows with python?
I am trying to keep a file . txt hidden. How can I do this using python command line?
-
3
votes1
answer38
viewsJoin method is not working
Good! I am creating the game Battleship and I found a problem creating the board. Code: board = [] for x in range(15): board.append(["O"] * 15) def print_board(board): for row in board: print ("…
-
3
votes1
answer170
viewsHow to add an image in the menu?
I need to add an image to the menu of my program in Python. I am using the wxpython library. The menu is like this: The code: #!/usr/bin/env python # -*- coding: utf-8 -*- import wx class…
-
3
votes1
answer147
viewsHow to change the position of the bitmap button?
I inserted a button with an image in my menu. But I can’t change its position. How do I change its position? because I need to insert 2 more buttons and organize them.I’m using the python wx…
-
3
votes1
answer1032
viewsHow to rotate an image without knowing the angle of inclination?
My program receives an image of a scanned CNH (with background paper). The goal is to remove the background and leave only the CNH. When the document is upright, there is no problem, since I can use…
-
3
votes0
answers952
viewsvoice recognition with Python 3
I’m developing a desktop application, I need to use voice recognition, but all the material I think is related to version 2 of Python. Does anyone know how to do this using libraries for Python 3?…
-
3
votes1
answer437
viewsAdd a new value to a list
Is there any way to add a new value to a Python list from a user input? Example: Entrada = int(input("Digite um número")) lista = [] #A partir da entrada acima eu gostaria de expandir esta lista…
pythonasked 8 years, 3 months ago user63295 -
3
votes1
answer529
viewsDifficulty with socket.recv()
I am experiencing continuity issues in my code after a function call, related to receiving data via socket with the following code: def le_dados(obj): lista_rcv = [] while True: data = obj.recv(2)…
-
3
votes3
answers1401
viewsI would like to know what is the function of: {} in the Python language and more specifically within the PRINT function as in this code?
I would like to know what the function of: {} in the Python language and more specifically within the function PRINT as in this code? Salario = int(input('Salario? ')) imposto = 27. while imposto…
-
3
votes2
answers991
viewsDo word search inside a list and return tuples sorted in PYTHON
The algorithm should receive a string, count how many words equal and return a list of tuples with the words that most appear in the string and how many times it appears. The problem is that in…
-
3
votes2
answers2422
viewsHow to get a list of processes running windows in python?
I would like to know how to get the processes running from windows and store them in a list in python. from os import system system('tasklist') I know that the code above shows the processes, but I…
-
3
votes1
answer2570
viewsHow to turn a . py into an . exe?
I have the following code : #coding-utf-8 from Tkinter import Frame, Tk, BOTH, Text, Menu, END import tkFileDialog from tkinter import filedialog as fd import dbf class Example(Frame): def…
-
3
votes2
answers936
viewsChained list: how to modify data from a list without changing the others?
I have a for that generates a list of data lists lista[[...], [...]] Inside the "daughters" lists may or may not have other lists lista[['dado11', 'dado12', [link1]],['dado21', 'dado22', [link2]]…
-
3
votes1
answer485
viewsCompress and unzip file in memory
I have a few functions that read the file directly from a cache path, but eventually it will cost a lot of space in the filesystem, there is some way to generate that file in memory and already save…
pythonasked 8 years, 3 months ago Guilherme Lima 3,129 -
3
votes1
answer229
viewsTypeerror: a float is required
This is my code: ### BIBLIOTECAS import scipy.special as sps import numpy as np import matplotlib.pyplot as plt import pandas as pd import scipy as sp from scipy.stats import norm from scipy.stats…
-
3
votes1
answer2187
viewsThe sum of the difference between 2 Python lists
I need a function compara_listas(lista1, lista2) which receives two random lists and calculates the sum of the difference between their elements. But if any element of the lista2 is greater than the…
pythonasked 8 years, 2 months ago Eduardo Oliveira 48 -
3
votes1
answer101
viewsAlgorithm for popular tables in Postgressql
I am writing an algorithm to popular all tables in a database in Postgres. I already get popular all tables who have no relationship, as follows: I get all tables with the following query: SELECT…
-
3
votes2
answers1142
viewsAlternatives for storing and analyzing data
A part of a project that I’m developing is to acquire voltage and current data from a solar plate. Per day I have around 40 measures like these that are here. 14/dez 16:54 18.21 0.12 18.35 0.0641…
-
3
votes2
answers1503
viewsMake server socket in Tkinter allow client input
The program works properly, it creates a server for your user, the server opens smoothly. But when I use a client to access it, the following message appears in the server client: Traceback (Most…
-
3
votes1
answer3296
viewsHow to make a text fit the size of the Tkinter screen?
I am making an application on Tkinter and I need the text typed on a single label to fit the window size, because otherwise I have to stay using line breaking. Can someone help me? from tkinter…
-
3
votes2
answers202
viewsDisplaying certain vectors in a 2D Python list
I have the following situation: - I have a variable called (vector_distances). This variable receives a 2D list with several vectors. - I wish it to be displayed, only vectors whose sum of their…
-
3
votes1
answer3590
viewsHow do I send a file as an attachment by email without automatically renaming it?
I am beginner in sending emails via script and am facing a problem. I use Python 3.5. When sending attachments with the following script, they lose the extension and are renamed: def…
-
3
votes1
answer1135
viewsFunction to mount query from table and add array in function
I’m trying to create a function where I need to send it an array that will have the same data as the Insert sequence in the database but I’m having no idea how to send this array inside the function…
-
3
votes1
answer852
viewsWhy is the variable 'data' not defined?
Code: arquivo = open("surfing_data.csv") id_de_verificação = int(input("Insira a ID do surfista desejado: ")) def pesquisa_de_surfista(pesquisa): dados = {} for linha in arquivo: (ID, nome, pais,…
-
3
votes2
answers1056
viewsClass return key and value of my attributes
I have the following class: class RegC100: def __init__(self,linha): def convFloat(valor): if (valor != ''): valor = float(valor.replace(",", ".")) return valor else: return '' def convInt(valor):…
-
3
votes1
answer99
viewsProblem when unzipping file
I have a zip that, inside it there are several files to be uncompressed. So far so good, I’m using the following method to twelve the same:? with closing(z), zipfile.ZipFile(io.BytesIO(z.content))…