snippsat 661 Master Poster

One way,you may need to break it up if list comprehension are something new.
List comprehension is very common to use in Python.

with open('number.txt') as f:
    lst = [i.strip() for i in f]
    print lst
    print [float(i.split('$')[1]) for i in lst] #split out $ and make float
    print sum(float(i.split('$')[1]) for i in lst) #sum upp all numbers

'''Output-->
['$10.00', '$10.00', '$10.00', '$10.00', '$10.00', '$10.00']
[10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
60.0
'''
snippsat 661 Master Poster

url is set to None,then you get this error message.

>>> url = 'http://www.google.com'
>>> url[0:4]
'http'
>>> url = None
>>> url[0:4]
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: 'NoneType' object has no attribute '__getitem__'

A tips is to just use print on url to see what you get.
So if there are no more url it will return None.
You can catch error and pass it out,then it will try to go futher.

>>> try:
...     url = None
... except TypeError:    
...     pass
snippsat 661 Master Poster
>>> lst = [[1,2,3], [4,5,6]]
>>> del lst[1]
>>> lst
[[1, 2, 3]]

>>> lst = [[1,2,3], [4,5,6]]
>>> lst.remove(lst[1])
>>> lst
[[1, 2, 3]]

>>> lst = [[1,2,3], [4,5,6]]
>>> lst.pop(1)
[4, 5, 6]
>>> lst
[[1, 2, 3]]
snippsat 661 Master Poster

[::-1] or reversed()

>>> s = 'hello' 
>>> s[::-1].upper()
'OLLEH'
>>> ''.join(reversed(s.upper()))
'OLLEH'
snippsat 661 Master Poster

So it looks like it reads from all three files, but it includes the words with punctuation now?

text is now a tuple.

>>> s = 'Test.'
>>> s1 = 'hello?'
>>> s2 =  '-world?,'
>>> text = s, s1, s2 #Python always make a tuple when you do this
>>> text
('Test.', 'hello?', '-world?,')
>>> "".join(c for c in text if c not in string.punctuation).lower()
'test.hello?-world?,'
>>> text = ' '.join(text) #Fix
>>> "".join(c for c in text if c not in string.punctuation).lower()
'test hello world

Learn to do small test as i do here.

snippsat 661 Master Poster

How would I make it so that only words with 2 or more characters are put into that file?

>>> s = 'hi this is a test'
>>> s = s.split()
>>> [i for i in s if len(i) >= 2]
['hi', 'this', 'is', 'test']

#With regular loop
>>> for item in s:
...     if len(item) >= 2:
...         print item
...         
hi
this
is
test

And for the file path, if I leave it as is right now, would that work if someone else is running the program on their computer?

If no path is given,files will always be in same folder as you or other run code(.py) from.

snippsat 661 Master Poster

There are some room for improvement in this code.
In line 14 you are removing punctuation,then in line 20 you are testing for punctuation that's already removed.
There is no need to use a file and append word,just use set().
So then it could look like this.

import string

with open('alice.txt') as f:
    text = f.read().lower()

words = "".join(c for c in text if c not in string.punctuation).split()
print(len(set(words)))
snippsat 661 Master Poster

Here is a differnt way,with a little change of good answer given by pyTony.
Using next() to skip first line(header).

def files_to_one(new_file, *files):
    with open(new_file, 'w') as fout:
        for f in (files):
            with open(f) as fin:
                next(fin)
                for line in fin:
                    fout.write(line+'\n')
snippsat 661 Master Poster

.I have not come across the curly brackets yet on this line of code

New string formatting came out in Python 2.6
Gribouillis has much about it here
A quick look at at old and new.

>>> old = 'My name is %s' % 'foshan'
>>> old
'My name is foshan'
>>> 
>>> new = 'My name is {}'.format('foshan')
>>> new
'My name is foshan'

I think Python doc is usaually is ok,but with new string formatting not so good.
Here a coulpe of good link.
http://ebeab.com/2012/10/10/python-string-format/
http://www.cs.cmu.edu/~nschneid/pythonathan/py-format-string-ref.pdf

snippsat 661 Master Poster

You can do this print(t[0:3] in s) read my post again.

You are checking if list ['16', '24', '30'] is in s and that is False.

And see how i make it True.

This should equal:One True for the 40 match the rest would be False:

31 40 45 57 58 - 01
01 13 21 22 40 - 31

You have to make a rule for this.
Because there are 4 elements that's in both list.

