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
-
4
votes1
answer256
viewsHow to allow just one instance of a program made in Python?
Assuming I created a program in Python and it is working perfectly, how do I allow just one instance of the program at a time? I Googled and found a person saying to have solved the issue using…
-
4
votes3
answers8272
viewsHow to call external command with Python?
How can I call an external command in Python, as if it ran in the Unix shell or Windows prompt?
-
4
votes1
answer2188
viewsRead rows and columns merged in excel, using python
I’m having trouble reading the information from a spreadsheet that has rows and columns merged. I tried to use merged_cell to get the value, but I don’t understand how it works. Can anyone help me?…
-
4
votes2
answers1011
viewsProblems with saving data in form-model Django
Gentlemen, good afternoon to you! I’m facing a small problem, I made some changes in an application I’m developing for studies. I come across the following, fill the form all right and when I go to…
-
4
votes1
answer102
viewsExceptions.py file
I program in python about a year ago, and I’ve always seen in some projects that I see on the web, an archive called exceptions.py. I can handle exceptions within my codes, this is not my doubt. I…
-
4
votes3
answers533
viewsDifficulty with web scraping
<tr bgcolor="FFF8DC"> <td valign="top">25/06/2014 20:37</td> <td valign="top">25/06/2014</td> <td> <a href="Javascript:AbreArquivo('430489');">BROOKFIELD…
pythonasked 10 years, 8 months ago rodriguesra 41 -
4
votes1
answer110
viewsHow this expression 'a' <= c <= 'z' is evaluated in Python
I would like to know the evaluation order of this expression in Python: if 'a' <= c <= 'z': # c é uma variável de tipo `chr` print("Ronal... D'oh!")
-
4
votes3
answers271
viewsHow to allow only one instance of a certain class?
If we execute the code below, a window will be created with a button inside, that every clicked will open another window (Window2)... How do I not allow a second instance of Window2? I want to do…
-
4
votes2
answers481
viewsDecode HTML entities in a Python string
I’m using Python 3 to access a web API. The response to the requests comes in the JSON standard and my problem is that one of the Strings comes encoded with HTML entities (specifically…
-
4
votes1
answer138
viewsDoubt in string comparison and list value for all lines
I have a table of 5 rows and 5 columns. For each column I have a name, for example: Name, Age, Gender, Weight, Height. And all cells 5*5 are filled. I need the following formatting: Idade João - 15…
-
4
votes2
answers126
viewsHow to calculate an optimal value for Scrapyd’s CONCURENT_REQUESTS variable?
One of the default settings in Scrapyd is the number of concurrent processes (is 16). CONCURRENT_REQUESTS = 16 What would be the best methodology to calculate an optimal value for this variable? The…
-
4
votes0
answers462
viewsDjango Session timer Countdown
I have it on my login screen: SESSION_COOKIE_AGE = 1200 # 20 minutos and would like to show the remaining time on my template. Someone knows a good middleware or package for Django that adds a time…
-
4
votes1
answer454
viewsHow to simulate a time trial with Tkinter?
I am developing a game in python "Who wants to be a millionaire" and wanted to put in the game the "time trial" to appear the time while we answer the question and when time runs out and the…
-
4
votes1
answer255
viewsDifferences between Rcurl, httr (R) and requests (python) when making a POST
I was wanting to access a page that gets you by clicking "Displays all the above documents" at that link. The company I took is just an example, I have no interest in it. I tried to resolve this…
-
4
votes1
answer2578
viewsRead serial port values using Pyserial
I created a plugin to monitor an Arduino presence sensor for Nagios. The plugin read values from the serial port in Arduino. The problem is that Nagios does not let the plugin running, it executes…
-
4
votes1
answer1863
viewsCalling python script via a php script accessed by the browser
I have a php script that will receive upload videos and I would like to convert these videos using ffmpeg. I created a python script that takes parameters from php and calls ffmpeg to do the…
-
4
votes1
answer326
viewsPython - Test read permissions
Is there a function that returns, in Python, True if I have read permissions for the python file?
-
4
votes1
answer907
viewsWhat is the best way to fragment a Django project into apps?
I’m doing a study project to apply what I’ve learned so far with Django. My question is: what is the best way to segment the project in apps? If you want to give an example so that something…
-
4
votes2
answers2699
viewsRevert a string and add method to native objects in Python
In Python, we have the method reversewithin the List. It reverses the order of a list. Example: [1, 2, 3].reverse() // [3, 2, 1] However this method is not present in a string. example (Python):…
-
4
votes1
answer606
viewsSingle email field on Django User model
I have a system that has a user register and I’m using the lib django.contrib.auth.models to make this registration. However I I need this model’s email field to be unique. from django.db import…
-
4
votes2
answers1301
viewsHow to format datetime in YYYY-MM-Ddthh:mm:ss.sTZD format in Django/Python?
I’m having a hard time in Django returning the datetime in the local Timezone. No Django configurei USE_TZ=True and TIME_ZONE = 'America/Sao_Paulo' By calling timezone.now(), returns the datetime…
-
4
votes2
answers1595
views -
4
votes2
answers152
viewsPermutations and files
I’m working on a game that involves permutations, to create a list of words, in several separate files. Problems start to arise when I require words with more than 4 letters, as the corresponding…
-
4
votes1
answer1443
viewsWhat is the difference between dump and dumps from the Pickle module in Python?
I have read the documentation of Python and also of Pickle himself, but I could not assimilate the content (lack of examples). On the Web I only found information about using "dump + load" and…
-
4
votes1
answer92
viewsGrouping function miscalculating
I’m trying to write a python function that takes two vectors, eliminates duplicates in the first and adds the corresponding data in the second. Kind of trying to emulate the following Mysql query:…
-
4
votes2
answers3087
viewsAccent problem, running at Windows Prompt
I am creating software in Python, I’m having trouble accentuating the strings. The program is simple.. It asks a question to the user (name, version, description, etc.) and adds the answers to those…
-
4
votes0
answers190
viewsError : The manifest file does not exist
I’m having this error when I compile my crosswalk app with the command: >>> python make_apk.py After this command step also the values as --package, --manifest. However, the manifest…
-
4
votes1
answer567
viewsHow to convert this code from Python version 2 to 3.4?
I’m having a hard time convert the code below for the version 3.4 of Python, the purpose of this code is to encode and decode hexadecimal, in order to create shellcodes. import binascii, sys, time…
-
4
votes4
answers12261
viewsHow to know which version in use of a particular package is installed via Pip?
I am starting programming in python and have tried to use best practices: virtualenv, Pip, etc. One of the packages I’ve been using (Pelican) has different help pages for each version. How do I know…
-
4
votes1
answer1262
viewsHow to get out of a loop with hotkeys
I have an app that runs in the background in an infinite loop. How do I stop the loop using hotkeys (Ctrl+F1~F12)?
-
4
votes1
answer159
viewsSmall doubt with numerical operations
I was doing a python function that gives me the results (x' and x") of bhaskara formula, just to train the logic a little bit. And playing a little bit in the shell, I ended up discovering something…
-
4
votes1
answer344
viewsOrganize list with more than one criterion in case of a tie
I’m using sorted to organize a list, but I need two criteria to organize it for tie cases, for this, I call sorted( ) twice. It has how to make this organization calling sorted( ) only once?…
-
4
votes3
answers476
viewsHow do I convert snake_case to camelCase (and vice versa) in Python?
How could I, in any way pythonic possible, convert a string snake_case for camelCase ? Example: snake1 = 'minha_string_snake_case' # minhaStringSnakeCase snake2 = '_teste_string' # _TestString…
-
4
votes1
answer76
viewsI can’t run code after the cycle is
I am using Selenium as Crawler on a website. I have no experience with python. Here I create a dataframe with the data of a .csv df = pd.DataFrame.from_csv( 'tabela_etickets_copa3.csv', columns =…
-
4
votes2
answers6881
viewsGraph possible python paths
I have a dictionary, where the key is a vertex and the value is a list of vertices adjacent to the vertex (key). dic = {'A':['B,'C'],'B':['A','C','D'],'C':['A','B','D'],'D':['B','C']} What I want is…
-
4
votes2
answers1225
viewsHow to read and render a.txt file in the Django template?
How do I render the data of a arquivo.txt in a Django template? contents of the archive: 1;'one';'foo' 2;'two';'bar' I return in the template 1 - one - foo 2 - two - bar Any hint where I start?…
-
4
votes3
answers392
viewsHow to open remote content with python?
In PHP, when I want to get a remote content (some url, for example), I use my own functions to open files and it works perfectly. Example: file_get_contents('/') And in Python, what is the correct…
pythonasked 9 years, 6 months ago Wallace Maxters 102,340 -
4
votes2
answers141
viewsHow to bulk assign variables in Python?
In PHP, to make a variable assignment "bulk" (declare it on the same line), we can do using the function list. Example: list($a, $b, $c) = array(1, 2, 3); How to do this kind of bulk assignment in…
pythonasked 9 years, 6 months ago Wallace Maxters 102,340 -
4
votes1
answer215
viewsWhat is the best way to display in Python? Double asterisk or Math.Pow?
How to best expose in Python? I must use the operator ** or math.pow? Example math.pow: > math.pow(3, 4); #Imprime: 81.0 Example with double asterisk? > 3 ** 4 #Imprime : 81 What I must take…
pythonasked 9 years, 6 months ago Wallace Maxters 102,340 -
4
votes1
answer220
viewsWhy does Python allow you to overwrite the value of False and True?
I’m studying Python and in these studies I came across something curious. > False = True #Imprime: True > print(False) #Imprime: True > False = bool(0) > print(False) #Imprime: False I…
pythonasked 9 years, 5 months ago Wallace Maxters 102,340 -
4
votes1
answer766
viewsI cannot change the state of an Entry() widget in Python and Tkinter
In my code, my Entry() the state is originally as DISABLED. To enable entry, the user would need to mark one of the checkbuttons. Well, at least that’s the idea. What happens is I mark one of the…
-
4
votes1
answer651
viewsHow to copy the path of a selected file in Window Explorer?
How to copy the full path containing the file name to the Clipboard using the "shortcut" CTRL-C? For example: Inside windows explorer select a file (teste.py) using the CTRL-C and then the CTRL-V in…
-
4
votes1
answer1707
viewsOrdering a second list according to the ordering of the first list
I have the following (silly example): lista=[[3,6,4,2,7],[8,4,6,4,3]] I want to put lista[0] in ascending order, modifying lista[1] in accordance with lista[0]. To illustrate what I want below:…
-
4
votes2
answers15191
viewsHow do I know if a list is empty in Python?
I’m starting at the python and always end up appearing some doubts at the beginning. I need to know how to test if a list is empty. As I always say, I come from PHP. So I used to make these shapes:…
-
4
votes1
answer2938
viewsHow to convert a string to Base64 in Python?
I am starting in Python and come from PHP. To convert a string to base 64 in PHP, I do it as follows: base64_encode('stack overflow'); //c3RhY2sgb3ZlcmZsb3c= And in the Python, how do I do that?…
pythonasked 9 years, 4 months ago Wallace Maxters 102,340 -
4
votes3
answers611
viewsHow to build time series with frequencies different from the original?
I have a dataframe with daily precipitation data, with dates 01/01/1900 until 31/12/2010, example: # Data Est_1 Est_2 Est_3 # 17/12/2010 NA 0 0 # 18/12/2010 NA 0 0 # 19/12/2010 NA 1.7 0 # 20/12/2010…
-
4
votes1
answer85
viewsWhat modules do I use to perform data sharing for a Python file?
I have a list of repository addresses git classified according to your accommodation location. @GitHub ('@' demonstra que a linha representa um local de hospedagem) url do repositório a (repositório…
pythonasked 9 years, 4 months ago user24280 -
4
votes1
answer21806
viewsRead rows and columns by Python, by excel
My doubt is if there is any resource for me to be able to read excel rows and columns. For example: I have experimental data in excel containing header in the first row having about 12 columns of…
-
4
votes1
answer279
viewsDo not let user have access to script data
I have a script generated in python and calls functions in R. At first it was developed for internal use, but now they are thinking of releasing for customer use. However, they do not want users to…
-
4
votes2
answers577
viewsInstance in Django model with problem
I’m working on a multi-app project. The department app model is as follows:: from emails.models import GerenciarEmails class Departamento(models.Model): #modelo de grupos de disciplinas class Meta:…