Background
I'm developing a django app for a vacation rental site. It will have two types of users, renters and property managers.
I'd like the property managers to be able to manage their rental properties in the django admin. However, they should only be able to manage their own properties.
I realize the default django admin doesn't...
Beginner here, stuck wondering what I need to do to learn development in different web environments. Say, for instance I want to play around in PHP & MySQL. But I also want to try things with Ruby on Rails and maybe even server things with Python. Do I need a different environment for each platform? Am I required to have a virtual ma...
Consider such code:
class A ():
name = 7
description = 8
color = 9
class B(A):
pass
Class B now has (inherits) all attributes of class A. For some reason I want B not to inherit attribute 'color'. Is there a possibility to do this?
Yes, I know, that I can first create class B with attributes 'name' and 'description' and t...
To follow best practices for Unicode in python, you should prefix all string literals of characters with 'u'. Is there any tool available (preferably PyDev compatible) that warns if you forget it?
...
I'm trying to convert a django project for GAE, and I've stumbled upon this:
(relational-databse)
class Clan(models.Model):
wars = models.ManyToManyField('self')
How can I do this in a non-relational database(i.e. gae datastore)?
...
pythonw.exe doesn't have a console so I can't see the output of print. But my program is OKAY in python.exe, failed in pythonw.exe. I just want to see the logs from python interpreter and the log printed by my "print" statement, is it doable?
...
I have python2.5 and multiprocessoring (get from http://code.google.com/p/python-multiprocessing/)
This simple code (get from docs), works very strange from time to time, sometimes it ok, but sometimes it throw timeout ex or hang my Windows (Vista), only reset helps :) Why this can happen?
from multiprocessing import Pool
def f(x):
...
I have several widgets bound to the same function call. How do I tell which one triggered that call?
...
hey guys,
When i use this expression:
re.sub("([^\s\w])(\s*\1)+","\\1","...")
I checked the regex at gskinner, its supposed to return me '.'
but it doesn't work.
If i use
re.sub(r"([^\s\w])(\s*\1)+","\\1","...")
It returns me the error:
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Can...
I am making a small program and at some point from each row of a matrix I need to subtract the average of the row itself. Quite a standard renormalization procedure.
Note in the code
def subtractaverage(data):
datanormalized=[]
for row in data:
average_row=sum(row)/len(row)
print "average=",average_row
# r...
I have managed to get C code calling Python scripts happily on Unix using PIPES within the C code. I now need to do the same on Windows.
Essentially I would like to write scripts in different scripting languages like Python / Lua etc on Windows and be able to execute them using STDIN / STDOUT etc.
I have been looking at the "CreateProc...
My question is very simple, but I didn't get the answer from google.
There is a python string:
s = "123123"
I want to replace the last 2 with x. Suppose there is a method called replace_last:
r = replace_last(s, '2', 'x')
print r
1231x3
Is there any built-in or easy method to do this?
UPDATE
Sorry, guys, since someone said...
I’m trying to use winpdb to debug a python scripts embedded in my own C++ application. I can connect and view the callstack, globals, etc. initially but I’m having problems getting breakpoints to halt execution.
When my breakpoint is hit the status bar in winpdb briefly switches to ‘WAITING AT BREAKPOINT’ then immediately switches back ...
how to get results from exec() in python 3.1?
#!/usr/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host = socket.gethostname()
port = 1234
sock.bind((host,port))
ret_str = "executed"
while True:
cmd, addr = sock.recvfrom(1024)
if len(cmd) > 0:
print("Received ", cmd, " command from "...
Hi,
I am trying to learn how to use Abaqus Scripting. I just downloaded Eclipse and added the pydev plugin. Everything seems to work fine.
What I want to do now is to add all the built-in Abaqus libraries or modules.
I would like, for example, the IDE to display the class members and methods when I press the ".".
I would like to see ...
When deploy java app on linux, we don't need to install anything, all third-party libs are jar files and we only update classpath in script file. But java needs jre which is quite large.
So is there any other language supported by linux can do that? By default our server only support perl/python/tcl, no gcc available, sigh.
...
In my class I run 4 process.
from multiprocessing import Process
procs = (
Process(target=ClassOne, name='ClassOne'),
Process(target=ClassTwo, name='ClassTwo'),
Process(target=ClassThree, name='ClassThree'),
Process(target=ClassFour, name='ClassFour'),
)
for p in...
Hi,
I'm new to python and I face an issue:
I try to extend my SConstruct file and to import a module located in a sub-directory of my project.
Here is my SConstruct file:
import os, sys
sys.path.append(os.path.abspath(os.path.join('.', 'custom_dir')))
import mymodule
mymodule.foo()
Here is the mymodule.py file, located into a subd...
import formatter
# a long string I want to format
s="""When running behind a load balancer like nginx, it is recommended to pass xheaders=True to the HTTPServer constructor. This will tell Tornado to use
headers like X-Real-IP to get the user's IP address instead of attributing all traffic to the balancer's IP address.
"""
fh=open("tmp....
Hi!
I have a file, that have lots of sequences of letters.
Some of these sequences might be equal, so I would like to compare them, all to all.
I'm doing something like this but this isn't exactly want I wanted:
for line in fl:
line = line.split()
for elem in line:
if '>' in elem:
pass
else:
for el in line:
...