def val():
var = float(raw_input("Age:"))
status = ("Working","Retired")[var>65]
print "You should be:",status
I was looking on how the ternary operator is implemented in python. I found the code mentioned above as a substitute (from what i have read, found that the ternary operator does not exist, I will be happy to know m...
I have a simple view function that's designed to allow the user to choose from items listed in an html table (records). Clicking on a record should divert the user to the template from which he can edit that specific record. The code is as follows:
def edit_record(request):
if request.method == 'POST':
a=ProjectR...
import urllib
print urllib.urlopen('http://www.reefgeek.com/equipment/Controllers_&_Monitors/Neptune_Systems_AquaController/Apex_Controller_&_Accessories/').read()
The above script works and returns the expected results while:
import urllib2
print urllib2.urlopen('http://www.reefgeek.com/equipment/Controllers_&_Monitors/...
A few days back I was messing around with Django, trying to get a feel for how stuff works, when I decided to try and build a simple forum, one that resembled a forum that I frequented (but is now closed down). The idea was that each of the comments would be parent to any number of comments, like so:
comment <--top
comment <-- comme...
So I'm trying to do more web development in python, and I've picked cherrypy, hosted by lighttpd w/ fastcgi. But my question is a very basic one: why do I need to restart lighttpd (or apache) every time I change my application code, or the code for an underlying library?
I realize this question extends from a basic mis(i.e. poor)underst...
I asked this similar question and got a satisfactory answer. However, doing the same with SVNPoller doesn't work.
So how can I pass --trust-server-cert as an extra param to SVNPoller in buildbot
...
Hello,
I am trying to email a results file. I am getting an import error:
Traceback (most recent call last):
File "email_results.py", line 5, in ?
from email import encoders
ImportError: cannot import name encoders
I am also unsure on how to get this to connect to the server. Can anyone help? Thanks
#!/home/build/test/...
I worked on a PHP project earlier where prepared statements made the SELECT queries 20% faster.
I'm wondering if it works on Python? I can't seem to find anything that specifically says it does or does NOT.
...
Hi, what im experimenting is the next:
S:\proj>manage.py shell
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) django 1.1.1
>>> from django.contrib.auth.models import User
>>> u = User(username='luis', password='admin')
>>> u.save() #sucessfull created in mysql db
>>> from django.contrib.auth import authenticate
>>> usuario = authenti...
Hi, how should I write "mąka" in Python without an expection?
I've tried var= u"mąka", var= unicode("mąka") etc... nothing helps :/
...
I have a nested class:
class WidgetType(object):
class FloatType(object):
pass
class TextType(object):
pass
.. and an oject that refers the nested class type (not an instance of it) like this
class ObjectToPickle(object):
def __init__(self):
self.type = WidgetType.TextType
Trying to ser...
I am trying to populate a Django formset using data from a POST request. I am able to display the formset properly and instantiate it again mostly alright, but I'm having an issue where the formset is ending up with 2 blank rows at the end, which is undesirable. Below is the function we've been using in views.py:
forms.py
class Depos...
Hi, I am using Python 2.6 + xlwt module to generate excel files.
Is it possible to include an autofilter in the first row with xlwt or pyExcelerator or anything else besides COM?
Thanks
...
I want to make the background of a textview widget black and the foreground white.
Been trying the .modify_bg and .modify_fg methods, but none affect the way this thing looks.
Can anyone suggest anything or is this just not possible?
...
Recall those applications that provide the option to "Send usage statistics to help improve X" during the installation? I presume it collects certain patterns of usage and sends it back to the server. Back at the server, there may be some sort of mining going on.
Is there a Python library to do this .. at least from the client part? (ot...
I'm trying to implement a service with Twisted that's fairly close to the "finger" tutorial found here: http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html
I've got a basic.LineListener waiting for a command and then executing it, then I have a client connecting and issuing commands. Trouble is that the command som...
If I want to redirect the user from a cgi script to a HTML page using core libraries from the following:
import cgi
Please could someone point me in the right direction. Nothing more. Simply redirect from cgi script to html page. How ever you would do this Python. If you have to physically write out the HTTP Response Headers to achi...
I went to write a system script using 3.0 and found the SIGALRM signal and signal.alarm() call missing amongst many others on the Windows deployment. Does anyone know why these are missing? Below is a dir() of the 2.5 vs 3.0 signal packages on windows. I haven't found any 3.0 docs yet mentioning that this was moved
EDIT: signals do work...
I need to make some GUIs for a Jython application, but would like to minimize translation time should the project switch over to CPython. HTML or XUL are possibilities, but ones that I'd like to avoid. Any ideas on a cross-implementation pythonic GUI toolkit?
...
I developpe a browser with python and pyqt4 but I don't know what I put in loaderror
try:
self.webView.load(QtCore.QUrl(self.lineEdit.text()))
except loaderreur:
self.webView.load(QtCore.QUrl('erreur.html'))
when the page doesn't exist
thx
...