I've recently started learning/using django; I'm trying to figure out a way to have two separate authentications systems for administrators and users. Rather than create a whole new auth system, I'd like to leverage django's built-in functionality (i.e. session management, @login_required decorator, etc.).
Specifically, I want to have ...
I sent a reference to a bool object, and I modified it within a method. After the method finished it's execution, the value of the bool outside the method was unchanged.
This leads me to believe that Python's bools are passed by value. Is that true? What other Python types behave that way?
...
I would like to display a percentage with three decimal places unless it's greater than 99%. Then, I'd like to display the number with all the available nines plus 3 non-nine characters.
How can I write this in Python? The "%.8f" string formatting works decently, but I need to keep the last three characters after the last string of nine...
Hi gentlemen,
learning python here, I want to check if anybody is running a web server on my local
network, using this code, but it gives me a lot of error in the concole.
#!/usr/bin/env python
import httplib
last = 1
while last <> 255:
url = "10.1.1." + "last"
connection = httplib.HTTPConnection("url", 80)
conn...
What I'm looking for is something that can translate 'tomorrow at 6am' or 'next moday at noon' to the appropriate datetime objects.
...
I have a very large collection of (p, q) tuples that I would like to convert into a dictionary of lists where the first item in each tuple is a key that indexes a list that contains q.
Example:
Original List: (1, 2), (1, 3), (2, 3)
Resultant Dictionary: {1:[2, 3], 2:[3]}
Furthermore, I would like to efficiently combine these dict...
Problem
When screen-scraping a webpage using python one has to know the character encoding of the page. If you get the character encoding wrong than your output will be messed up.
People usually use some rudimentary technique to detect the encoding. They either use the charset from the header or the charset defined in the meta tag or t...
Quite simple, I'm learning python and I can't find a reference that tells me how to write the following:
public class Team {
private String name;
private String logo;
private int members;
public Team(){}
// getters/setters
}
Later:
Team team = new Team();
team.setName( "Oscar" );
team.setLogo( "http://......
With my luck this question will be closed too quickly. I see a tremendous possibility for a python application that basically is like a workbook. Imagine if you will that instead of writing code you select from a menu of choices. For example, the File menu would have an open command that lets the user navigate to a file or directory o...
Having great luck working with single-source feed parsing in Universal Feed Parser, but now I need to run multiple feeds through it and generate chronologically interleaved output (not RSS). Seems like I'll need to iterate through URLs and stuff every entry into a list of dictionaries, then sort that by the entry timestamps and take a sl...
I have a wxPython application (http://www.OpenSTV.org) that counts ballots using methods that have multiple rounds. I'd like to do two things:
(1) For a large number of ballots, this can be a bit slow, so I'd like to show the user a progress dialog so he doesn't think the application is frozen.
(2) I'd like to allow the user to break ...
I'm trying to load a transparent image into pygame using the following code:
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', fullname
raise SystemExit, message
image = imag...
I would like to enable students to submit python code solutions to a few simple python problems. My applicatoin will be running in GAE. How can I limit the risk from malicios code that is sumitted? I realize that this is a hard problem and I have read related Stackoverflow and other posts on the subject. I am curious if the restrictions ...
Can I pass a list of kwargs to a method for brevity? This is what i'm attempting to do:
def method(**kwargs):
#do something
keywords = (keyword1 = 'foo', keyword2 = 'bar')
method(keywords)
...
Hi everybody,
I have question regarding the SQLAlchemy. I have database which contains Items, every Item has assigned more Records (1:n). And the Record is partially stored in the database, but it also has an assigned file (1:1) on the filesystem.
What I want to do is to delete the assigned file when the Record is removed from the datab...
I often need to process large text files containing headers in the first line. The headers are often treated differently to the body of the file, or my processing of the body is dependent on the headers. Either way I need to treat the first line as a special case.
I could use simple line iteration and set a flag:
headerProcessed = false...
My team is incorporating the Python 2.4.4 runtime into our project in order to leverage some externally developed functionality.
Our platform has a 450Mhz SH4 application core and limited memory for use by the Python runtime and application.
We have ported Python, but initial testing has highlighted the following hurdles:
a) start-...
I'm programming in Python with a wrapper of the kernel32 dll, so I can use any functions of this dll, like GetLogicalDrives(), for instance. I'm trying to obtain the information of the physical drives, even if they are not mounted. I've seen a question similar to this, but I need the information of the not mounted drives. All methods I'v...
I am trying to write a sample client in Python using ZSI for a simple Web Service. The Web Service WSDL is following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd...
In the computers of our laboratory, which have Python 2.6.2 installed in them, my program, which is an animation of the 2D random walk and diffusion, works perfectly.
However, I can't get the exact same program to work on my laptop, which has Python 2.5. By that not working, I mean the animation is screwed; the axis always changes ever...