I am trying to create a checking program to see if the word is in a matrix horizontally or vertically. I have the code for checking the row, but would checking the column be similar to the row code?
def checkRow(table, r, pos, word):
for i in range(0, len(word)):
if table[r][pos+i] != word[i]:
return False
re...
One issue that comes up during Pinax development is dealing with development versions of external apps. I am trying to come up with a solution that doesn't involve bringing in the version control systems. Reason being I'd rather not have to install all the possible version control systems on my system (or force that upon contributors) an...
This is my code snippet, but it not execute the way that I want.The first if statement executes successfully if the input is a non-negative/character value, but if it is a negative value it ignores the elif statement. What's the issue.I'm using Python 2.6
from math import sqrt
import cmath
y = raw_input("Enter your number:")
if y.isd...
The issue stems from the OAuth authentication portion of my code. I truncated a bunch of it and cut at the part where I get my error. My specific error is "gaierror: (11001, 'getaddrinfo failed'". I really have no idea why. I'm using Leah Culver's OAuth library (http://oauth.googlecode.com/svn/code/python/oauth/). Pretty much following t...
Hi as far as I see in Python variables are untyped. So now I want to have a baseclass
class baseClass:
def x():
print "yay"
and two subClasses
class sub1(baseClass):
def x():
print "sub1"
class sub2(baseClass):
def x():
print "sub2"
in other programming languages I can develop against interfaces just like
baseClass c =...
In Python, I have just read a line form a text file and I'd like to know how to code to ignore comments with a hash # at the beginning of the line.
I think it should be something like this:
for
if line !contain #
then ...process line
else end for loop
But I'm new to Python and I don't know the syntax
...
Note: This is not a post regarding which is better, zope or django? Its about understanding zope internals/architecture, when compared to Django's
I am a newbee to zope and I previously worked on Django for about 2.5 years. So when I first jumped into Zope(v2)(only because my new company is using it since 7 years), I faced these questio...
I am trying to use Python to write a client that connects to a custom http server that uses digest authentication. I can connect and pull the first request without problem. Using TCPDUMP (I am on MAC OS X--I am both a MAC and a Python noob) I can see the first request is actually two http requests, as you would expect if you are famili...
I'm having troubles loading a numpy matrix. I successfully saved it to disk through:
self.q.dump(fileName)
and now I want to be able to load it. From what I understand, the load command should do the trick:
self.q.load(fileName)
but it seems not. Anyone knows what might be wrong? Maybe the function is not called load?
...
Is there any custom widget (or a special magic way) to upload multiple files (or a whole folder!) through one form field?
I have tried this multifile widget but it uses many simple FileFileds.
...
When I do a raw_input() and enter values, I am not able to use my arrow-keys to change stuff... is there any way for doing that?
Thanx readline module helps in line editing features. How to use the readline module?
Just importing the readline module works!
...
Hi,
Setting up a virtualenv for the first time, when i try to install MySQL-python using
pip -E <<some virtual env>> install MySQL-python
i get
File "setup_windows.py", line 7, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] The system cannot find the file ...
I have a problem when I'm printing (or writing to a file) the non-ASCII characters in Python. I've resolved it by overriding the str method in my own objects, and making "x.encode('utf-8')" inside it, where x is a property inside the object.
But, if I receive a third-party object, and I make "str(object)", and this object has a non-ASCI...
Hi,
I created little app for sending out emails when something is wrong with server. Used py2exe to create exe file. While it is works absolutely fine on Win7 i have problems with running it on WinSRV2003. I do not believe that it has something to do with code itself.
Please see imports below
import pyodbc, sys, smtplib, os
from dat...
I am using the OptionParser from optparse module to parse my command that I get using the raw_input(). When I give a -h it displays the help screen and exits my application. I dont want it to display the help screen or exit the application. How can this be accomplished?
Thanx in advance.
...
Hi,
I have some text file like this, with several 5000 lines:
5.6 4.5 6.8 "6.5" (new line)
5.4 8.3 1.2 "9.3" (new line)
so the last term is a number between double quotes.
What I want to do is, using Python (if possible), to assign the four columns to double variables. But the main problem is the last term, I found no way of r...
Is there a straightforward way to find all the modules that are part of a python package? I've found this old discussion, which is not really conclusive, but I'd love to have a definite answer before I roll out my own solution based on os.listdir().
...
Hello, I need to call a python function from MATLAB. Any ideas how can I do this?
...
XML specification lists a bunch of Unicode characters that are either illegal or "discouraged". Now, given a string, what is the best way to remove all those illegal chars from it?
Right now, my best bet is a regular expression, but it's a bit of a mouthful:
illegal_xml_re = re.compile(u'[\x00-\x08\x0b-\x1f\x7f-\x84\x86-\x9f\ud800-\udf...
I am reading the book Programming Collective Intelligence, What exactly the following piece of python code do?
# Add up the squares of all the differences
sum_of_squares=sum([pow(prefs[person1][item]-prefs[person2][item],2)
for item in prefs[person1] if item in prefs[person2]])
I am trying to play with the ...