Questions tagged as 'python'

2
answers

'key' in dict vs. dict.get ('key')

What is the main difference between: >>> dic = {} >>> existe = dic['key'] if 'key' in dic else None >>> existe None Y: >>> dic = {} >>> existe = dic.get('key', None) >>> existe None...
asked by 05.04.2018 / 18:05
2
answers

Error in MySQL stored procedure - Python

I have this procedure in MySQL: sql_procedure = """CALL INSERTAR_OPORTUNIDAD(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%...
asked by 03.08.2017 / 22:18
1
answer

Error entering data with input ()

This is my code, which I run in Python 2.7.13: print "hola" hiola = input() if hiola == salsa: print "hola" And the error that throws me is the following: Traceback (most recent call last): File "C:\Programacion\Python\hola.py", li...
asked by 17.05.2017 / 21:03
3
answers

Standalone with django + pyinstaller

Dear, I have developed an app with django, but now I have a problem when I want to compile binary (.exe). I'm using Django + PyInstaller, although I can get to get the binary, but when executing it there is an error that obstructs the execution...
asked by 19.05.2017 / 14:22
2
answers

Concatenate byte with string in Python 3.5.2

I am making an application where I detect data from a sensor from Arduino and I want to print them together with the date and time. The data I read from the Arduino serial port is byte type, while the date and time are str. I want to concaten...
asked by 28.09.2016 / 08:30
2
answers

How to get the elements of a list by pairs in python [closed]

I have this list in python [a,b,c,d,e,f,g,h] How can I get the elements by pairs stored in a list of tuples. In this way: [(a,b),(c,d),(e,f),(g,h)]     
asked by 04.09.2016 / 20:54
1
answer

Does the method (Copy ()) of the lists in python make sense? (Python)

The method copy() makes a superficial copy of the list, but I do not see any sense to use it, if I want to make a copy of the list I simply do: lista2 = lista1 Instead of: lista2 = lista1.copy() What is the copy() metho...
asked by 17.03.2017 / 23:29
1
answer

What is the difference between using a field validator or validating the model using clean?

Assuming I have a Django model like the following: class Comprobante(models.Model): punto_venta = models.IntegerField(blank=True) And I want to validate the model and particularly that punto_venta is a value from 1 to 9999. I und...
asked by 01.05.2018 / 06:18
1
answer

Iterate over a list and a dictionary to find mutations in a DNA sequence

I want to find a series of mutations by comparing a couple of sequences. The mutations are defined in two dictionaries and the two sequences have been converted into a list of tuples per position with zip() . I have written the followin...
asked by 01.06.2017 / 15:34
1
answer

Transform dataframe dictionary into a single DataFrame

I have a dictionary that has Pandas dataframes as values. I want to get a new DataFrame joining all the dataframes contained in the dictionary. The problem is that I need to create a new column in which each row has the value of the key o...
asked by 06.07.2017 / 11:50