Questions tagged as 'python-3.x'

3
answers

Take a parameter in a url and send it to the model when a form is sent

I have a CreateView view to which I am passing a PK by the URL, what I want to do basically is to take that station and send it to a field of the model with which this view works (the form does not contain the model field to which I want...
asked by 18.07.2017 / 06:45
2
answers

How to avoid an error

I have a list with 2 elements a=[1,2] if I put for example [2] as it will mark > > Traceback (most recent call last): File "<pyshell#13>", line 1, in <module> > if a[2]== IndexError(): IndexError: list index o...
asked by 24.03.2018 / 19:57
3
answers

Search for a sequence from a list in another list

I'm trying to find a sequence from a list in another list. But I do not understand why my exit is "no". all: is not a solution because it returns true even if the elements are not in order set: is not a solution because I need the repe...
asked by 14.09.2017 / 16:04
1
answer

Use of * args and ** kwargs in python [closed]

I have seen examples of code in which the functions receive parameters *args and **kwargs . I do not understand that syntax nor in what cases it should be used. Although I have tried to read about it, I have only found informatio...
asked by 20.09.2018 / 07:48
2
answers

Is there any way to deny something like isinstance () in Python?

To make my question clearer, I give an example in code R which is the language in which I have a little more experience. Suppose I have the simple variable "a" that is worth 5. First of all I want to validate if it is numeric using is.num...
asked by 16.11.2018 / 20:50
2
answers

Why do the private attributes of a class change despite assigning them to another variable?

You define a class with a 'private' attribute called __rango then you want to make a copy of this attribute in the variable rangoT to modify it without affecting the original attribute, but both change its value. Class definitio...
asked by 10.04.2018 / 21:06
2
answers

problem with list in python

The exercise asks me to store 5 numbers read in a list and to show the POSITIONS of the largest number, but I do not know how to do it, because if the higher number is repeated 1 time, the program works for me, but if it is repeated several time...
asked by 30.09.2018 / 06:27
1
answer

I do not understand how Or works in python I refer to the following code

Someone can help me because and how it works in python because I try to do it according to the documentation and it gives me different results import operator operator.or_(2,8) 10 operator.or_(8,2) 10 8 | 2 10 2 | 8 10 2 or 8 2 2 | 8 10...
asked by 04.01.2019 / 16:04
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