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
-
0
votes1
answer1391
viewsError installing python library
I’m having a problem trying to install the library pyaudio in Windows. The following result appears: Command "c: users digia appdata local Programs python python37-32 python.exe -u -c "import…
-
0
votes1
answer782
viewsPython asyncio and threading
I’m studying the module asyncio of Python and there is the function run_coroutine_threadsafe which should be executed in a different thread than the event loop. Follow my script: #!usr/bin/python3 #…
-
0
votes1
answer806
viewsCollection of float type data from an Entry Widget - Python Tkinter
I am developing a program for civil engineering calculations and I have a problem in the result collided in an Entry Widget, that same Entry is with you in an if condition as shown in the code…
-
0
votes1
answer151
viewsPyvcf lib problem - Extract data from vcf files
I get the error while trying to read a vcf file, did not find solution or other lib to handle vcf files, any suggestions? I tried with the two verses of python Traceback (most recent call last):…
-
0
votes1
answer82
viewsHow to read the following code in python?
I found a code in Python, but I’m not getting how it works. from itertools import permutations n = 8 cols = range(n) contador = 0 for vec in permutations(cols): if n == len(set(vec[i]+i for i in…
-
0
votes1
answer242
viewsWrite to csv file
I have a function that returns a line and this should be inserted in a CSV file. The line has the following structure when returned by the function: ['x' - 'y', 'z', ['a', 'b', 'c', 'd', 'e', 'f']].…
-
0
votes1
answer455
viewsDjango Session, emite: Object of type '' is not JSON serializable
I am creating a student but when I try to save it within a session, returns me the following error: Object of type 'Student' is not JSON serializable In Settings.py: INSTALLED_APPS = […
-
0
votes1
answer46
viewsPython cluster application deploy
I need to deploy a python application in a cluster kubernetes. This application is using the venv and I don’t know if it’s right to generate a container image with the venv directory. What is the…
-
0
votes1
answer63
viewsNumber of attributes in a Python class
Is there any "rule"/convention for the amount of attributes in a class? Example: In a game, a Character(class) has more than 30 attributes between name, level, strength, etc. With all the attributes…
-
0
votes1
answer290
viewsPhoto gallery ordered in Python
Good morning I’m developing an image gallery listing them from a directory. What I have to do is separate these images or sort in order of creation. I have a script that generates the images as…
-
0
votes1
answer68
viewsPrint Mongodb BSON with several different structures
I’m making an application using Python (Flask) and Mongodb. In this application the user can mount his page by inserting Images, Text or Youtube link. With the sequence you want. This first part I…
-
0
votes2
answers1368
viewsIs it a good idea to use JSON as a database?
I’m doing a mobile app project. Using Python and Kivy. My project has three main classes to save in a database (it’s a ticket selling app): Tickets, Events and Users. Searching, I saw that JSON is…
-
0
votes0
answers80
viewsRunning an asynchronous mode Python function with Celery
I have the function test() that takes a long time and I want to execute it asynchronously. I put the decorator of the Celery in the same as below: from celery import task @task def test(): (...)…
-
0
votes1
answer103
viewsHow to run a python script in Notepadqq?
when I press "RUN" this window appears
-
0
votes1
answer37
viewsopencv in python
I need to make an algorithm that reads the color code and opens a window with the color. I know I need to use the library cv, but I don’t know how you do it and I can’t find anything like it on the…
-
0
votes1
answer326
viewsPython does not insert data in sqlite3
I have the following code: #!/usr/bin/python3 import sqlite3 app = '/backup/app/' bd = app + 'bd/' contato_banco = bd + 'contato.db' contato_tab = (('nome' , 'TEXT'), ('email' , 'TEXT'), ('whatsapp'…
-
0
votes2
answers1557
viewsMaking a date set Random with pandas
I’m trying to extract 15O lines from a 500-line dataset. So I’d like to do it on Andom. My data objeto,cor,label cachorro,branco,animal manga,laranja,fruta calça,preta,roupa My script import pandas…
-
0
votes3
answers661
viewsDoubt - insert element at the end of the list - (Python)
I’m new here and I’m learning Python now. I have a question here of how to insert an element at the end of the list. I searched on the Internet as if to insert some element at the end of the list,…
pythonasked 5 years, 8 months ago leonardo santana 1 -
0
votes1
answer66
viewsAccess user data via Django template
I have the user model that I extended from the Django standard class TradingUser(User): avatar = models.ImageField(upload_to='images/', default='images/none.jpg') Only when I try to access this…
-
0
votes1
answer647
viewspython (Logging) daily log file
Hello, I would like to know how to create a log file for each day. Currently saved in a single file. log_file = path.join(path.dirname(path.realpath(__file__)),"Log.txt")…
pythonasked 5 years, 8 months ago Lorena Jesus 15 -
0
votes1
answer62
viewsHow to make a date Slug?
I’m trying to add a Slug that converts the date to a tip that html accepts, but I don’t know how to make it work. on the models.py part class Por_dia(models.Model): pedidos =…
-
0
votes2
answers2474
viewserror to import pandas library and numpy
Guys, I have a problem to import panda library and numpy for my project, when I try to run on pycharm... the following code, this error presents: code: import pandas as pd import numpy as np error:…
-
0
votes1
answer116
viewsCapture using Xpath
I’m making a capture of a site using python (scrapy) and xpath How to capture only 232,990 of the code below? <div class="price-advantages-container"> <div class="price-comparison">…
-
0
votes1
answer118
viewsHow to convert a text in Mathml to Latex using Pandoc?
I’m trying to use the site http://pandoc.org/try/ to convert html text to latex. My python code is as follows:: import requests mathml = "<math…
-
0
votes1
answer244
viewsPython error in Def _init_ function when creating a Chatbot
class wppbot: dir_path = os.getcwd() bot.def __init__(self, nome_bot): self.bot = ChatBot(nome_bot) self.bot.set_trainer(ListTrainer) self.chrome = self.dir_path+'\chromedriver.exe' self.options =…
-
0
votes1
answer70
viewsDjango + Postgresql Object has no attribute
I am trying to do a validation before submitting my form, but returns me the following error: 'Studentform' Object has no attribute 'termAccepted' models.py of the app: from django.db import models…
-
0
votes1
answer734
viewsRegex in Python Validate E-mail
Good morning! valid = re.search(r'^[a-zA-Z0-9._-]+@[a-zA-Z0-9]+\.[a-zA-Z\.a-zA-Z]{1,3}$', email) I have this regular expression, and there are some rules to return the correct emails, are 8 tests,…
-
0
votes1
answer269
viewsPython lib to convert PDF/EPUB to txt
I’ll use the NLTK, but I need some plain text. The material I have is in epub and pdf, so I need a lib that converts one of these formats to txt. Does anyone know if you have anything like this?…
-
0
votes1
answer194
viewsI cannot render html in python 3
I have the following app: #!/usr/bin/python3 from bottle import template, route, run import html cabeca = (''' <html lang="pt-br"> <head> </head> <body> <nav id="menu">…
-
0
votes0
answers47
viewsWhat is the name of the function before the loop for in Python?
Hello I come from the language c++ and java, and I am learning python. I came across the following piece of code: data = {'Player' : ['Wade', 'James', 'Kobe', 'Curry'], 'First' : [10, 10, 8, 12],…
-
0
votes1
answer7196
viewsModulenotfounderror: No module named 'authorizations'
How can I import a folder using Python in Spyder ? Currently I have the following structure of dir Gestao | |_ Aplicacao | |_ Autorizacoes In the script import pandas as pd import imaplib import…
-
0
votes1
answer103
viewsRemove a value from a list
I want to remove two values from a list. Of type I have an array: vet[0]*3 for i in range(3): vet[i]=input('Digite um valor: ') I want to remove as much and as little as possible. How do I? I’ve…
-
0
votes1
answer406
viewsDjango Forms.Checkboxselectmultiple emits: Select a Valid Choice. [''] is not one of the available Choices
I’m trying to use a checkbox to select items in a list, but returns me the following error: Select a valid choice. [''] is not one of the available choices. py.models app: from django.db import…
-
0
votes1
answer552
viewsWhat is the difference between request and request. Session()?
I would like to know the difference between request and request. Session() of the request module. What would be the ideal use of each?
-
0
votes1
answer45
viewsUpdating a JSON-like column in Postgres with Python and Psychopg2
When trying to run an update like the below in postgres via psycopg2 of Python is giving the error: psycopg2.Programmingerror: can’t Adapt type 'Dict' I’m trying to run a code like this:…
-
0
votes1
answer219
viewsCalculating a date inside the Model Django timedelta
I am declaring a function (data_prox_prog) to calculate a future date and store in the model, but it is not happening as expected. Follows code: class ProgressaoDocente(models.Model): servidor =…
-
0
votes2
answers408
viewsDjango + Python update and do not insert
I am using a filter to return some student and update their data, but when I try to save I get the following error: Student with this CPF already exists. and Student with this RA already exists. My…
-
0
votes1
answer38
viewsProblem with assign,
class transaction: ... def send(from_key, to_key, SN): if SN in from_key.parts: str(from_key)+str(to_key)+str(SN)=transaction(SN,from_key,to_key,True) Syntaxerror: can’t assign to Operator I can’t…
pythonasked 6 years, 2 months ago João Victor Verona 1 -
0
votes1
answer320
viewsHow do I get the name with the file extension in a Python URL?
I want to extract the name of an image with its given extension uses full URL, for example: image_url = 'http://dominio.com.br/caminho/da/imagem/imagem.png' I want to have only: image = 'imagem.png'…
pythonasked 5 years, 8 months ago Thiago Krempser 1,878 -
0
votes1
answer2019
viewsHow to get the current file name in python
Speak people, speak people, I am making a code creator for sqlite in python. I was wondering if there is any way to get the name of the current file to pass directly on the function. currently pass…
-
0
votes1
answer225
viewsReturn HD size and free space to client-server
I would like to return to the customer the information of HD size beyond the available space. Client code import socket, pickle HOST = 'localhost' PORT = 9991 udp = socket.socket(socket.AF_INET,…
-
0
votes1
answer56
viewsMake the camera fill the entire screen with Python/Kivy
I’m not facing errors, but when accessing the camera using kivy, I don’t know how to make the image occupy the whole size of the window. Below is the part of Kv file that does this:…
-
0
votes1
answer57
viewsError creating Django filter
I am trying to create a filter but get error: Related Field got invalid lookup: icontains msm if I use the related_name before the attribute n works. class…
-
0
votes1
answer441
viewsHow to get the index comparing two lists of different lengths in Python?
I have two different lists in two CSV files. The first list has 47843 items and the second 813331, which is the first multiplied by 17. I want to take the index position in the first, based on the…
-
0
votes1
answer315
viewsHow to enter new data for prediction (text)?
I’m new to Python and new to Machine Learning. I built an algorithm so that it can be trained to sort texts. So you can predict in which category fits certain text. The training and the score are…
-
0
votes1
answer52
viewsPercentage of Video Game Genres in Spyder
I want to show the percentage of various genres in my code with the date set and it is giving a following error: Valueerror: Lengths must match to compare The part that has the error in my code is…
-
0
votes2
answers295
viewsWhat’s the difference between using Return and print in this recursive function that calculates the sum of numbers?
I made a simple function in Python to give me the sum of the numbers n until 0: def retorna(n, zero, soma): if n <= zero: soma += n return soma retorna(n+1, zero, soma) ret = retorna(1, 5, 0)…
-
0
votes2
answers724
viewsFlask MVC - doubts
I have doubts about making my application as organized as possible, I’m having trouble implementing MVC ... This is the file that starts the application from flask import Flask app =…
-
0
votes1
answer414
viewsHow Exploits are created?
I was researching server security, and I ran into the subject of exploits, I already understood the logic of a DDOS attack and an exploit buffer overflow, but I’m curious about one thing: How do…
-
0
votes1
answer111
viewsIs it possible to compare items without if?
I now challenged myself little to develop a function that returns if a number is greater than 5 without the use of any comparison operator, as assertion, while, ternary operator, if which directly…