Hello
This may be a 'Python Web Programming 101' question, but I'm confused about some code in the aeoid project (http://github.com/Arachnid/aeoid). here's the code:
_current_user = None
def get_current_user():
"""Returns the currently logged in user, or None if no user is logged in."""
global _current_user
if not _curren...
Hello,
I'm creating an initialising function for the class 'Room', and found that the program wouldn't accept the tests I was doing on the input variables.
Why is this?
def __init__(self, code, name, type, size, description, objects, exits):
self.code = code
self.name = name
self.type = type
self.size = size
self.d...
I'm in the final year, final semester of my law degree, and will be graduating very soon. (April, to be specific.)
But before I begin practice, I plan to take 2 two months off, purely for serious programming study. So I'm currently looking for some Python-related books, gauged intermediate to advanced, which are interesting (because of...
I've got a pile of C code that I'd like to unit test using Python's unittest library (in Windows), but I'm trying to work out the best way of interfacing the C code so that Python can execute it (and get the results back). Does anybody have any experience in the easiest way to do it?
Some ideas include:
Wrapping the code as a Python C...
Hi,
How can I set default language for trac. There's nothing about i18n in trac.ini
...
I'm having a problem, where I wish to run several command line functions from a python program using a GUI. I don't know if my problem is specific to PyQt4 or if it has to do with my bad use of python code.
What I wish to do is have a label on my GUI change its text value to inform the user which command is being executed. My problem h...
i want to build a general tree in which a root node contains 'n' childrens and those childrens may contain other childrens.....
...
Hi All,
How can i check the read/ write permission of the file storing media? ie assume i have to write some file inside a directory and that directory may be available on read only media like (cd or dvd)or etc. So how can i check that storing media ( cd, hard disk) having a read only or read write both permission.
I am using windows x...
Hello,
I have three panes with the InfoPane center option.
I want to know how to set their size.
Using this code:
import wx
import wx.aui
class MyFrame(wx.Frame):
def __init__(self, parent, id=-1, title='wx.aui Test',
pos=wx.DefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE):
...
In my script, I have a function foo which basically uses pynotify to notify user about something repeatedly after a time interval say 15 minutes.
def foo:
while True:
"""Does something"""
time.sleep(900)
My main script has to interact with user & does all other things so I just cant call the foo() function. direct...
Suppose I have a function which can either take an iterable/iterator or a non-iterable as an argument. Iterability is checked with try: iter(arg).
Depending whether the input is an iterable or not, the outcome of the method will be different. Not when I want to pass a non-iterable as iterable input, it is easy to do: I’ll just wrap it w...
I have an array of points in numpy:
points = rand(dim, n_points)
And I want to:
Calculate all the l2 norm (euclidian distance) between a certain point and all other points
Calculate all pairwise distances.
and preferably all numpy and no for's. How can one do it?
...
In python I have the following function:
def is_a_nice_element(element, parameter):
#do something
return True or False
Now I would like to filter a list with this function as predicate, giving a fixed parameter. Python has the itertools.ifilter function, but I can't figure out how to pass the parameter. Is this possible? If no...
Anybody knows some actual documentation written? I can't find anything good for any of the 2 competing modes. Looks like Emacs is pretty much abandon when it comes to Python and it is a shame as there is no other programmable programming editor that comes close to Emacs.
...
I have been asked to write a program using python for an assignment.
I have been given a syslog file and I have to find things out about it
How do I find out how many attempts were made to login to the root account?
Any advice would be highly appreciated as I am very new to python and completely lost!
...
I am pulling data from Twitter's API and the return date is UTC in the following form:
Sat Jan 24 22:14:29 +0000 2009
Can MySQL handle this format specifically or do I need to transform it? I am pulling the data using Python.
...
Given an array 'a' I would like to sort the array by columns "sort(a, axis=0)" do some stuff to the array and then undo the sort. By that I don't mean re sort but basically reversing how each element was moved. I assume argsort() is what I need but it is not clear to me how to sort an array with the results of argsort() or more important...
In a Django view function which uses manual transaction committing, I have:
context = RequestContext(request, data)
transaction.commit()
return render_to_response('basic.html', data, context) # Returns a Django ``HttpResponse`` object which is similar to a dictionary.
I think it is a better idea to do this:
context = RequestContext(...
how do i count how many logins were done per day on a system using the log file n python?
...
I have the following script, which is working for the most part Link to PasteBin The script's job is to start a number of threads which in turn each start a subprocess with Popen. The output from each subprocess is as follows:
1
2
3
.
.
.
n
Done
Bascially the subprocess is transferring 10M records from tables in one database to diff...