>>> s = '31 40 45 57 58 - 01'.split()
>>> t = '01 13 21 22 40 - 31'.split()
>>> [item for item in t if item in s]
['01', '40', '-', '31']

>>> #Or with set() as Grib posted
>>> ys = set(s)
>>> yt = set(t)
>>> print(ys & yt)
set(['31', '01', '-', '40'])

you can see the first number is 01 this 01 has no bearing on the sixth 01 on the first line

I guess the same is for 31,then you can take away last 2 element.

>>> s = '31 40 45 57 58 - 01'.split()[:-2]
>>> s
['31', '40', '45', '57', '58']
>>> t = '01 13 21 22 40 - 31'.split()[:-2]
>>> t
['01', '13', '21', '22', '40']
>>> [item for item in t if item in s]
['40']

>>> ys = set(s)
>>> yt = set(t)
>>> print(ys & yt)
set(['40'])

This should equal:One True for the 40 match the rest …

snippsat 661 Master Poster

Some hint.

>>> s = ['06', '15', '26', '34', '36', '-', '16']
>>> t = ['16', '24', '30', '34', '43', '-', '20']
>>> s[0]
'06'
>>> t[0]
'16'
>>> s[0] == t[0]
False
>>> s[3] == t[3]
True
>>> s[5] == t[5]
True

But I dont know why it came out <False> when <16> is in <s>

>>> t[0:3]
['16', '24', '30']
>>> t[0:3] in s
False

>>> #To make it True
>>> s = [['16', '24', '30'],'06', '15', '26', '34', '36', '-', '16']
>>> t[0:3] in s
True

You are checking if list ['16', '24', '30'] is in s and that is False.

Iterate over both list and compare.

>>> s = ['06', '15', '26', '34', '36', '-', '16']
>>> t = ['16', '24', '30', '34', '43', '-', '20']
>>> for x,y in zip(s, t):
        print x == y

False
False
False
True
False
True
False

Or make it a list,with use of comprehension.

>>> [x == y for x,y in zip(s, t)]
[False, False, False, True, False, True, False]
snippsat 661 Master Poster

Microframework like Flask and Bottle would be fine for a task like this.
There are many 14 Minimal Web Frameworks for Python

(mayby web2py)

Would also be ok.

or should I just dive into HTML/CSS?

You should look in to it hard to do web stuff without it,also AJAX and jQuery can be ok to look into.

I have earlier done some coding with CGI and own Python code to produce table in HTML for web display

CGI is pretty much dead after PEP 333 now is WSGI used in all modern Python web-framework and microframework.

Some more info here

WSGI is Python only. Rather than a language agnostic protocol, a standard function signature is defined:

You can look at an Run some Flask code here

snippsat 661 Master Poster

I need it for a code such as this:

No that just stupid code.
Explain better what you want do,then you get suggestions for better ways to solve it.

snippsat 661 Master Poster

. The given md5 hash isn't inside <strong> tags. Its simple plain text

Even if it's in plain text,it's inside HTML on a website.
Then using a parser is the right tool,of course there is possible get one value like this with regex.
If you need help you have to post where it are,or some lines where value is present.

Here are some example for web scripting in python:

This has nothing to do with web-scraping.

snippsat 661 Master Poster

And is there any other/better way to scrape particular data ?

There is a better way,and HTML and regex is not the best way.
Read bobince funny and good answer her.

Python has two star paser Beautiful Soup and lxml
A couple of example parsing a <strong> tag.

from bs4 import BeautifulSoup

html = """\
<html>
<head>
   <title>html page</title>
</head>
<body>
  <strong>Hello world</strong>
</body>
</html>
"""
soup = BeautifulSoup(html)
tag = soup.find('strong')
print tag.text #--> Hello world

With lxml let say a website has <strong> tag contain text Hello world.

from lxml.html import parse

page = parse('http://www.website.com').getroot()
print page.xpath('//strong')[0].text  #--> Hello world
snippsat 661 Master Poster

Sorry but the code is not good at all.
Now you have a while True loop start at line 14 with a lot of code in it.
You have to use function or class when code get longer.

Look at code in first part here
See how function get_name() show_name() process_name() are short and give a hint what they do,this make code easy to test and read.

A single function should pretty much always be less than 15 lines,and even that is pushing it.
In your code you have all code in global space,wish make it hard to read and test.

snippsat 661 Master Poster

if we want to convert 'xyz' to uppercase, why dont we enter the argument inside the function

