hi, i want to try to calculate the O(n) of my program (in python). there are two problems:
1: i have a very basic knowledge of O(n) [aka: i know O(n) has to do with time and calculations]
and
2: all of the loops in my program are not set to any particular value. they are based on the input data.
...
I need to read some very huge text files (100+ Mb), process every lines with regex and store the data into a structure. My structure inherits from defaultdict, it has a read(self) method that read self.file_name file.
Look at this very simple (but not real) example, I'm not using regex, but I'm splitting lines:
import multiprocessing
...
Base project structure
baseproject
baseapp
models.py
class BaseModel(models.Model)
...
Other project structure:
project
app
views.py
urls.py
project.app.views.py
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
from django.conf import settings
from baseproj...
I'm looking to use twisted to control communication across Linux pipes (os.pipe()) and fifos (os.mkfifo()) between a master process and a set of slave processes. While I'm positive tat it's possible to use twisted for these types of file descriptors (after all, twisted is great for tcp sockets which *nix abstracts away as file descriptor...
I'm using the pywin32 extensions to access the win32 API under Python. I'm new at doing Windows programming in Python -- I'm a POSIX guy -- so I may be doing things in a bone-headed manner.
I'm trying to use the win32file.ReadFile function properly, and I'm having some trouble interpreting the possible result codes.
I'm calling the fun...
Hello,
please i need some help in converting a python code to a php syntax
the code is for generating an alphanumeric code using alpha encoding
the code :
def mkcpl(x):
x = ord(x)
set="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for c in set:
d = ord(c)^x
if chr(d) in set: ...
Here are a couple of examples taken from django-basic-apps:
# self.title is a unicode string already
def __unicode__(self):
return u'%s' % self.title
# 'q' is a string
search_term = '%s' % request.GET['q']
What's the point of this string formatting?
...
I'm trying to "modularize" a section of an appengine website where a profile is requested as a small hunk of pre-rendered html
Sending a request to /userInfo?id=4992 sends down some html like:
<div>
(image of john) John
Information about this user
</div>
So, from my google appengine code, I need to be able to repeate...
Hi,
I would like to listen on 2 different UDP port with the same server.
I use SocketServer lib for my server, and basicly it looks like that;
SocketServer.UDPServer(('', 7878),CLASSNAME)
I would like to listen on 7878 and 7879 with the same server and same file.
Is that possible ? If yes how ?
Thanks in advance.
...
What sorts of methods exist for prematurely exiting an if clause?
There are times when I'm writing code and want to put a break statement inside of an if clause, only to remember that those can only be used for loops.
Lets take the following code as an example:
if some_condition:
...
if condition_a:
# do something
...
I would like the GAE to do something else once my app has sent a response.
The handler would look like this:
class FooHandler(webapp.RequestHandler):
def post(self):
self.response.out.write('Bar')
send_response() # this is where I need help!
do_something_else() # at this point, the response should have b...
From Python docs:
"Option.dest : If the option’s action implies writing or modifying a value somewhere, this tells optparse where to write it: dest names an attribute of the options object that optparse builds as it parses the command line."
Can we put some check on the name of the attribute (dest) to check if it's value was provided? ...
>>> hash("\x01")
128000384
>>> hash("\x02")
256000771
>>> hash("\x03")
384001154
>>> hash("\x04")
512001541
Interesting part is 128000384 x 2 is not 256000771, and also others
I am just wondering how that algorithm works and want to learn something on it.
Thanks in advance.
...
I have a (GoogleAppEngine) Django ModelForm:
class A(db.Model):
a = db.StringProperty()
class MyAForm(djangoforms.ModelForm):
class Meta:
model = A
This creates a form which has one string field a. On my form I'd like to call this something else, say b. So I'd like a form with a field called b and when the form is POSTed we ...
In Python, How can one subtract two non-unique, unordered lists? Say we have a = [0,1,2,1,0] and b = [0, 1, 1] I'd like to do something like c = a - b and have c be [2, 0] or [0, 2] order doesn't matter to me. This should throw an exception if a does not contain all elements in b.
Note this is different from sets! I'm not interested in ...
I have written some Python in which some lines exceed 80 characters in length, which is a threshold I need to stay under. How can I adapt my code to reduce line lengths?
...
*I am trying to display preview from webcam captured using v4l.
Here is an idea of how the code looks like:
from ctypes import *
from v4l2 import *
from Image import fromstring
from Tkinter import Tk, Label
from ImageTk import PhotoImage
from ctypes.util import find_library
libc = CDLL(find_library('c'))
posix_memalign = libc.posix_me...
I have some problems with following string while
trying to syntax highlight them:
Example
<code class="php"><? echo "<input type=\"text\">"; ?></code>
The php part is rendered correctly, but the html part breaks.
I use the Markdown and Syntax Highlighting snippet from
http://www.djangosnippets.org/snippets/119/
Any idea how to e...
I'm currently learning Python and coming from a strong C# background. I keep hearing about doing things in a Pythonic way to take advantage of the dynamic nature of the language and some of it I get and some I don't.
I'm creating a site with Django and my approach to views is to use classes. My current thinking is to have a base class...
Hi:
Everything goes well days ago. But since today, when I run fastcgi, the process will be killed by system automatically. The worst thing is I don't know why and which process kill the fastcgi process.
Let me give some detail.
we use nginx to serve static files for another django app which listen to 80 port.(this is for production ...