I had got a following case of circular import (here severly simplified):
array2image.py conversion module:
import tuti
@tuti.log_exec_time # can't do that, evaluated at definition time
def convert(arr):
'''Convert array to image.'''
return image.fromarray(arr)
tuti.py test utils module:
import array2image
def log_exec_time...
Here's the test case...
import Tkinter as tk
import thread
from time import sleep
if __name__ == '__main__':
t = tk.Tk()
thread.start_new_thread(t.mainloop, ())
# t.iconbitmap('icon.ico')
b = tk.Button(text='test', command=exit)
b.grid(row=0)
while 1:
sleep(1)
This code works. Uncomment the t.iconbit...
I have a project written in Django. All fields that are supposed to store some strings are supposed to be in UTF-8, however, when I run
manage.py syncdb
all respective columns are created with cp1252 character set (where did it get that -- I have no idea) and I have to manually update every column...
Is there a way to tell Django to ...
What is the best way to split a list into parts based on an arbitrary number of indexes? E.g. given the code below
indexes = [5, 12, 17]
list = range(20)
return something like this
part1 = list[:5]
part2 = list[5:12]
part3 = list[12:17]
part4 = list[17:]
If there are no indexes it should return the entire list.
...
Greetings, I have these 2 models:
from django.db import models
class Office(models.Model):
name = models.CharField(max_length=30)
person = models.CharField(max_length=30)
phone = models.CharField(max_length=20)
fax = models.CharField(max_length=20)
address = models.CharField(max_length=100)
def __unicode__(self)...
In Python you can have multiple iterators in a list comprehension, like
[(x,y) for x in a for y in b]
for some suitable sequences a and b. I'm aware of the nested loop semantics of Python's list comprehensions.
My question is: Can one iterator in the comprehension refer to the other? In other words: Could I have something like this:
...
Hi, I'm refactoring a function that, given a series of endpoints that implicitly define intervals, checks if a number is included in the interval, and then return a corresponding (not related in any computable way).
The code that is now handling the work is:
if p <= 100:
return 0
elif p > 100 and p <= 300:
return 1
elif p > 300 ...
how can i import modules/packages at python3.0 editor IDLE.
and can we see all the modules contain/included by it.
...
I have a CSV file which I am processing and putting the processed data into a text file.
The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file?
For eg. Assume there is a column called 'col'.
I just put s...
As stated in the Storm documentation, I am doing the following to import the necessary symbols for using Storm:
from storm.locals import *
I'm using it alongside with Pylons, and storm is indeed installed as an egg in the virtual Python environment which Pylon setup for me, and it also searches the correct paths.
However, when the im...
Hi, I'm trying to reduce the number of scripts included in our website and we use buildout to handle deployments. Has anybody successfully implemented a method of combining and compressing scripts with buildout?
...
We have a python project that we want to start testing using buildbot. Its unit tests include tests that should only work on some platforms. So, we've got tests that should pass on all platforms, tests that should only run on 1 specific platform, tests that should pass on platforms A, B, C and tests that pass on B and D.
What is the bes...
I've been told by my hosting company that Python is installed on their servers. How would I go about using it to output a simple HTML page? This is just as a learning exercise at the moment, but one day I'd like to use Python in the same way as I currently use PHP.
...
How does one go about structuring his db.Models effectively?
For instance, lets say I have a model for Countries, with properties like "name, northern_hemisphere(boolean), population, states (list of states), capital(boolean).
And another model called State or county or something with properties "name, population, cities(list of cities...
here at office we have a library named after the company name and inside of it sublibraries, per project more or less, and in each sublibrary there might be more modules or libraries. we are using Django and this makes our hierarchy a couple of steps deeper...
I am a bit perplex about the differences among the following import instruct...
Hi
I'm using cython for a correlation calculation in my python program. I have two audio data sets and I need to know the time difference between them. The second set is cut based on onset times and then slid across the first set. There are two for-loops: one slides the set and the inner loop calculates correlation at that point. This m...
Hi,
how can I specify a blacklist for a CharField. However I want the blacklist to be effective in the Django admin panel aswell...otherwise I would just validate it in the view.
By blacklist I mean values that can't be used. I also set unique for the value but I would like to disable a few strings aswell.
Thanks,
Max
...
I'm trying to customise a CMS written in Django. The content editors aren't flexible enough so I'm trying to come up with a better solution.
Without over-explaining it, I'd like it to be a bit like django-better-chunks or django-flatblocks. You set up an editable region entirely from within the template. I want to bind these editable re...
I am making a small application with Tkinter. I would like to clean few things in a function called when my window is closed. I am trying to bind the close event of my window with that function. I don't know if it is possible and what is the corresponding sequence.
The python documentation says: "See the bind man page and page 201 of Jo...
There are similar questions to this one, but I'd like to see a clarified answer. I'm building a simple GUI with PythonCard to wrap a command line process. Specifically, it's a wrapper for a series of ANT Tasks and other custom operations so non-devs can use it.
I'd like to redirect the output of the subprocess to a TextArea in the windo...