Because uppercase() is a method that belong to string class and only works on strings.
The Built-in Functions work on many class/objects.
Let's see how len() work on string and list.

>>> s = 'hello'
>>> len(s)
5

>>> lst = [1,2,3]
>>> len(lst)
3

Both string and list has methods that belong only to string and list class.
Look at append() for list.

>>> lst = [1,2,3]
>>> lst.append(4)
>>> lst
[1, 2, 3, 4]

append() work only for list,so no point that it should built in function.

s = 'hello'
>>> s.append('world')
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'str' object has no attribute 'append'

Use dir(str) or dir(list) to see methods that belong to string and list class.

snippsat 661 Master Poster

Good idèe bye slate to update objects namespace.
You can also just work with dictionary if you need result variable2 + variable3 wish is 30.
Herer a little compressed version.

>>> s = 'variable1=5&varible2=3&variable3=27&varible4=1'
>>> d = dict((k[0], k[1]) for k in [i.split('=') for i in s.split('&')])
>>> int(d['varible2']) + int(d['variable3'])
30
snippsat 661 Master Poster

That way is a little unpythonic way to do it rrashkin.

d = {'Seven': 22, 'Six': 0, 'Three': 35, 'Two': 0, 'Four': 45, 'Five': 34, 'Eight': 0}
for k,v in d.items():
    if v == 0:
        del d[k]

print d
#--> {'Five': 34, 'Four': 45, 'One': 10, 'Seven': 22, 'Three': 35}

For both dictionary and list it's not so normal to use del.
Here create a new dictionary using dict comprehension,as you see no del.

>>> d = {'Seven': 22, 'Six': 0, 'Three': 35, 'Two': 0, 'Four': 45, 'Five': 34, 'Eight': 0}
>>> {k:v for k,v in d.items() if v != 0}
{'Five': 34, 'Four': 45, 'One': 10, 'Seven': 22, 'Three': 35}

Just to show the same with a list.

>>> lst = [1, 2, 0, 4, 0, 3, 0, 2, 0, 2]
>>> [i for i in lst if i != 0]
[1, 2, 4, 3, 2, 2]
snippsat 661 Master Poster

returns the last line of that txt file and not the first (as I need).

If you just need first line why make it more difficult than it is.
just readline() give back first line.
If need line by line drop while 1 and just iterate over lines with a for loop and grab line you want.
A coulpe of example here i use open() but you can also iterate over urlopen() in a similar way.

"""latest.txt-->
version 2
version 5 latest
version 3
"""

with open('latest.txt') as f:
    for line in f:
        if 'latest' in line:
            print line.strip() #The line you want
            print 'The latest version is "{}"'.format(line[:9]) #The current version

"""Output-->
version 5 latest
The latest version is "version 5"
"""

Just first line,if lastest version is always there.

with open('latest.txt') as f:
    first_line = f.readline()
    print first_line.strip() #--> version 2
snippsat 661 Master Poster

cx_Freeze works Python 2 and 3.
gui2exe for all installers into a GUI interface.

As mention by Gribouillis on Linux it's ofen no problem to just give away .py files.

In my project wx_nrk for downloading all on norwegian TV.
I choiced to compiled to exe for Windows user and for Linux user i just made read_me file with step how to use it.
I could have make a compiled version for Linux but it's more easy for Linux user because Python is pre_installed.

snippsat 661 Master Poster

Does this work for what you are asking?

nichom your function is not recursive wish is the task here.
Look at pyTony soultion.

snippsat 661 Master Poster

One with Requests
So popular that it can be in standar libary in future,maybe in Python 3.4.

When file is big as here(over 400mb) is a good choice to not load all in memory.
So here here it download in chunks of 4096 bytes.

import requests

url = "http://www.cs.cmu.edu/~enron/enron_mail_20110402.tgz"
r = requests.get(url, stream=True)
file_name = url.split('/')[-1]
file_size = r.headers["Content-Length"]

with open(file_name, "wb") as f_out:
    for block in r.iter_content(4096):
        if not block:
            break
        f_out.write(block)
    print "Downloading: {} Bytes: {}".format(file_name, file_size)
snippsat 661 Master Poster

Make a list index out of range error.

>>> lst = [1,2,3]
>>> lst[2]
3
>>> lst[3]
Traceback (most recnt call last):
  File "<interactive input>", line 1, in <module>
IndexError: list index out of range

