I have been studying unicode and its Python implementation now for two days, and I think I'm getting a glimpse of what it is about. Just to get confident, I'm asking if my assumptions for my current problems are correct.
In Django, forms give me unicode strings which I suspect to be "broken". Unicode strings in Python should be encoded ...
I had a simple table:
class test(Base):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
title = Column(String)
def __init__(self, title):
self.title = title
When using this table, id was set automatically. I want to add another field that is unique and efficient to search, so I added the field:
...
can any one please expain me the functionality of this function
wx.grid.Grid.create()
i created a frame and inside that i create a grid using this function
every thing is fine but while closing that frame my whole application is closing
while closing i just need to distroy the frame only not the whole application
thankz in advance...
I want to do the below list iteration in django templates:
foo = ['foo', 'bar'];
moo = ['moo', 'loo'];
for (a, b) in zip(foo, moo):
print a, b
django code:
{%for a, b in zip(foo, moo)%}
{{a}}
{{b}}
{%endfor%}
I get the below error when I try this:
File
"/base/python_lib/versions/third_party/django-0.96/djang...
Hello,
I am working on PostgreSQL and psycopg2. Trying
to get feed data which is updated every after 10 mins
and keep this feeds contents in PostgreSQL database.My target is to retrieve
and print those data from that table.
But facing problem as duplicate data is also stored in the database every time I run that script due to insertio...
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import Tkinter
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent=parent
def initialize(self):
self.grid()
self.entry=Tkinter.Entry(self)
self.entry.grid(column=0,row=0,sticky='EW')
...
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import Tkinter
import twitter
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
api=twitter.api()(username='-----',password='---...
Very newbie question, but please be gentle with me. Our site uses Django CMS and we're trying to insert some javascript into particular stories, but it appears Django is stripping out any javascript or iframes we put in there as soon as we save the story. How do we allow javascript to be used in stories? Is it being deliberately excluded...
Django's get_or_create function always cause "get() returned more than one Model name" error in a multi-threaded program.
I even tried to put get_or_create statement inside a lock.acquire() and lock.release() block but still didn't work.
The program only works when I set thread_count=1
The database is on InnoDB engine. How to fix this...
I have downloaded the web page into an html file. I am wondering what's the simplest way to get the content of that page. By content, I mean I need the strings that a browser would display.
To be clear:
Input:
<html><head><title>Page title</title></head>
<body><p id="firstpara" align="center">This is paragraph <b>one</b>.
...
class Teller(object):
def __init__(self):
self.occupied = False
self.timeLeft = 0
self.totTime
def occupy(self, timeOcc):
self.occupied = True
self.timeLeft = timeOcc
def nextMin(self):
self.timeLeft -= 1
self.totTime += 1
if self.timeLeft == 0:
sel...
How can I find what directory a module has been imported from, as it needs to load a data file which is in the same directory.
edit:
combining several answers:
module_path = os.path.dirname(imp.find_module(self.__module__)[1])
got me what i wanted
...
I want to use this regular expression in Python:
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
(from http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/)
def removeHtmlTags(page):
p = re.compile(r'XXXX')
return p.sub('', page)
It seems that I cannot directly substitute the complex r...
Hello.
Just a quick question. When I use the _() function provided by the Pylons i18n module, everything works just as expected.
My problem is with the lazy version of this function, lazy_gettext. When I run :
python setup.py extract_messages
I get in the POT file the strings to be translated with the _() function, but not those wuth...
Using python and MySQLdb, how can I check if there are any records in a mysql table (innodb)?
...
I've got a very large SQLite table with over 500,000 rows with about 15 columns (mostly floats). I'm wanting to transfer data from the SQLite DB to a Django app (which could be backed by many RDBMs, but Postgres in my case). Everything works OK, but as the iteration continues, memory usage jumps by 2-3 meg a second for the Python process...
I have a list that I need to send through a URL to a third party vendor. I don't know what language they are using.
The list prints out like this:
[u'1', u'6', u'5']
I know that the u encodes the string in utf-8 right? So a couple of questions.
Can I send a list through a URL?
Will the u's show up on the other end when going throug...
In python, If I have a class foo, I can call foo.__module__ to get a string with the name of the module it is part of.
If I have a module bar, I can call bar.__file__ to get a string with the path where the module was loaded from.
How, when I only have class foo can I get the path of the module it is part of? (foo.__module__ returns a ...
Hi everyone;
I've wrote a piece of code in python and pygtk for an embeded mplayer in a gui.
I assume I use GtkSocket and the slave mode of mplayer with the -wid option.
But I've got an issue, when the size of my GTK window is smaller than my stream, the stream appears to be cropped. And when the size of my window is bigger than my stre...
I am using matplotlib and numpy to make a polar plot. Here is some sample code:
import numpy as N
import matplotlib.pyplot as P
angle = N.arange(0, 360, 10, dtype=float) * N.pi / 180.0
arbitrary_data = N.abs(N.sin(angle)) + 0.1 * (N.random.random_sample(size=angle.shape) - 0.5)
P.clf()
P.polar(angle, arbitrary_data)
P.show()
You wil...