Tagged Questions
Python is a dynamically and strongly typed programming language whose design philosophy emphasizes code readability. Two significantly different versions of Python (2 and 3) are in use. Please mention the version that you are using when asking a question about Python.
0
votes
0answers
2 views
Two Pylons logger handlers (Sentry/Raven and console) for the same qualname
I have a Pylons/TurboGears app. I would like to log the same logger (as specified by the qualname property) to use two different log handlers, each with their own log level.
The Sentry / Raven ...
0
votes
0answers
5 views
A fast method for calculating the probabilities of items in a distribution using python
Is there a quick method or a function than automatically computes probabilities of items in a distribution without importing random?
For instance, consider the following distribution (dictionary):
...
0
votes
0answers
10 views
map, then iterate - why?
In DEAP example (Python framework) there is a code:
# Evaluate the entire population
fitnesses = list(map(toolbox.evaluate, pop))
for ind, fit in zip(pop, fitnesses):
ind.fitness.values = fit
...
0
votes
0answers
7 views
Flask url_for incorrectly links to static pages outside of templates
I'm currently in the process of moving all of my static files to S3, as well as allowing some image uploads to my site. In general this is going fantastically. I got all of my existing css and js ...
0
votes
0answers
12 views
Fixing or replacing Python IDLE on Mac OS
I recently ran a .py file to IDLE that caused IDLE to crash (after running for some time). While it was running I tried many things including Force Quit etc. After the crash I tried opening IDLE and ...
0
votes
1answer
18 views
concatenating arrays in python like matlab without knowing the size of the output array
I am trying to concatenate arrays in python similar to matlab
array1= zeros(3,500);
array2=ones(3,700);
array=[array1, array2];
I did the following in python:
array1=np.zeros(3,500)
...
0
votes
1answer
29 views
How to convert string to dictionary into python
How can I convert a string
s = "1:5.9,1p5:7,2:10,4:18,8:40"
to a dictionary like this?
s = { '1':'5.9','1p5':'7','2':'10','4':'18','8':40'}
0
votes
0answers
11 views
How to update My Places on Google Earth with kmz files from my computer every week using Python
I am very new to programming and am having problems creating a Python script that will first loop through a folder to select all the .kmz files and see if there are new ones in the folder, then take ...
0
votes
3answers
19 views
Django default value for form
I have a following model:
class Question(models.Model):
section = models.ForeignKey(Section)
description = models.TextField()
answer = models.TextField(blank=True, null=True)
author = ...
0
votes
1answer
10 views
Convert string saved in hex format to its previous form in python
I'm writing program in Python
I have unicode characters based text and it is saved in file in following format:
...
0
votes
1answer
23 views
UnicodeDecodeError: 'utf8' codec can't decode byte “0xc3”
In python 2.7 I have this:
# -*- coding: utf-8 -*-
from nltk.corpus import abc
with open("abc.txt","w") as f:
f.write(" ".join(i.words()))
I then try to read in this document in Python 3:
...
0
votes
0answers
6 views
Python ttk entry validation with hex value
I've been thinking in a way to validate a ttk Entry box for a Hex value of 4 characters.
I came to a solution but I'm not sure if there is a more correct/pythonist way to do it.
This is the Entry ...
-2
votes
1answer
34 views
While Statement to close my program
I have an homework question. I should create a dictionary with the following:
North leads to the garden.
South leads to the kitchen.
East leads to the dining room.
West leads to the living room.
...
0
votes
0answers
11 views
Django template importing when creating a package
I'm create a new package, something very simple. I'm confused tho, how should I be doing templates?
You see I never know what project this application gets installed on i.e. pip install ...
0
votes
1answer
12 views
How to add filter to group_by query
I need to find number of level of specific type in database.
for l, c in session.query(Player.level, func.count(Player.level)).group_by(Player.level).all()
# how to add condition Player.type==1
I ...