So it should be easy to understand if you look at list(print or repr).
Then you see that index you try use is out of list range.

This can mean that meta.getheaders("Content-Length") is returning an empty list.
The if you index it with [0],the empty list give back list index out of range error.
which might happen if something went wrong in the urlopen call.

snippsat 661 Master Poster

You first post.
http://www.daniweb.com/software-development/python/threads/470301/problem-in-copying-domain-name-from-one-notepad-to-another-using-regex
You have postet more info about the task,but it still not as clear as it should be.
You can try this.

import re

with open('1.txt') as f1,open('2.txt') as f2,open('result.txt', 'w') as f_out:
    f1 = re.findall(r'rhs="(.*)"', f1.read())
    f2 = re.findall(r'rhs="(.*)"', f2.read())
    diff = [i for i in f1 if i not in f2]
    #print diff
    f_out.write(','.join(diff))
snippsat 661 Master Poster

It is better to use re.finditer when iterate over text and save to file.
Look like this.

import re

data = '''\
line2 jdsbvbsf
line3 <match name="item1" rhs="domain.com"></match>
line4 <match name="item2" rhs="domainn.com"></match>
line5 <match name="item2" rhs="1010data.com"></match>'''

with open('result.txt', 'w') as f_out:
    for match in re.finditer(r'rhs="(.*)"', data):
        f_out.write('{}\n'.format(match.group(1)))

'''Output-->
domain.com
domainn.com
1010data.com
'''
snippsat 661 Master Poster

If you remove re.IGNORECASE look better?

import re

data = '''\
Amiloride-sensitive cation channel, ASIC3 (also called BNC1 or MDEG) which is an acid-sensitive (proton-gated)'''

cleantext = re.sub(r'\(|\)|\[|\]', '' ,data)
cleantext = re.sub(r'\w{1,}( |-)(gated|sensitive)', '' ,cleantext)
print cleantext.strip()

'''Output-->
cation channel, ASIC3 also called BNC1 or MDEG which is an
'''
snippsat 661 Master Poster

Hy I would like to know what python gui framework, I can use that will be compatible cross platform

You can use most Python GUI framework as the work fine crossplatform or with minor changes.
Talking about Wxpython,PyQt(PySide),PyGTK and build in Tkinter.

kivy is new in Python GUI world,can be a good choice.
The problem with new stuff is examples and stuff to look at that can help a lot..

With Other GUI the help is very good as an example mega post on this fourm.

I thought I can use kivy to create my graphical interface than use standalone python to create the rest.

There is no standalone Python(of course Portable Python but that has other usercase),you make Python code interact with GUI.
Then at the end it can be a standalone program,with Python/GUI code merged into one unit.

snippsat 661 Master Poster

but absolutelly no doubt that building web on PHP will be faster/easier,

That is of course a lot bullshit for someone that use Python.
I use Python for web development and don't like messy PHP.
PHP: a fractal of bad design

I wrote a little about Python and web here.
http://www.daniweb.com/software-development/python/threads/468399/learning-python

snippsat 661 Master Poster

Your code doesn't make sense as it are now.
If you are gone use sys.argv,you know that means running script from command line and pass in argument from command line?

#site_check.py
import sys

def printWebsite(url):
    print "url for sys.argv {}".format(url)

def main():
    printWebsite(sys.argv[1])

if __name__ == '__main__':
    main()

Running from command line(cmd) of terminal linunx.
python site_check.py www.google.com
This take command line arguments www.google.com and bring it into site_check.py.
sys.arg is name of script,sys.arg[1] is passed in agrument.
Dos this make sense?

Then you can check if url is vaild or not,this means that you have to check status code like "404" or catch exception if site is down.

Always 4 space indentation in Python.

snippsat 661 Master Poster

1.is is used for web development

Python is great for all web stuff you can think of.
Is normal to use Web Framework when making websites.
Django is the most known and has good documentation,some sites run bye Django djangosites.
Some info about setup Apache with mod_wsgi/mod_python here
HOWTO Use Python in the web

There are also CMS like Plone and Django CMS.

Micro framework has in the last couple of year become very popular, Flask, Bottle, Pyramid to mention some.

There a lot of more stuff that make Python great to interact with web,as honorable mention Requests: HTTP for Humans, Beautiful Soup, lxml

snippsat 661 Master Poster

Python has a scheduler module,wish is a option to OS scheduler like Cron or Windows task scheduler.
I have used it's some times and it work well sleeping in background and do work only when it shall.
One positive aspect is that is crossplatform.

