Questions tagged as 'python'

1
answer

Wait for thread to finish before closing program

I have a loop while that ends only when I press the q key, then the program quits. Within this loop , at a certain time or condition, I start a thread that takes a few 10 seconds to execute. My problem is, if I exit the loop...
asked by 26.03.2015 / 16:02
4
answers

Generate random values from a distribution in Python

Hello I'm trying to generate random values from a distribution (Gamma, normal and etc) in python, but I'm having trouble importing the library. I am using the following library "import scipy.special as sps", but it is giving error ... using b...
asked by 11.11.2015 / 19:24
2
answers

How to put part of a bold text in Tkinter?

I need to display text in a GUI interface made with TkInter, however, I would like only one word in the middle of this text to be bold. I'm using it as follows: texto = Label(Frame, text="Texto qualquer com mais de 5 linhas", font= fonte qu...
asked by 29.07.2015 / 13:56
1
answer

Can not assign "'Maria'": "Student.name_mae" must be a "Student" instance. When I try to access a field from the student subclass

I have a system with multiple users, I decided to make inheritance from the standard Django User, I have two users: student and teacher, which has several characteristics in common, so I created a User base class and subclasses Student and...
asked by 11.06.2015 / 19:56
4
answers

Python - NIM Game

Statement You should write a program in the Python language, version 3, which will allow a "victim" to play the NIM against the computer. The computer, of course, should follow the winning strategy described above. Let n be the starting...
asked by 15.02.2017 / 01:51
1
answer

Start and tear down test bank flask

I'm doing a test of api, that I pass a json it validates me if everything went ok: My base class: # -*- coding: utf-8 -*- # base.py import os import unittest from app import initialize from mock import mock from flask import Flask from fla...
asked by 22.03.2017 / 21:49
1
answer

Dropdown dependent on each other

I'm using a function from this site: link The function works perfectly, when I select an option in a dropdown, the 2nd DropDown already brings me what I want, the only problem is after clicking the submit button that does not bring me...
asked by 25.06.2016 / 05:02
1
answer

Lists and dictionaries python

I'm working on Python 2.7. import collections counter_ger=collections.Counter(sub_todaas) a=counter_ger.values() b=counter_ger.keys() sub_ind_novo = [Ntodos.index(i) for i in b if i in Ntodos] (where Nodes contains many names, among which a...
asked by 30.05.2016 / 18:58
2
answers

render specific part of a page

I'm using the following code to render a webpage: import dryscrape # set up a web scraping session sess = dryscrape.Session(base_url = 'http://www.google.com.br') # we don't need images sess.set_attribute('auto_load_images', True) # visit s...
asked by 26.05.2015 / 16:08
1
answer

Define class for a table

I'm starting now with Flask and I came across the following question: how do I define a table class using flask_table ? Here is my sample code and the result: from flask_table import Table, Col class TabelaDados(Table):...
asked by 04.05.2015 / 23:03