Nice to meet you.
A socket makes a program in Python by Linux (the transmission of a message) ⇒ Windows (the reception), b
ut the following errors occur and cannot connect now.
Linux, Windows are network connection together, and there is the authority to cut.
socket.error: (111, 'Connection refused')
Could you help me!?
...
I'm trying to create a daemon in python. I've found the following question, which has some good resources in it which I am currently following, but I'm curious as to why a double fork is necessary. I've scratched around google and found plenty of resources declaring that one is necessary, but not why.
Edit: Thanks for the excellent answ...
I'm currently working with a web application written in Python (and using SQLAlchemy). In order to handle authentication, the app first checks for a user ID in the session, and providing it exists, pulls that whole user record out of the database and stores it for the rest of that request. Another query is also run to check the permissio...
I have an inline on a model with data with a fixed length, that has to be entered very fast, so I was thinking about a way of "tabbing" through fields automatically when the field is filled...
Could that be possible?
...
Recently I was trying some practice programs in python and I came across this small problem.
when I typed
print ""
in IDLE, the python shell printed a null character.
If I typed
print """"""
in IDLE, the python shell printed a null character.
but the python shell is waits for an input if I type
print """"
Why is this behavio...
In a Python system for which I develop, we usually have this module structure.
mymodule/
mymodule/mymodule/feature.py
mymodule/test/feature.py
This allows our little testing framework to easily import test/feature.py and run unit tests. However, we now have the need for some shell scripts (which are written in Python):
mymodule/
mymo...
I have a function that accepts a class (not an instance) and, depending on whether or not it's a specific class or a subclass of that, I need to pass it in to one of two other (third-party) factory functions.
(To forestall any objections, I'm aware this is not very Pythonic, but I'm dependent on what the third-party library accepts.)
i...
Is there any way to get the effect of running python -u from within my code? Failing that, can my program check if it is running in -u mode and exit with an error message if not? This is on linux (ubuntu 8.10 server)
...
hey,
i want to use 2 model in one foreignkey
it means;
i have 2 model named screencasts and articles. and i have a fave model, for favouriting this model entrys. can i use model dynamicly ?
class Articles(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
class Casts(models.Model):
title = ...
I've been trying to understand what's the optimal way to do Ajax in Django. By reading stuff here and there I gathered that the common process is:
formulate your Ajax call using some JavaScript library (e.g., jQuery), set up a URL pattern in Django that catches the call and passes it to a view function
in the Python view function retr...
Are unit tests kept in the same file as the code, a separate file in the same directory, or in an entirely different directory?
...
Brand new to web design, using python. Got Apache up and running, test python script working in cgi-bin directory. Get valid results when I type in the URL explicitly: ".../cgi-bin/showenv.py"
But I don't want the URL to look that way. Here at stackoverflow, for example, the URLs that display in my address bar never have the messy d...
I found the sample code cccwiki which is good, but I would like a wiki that keeps tracks of all revisions to the pages and lets users show diffs and revert to previous versions.
...
How can I send the html content in the email using python? I can send simple text.
...
Say I write this:
from subprocessing import Popen, STDOUT, PIPE
p = Popen(["myproc"], stderr=STDOUT, stdout=PIPE)
Now if I do
line = p.stdout.readline()
my program waits until the subprocess outputs the next line.
Is there any magic I can do to p.stdout so that I could read the output if it's there, but just continue otherwise? I...
So I have some Python scripts, and I've got a BaseHTTPServer to serve up their responses. If the requested file is a .py then I'll run that script using execfile(script.py).
The question is this: are there any special rules about imports? One script needs to run just once, and it would be good to keep the objects it creates alive betwee...
On a django site, I want to generate an excel file based on some data in the database.
I'm thinking of using xlwt, but it only has a method to save the data to a file. How can get the file to the HttpResponse object? Or maybe do you know a better library?
I've also found this snippet but it doesn't do what I need. All I want is a way t...
I have a wxPython program with two processes: A primary and a secondary one (I'm using the multiprocessing module.) The primary one runs the wxPython GUI, the secondary one does not. However, there is something I would like to do from the secondary process: Given a string that describes a color, to check whether this would be legitimate ...
Hi all,
I am testing for Exceptions using unittest, for example:
self.assertRaises(UnrecognizedAirportError, func, arg1, arg2)
and my code raises:
raise UnrecognizedAirportError('From')
Which works well.
How do I test that the argument in the exception is what I expect it to be?
I wish to somehow assert that capturedException.ar...
I am trying to run a simple multiple processes application in Python. The main thread spawns 1 to N processes and waits until they all done processing. The processes each run an infinite loop, so they can potentially run forever without some user interruption, so I put in some code to handle a KeyboardInterrupt:
#!/usr/bin/env python
im...