Which technology is better to use in terms of performance for high performance scalable web application? PHP or Python?
The project is going to involve database.
I erroneously wrote this code in python:
name = input("what is your name?")
if name == "Kamran" or "Samaneh":
print("That is a nice name")
else:
print("You have a boring name ;)")
It always prints out "That is a nice name" even when the input is neither "Kamran" nor "Samaneh".
Am I correct in saying that it considers "Samaneh" as a…
#!/usr/bin/python
#this looks for words in dictionary that begin with 'in' and the suffix is a real word
wordlist = [line.strip() for line in open('/usr/share/dict/words')]
newlist = []
for word in wordlist:
if word.startswith("in"):
newlist.append(word)
for word in newlist:
word = word.split('in')
print newlist
how would I…
Dear All,
I would like to automatically generate a flowchart similar to this one ( http://en.wikipedia.org/wiki/File:%281%29_2008-04-07_Information_Management-_Help_Desk.jpg ) with Python.
Do you have any advice regarding the library I should use to draw boxes, arrows (with the shortest path), text and some colors.
Many thanks in…
What's the best way to sanitise user input for a Python-based web application? Is there a single function to remove HTML characters and any other necessary characters combinations to ensure that an XSS or SQL injection attack isn't possible?
Hi,
I'm writing a parser in Python. I've converted an input string into a list of tokens, such as:
['(', '2', '.', 'x', '.', '(', '3', '-', '1', ')', '+', '4', ')', '/', '3', '.', 'x', '^', '2']
I want to be able to split the list into multiple lists, like the str.split('+') function. But there doesn't seem to be a way to do…
I'm looking for a quick bash script or program that will allow me to kick off a python script in a separate process. What's the best way to do this? I know this is incredibly simple, just curious if there's a preferred way to do it.
Am surprised there's 3 different forms: RawConfigParser, SafeConfigParser and ConfigParser. I read the differences but why isn't everyone using SafeConfigParser, since it seems, well, safe? I can understand that in the case for Python 2 that the other two were kept for backward compatibility.
I'm writing a shell for a project of mine, which by design parses commands that looks like this:
COMMAND_NAME ARG1="Long Value" ARG2=123 ARG3=me@me.com
My problem is that Python's command line parsing libraries (getopt and optparse) forces me to use '-' or '--' in front of the arguments. This behavior doesn't match my…
hello.
What is the pythonic way to test if there is a tuple starting with another tuple in collection? actually, I am really after the index of match, but I can probably figure out from test example
for example:
c = ((0,1),(2,3))
# (0,) should match first element, (3,)should match no element
I should add my python…
I'm running OS X Leopard. I followed this site to install it. Trying to run any demo script, I now get "No module named opencv.cv", which is obviously stopping me from doing any programming. I am running python 2.5.1 (yes, I know it's kind of old).
Why would this be, and how can I solve it?
Thanks
Hi there,
I feel like this is quite delicate,
I have various folders whith projects I would like to backup into a zip/tar file, but would like to avoid backing up files such as pyc files and temporary files.
I also have a Postgres db I need to backup.
Any tips for running this operation as a python script?
Also,…
I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is there a better way?
I'm running a python program. When it get's to these lines:
f = open("/dev/bus/usb/007/005", "r")
x = fcntl.ioctl(f.fileno(), 0x84005001, '\x00' * 256)
It fails saying:
IOError: [Errno 1] Operation not permitted
What could be causing this problem?
I am trying really hard to make a sliding frame containing widgets in tkinter in python. There is this frame inside a big window with different widgets. And as soon as i click on the next button on that frame the frame should slowly slide towards the left and vanish ultimately. As soon as it vanishes, i want new frame…
I've always laughed to myself when I looked back at my VB6 days, "What modern language doesn't allow incrementing with double plus signs?":
number++
To my surprise I can't find anything about this in the Python docs. Must I really subject myself to number = number + 1? Doesn't people use the ++/-- notation?
:-(
Is it possible for my python web app to provide an option the for user to automatically send jobs to the locally connected printer? Or will the user always have to use the browser to manually print out everything.
How can I split a line in Python at a non-printing ascii character (such as the long minus sign hex 0x97 , Octal 227)?
I won't need the character itself. The information after it will be saved as a variable.
I'm trying to work with sockets and I have such problem
In code example:
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0')
I have error
AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE'
On Linux machine this attribute is OK but on FreeBSD trere are no any SO_*…
Hi all
I am a newbie to the python. Can I unhash, or rather how can I unhash a value. I am using std hash() function. What I would like to do is to first hash a value send it somewhere and then unhash it as such:
#process X
hashedVal = hash(someVal)
#send n receive in process Y
someVal = unhash(hashedVal)…
In C++ we can enter multiple lines by giving our own choice of delimiting character in the getline() function.. however I am not able to do the same in Python!! it has only raw_input() and sys.stdin.readline() methods that read till I press enter. Is there any way to customize this so that I can specify my…
This is a question I have wondered about for quite some time, yet I have never found a suitable solution. If I run a script and I come across, let's say an IndexError, python prints the line, location and quick description of the error and exits. Is it possible to automatically start pdb when an error is…