Questions tagged as 'python'

2
answers

Use order_by in Django

I try to sort a post list in Django. I read that you have to use .order_by('-fecha') . I have tried the following in the template: {% for post in persona.post_set.all.order_by('-fecha') %} {{ post.texto }}<br> {% endfor %} B...
asked by 01.08.2017 / 08:55
2
answers

Why does it mark me list index out of range?

Can someone tell me what error I have in my code if it is not too much trouble. def CreaLista(k): L = [] for i in range(k+1): L.append(0) return L def CountingSort(A,k): C=CreaLista(k) B=CreaLista(len(A)-1) for...
asked by 27.02.2017 / 09:01
2
answers

re.search does not read all matches

I am making a regular expression to find all the words in a sentence. I have the following: import re emoji_pattern = re.compile('[A-Za-z]+') print(emoji_pattern.search("jajaja que haces?")) But when I run it, it gives me <_sre.SRE_...
asked by 07.03.2018 / 05:18
1
answer

Decorator with parameters in Python

I need to implement a decorator with classes or functions that receive parameters, like the following example @MyDec(flag='foo de fa fa') def bar(a,b,c): print('En bar(...) : ',a,b,c)     
asked by 11.08.2018 / 21:53
3
answers

Calculate exponent - Difference between pow () and **

As I said in the title, I found two ways to calculate the exponent in python and both work for me, a = 2 print (a**2) print (pow(a,2)) Both give the same, what is the difference? When to use one or the other? Health and thanks!     
asked by 08.10.2018 / 19:16
4
answers

Minimum value of a list

I'm putting together a list lista.append(['{}{}'.format('Metros: ', metros),nombre,direccion]) and the output is: [['Metros: 405', 'edificio A', 'San Lorenzo'], ['Metros: 1843', 'edificio B', 'Eusebio Blanco'], ['Metros: 3067', 'edificio...
asked by 10.04.2018 / 17:07
2
answers

How to know in Python if the elements in a list are different?

I want to know how I can do to verify that the elements of a list are all different (none repeated). Ex: lista=[1,-1,1,3,9,5] codigo_verificador() Exit: True # Hay un elemento repetido How can I know that there are repeated elements...
asked by 13.10.2018 / 03:02
2
answers

Add integers of an array in python

This is a simple question but I have not found any post related to this topic. matriz=[[1,2,3],[4,5,6][7,8,9]] I would like to add all the grids of this matrix to each other (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) so that I returned 45 in a new...
asked by 23.05.2018 / 23:43
2
answers

Kivy: Display a text saved in a variable

based on the example of this question I want to make a program that shows me a text saved in a variable, "g". There goes the code: # config from kivy.config import Config Config.set('kivy', 'keyboard_mode', 'system') #¿Para qué sirve esta lí...
asked by 15.04.2017 / 21:16
1
answer

VUE Js does not work as a bookstore at DJango

I have an application that I am developing in django and I want to use VUE js as a library but not as a framework, download the library and import it but I do not even work the example of vue Base.html The lbreira de vue is imported here...
asked by 02.10.2018 / 17:14