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
answer694
viewsHow to build a url in Django?
I am learning Django, but one thing I have not understood so far is, how to build a url, I know it uses regular expression, but someone there has how to explain to me, or indicate me a material that…
-
3
votes1
answer853
viewsTime interval query in mongodb using pymongo
I need to perform a query in a mongodb database that results in a set of results per time range. I am using pymongo. My consultation is as follows: queryConsulta = {"$and": [ {"id_no": id_node},…
-
3
votes2
answers1841
viewsHow to forecast values of a variable?
Long live. I don’t know much or anything about predicting values. My problem is knowing how to predict future values of a certain variable based on a set of previously annotated values ... Know…
-
3
votes1
answer534
viewsHow to call a Python script in a C++ code in Qt Creator?
How do I call a Python script in a C++ code in Qt Creator?
-
3
votes2
answers208
viewsI cannot get return of floats through expressions
When I try to give print(6/10) get a int (0) instead of a float (0.6) And if I give type(6/10) returns int. I’m following this tutorial and doing exactly the same steps in both pyCharm and IDLE,…
-
3
votes1
answer1176
viewsSearch for nested list elements
I’m having a problem with a code. I have to find a specific element (I know what element it is, but I don’t know its position, because it is random). Under normal conditions, I would use a index and…
-
3
votes1
answer126
viewsHow to manage the operation and failure in the execution of Spiders?
I’m developing a module to get information about the Piders that run on the company’s system. Below is the model where we keep the beginning of operations and the job. I would like to validate if…
-
3
votes2
answers232
viewsPython-docx module error in Windows
I’m using the following code: from docx import Document d = Document(open("arquivo.docx")) This code works on Ubuntu but does not work on windows. In windows I have the return in the terminal:…
-
3
votes2
answers833
viewsHow do I know if request.FILES is empty?
I have a code on Django where I want to upload a file from a form. At a given precise moment check if the index exists "arquivo" within the variable request.FILES I did it using the method has_key…
-
3
votes3
answers1207
viewsWhat’s the difference when calling a function with parentheses and without in.py urls with Django 1.7?
In mapping my.py urls I use from common functions to class-based views. I want to know the difference between calling the view with or without parentheses, given that if I have the input url(r'^$',…
-
3
votes1
answer916
viewsUnderstanding the Django 1.7 permissions system
I have an app called forms_and_models which I use for study. In documentation of Django 1.7 says that: Assuming you have an application whose app_label is foo and a model called Bar, to test basic…
-
3
votes1
answer552
viewsInsert data into mysql, commit() does not work
I wanted to enter in the database definitely. But with this code I am not able, the record is saved but does not commit(): import MySQLdb def conn(): try: db =…
-
3
votes1
answer230
viewsPython subprocess.check_output command
I am calling a program in Java via command subprocess.check_output python. It is not working. In this command I pass a file as parameter. There’s something wrong with the command below? import…
-
3
votes3
answers683
viewslist index out of range when trying to resolve the issue of google Developer day 2010
First of all, I am going to copy here the statement of the question to place: In the quiet village of Ponteironuloville, all the phones have six digits. The phone company establishes the following…
-
3
votes1
answer1296
viewsHow to accent in Python
I’m writing a program and it keeps giving ascii error. I’ve put this on the first line and nothing: # -*- coding: utf-8 -*- On request, follows edition explaining what is now. now is variable for…
-
3
votes0
answers889
viewsLinux Script - Find, Copy, Paste and Change Text Files
I have these 3 files: Access.txt: Large text file with row records and columns separated by " ; ". NewAcess.txt: List of new accesses to add. NewUsers.txt: List of new users to add. File Example:…
-
3
votes1
answer84
viewsEditing of python files
I intend to insert in files .py the stretch below: -*- encoding: utf-8 -*- needs to be in specific line, and in large amount of files. Is there any Unix/linux tool that can perform this task?…
-
3
votes2
answers911
viewsWhich plugin do I use to commit on Github using Pycharm?
I’m a beginner in Python and would like to know which plugin is required to commit on Github using Pycharm.
-
3
votes1
answer479
viewsHow to simulate a form action=POST with urllib2
I want to create a program that reads my college notes and display on the screen , for this I am using urllib2 to receive the web page where my notes are presented but to receive I need to log in.…
-
3
votes2
answers1020
viewsDoes Netbeans support Django?
I installed the Netbeans and the plugins for python. Everything worked out, but I found what did not happen.This plugin alone would already support Django. I saw on this blog the author saying that…
-
3
votes1
answer611
viewsProblem comparing strings and string being broken into two python lines
I was creating a game that scrambles words, and the user has 6 attempts to guess what the word is. I’ll put the code here: import random def main(): while True: input('Presisone enter para sortear…
-
3
votes2
answers355
viewsHow to find, check and change file?
I have a question about being new to the python. I have a file for example: bla bla bla bla bla bla 5 bla bla bla 846:545 energia 3 I intend to read from the file teste.txt the energy information.…
-
3
votes1
answer112
viewsAttraction of objects in python
I’m writing a code where one image goes toward another only for some reason it’s not working. I take the distance between them calculate the gravitational force Fg = G*M1*M2/D^2 of attraction…
-
3
votes1
answer616
viewsQueryset on Django without case-sensitive
I have a question about Querysets in Django. I need to search a field that’s a Charfield, only the research I’m doing appears to be case sensitive. And I wanted that when searching for 'Stack' the…
-
3
votes2
answers1428
viewsSend objects to a base.html Django template
My situation is this, I have a file base.html where more than one page extend in it. My question is, how do I send two objects to this file, so that these objects are shown in all other views, which…
-
3
votes1
answer228
viewsPython exercise
In the codeacademy, I’m having the error with the following code: # Tenha certeza que the_flying_circus() retorna True def the_flying_circus(): if 5==5 : # Comece seu codigo aqui! return True # Nao…
-
3
votes3
answers9505
viewsDifference between dates/times in Python
I need to calculate the difference between two dates in python, but always some error. >>> from datetime import datetime >>> data1 = datetime(2015, 8, 5, 8, 12, 23) >>>…
-
3
votes1
answer169
viewsHave two versions of Python in OSX, no overwrite
Is there any way to install version 3.x of Python without overwriting the pre-installed (essential) version of OSX? I already know the virtualenv but I would like to avoid it, because I only use…
-
3
votes1
answer400
viewsWhich component to use in Pyqt4 to display records of an on-screen SQL query?
I’m developing a graphical Python desktop application using Pyqt4 (Qt Designer), my doubt is about which component use to display on my screen frmTelaPesqAluno records of an SQL query, and how to…
-
3
votes1
answer3054
viewsDynamically display jpg image in python Tkinter label
I am trying to display a chosen image of a Listbox on a Label. The following code works: import Tkinter as tk from PIL import ImageTk, Image window = tk.Tk() path = 'img\\2015722_univ_sqs_sm.jpg'…
-
3
votes2
answers589
viewsRead the last 5 lines of a file through Python
I asked that question here at Stackoverlow Display last 5 lines of a PHP file? Now I wonder how I could do the same thing in Python. How could I get the last 5 lines of a large file without having…
-
3
votes2
answers70
viewsLimit motion copy on specific axes
I’m developing a game in Blender and programming in Python. I had to develop solutions to work with Oculus Rift. Where my character follows the movement of user vision. I am using the following…
-
3
votes1
answer55
viewsIs there any way to disable Scrapyd’s web interface?
Is there any way to disable the Scrapyd web interface? I would like to monitor the server only by the api.
-
3
votes3
answers1652
viewsHow to start a Django project using virtualenv?
I have searched and found several different ways and conventions to create a project in Django using virtual environment (virtualenv). Is there a pattern to this? Someone helps me with a correct…
-
3
votes1
answer878
viewsPython functions
I did this Python exercise, version 2.7: Instructions First, define (def) a function called Cube (cube) that takes an argument called number (number). Do not forget the parentheses and colons! Make…
-
3
votes1
answer1553
viewsHow to extract data from Linkedin with python?
Hey, guys, what’s up? So, I need to extract some information for a research I do at the university and I need to extract some data from Linkedin pages, I was extracting with python using regular…
-
3
votes1
answer132
viewsHow to create multiple homepage in a single portal in Plone?
In a Plone portal, as in any CMS, the content is inserted as images, files, folders, pages, news etc. All this is accessed through a "HOME" Home Page with menus and content that directs the user…
-
3
votes3
answers2559
viewsIs it possible to add int with str composed of text and numbers in Python?
I asked that question Why in PHP the expression "2 + '6 apples'" is 8? here for finding this behavior strange. And in the case of python? I can convert the string '1' str for 1 int. Example: 1 +…
-
3
votes3
answers1818
viewsHow to convert datetime/date to milliseconds in Python?
How to convert a type date and a datetime millisecond? >>> ontem # tipo date datetime.date(2015, 9, 29) >>> hoje # tipo datetime datetime.datetime(2015, 9, 30, 18, 15, 36, 856736)…
-
3
votes3
answers176
viewsIs there a difference between "str(my_object)" and "my_object. __str__()" in Python?
I observed that, in Python, when we have an object with the method __str__, it is responsible for returning a string representing the object - or something like that. Example: from uuid import uuid4…
pythonasked 9 years, 4 months ago Wallace Maxters 102,340 -
3
votes1
answer373
viewsGet image of only one sector in a scanner (python)
Good afternoon! I need to develop a python application and I’m not getting the program to get an image of a scanner sector, only of the entire area that the scanner can scan (approximately a A4…
-
3
votes4
answers14598
viewsPrint only the column of a matrix
I’m a beginner in python and I’m having doubts about the use of list and tuple and its operators. I’m trying to print only the column of an array but I’m not getting it. I’ve tried the following to…
pythonasked 9 years, 4 months ago André Sanches 359 -
3
votes1
answer2229
viewsCoordinates of a Pygame image
How can I get the x and y coordinates of an image in Pygame? I need this for a game where I have to get the shot out right below an enemy. This is the code: # -*- coding: cp1252 -*- import sys…
-
3
votes1
answer138
viewsProblem with the urllib
I am trying to solve the python challege #4 but when I run my possible solution I get an error. My solution is the following: import urllib, re pattern = re.compile("and the next nothing is \d")…
-
3
votes2
answers841
viewsBlock source code Django
I am developing some projects where I will use Django, but I will have to host the server on the client’s machine. Where it will be installed there is no internet, so I have to make the system work…
-
3
votes1
answer1820
viewsHow to make a Join with Django?
I’m trying to run this SQL, using Django’s ORM SELECT * FROM test JOIN questionnaire q ON (q.id = test.questionnaire) WHERE q.discipline = 4; Models: Test, Questionnaire, Discipline…
-
3
votes2
answers698
viewsPython clock does not update
I am trying to create a clock in Pygtk. But it seems that there was some semantic error here: #!/usr/bin/env python2 # -*- coding: utf-8 -*- import pygtk pygtk.require('2.0') import gtk from…
-
3
votes1
answer88
viewsList element Zera after loop for
I created an array and filled it with 100 [0] (because I don’t know a better way to do it) and after that I wanted to change these values using a loop for within another loop for. But what happens…
pythonasked 9 years, 3 months ago Pedro Almeida 61 -
3
votes1
answer1636
viewsDjango - Getting form information
I have a template called listaarquivos.html where a table with information of an object of the models.py called JOB. However, now I need to filter this table by date. I then inserted two inputs in…
-
3
votes0
answers494
viewsPython + BH City Hall
I am trying to integrate my Python system with PBH in the question of Nfse. The layout of the file is correct, however, I cannot sign the XML. The layout and this one : <Signature…