So this will run every 2 hours.

from bs4 import BeautifulSoup
import re
import urllib2
import sched, time

def do_event():
    url = "http://www.boston.com/yourtown/"
    page = urllib2.urlopen(url)
    soup = BeautifulSoup(page.read())
    news_titles = soup.find_all('h4')
    for nts in news_titles:
        for n in nts("a"):
            print n.renderContents()
    s.enter(7200, 1, do_event, ())

s = sched.scheduler(time.time, time.sleep)
s.enter(7200, 1, do_event, ())
s.run()
Gribouillis commented: good idea +14
snippsat 661 Master Poster

The Problem with Integer Division
Not much else to say if you read that post.
One tips is to use from __future__ import division for Python 2.x.
Python 3.x has made chage to integer-division.

#Python 2.7
>>> 10 / 3
3
>>> from __future__ import division
>>> 10 / 3
3.3333333333333335

--

#Python 3.3
>>> 10 / 3
3.3333333333333335
Gribouillis commented: good link +14
snippsat 661 Master Poster

Reapting code(answer).
Class or function's is a must to stucture code when it get longer.
This is maybe something you need to learn.

Some tips to get rid of all that if's.
Here use dictionary and convert all input to lowercase(lower())
Then you dont need this 'run' or answer=='Run':
Another option can be to load all that printing info from a file.

game_dict = {
    'walking':
'''This will be a long and treacherous journey.Prepare yourself with a weapon.
Would you like to take the sword or the scimitar?''',
    'teleporting':
'You teleport yourself into the city of Marshingo with ease.',
    'sword':
'You arm yourself with the sword and head out on your way.'
}

answer = input('How will you get to Marshingo, by walking or by teleporting?').lower()
if answer in game_dict:
    print(game_dict[answer])
else:
    print('{} not found in game_dict'.format(answer))
snippsat 661 Master Poster

Start bye testing your convert function,it's not working.

def covert_temperature(fahrenheit):
    '''Convert fahrenheit to celsius'''
    return (fahrenheit - 32) * 5.0/9.0

Test:

>>> covert_temperature(1)
-17.22222222222222
>>> covert_temperature(50)
10.0

So working correct.
== Checks if the value of two operands are equal or not.
You can not have it your function and "celsius" has no meaning in function.

snippsat 661 Master Poster

find_all()

The find_all() method scans the entire document looking for results,

snippsat 661 Master Poster

if there are more number of parameters, out of which we need to print version and type only

can you please help with the code to get out this

You have to post an example of how the other parameters look.
There are many ways to do this,if data is unformatet/changing regex can be and option.

import re

data = '''\
abc : 123
version: 7.0.0.9
type : NAS
ggg.2 : 4444
version: 8
type : FOO
hg.1234: test'''

result = re.findall(r"version.*|type.*", data)
print result
print zip(*[iter(result)]*2)
print [tuple(x.strip() for x in y.split(":")) for y in result] 

"""Output-->
['version: 7.0.0.9', 'type : NAS', 'version: 8', 'type : FOO']
[('version: 7.0.0.9', 'type : NAS'), ('version: 8', 'type : FOO')]
[('version', '7.0.0.9'), ('type', 'NAS'), ('version', '8'), ('type', 'FOO')]
"""
snippsat 661 Master Poster

Give an example or link og what you try to extract/parse.
As mention by krystosan it's XML data,and there are good tool for this in Python.
And library that is only for parsing RSS like Universal Feed Parser
I like both Beautifulsoup and lxml.
A quick demo with Beautifulsoup.

from bs4 import BeautifulSoup

rss = '''\
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>Python</title>
<link>http://www.reddit.com/r/Python/</link>
<description>
news about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
</description>'''

soup = BeautifulSoup(rss)
title_tag = soup.find('title')
description_tag = soup.find('description')
print title_tag.text
print description_tag.text

"""Output-->
Python

news about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
"""
snippsat 661 Master Poster

Fun this odd/even stuff,one with ternary operator.
Did like the clean look of this one.

>>> from collections import Counter
>>> from random import sample
>>> Counter("Odd" if i % 2 else "Even" for i in sample(range(0, 1000), 100))
Counter({'Even': 56, 'Odd': 44})
snippsat 661 Master Poster

This is a compressed version,if you see me post in link you see more how it works in part.

