Questions tagged as 'python'

1
answer

Store Log of errors and debug for django

I hope you can help me, I am using this code to store the log of my application with django 1.10 but I continue to generate the log of a large size (more than 200mb and increasing), I would like to know how to make it to generate a more small an...
asked by 24.10.2016 / 16:10
2
answers

Problems with Dictionaries

I am trying to use a diccionario as a switch , My code is: a = {'1': f1(x, y), '2': f2(x)} while True: try: selection = getOption() b = a[selection] break except Exception: print "Error"...
asked by 13.03.2016 / 18:47
2
answers

How could I read a file.txt line by line and pass those values to a Python file?

with open("login.txt") as fichero: dirServer = fichero.readline().split(":")[1].strip() usuario = fichero.readline().split(":")[1].strip() passwd = fichero.readline().split(":")[1].strip() datos = {} busco = ['dirServer', 'usuario',...
asked by 25.10.2018 / 10:50
2
answers

Go through and remove all zeros from a list

I have the list a = [1,2,0,3,0] And I need to delete the zeros so that the list to have this a = [1,2,3]     
asked by 28.02.2018 / 18:35
4
answers

command to be able to compare between a string and an integer in Python (as a condition)

I have a question, how can I compare between string and integer in Python? I want that if my data entered is a string, give me a message and if it is an int that my code continues. Code that I tried: n=raw_input("ingrese numero jugadores: "...
asked by 16.04.2017 / 16:04
1
answer

IndentationError: expected an indented block

By running this code in jupyter: def plot_feature_importances_cancer(model): n_features = cancer.data.shape[1] plt.barh(range(n_features), model.feature_importances_, align='center') plt.yticks(np.arange(n_features), cancer.feature_names) plt....
asked by 15.06.2017 / 14:34
1
answer

Python MemoryError, maximum limit?

I need to create a matrix NxN where N=55000 , the problem is that I do not know if I reach the memory limit supported by python. When I run this line: metric_space = np.zeros((N,N)) simply returns me: MemoryError is there...
asked by 15.05.2017 / 12:08
2
answers

In python I use the key to see the commands that an object has

For example with numpy, if I give it "numpy." after the . I want to see the command list that I have, before I did it with the tabulator key but it is not working anymore, or I do not remember correctly, I'm using the idle 3.6.0     
asked by 29.03.2017 / 19:03
3
answers

How to get names and surnames from a text string with spaces and save them in a list in Python?

I am working on the processing of excel files that have a work data form. I am currently using Pandas and I get lists for each field consisting of 2 cells. The problem that occurs to me now is in terms of the data of the worker's children,...
asked by 09.11.2018 / 16:32
1
answer

How to simulate a C struct in Python

I want to do is create a class called Person containing three items (name 'str', age 'int' and dni 'int') in turn have a separate function that is responsible for filling those fields to a person xy so save the data of that person x inside a fil...
asked by 26.12.2018 / 10:56