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
-
2
votes1
answer519
viewsPing - store positive results in a list
I have this code, it’s working fine, but the problem is that I would like to save the hits (ping with feedback) in a list, but I don’t know how to do this screening successes/failures. import…
-
2
votes1
answer121
viewsFile per folder limit - Django 1.7
Does Django 1.7 provide any upload control mechanism per folder? I say this because when the number of files in a folder gets too large it tends to get slower. An example would be: Every 800 files…
-
2
votes0
answers816
viewsPhilosophers' Dinner in Python
I wonder if anyone has implemented the python Philosophers' Dinner algorithm. I need to do it, but only find examples with implementation using thread and need to do without using thread.…
-
2
votes2
answers205
viewsTypeerror: 'float' Object has no attribute 'getitem'
First, as soon as the mouse is clicked, the shooting angle ( that is the same angle of the player) is stored in the bullets_array list. Second, it is given speed to the shot through the 'cos' and…
-
2
votes1
answer165
viewsHow to build a queryset that returns only the cars with the last approved revision?
I’m looking to create a queryset that returns only the cars that have had the last approved review. It is known that there may be n cars, and each car has a history of revisions, so there may be n…
-
2
votes1
answer236
viewsError trying to install yowsup: Unable to find vcvarsall.bat
I’m trying to install an application that performs cell phone registration on Whatsapp. I tried to use the command below: python setup.py install And the following error occurs: error: Setup script…
-
2
votes2
answers376
viewsProblems with Javascript, urllib and Beautifulsoup
The idea of my code is to catch the link of the video and run directly on the VLC, but I came to a problem: apparently the urllib does not execute Javascript code, since player is placed on the page…
-
2
votes2
answers157
viewsProgramming in Python
I downloaded python 3.4 on the site, but some commands do not work in this version compared to python2.7 is there any difference? In the python2.7 manual, and I can install two?
-
2
votes2
answers1700
viewsIDLE closing alone by pressing quote
Until today I was using the terminal itself to program in Python, but today I decided to download IDLE. When I try to put the single quote ( ' ) it just closes. Can someone help me?…
-
2
votes5
answers11991
viewsHow to validate and calculate the control digit of a CPF
How does the algorithm that calculates the digit of a CPF (Cadastro da Pessoa Física Brasileiro) work? And how is this calculation used to validate the CPF? If possible, I would like examples in…
-
2
votes2
answers106
viewsswap commands in the shell
The command python foo.py When called on the terminal, it runs the uploaded python file. Imagine that I have a python file that always needs to be called as follows: xvfb-run python foo.py to work.…
-
2
votes2
answers674
viewsHow to use an iterator twice within an understanding?
Let’s say I have a list: lista = [(1,1), (1,2), (1,3), (2,6), (2,4), (3,1), (3,2)] And I want to know the maximum and minimum values of the second element, grouped by the first. That is to say: {…
-
2
votes1
answer1452
viewsQuestion: how to fix the Unicodeencorror in Python?
Since I changed machines, I’ve been having the following problem with the interpreter Python: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 17: ordinal not in…
-
2
votes1
answer382
viewsHow does Python interpret multiple comparison operators in sequence?
I found the following using a Python REPL: 3 == 3 > 2 => True Initially I thought it might be something related to the precedence of operators, however: 3 == (3 > 2) => False (3 == 3)…
pythonasked 9 years, 5 months ago bfavaretto 64,705 -
2
votes1
answer117
viewsEditing Exif of an image
I need to edit the information exif of an image, such as location and date, for example, but I’m not able to find any library that does this with Python 3.4 and Windows. The most I got was using…
-
2
votes2
answers1336
viewsModules in Python linux
I’m having some problems installing modules in my python on linux. I’m currently using python 2.7.10, most modules I use Pip to install, but when I run python 2.7.10 and import my module it says it…
-
2
votes1
answer1015
viewsProblem handling text files with python
I’m trying to make a hangman game, and for that, I’m taking word lists and putting them in files in format .txt for Python to use in the game. When picking up a list of names of people, have some…
-
2
votes1
answer503
viewsWhich language performs best for the multithread webcrawler using parallelism
I will start a project in which one of the phases will fetch certain information on websites of other companies. Bearing in mind that the webcrawler will go through x sites, and on each site will…
-
2
votes1
answer340
viewsDoubt to transpose part of a table with Python
I need help to build a Python script that transposes part of a csv as in the example below: [[0A,0B,0C,0D,0E,0F] [01,02,03,04,05,06] [07,08,09,10,11,12] [13,14,15,16,17,18] [19,20,21,22,23,24]]…
-
2
votes1
answer1040
viewsPackage strings using struct
I’m doing a basic exercise using the module struct, and I came across a problem: To pack a string, we should inform in the method struct.pack() the number of characters it has, right? But what if…
-
2
votes2
answers54
viewsI can’t delete key in dbm
I made a basic program to store some data and I am in trouble if the user chooses the option to delete some stored dictionary key. The function that erases data in my program is this: def…
-
2
votes2
answers738
viewsProblems trying to save to "POST" = "no-such-table" Django / Python database
I’m following a course by Python and Django, and the problem begins when the version in the course is 1.1.2 and mine is 1.8.2 I managed to generate a form to save "Events" however, when clicking on…
-
2
votes1
answer812
viewsLicensing of programs made in Python
Because it is an open programming language, will any software created from it be opened? Or it is also possible to develop closed operating systems?
-
2
votes1
answer156
viewsProblems with Psycopg2 on MAC
I’m getting beat up with Python + Postgre and Psycopg2. I installed Python 3.4 on my MAC, then Postgre and then followed the following steps: export PATH=/Library/PostgreSQL/9.4/bin:$PATH pip…
pythonasked 9 years, 4 months ago Leandro Garcia 21 -
2
votes1
answer86
viewsError with the asyncio module
I’m trying to run the example below in IDLE (Python 3.43, Windows 7, 64bits), there are days, but always gives an error. I tried to search for solution on the English version site, on google, and…
-
2
votes1
answer168
viewsInsufficient Permission with Google Calendar api v3 using python
I’m not getting permissions to create the event. Below the code I’m using: import httplib2 import os import json from apiclient import discovery import oauth2client from oauth2client import client…
-
2
votes2
answers1166
viewsHow to return a query in JSON format with extra values and custom Keys?
I want to return the result in JSON following this format: {"cadastros": [ {"id": 1, "STATUS": true, "pessoas": [], "podeEscrever": true}, {"id": 2, "STATUS": false, "pessoas": ['Maria', 'Ana'],…
-
2
votes1
answer669
viewsWhat can happen to my project if I remove the virtual environment set up for it?
Let’s say I created a virtual environment through virtualenvwrapper $ mkvirtualenv venv. I create my project, make the necessary settings, start working on the project and one fine day I do the…
-
2
votes3
answers381
viewsHow to create expression that returns 1,12,123,1234 in Python
I’m learning the basics of python and I came across an exercise where I have to build the following sequence: 1 12 123 1234 12345 123456 1234567 12345678 123456789 I think it’s something very simple…
pythonasked 9 years, 2 months ago Marcos Lopes 145 -
2
votes1
answer445
viewsAngularjs and Django integrationForms to record data
How you’re handling Javascript frameworks integration with forms django? Sample scenario Address forms where there is a telephone field (Many-to-ONE), which in the template is represented by an…
-
2
votes1
answer574
viewsError with Flask Babel Python3 app (Windows)
I’m following the article tutorial http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-web-forms/page/3#comments I got to part three and made that mistake. I’m confused because the…
-
2
votes1
answer162
viewsProblems with Contour() in python
Hello, I’m having some problems with pylab’s Contour() function. In the final image, the values of the x and y axis are ranging from 0 to 600, which was the number of intervals in my arange().…
-
2
votes1
answer163
viewsHow to register a data matrix in Django
I have an array of data in my Storage Session related to products from a store, and would like to register a sale as soon as the user registers all their products and click Finish Sale. This matrix…
-
2
votes1
answer82
viewsRemove Session Data Dictionary with ajax in Django
I have an array with a data dictionary in my Session and would like to remove according to the row the user is going to click on a table where these values are displayed. My view: def…
-
2
votes1
answer3340
viewsPython: Unsupported error operand type(s) for /: tuple and 'int'
Hi, I’m having a problem with a Python function, which involves a tuple stack. When performing this assembly function calling the tuple tuple votes: votacoes = ( (0, 15729, 220408, 1297, 0, 3040,…
-
2
votes1
answer478
viewsPrimes Numbers Using Python Threads
well I need to create a program in python using threads that find the largest number of primes in 60 seconds, but I cannot understand the use of threads for it:` import time import math def…
pythonasked 9 years ago Marcelo Souza 23 -
2
votes1
answer1017
viewsProduct of a function
Hi, I was wondering if there are any commands to perform the production of a function in Python. I’m creating a function to make the product of another function. def fx(a, v, t): return (…
-
2
votes0
answers76
viewsWorking with vectors
I need to generate a vector with 100 random number positions and see what the ratio of numbers 2 to every 10 vector positions, the first part I got, but not the rest, it helps? import random as rd…
-
2
votes1
answer161
viewsRefactoring Python code
How do I improve this code? import random import string import requests from django.core.management.base import BaseCommand, CommandError from django.core.exceptions import ValidationError from…
-
2
votes1
answer342
viewsANSI codes are not working on a Qtextedit
So I’m developing a Python project and I’m using Pyqt5. In the project there is a QTextEdit where I need to put some words in different colors. I’m using ANSI encoding but it’s not working, I’ve…
pythonasked 8 years, 11 months ago user36793 -
2
votes1
answer642
viewsHow to protect image files and ini files?
I am developing a software in Python and I’m using files .ini and images. Does anyone know a way to protect these files against user editing? I don’t want the user to keep changing the images of the…
pythonasked 8 years, 11 months ago user36793 -
2
votes1
answer334
viewsCreate python executables (portability)
I have python code developed on macos system. It is possible to generate executables to run on other systems (windows, linux)? Example: the file file.py was written and tested on macOS system, but I…
-
2
votes0
answers170
viewsPython board writing problem: 'Typeerror: not all Arguments converted During string formatting'
How can I fix this? There’s the code. `` looks like this: [(((2,), (3,), (2,), (2, 2), (2,)), ((2,), (1, 2), (2,), (3,), (3,))), [['?', '?', '?', '?', '?'], ['?', '?', '?', '?', '?'], ['?', '?',…
pythonasked 8 years, 11 months ago João Machado 27 -
2
votes1
answer63
viewsNameerror in get_special_folder_path
I did a little test in Python 2.X to try copying a file from the folder the script is in to the Windows startup folder: import shutil import sys, os startuplocation =…
-
2
votes2
answers2646
viewsPython installed but Environment Variables (Environment Variables) does not contain the information
I installed Python 3.5 and in its installer comes with the option to put it automatically in Environment Tables, but it didn’t work, as I do to add it so it can compile?
-
2
votes2
answers398
viewsSelenium Python
I’m having trouble manipulating popup. Apparently, the popup code is generated in real time, not being captured by Selenium. In fact, it is possible to see the use of jQuery, I did not detect Ajax,…
-
2
votes1
answer86
viewsSession in Forms
What I did I have a view that calls a template with a form. In a given case, I need to save some data in the session scope and send it to another url - which will call another view and another…
-
2
votes2
answers2854
viewsChoose folder to save a file
I have this code that I select the place to save the file filename_2 = QFileDialog.getSaveFileName(self.dlg, "Select output file") self.dlg.pasta_saida.setText(filename_2) however I would like to…
pythonasked 8 years, 10 months ago Guilherme Lima 3,129 -
2
votes1
answer57
viewsInclude in <head> Djanto Templates
I have the following files: base.html: <!-- base.html -- --> <html> <head> <title>Title</title> {% include "head.html" %} </head> <body> Body </body>…
-
2
votes1
answer71
viewsError installing module - egg_info
Good afternoon, I’m using python 3 through Anaconda. I need to install the Pattern module and I’m trying to install it through eating Pip. Pip install Pattern I get the following error: "python…