Hello,
I hav codes eg1.py , eg2.py , eg3.py
eg3.py imports eg2.py which in turn imports eg1.py
When i run eg3.py for first time everything is fine
If i import it again and again only eg3.py runs
I need a solution for this.
I will code eg3.py in such a way that :
while(1):
import eg2.py
Where I went wrong.Please give me a solut...
hi
i want a python program that given a directory, it will return all directories within that directory that have 775 (rwxrwxr-x) permissions
thanks!
...
I want to add event to list such that on adding items actions are taken based on the item e.g. genrating new data structures, change in screen output or raising exception.
How do I accomplish this?
...
I have a script that uses the cmd Python module. The cmd module uses a triple quoted multiline string as it's help text. Something like this
def x(self, strags = None):
"""class
help text here
and some more help text here"""
When running the script, the command 'help x' will print the string. It will, however, print the ne...
Hi, I encounter a problem.
In my user models there is an atrrbution: user.avatar = ImageField
('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
then i use a modelform as an create user form. And the avatar is
uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
avatar into AVATAR_ORIGINAL_PATH and make user.avata...
Hi,
I have a python (2.5.4) script which I run in cygwin (in a DOS box on Windows XP). I want to include a pound sign (£) in the output. If I do so, I get this error:
SyntaxError: Non-ASCII character '\xa3' in file dbscan.py on line 253, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
OK. So I looke...
Hello.
It's a common programming task to loop iteration while not receiving next item. For example:
for sLine in oFile :
if ... some logic ... :
sLine = oFile.next()
... some more logic ...
# at this point i want to continue iteration but without
# getting next item from oFile. How can this be done in python?
...
Suppose I have a simple view which needs to parse data from an external website.
Right now it looks something like this:
def index(request):
source = urllib2.urlopen(EXTERNAL_WEBSITE_URL)
bs = BeautifulSoup.BeautifulSoup(source.read())
finalList = [] # do whatever with bs to populate the list
return render_to_response('...
I'm using the json module in Python 2.6 to load and decode JSON files. However I'm currently getting slower than expected performance. I'm using a test case which is 6MB in size and json.loads() is taking 20 seconds.
I thought the json module had some native code to speed up the decoding?
How do I check if this is being used?
As a com...
I've spent hours searching for examples of how to use the bsddb module and the only ones that I've found are these (from here):
data = mydb.get(key)
if data:
doSomething(data)
#####################
rec = cursor.first()
while rec:
print rec
rec = cursor.next()
#####################
rec = mydb.set()
while rec:
key, val = r...
I'm looking for a web framework or an application in Java that does what Django admin does - provides a friendly user interface for editing data in a relational database. I know it's possible to run Django on Jython and that way achieve a somewhat Java-based solution, but I'd prefer something pure-Java to keep the higher-ups happy.
...
Here is a snippet of an HTML file I'm exploring with Beautiful Soup.
<td width="50%">
<strong class="sans"><a href="http:/website">Site</a></strong> <br />
I would like to get the <a href> for any line which has the <strong class="sans"> and which is inside a <td width="50%">.
Is it possible to query a HTML file for those multipl...
I am currently faced with XML that looks like this:
<ID>345754</ID>
This is contained within a hierarchy. I have parsed the xml, and wish to find the ID node by searching on "345754".
...
In Python, is it possible to define an alias for an imported module?
For instance:
import a_ridiculously_long_module_name
...so that is has an alias of 'short_name'.
...
Is it possible to pass a method as a parameter to a method?
self.method2(self.method1)
def method1(self):
return 'hello world'
def method2(self, methodToRun):
result = methodToRun.call()
return result
...
I have a simple table in mysql with the following fields:
id -- Primary key, int, autoincrement
name -- varchar(50)
description -- varchar(256)
Using MySQLdb, a python module, I want to insert a name and description into the table, and get back the id.
In pseudocode:
db = MySQLdb.connection(...)
queryString = "INSERT into tablenam...
What's the best way to pass a method and a method parameter to another method?
Is there a better way to do the following?
def method1(name)
return 'Hello ' + name
def method2(methodToCall, methodToCallParams, question):
greetings = methodToCall(methodToCallParams)
return greetings + ', ' + question
method2(method1, 'Sam',...
Hi,
How can I call an external program with a python script and retrieve the output and return code?
...
Is there a way to determine if the current file is the one being executed in Perl source? In Python we do this with the following construct:
if __name__ == '__main__':
# This file is being executed.
raise NotImplementedError
I can hack something together using FindBin and __FILE__, but I'm hoping there's a canonical way of doi...
This is only marginally a programming problem and more of a networking problem.
I'm trying to get a Django web app to run in my home network and I can't get any machines on the network to get to the web page. I've run on ports 80 and 8000 with no luck. Error message is: "Firefox can't establish a connection to the server at 192.168.x.x....