Python is a great programming language, but certain things about it just annoy the heck out of me.
As such, I:
1) wanted to find out how to remove these annoyances from the language itself, or
2) find a language that is Python-like that don't have these annoyances.
I love Python for everything except:
self: just seems stupid to me...
Is there a way to run cProfile or line_profile on a script on a server?
ie: how could I get the results for one of the two methods on http://www.Example.com/cgi-bin/myScript.py
Thanks!
...
I'm a very early-stage python programmer, and I wrote this simple script to convert miles to kilometers or kilometers to miles:
metrics_dict = {("miles", "kilometers"):1.609344, ("kilometers","miles"):0.62137119}
number = float(raw_input("Enter the number of units you would like to convert: "))
from_metric = raw_input("I would like to...
Say I wanted to print the response time on my pages like Google do.
How would I go about doing this?
...
Possible Duplicates:
python self explained
Why do you need explicitly have the self argument into a Python method?
Why does Python require the "self" parameter for methods?
For example def method_abc(self, arg1)
And is there ever a date that the need for it will be removed?
...
I came across this syntax browsing through code for examples. From its surrounding code, it looked like would a) get the entity with the given keyname or b) if the entity did not exist, create a new entity that could be saved. Assume my model class is called MyModel.
my_model = MyModel(key_name='mymodelkeyname',
kwa...
I have a script that fetches several web pages and parses the info.
(An example can be seen at http://bluedevilbooks.com/search/?DEPT=MATH&CLASS=103&SEC=01 )
I ran cProfile on it, and as I assumed, urlopen takes up a lot of time. Is there a way to fetch the pages faster? Or a way to fetch several pages at once? I'll do whatever...
I have a file of the following format.
"08-10-2010 13:29:31 1 APs were seen
"
"08-10-2010 13:29:31 MAC Address SSID RSSI"
"08-10-2010 13:29:31 00:1e:79:d7:d5:b0 -80"
"08-10-2010 13:30:32 2 APs were seen
"
"08-10-2010 13:30:32 MAC Address S...
Hello,
With Ruby you can do gem install from the command line to install a module...even if it is not on your machine.
Can you do that with python. Does someone know of a module?
Seth
...
I'm used to writing python scripts that interact with files, data and databases but I haven't done user-interfaces.
For my current project, I want to show an image (jpg/gif/png) to a user so it can be region-tagged. Region-tags are not just information about the image (like location or has/doesn't have people in it) but about the conten...
I'd like some advice on performing a simple image analysis in python. I need to calculate a value for the "brightness" of an image. I know PIL is the goto library for doing something like this. There is a built-in histogram function.
What I need is a "perceived brightness" values I can decide if further adjustments to the image are nece...
In Python,
I have list of dicts:
dict1 = [{'a':2, 'b':3},{'a':3, 'b':4}]
I want one final dict that will contain the sum of all dicts.
I.e the result will be: {'a':5, 'b':7}
N.B: every dict in the list will contain same number of key, value pairs.
...
I'm trying to build a python script and freeze it with cx-freeze but with Vista User Access Control support.
As it stands my script runs fine under Server 2003/Win XP, however I need to be able to write files into the root of a drive which requires elevated privileges under UAC.
My compiled script is then executed by another process (s...
Dears
I am working on custom monitoring system to my server.
the application is developed using python and Django.
The server is running java web applications and I need to monitor the JVM under which the application server is running, so I start the applications with enable the JMX.
Now I need to connect my python application to the...
Hello,
I have the following two quesions:
1 I want to be able to shutdown windows xp from python code. I am able to do that by running the following code in the python console:
import os
os.system("shutdown -s -f")
But, if i put the same code in a .py file and try to execute it,it does not work. I get the help prompt for the shutdo...
#!usr/bin/python
listofnames = []
names = input("Pls enter how many of names:")
x = 1
for x in range(0, names):
inname = input("Enter the name " + str(x))
listofnames.append(inname)
print listofnames
error
inname = input("Enter the name " + str(x))
File "", line 1, in
NameError: name 'Jhon' is not defined
...
I know how to do this with httplib, but I need to also set the user-agent and I'm sure you need urllib to do that. How can I get the http response codes with urllib?
...
Hi Alls,
I'm trying to figure out how can I scan a class C ip range;
For example a user provide by cmd line to my script :
python script.py 192.168.0.0/24 (OR 192.168.0.1-255)
Let's figure my script does only a tcp connect action:
import socket, sys
host = sys.argv[1],65535
s = socket(AF_INET, SOCK_STREAM)
s.connect(host)
s.send("...
I am new to NumPy/SciPy. From the documentation, it seems more efficient to preallocate
a single array rather than call append/insert/concatenate.
For example, to add a column of 1's to an array, i think that this:
ar0 = np.linspace(10, 20, 16).reshape(4, 4)
ar0[:,-1] = np.ones_like(ar0[:,0])
is preferred to this:
ar0 = np.linspace...
Hi,
Consider the following code in Python, using psycopg2 cursor object (Some column names were changed or omitted for clarity):
filename='data.csv'
file_columns=('id', 'node_id', 'segment_id', 'elevated',
'approximation', 'the_geom', 'azimuth')
self._cur.copy_from(file=open(filename),
table=self.new_...