python

How come I can not activate my Virtual Python Environment with 'source env/bin/activate' command?

I am trying to activate my Virtual Python Environment to use with Pylons but I think I am executing the commands wrong. jem@jem-laptop:~$ source env/bin/activate bash: env/bin/activate: No such file or directory What am I doing wrong? How should I do it right? ...

Please recommend some Python hashing algorithms

I'm doing a password hashing program in python. I need to make my hashing dynamic, i.e. each time I need to get different hashed code. I am using md5 library. ...

Static or constant or what are they?

I just want to know how I can call certian classes in design pattern here, like which type are they classified in OO design (1) I use a class that has just named constants , this class is used directly other classes to get values of constants in it.I dont instantiate the class. (2) I use a class with full of static methods, this class ...

[python] getting dogtail example script to run on Ubuntu 10.04

I recently installed Dogtail, an open source GUI testing tool and automation framework. I downloaded the example script (https://fedorahosted.org/dogtail/browser/examples/gedit-test-utf8-tree-api.py?format=txt) to my computer, but am having trouble getting it work. When I invoke it, I get a message saying: corey@corey-laptop:~/Desktop/e...

How to declare the welcome file (e.g. index.html) in app.yaml

Hey all, In Java, the web.xml might contain some <welcome-file> elements. I am trying to do something equivalent in python with no luck. application: wk version: 1 runtime: python api_version: 1 handlers: - url: / static_dir: docs welcome_files: - index.html Any thoughts? I get an error that "welcome_files" is not understood. ...

My .yaml is not redirecting properly.

app.yaml application: classscheduler9000 version: 1 runtime: python api_version: 1 handlers: - url: /static static_dir: static - url: /images static_dir: static/images - url: /stylesheets static_dir: static/stylesheets - url: /users\.html script: main.py - url: /.* script: login.py main.py import hashlib from googl...

simple python connect 4 game. why doesnt this test work?

Everything about this code seems to work perfectly, except the tests for diagonal wins. The tests for vertical and horizontal wins seem to be exactly the same concept, and they work perfectly. The comments should mostly explain it, but the test should basically iterate through the board and check for x's in the bottom left hand corner ...

Best way to generate xml in python?

I'm creating an web api and need a good way to very quickly generate some well formatted xml. I cannot find any good way of doing this in python. Note: Some libraries look promising but either lack documentation or only output to files. ...

Django Group By

Hello. I'm writing a simple private messenger using Django and am implementing message threading. Each series of messages and replies will have a unique thread_id that will allow me to string sets of messages together. However, in the inbox view ALL of the messages are showing up, I'd just like to group by the thread_id so that althoug...

how to get video duration in python or django?

hi folks, i need to get the video duration in python (django), the video formats that i need to get are mp4, flv, avi, mov... I have a shared hosting so i have no ffmpeg support. Thanks! sorry for my english. ...

cant upload file in google app engine

I don't know why I cant upload my file? When I hit submit instead of redirecting to the default page(which is http://localhost:8082) , it redirects to http://localhost:8082/sign. I didn't build no such path, so it return link broken. Here's my html: <form action="/sign" enctype="multipart/form-data" method="post"> <div><...

What structured text format is the best supported in Python?

This question may be seen as subjective, but I'd like to ask SO users which common structured textual data format is best supported in Python. My initial choices are: XML JSON and YAML Which of these three is easiest to work with in Python (ie. has the best library support / performance) ... or is there another format that I haven't...

Receiving 0.0 when expecting a non-zero value after division

Hai... i am facing a problem while inserting values to an array. the programming language using is python. the problem is, i need to insert a value to array after performing a division. but every the value in array is always 0.0 . i am attaching the code here.... print len(extract_list1) ratio1=range(len(extract_list1)) i=0 ...

check if all elements in a list are identical

I need the following function: Input: a list. Output: True if all elements in the input list evaluate as equal to each other using the standard equality operator; False otherwise. Performance: of course, I prefer not to incur any unnecessary overhead. I feel it would be best to iterate through the list, compare adjacent elements, and...

Mercurial for Windows - Python version?

What version of Python is needed to run Mercurial? I see that the website says it requires 2.4. Does that mean 2.4, or 2.x? or something higher than 2.4, i.e., could I install 3.x? I've installed Mercurial without reading the requirements and I installed it anyway and hg.exe executes fine. Looking in the directory that hg.exe lives (C:...

Python: Boolean operators vs Bitwise operators

I am confused as to when I should use a Boolean vs Bitwise operators and vs &, or vs | Could someone enlighten me as to when do i use each and when will using one over the other affect my results? ...

AttributeError - Django, GAE

This is my code for views.py def addCategory(request): user = users.get_current_user() if users.is_current_user_admin(): if request.method == 'POST': form = CategoryForm(request.POST) if form.is_valid(): cd = form.cleaned_data Category.objects.create_category(cd['na...

Is it possible to solve this problem with Regular Expression?

I'm trying to divide long text in small parts, so that every part is at least N characters and ended with some of the stop punctuation marks (? . !). If the part is bigger than N characters we sttoped when the next punctuation mark appear. For example : Lets say N = 10 Do you want lime? Yes. I love when I drink tequila. This sente...

Python: how can I check if the key of an dictionary exists ?

Possible Duplicate: What is a good way to test if a Key exists in Python Dictionary Let's say I have an associative array like so: {'key1': 22, 'key2': 42}. How can I check if key1 exists in the dictionary? ...

Running matplotlib in tkinter

I have this beautiful sphere I made in matplotlib. How would I go about putting it in a tkinter frame widget? It'd be nice to be able to integrate it into an existing tkinter GUI. Also is it possible to rid of the menu bar below the display? I have no need to save the output or zoom, so it's useless to me. from mpl_toolkits.mplot3d imp...