>>> from collections import Counter
>>> import random
>>> Counter(map(lambda x : 'even' if x % 2 == 0 else 'odd', (random.randint(0,1000) for i in range(100))))
Counter({'even': 58, 'odd': 42})
snippsat 661 Master Poster

First page 8 post down.
Generating count for odd & even

snippsat 661 Master Poster

Some hint and look at differnt ways to count.
For counting this is a standar way.

import random

n = 100
even = 0
for item in range(n):
    if random.randint(1,n) % 2 == 0:
        even += 1

print('Even numer count is {}\nOdd number count is {}'.format(even, n - even))

"""Output-->
Even numer count is 53
Odd number count is 47
"""

So here i just count and dont't show numbers,if you need to show numbers use "else" and lists you append number to.

Your list comprehension stuff in last post is wrong.
A quick demo.

>>> lst = [random.randint(1,10) for i in range(10)]
>>> even = [i for i in lst if i % 2 == 0]
>>> odd = [i for i in lst if i % 2 == 1]
>>> even
[4, 10, 10, 2, 8, 8]
>>> odd
[5, 5, 5, 7]
>>> len(even)
6
>>> len(odd)
4

In first post you have a is_even helper function,this is a good way.
So here almost same function i use name to make it clearer.

def odd_even(n):
    if n % 2 == 0:
        return 'even'
    return 'odd'

Use function.

    lst = [random.randint(1,10) for i in range(10)]
    >>> map(odd_even, lst)
    ['even', 'even', 'odd', 'even', 'odd', 'odd', 'odd', 'even', 'odd']
    >>> # Or list comprehension
    >>> [odd_even(i) for i in lst]
    ['even', 'even', 'odd', 'even', 'odd', 'odd', 'odd', 'even', 'odd']

So here it show odd/even next step can be …

snippsat 661 Master Poster

Php will be still around because it can work on almost any host.

So the future is php python javascript.

Yes all of this languages will be there in the future.
I wish that PHP would be less popular because it's a messy language,but i dont think so.
PHP: a fractal of bad design

I wrote a little about Python and web here.
http://www.python-forum.org/viewtopic.php?f=10&t=3546

snippsat 661 Master Poster

The import statement will return the top level module of a package.
You can try this.

varhelp = __import__("sys").path

But be careful and try to keep "magic stuff" away from import statement.
import(doc)

Note This is an advanced function that is not needed in everyday Python programming, unlike importlib.import_module().

snippsat 661 Master Poster
>>> from collections import OrderedDict
>>> s = "Mathematics".upper()
>>> ''.join(OrderedDict.fromkeys(s))
'MATHEICS'
snippsat 661 Master Poster

How do you run PyPy?

Run PyPy is very easy.
Windows download Windows binary (32bit)
Pack out to example C:\pypy
Navigate to folder in cmd then.
C:\pypy>pypy some_file_to_run.py

Linux example Mint,search software manager for PyPy install.
Navigate to folder.

tom@tom-VirtualBox:/usr/lib/pypy/bin > ./pypy-c -m timeit [1,2,3,4]
1000000000 loops, best of 3: 0.000777 usec per loop
tom@tom-VirtualBox:/usr/lib/pypy/bin > 

So pypy or pypy-c just replace python as run command.

For even better performance,look at video from 9 min.
There is possible to run translate.py -Ojit on your computer.

snippsat 661 Master Poster

Doesn't PyPy actually translate to C?

Yes that one of the process,if you look at video bye David Beazle you get a better overview.
There is a lot of heavy stuff under the cover.

snippsat 661 Master Poster

So how would speed test over look in PyPy?

C:\pypy>pypy -m timeit (1,2,3,4)
1000000000 loops, best of 3: 0.00102 usec per loop

C:\pypy>pypy -m timeit [1,2,3,4]
1000000000 loops, best of 3: 0.00102 usec per loop

Hmm faster and no time differnce,don't ask why PyPy is the diabolical work of super programmers.
A god a funny video when David Beazley look into PyPy.

snippsat 661 Master Poster

A tuple uses much less memory than a list.

And should be faster.

C:\>python -m timeit (1,2,3,4)
10000000 loops, best of 3: 0.0226 usec per loop

C:\>python -m timeit [1,2,3,4]
10000000 loops, best of 3: 0.194 usec per loop

Yes tuple are faster than list.

snippsat 661 Master Poster

it seems you are using the new version of python

No he is using Python 2.4,do you not see output from sys.version in his post?