snippsat 661 Master Poster
infile = open("afile.txt")
count = {}
for aline in infile:
    words = aline.split()
    for word in words:
        if word in count:
            count[word] += 1
        else:
            count[word] = 1

print(count)

An other way this code also remove punctuation and covert to lower case.

from collections import Counter

with open('afile.txt') as f:
    text = f.read().lower()
words = [c for c in text.split() if c.isalpha()]

print(Counter(words))
snippsat 661 Master Poster

Dont use input as a varible name,is reserved word for user input.
To simpilfy it,there is capitalize string method.

>>> s = 'the money is in the bag. however you dont want it.'
>>> [i.capitalize() for i in s.split()]
['The', 'Money', 'Is', 'In', 'The', 'Bag.', 'However', 'You', 'Dont', 'Want', 'It.']

You can of course use upper() method and take out first word[0] in same way.
list comprehensions as i use is very common is python,so you better learn right away.
Try to break it up and write is an ordinary loop,to understand it.

snippsat 661 Master Poster

This will do it.

with open('file_in.txt') as f:
    for numb,line in enumerate(f, 1):
        if 1 <= numb <= 150:
            print line
snippsat 661 Master Poster

You can look at this and see if it helps.

>>> import socket 
>>> socket.gethostbyname_ex('python.org')
('python.org', [], ['82.94.164.162'])
>>> socket.gethostbyaddr('82.94.164.162')
('dinsdale.python.org', [], ['82.94.164.162'])
>>> socket.gethostbyaddr('111.111')
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
gaierror: [Errno 11004] getaddrinfo failed
>>> socket.gethostbyaddr('11.111.111.111')
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
herror: [Errno 11004] host not found
import socket

def foo(ip):
    try:
        name = socket.gethostbyaddr(ip)
        return name[0]
    except (socket.gaierror,socket.herror):
        return 'No DNS name found for this ip'

#ip = '82.94.164.162'
#dinsdale.python.org

ip = '11.111.111.111'
#No DNS name found for this ip

print foo(ip)
snippsat 661 Master Poster

I want to extract the following link "http://media1.santabanta.com/full5/indian celebrities(f)/aalesha/aalesha-1a.jpg".

There is a problem the link you want is loaded bye javascript.
We can see the link in downloaded text,then we can drop to simulate javascript and use regex(because Beautifulsoup cant find stuff in javascript)

from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
import re

webpage = urlopen('http://www.santabanta.com/photos/aalesha/10066001.htm')
soup = BeautifulSoup(webpage)
#print soup

bac_img = re.search(r"""backgroundImage="url\('(.*)'""", str(soup))
print bac_img.group(1)
#http://media1.santabanta.com/full1/Indian  Celebrities(F)/Aalesha/aalesha-1a.jpg

#Example of how to print image location,that is not loaded bye javascript
'''
imagelocation = soup.findAll('img')
for imgTag in imagelocation:
    print imgTag['src']'''
snippsat 661 Master Poster

Windows look in environment variable(path) for python version.
http://www.windows7hacker.com/index.php/2010/05/how-to-addedit-environment-variables-in-windows-7/
To path you can add ;C:\python27\;C:\python27\scripts
Restart.
When you write pyhon in cmd python 2.7 will start.
Change to ;C:\python32\;C:\python32\scripts
Restart.
When you write pyhon in cmd python 3.2 will start.
This also mean that stuff get installed in python 3.2.
With the use of easy install or python module_name.py install

snippsat 661 Master Poster

An other way,nice use of itertools Gribouillis.

def blocks(filename, chunks):
    with open(filename) as f:
        numb_list = [i for i in f]
    return [numb_list[i:i+chunks] for i in range(0, len(numb_list), chunks)]

filename = 'numb.txt'
chunks = 4
print blocks(filename, chunks)

""" Out-->
[['56.71739\n', '56.67950\n', '56.65762\n', '56.63320\n'], ['56.61648\n', '56.60323\n', '56.63215\n', '56.74365\n'], ['56.98378\n', '57.34681\n', '57.78903\n', '58.27959\n']]"""
snippsat 661 Master Poster

So everytime if we have a function to define, and If i wanna write
to an output file, I always have to put it outside the function.

No of course not,we could have placed all in one function.
For better design it can be smarter to make a new function like code under.
A function should not do to many task,if a function do to many task code get harder to read.

def makeMagnitudeList():
        quakefile = open("in.txt","r")
        headers = quakefile.readline()
        maglist = []
        for aline in quakefile:
            vlist = aline.split()
            maglist.append(float(vlist[1]))
        quakefile.close()
        return maglist

def write_to_file(arg):
    outfile = open("out.csv", "w")
    outfile.write(', '.join(str(i) for i in arg))
    outfile.close()

magList = makeMagnitudeList()
write_to_file(magList)
Gribouillis commented: wise advice +13
snippsat 661 Master Poster

If i run your sample file in my code output will be.
4.3, 5.2, 5.0, 4.8, 4.6
Is that what you want?

The .join function, is there a different way to show that part?

join is important to learn about,here is an example.

>>> l = [4.3, 5.2, 5.0, 4.8, 4.6]
>>> l
[4.3, 5.2, 5.0, 4.8, 4.6]
>>> #So a list with floats,if write to a file it has to be string
>>> s = [str(i) for i in l]
>>> s
['4.3', '5.2', '5.0', '4.8', '4.6']
>>> #Now it`s a list with strings,so to make it a string we use join
>>> ''.join(s)
'4.35.25.04.84.6'
>>> #Have to but in a ,
>>> ', '.join(s)
'4.3, 5.2, 5.0, 4.8, 4.6'
>>> #Now is ready to be written to a file.
snippsat 661 Master Poster

All makeMagnitudeList() function do is to return maglist.
outfile will be local to function,to make it work we have to move it out.
Remember to close() file or use with open() .
you can not write a list to file,it has to string.
If you give a sample of earthquakes.txt file it is easier to test it out,here just a file a found.
Python has a CVS module who is made for work with cvs.

'''#in.txt
header something
1900	13
1901	14
1902	 8
1903	10
1904	16
'''

def makeMagnitudeList():
        quakefile = open("in.txt","r")
        headers = quakefile.readline()
        maglist = []
        for aline in quakefile:
            vlist = aline.split()
            maglist.append(float(vlist[1]))
        quakefile.close()
        return maglist

magList = makeMagnitudeList()
print(magList)

outfile = open("out.csv", "w")
outfile.write(', '.join(str(i) for i in magList))
outfile.close()

'''#out.csv
13.0, 14.0, 8.0, 10.0, 16.0
'''
snippsat 661 Master Poster

One with regex you can look at,this is also not an ideal way when it comes to html.

import re

def find_attribute_value(html, att):
    s = re.search(r'%s="(.*?)"' % att, html)
    return s.group(1)

html = '''<img align=top src="photos/horton.JPG" alt="Image of StG instructor (Diane Horton)">', "src"'''
print find_attribute_value(html, 'src')
#photos/horton.JPG

print find_attribute_value(html, 'alt')
#Image of StG instructor (Diane Horton)
snippsat 661 Master Poster

Now do python have strong parser like lxml and BeautifulSoup,that do job like this much easier.

>>> from BeautifulSoup import BeautifulSoup
>>> html = '''<img align=top src="photos/horton.JPG" alt="Image of StG instructor (Diane Horton)">', "src"'''
>>> soup = BeautifulSoup(html)
>>> tag = soup.find('img')
>>> tag['src']
u'photos/horton.JPG'
snippsat 661 Master Poster

Some note.
For better look/style than just stuff all code in a main function,it can be better to make som more functions.
Then bring it all togeher in the main function.
Here you also see that i use docstring in function name_calc.

def name_input():
    name = raw_input("Please enter your first or last name (no spaces): ").lower()
    first,last = name.split()
    return first, last

def name_calc(first,last):
    '''Calculate numeric value from input names'''
    first_calc = sum([ord(c)-96 for c in first])
    last_calc = sum([ord(c)-96 for c in last])
    return first_calc, last_calc

def main():
    first,last = name_input()
    f, l = name_calc(first,last)
    print '%s(%d) %s(%d) total numeric value %s' %  (first,f, last,l, f+l)
    #williams(98) smith(69) total numeric value 167

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

Some point to this.

>>> a = 2
>>> b = 1
>>> c = 4
>>> d = 3
>>> l = [a,b,c,d]
>>> l
[2, 1, 4, 3]
>>> sum(l)
10
>>>

So here i declare variables an put it in a list and sum() it up. ['a','b','c','d'] will always be list with strings.
So 'a' wil be a.
You can make a new list with numbers,and make it to dictionary so a point to 2.

>>> l = ['a','b','c','d']
>>> n = [2,1,4,3]
>>> d = dict(zip(l, n))
>>> d
{'a': 2, 'b': 1, 'c': 4, 'd': 3}
>>> d['a']
2
>>> [i for i in d.keys()]
['a', 'c', 'b', 'd']
>>> [i for i in d.values()]
[2, 4, 1, 3]
>>> sum([i for i in d.values()])
10
>>> for k,v in d.items():
...     print('%s has a value of %s' % (k, v))
...     
a has a value of 2
c has a value of 4
b has a value of 1
d has a value of 3
snippsat 661 Master Poster

If .py files are assigned to be opened by python on your system, then you only need to put a shortcut into your startup folder.
C:\Documents and Settings\All Users\Start Menu\Programs\Startup

More andvance solutions is.
- add it to the windows registry (HKCU\Software\Microsoft\Windows\CurrentVersion\Run)
- package it into a service, that should then be installed

snippsat 661 Master Poster

You have to explain yourself better.
Just one way to take out a line.

data = '''\
450 42.5 16625.0
460 42.0 16820.0
470 41.5 17005.0
480 41.0 17180.0
490 40.5 17345.0
500 40.0 17500.0'''

for line in data.split('\n'):
    if line.startswith('470'):
        print line
        #470 41.5 17005.0
snippsat 661 Master Poster
>>> equation = 5
>>> if equation == a:
...     print 'something'
...     
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
NameError: name 'a' is not defined
>>> a = 5
>>> if equation == a:
...     print 'something'
...     
something
>>>

Python always read from line-1 line-2... if you not use function/class that has to be called.
So in your code it dos not find a,before you compare(==) equation with a.

snippsat 661 Master Poster

I think you use python 3?
In python 3 input() return a string.
And formula will not work.
You can try this,and use code-tag also post error message(Traceback)

import cmath

print("Welcome to the Quadratic Program")
print("--------------------------------")

a = int(input("Enter a: "))
b = int(input("Enter b: "))
c = int(input("Enter c: "))

answer = (-b + cmath.sqrt(b ** 2 - 4 * a * c)) / 2
print(answer)
snippsat 661 Master Poster
import os

with open('file_1.txt') as file_1, open('file_2.txt') as file_2:
    f1 = [i.strip() for i in file_1]
    f2 = [i.strip() for i in file_2]
    comp =  [f for f in f2 if f not in f1]
    for f in comp:
        #print f
        #print os.path.basename(f)
        with open('new.txt', 'a') as f_out:
            f_out.write(f + '\n')

So in file_1 1.txt .
In file file_2 1.txt 2.txt 3.txt .
Saved to new.txt 2.txt 3.txt .

This will not work for you because your filename is strange. .ktb_ux453039 . amr.12.20.2002.tar~ In a normal case os.path.basename() would extract filename.

>>> import os
>>> os.path.basename('/root/desktop/python.py')
'python.py'
>>> os.path.basename('FILE /paci/ucb/ux453039/.ktb_ux453039 05/31/2006 17:52:04 09/01/2007 14:25:33')
'2007 14:25:33'

If your filename look like this i think write a regex is the only option,to extract those strange looking filename.

snippsat 661 Master Poster

As pyTony say you complicated it by use of ternary operator( a if b else c )
One thing also to remember is to remove punctuation.
Here one with translate.

from string import punctuation

def is_palindrom(word):
    word = word.lower().translate(None, punctuation)
    return word == word[::-1]

print is_palindrom('Saippuakivikauppias') #True

And a test with a longer palindromic sentence.

def is_palindrome(s):
    letters = [c for c in s.lower() if c.isalpha()]
    return letters == letters[::-1]

s = '''\
A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe,
percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again
(or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats,
a peon, a canal ? Panama!'''

print is_palindrome(s) #True
snippsat 661 Master Poster

You miss the point pyguy62 .
It shall not replace "e" in words,but print all word that not contain 'e'.

prints all the words from a list (words.txt) that doesn't contain the letter e.

snippsat 661 Master Poster

After your description this function dos what you want.
It`s more common to return out of function,than use print.
As you se it has no argument,because words comes from file.

def no_e():
    with open('fox.txt') as f:
        for item in f:
            words = item.split()
    return [word for word in words if 'e' not in word]

print no_e()

If we spilt it up it can look like this.
Now functions only dos 1 jobb an return out,this also show use of docstring.
This can be a good practise when code grow larger.

def read_file():
    '''Read a file and return words'''
    with open('fox.txt') as f:
        for item in f:
            words = item.split()
    return words

def no_e(words):
    '''Return all words,but not words that has "e" in it'''
    return [word for word in words if 'e' not in word]

if __name__ == '__main__':
    words = read_file()
    print no_e(words)
    help(read_file)
snippsat 661 Master Poster

Here something you can look at.

>>> s = 'The quick brown fox jumps over the lazy dog'
>>> [i for i in s.split() if 'e' not in i]
['quick', 'brown', 'fox', 'jumps', 'lazy', 'dog']

Can break it up,code over is list comprehensions wish is much used in python.

>>> s = 'The quick brown fox jumps over the lazy dog'
>>> for item in s.split():
...     if 'e' not in item:
...         print item
...         
quick
brown
fox
jumps
lazy
dog
Lomholdt commented: Gave me a quick hint, and made me solve it in seconds! Excellent! +0
snippsat 661 Master Poster

There are many years since DOS was a part of windows.
No there is cmd(command line),but that is not DOS.
They only way run DOS these day,is to run it as an own OS.

snippsat 661 Master Poster

And just an FYI: The Professor said the code could be done in very few lines (15 or less) so keep that in mind.

He was nice with 15 lines you can du a lot in python.

>>> ''.join(i + '*' for i in raw_input('word: '))
word: Hello
'H*e*l*l*o*'
>>> raw_input('word: ')[::-1]
word: Hello
'olleH'

You should try to break this up little,or Professor will understand that you got help.
Something like the code MS posted.

snippsat 661 Master Poster

None of these really answer my question. I want to read every line not just the final line.

You could have tried to figure something yourself with the help you have gotten.
I am gone write a soultion of what you want.

So here is my version,i bring in some new factor like [::-1] the pythonic reverse.
And string.punctuation to remove punctuation,because a palindrome can also be a number.

#p.txt
racecar.
1881!!
test
radar
import string

def is_palindrom(word):
    word = ''.join(c.lower() for c in word if c not in string.punctuation)
    if word == word[::-1]:
        return True
    return False

with open('p.txt') as f:
    for numb,line in enumerate(f, 1):
        if is_palindrom(line.strip()):
            print 'Line %d is a palindrome' % numb
        else:
            print 'Line %d is not a palindrome' % numb

'''Out-->
Line 1 is a palindrome
Line 2 is a palindrome
Line 3 is not a palindrome
Line 4 is a palindrome
'''
snippsat 661 Master Poster

Uinicode should work regardless of the encoding used.

#u.py
print unichr(163)
print u"\u00A3"

Microsoft Windows [Versjon 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Med enerett.

C:\>python u.py
£
£
snippsat 661 Master Poster

Just a note var2=[] is not needed as findall() is returing a list. finditer() can also be a good solution for iterating over larger files.
Always use raw string with regex r' '

import re

data = '''\
This rule says that any match that begins earlier
in the string is always preferred over any plausible match that begins later.'''

pattern = re.compile(r'p\w+')
for match in pattern.finditer(data):
    print match.group()

'''Out-->
preferred
plausible
'''
snippsat 661 Master Poster

When you use 's' it`s a string s,not variable s.

>>> int('s')
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 's'
>>> s = '42'
>>> type(s)
<type 'str'>
>>> x = int(s)
>>> x
42
>>> type(x)
<type 'int'>

@pyguy62 when you do s = 10,then s is a integer.
No need to convert to integer.

snippsat 661 Master Poster

When you get IOError,pass make it countinue to end.
Other errors than IOError will raise error as normal.

try:
  doSomething()
except IOError:
  pass
snippsat 661 Master Poster

You are making some mistake and it can be done much eaiser with some python power.
You are trying to count with dictionary 2 times 1 is enough.
.strip(',:.;')
You should take out more than this also ?!
An example.

>>> import string
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
>>> s = 'The quick:: brown! fox jumps? over+ the lazy?? dog.'
>>> ''.join(c for c in s if c not in string.punctuation)
'The quick brown fox jumps over the lazy dog'
>>>

So another way this time a complete script.

import re
from collections import Counter

with open('text.txt') as f:
    text = f.read().lower()
words = re.findall(r'\w+', text)

print(Counter(words).most_common(4))

This use regex \w+ that dos the same as i showed in code over remove special character.
And counting is done bye collections Counter new from 2.7-->
Counter also has a most_common function,that dos what name say.
This will show the 4 most common word in text.txt.

snippsat 661 Master Poster

Remember use code tags.
Here a some lines that should help you.

>>> s = 'John Marvin Zelle'
>>> l = s.split()
>>> l = ''.join(l)
>>> l
'JohnMarvinZelle'
>>> sum((ord(i)-64 for i in list(l.upper())))
184

And dont use sum as variable name,as you se in code over sum() is used by python.

>>> help(sum)
Help on built-in function sum in module __builtin__:

sum(...)
    sum(sequence[, start]) -> value
    
    Returns the sum of a sequence of numbers (NOT strings) plus the value
    of parameter 'start' (which defaults to 0).  When the sequence is
    empty, returns start.

>>>
snippsat 661 Master Poster

I can help you with first problem.
You have to show some effort,some just post there school task here.
That means that you have to post some code of what you are struggling with.

>>> s = 'a fine day with beautiful sun'
>>> l = s.split()
>>> l
['a', 'fine', 'day', 'with', 'beautiful', 'sun']
>>> [i for i in l if len(i) >= 3 and len(i) <=7]
['fine', 'day', 'with', 'sun']
>>> #Or better
>>> [i for i in l if 3 <=  len(i) <= 7]
['fine', 'day', 'with', 'sun']

Here i use list comprehension this is ofen used in python.
If you dont understand it,try to break it up with a ordinary loop.

snippsat 661 Master Poster

P.S on what highest python version wxpython works?

2.7 wxpython Roadmap

Just a note dont use findall() in a loop.
findall() iterate through all text it`s given.

g = regex.findall(regex, failas.read())

If you shall iterate through to text,use finditer()

for line in failas:
    for match in regex.finditer(line):
        print (match.group())[:-1]

And print in GUI is most for troubelshoothing.
You wirte to a label text,texbox ...

snippsat 661 Master Poster

However when I run the program it ends up blue just like the "please enter our name" string.

Blue is correct,red comes if you make an error.
This is how it should be and has always been in IDLE.
You can try to change that color option->configure IDLE.
But that is just stuid,so leave alone.

snippsat 661 Master Poster

You can also use cryptographic solution,python has a good libary build in hashlib .
Here is a quick demo with sha512 that is very safe.

>>> import hashlib
>>> hashlib.sha512("my password").hexdigest()
'e28bdbf8faa97dab2203fcc89e397a4bf8d4a5b370421e5481a55f317caee4f81be5a810bb1cffc4695c32198717b9a6e835895852ee3a8689d0963463f2db15'

Here we get 128 character,this is a one way solution.
So how to now that this character 128 is my password?

>>> user_input = hashlib.sha512("my password").hexdigest()
>>> if user_input == 'e28bdbf8faa97dab2203fcc89e397a4bf8d4a5b370421e5481a55f317caee4f81be5a810bb1cffc4695c32198717b9a6e835895852ee3a8689d0963463f2db15'
:
...     print 'Your password is valid'
...     
Your password is valid

So not so difficult,you just have a bunch 128 character(can use a simple text file)
And iterate trough it to check if password is vaild.

snippsat 661 Master Poster
>>> s = [('word1', 3), ('word2', 2), ('word3', 1), ('word4', 1), ('word5', 2)]
>>> for i in s:
...     print '%s %s' % (i[0], i[1])
...     
word1 3
word2 2
word3 1
word4 1
word5 2
>>>

If writing to a file.

s = [('word1', 3), ('word2', 2), ('word3', 1), ('word4', 1), ('word5', 2)]
with open('new.txt', 'w') as f_out:
    for item in s:
        f_out.write('%s %s\n' % (item[0], item[1]))
snippsat 661 Master Poster

You gone struggle with this if your regex and python skill are not so good.
This file is a mix of javascript and html.
Regex and html is not and the best fit,that`s why it exist parser like lxml and BeautifulSoup.

So this time you want to find something completely diffrent than the first post.
I use with open() then you dont need to close fileobject.

import re

pattern = re.compile(r'pr(.+i)n')
with open('test.txt') as f:
    for match in pattern.finditer(f.read()):
        print(match.group(1)) #eload" /><i

And why do you want to only find a part of word and some tag delimiter?

snippsat 661 Master Poster

Can you post a sample of the file.
You are making some basic mistake,so what you do will not work.

snippsat 661 Master Poster

You may have to give more exact info,like post more of the file.
Here is a regex example with the string you posted,that may need some changes to be more greedy.

import re

s = '(a,b){var c=encodeURIComponent,d=["//www.google.com/gen_204?atyp=i&zx=",(new Da "'
r = re.findall(r'\gen_(\d.*)="', s)
print(r) #['204?atyp=i&zx']
snippsat 661 Master Poster

(I dont even know what traceback means

Traceback you get when something goes wrong.

>>> a
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
NameError: name 'a' is not defined
>>> # We most define a
>>> a = 5
>>> a + '6'
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> # We most covert to int or str
>>> str(a) + '6'
'56'
>>> a + int('6')
11

As you see Traceback give back a very good clue to what went wrong.
Then is just to fix it:confused:,as you use python more this will become very familiar.

How can i give the command line a directory without typing double "\\" ? I get an error if i just type "C:\" which i understand because the interpreter thinks \ is a special character.

r'C:\something\' # ok
c:/something/    # ok
snippsat 661 Master Poster

But still nothing is working for webbrowser.get('whateverbrowser')

webbrowser.get('whateverbrowser') will search in environment variable path.
If it dont find path to firefox it will give back.
webbrowser.Error: could not locate runnable browser

So to environment variable path you have to add path to firefox.
;c:\...path to firefox for me it look like this ;C:\Programfiler\Mozilla Firefox\
Then restart and try again.

snippsat 661 Master Poster

i'm thinking maybe it's an indentation problem but I don't know

while if elif else while if elif continue if ..... a mess where am i now:confused:
Most can understand a while if elif else..,but if you nest it together then code lose readability.

The code will be much harder to debug/troubleshoot.
Write more function like you start of with,good code almost need no documentation.
I see you have get good help before in this post,i did start to look at your code but i lost motivation because of reason explaind.

snippsat 661 Master Poster

chr[seq[x]] wrong chr[] shall be chr().
But that dosent matter it will still be wrong.
You most split user input,so if someone enter 67 65 82 they get CAR.

seq = input("enter string ASCII numbers to be converted into text: ")
text = ''
for item in seq.split():
    text += chr(int(item))

print(text)

Next time post Traceback and what version of python you use(i guess python 3)
Most of use python 2.x,then you will get answer that only work for python 2.x.

snippsat 661 Master Poster

As Tony poster regex is not a god choice for html or xml.
This is why paser exist to do this job.

from BeautifulSoup import BeautifulSoup

html = '''\
<html>
...some code....
<B><FONT color="green">TEXT to BE EXTRACTED 1</FONT></B><br>
<P>
<B><FONT color="green">TEXT to BE EXTRACTED 2</FONT></B><br>
<P>
<B><FONT color="red">TEXT to BE EXTRACTED 3</FONT></B>
....some code....
</html>'''

soup = BeautifulSoup(html)
tag = soup.findAll('font')
for item in tag:
    print item.text

'''Output-->
TEXT to BE EXTRACTED 1
TEXT to BE EXTRACTED 2
TEXT to BE EXTRACTED 3
'''
snippsat 661 Master Poster
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> for k, v in knights.iteritems():
...     print k, v
...     
gallahad the pure
robin the brave

If you use python 3,then print is a function.
So it have to look like this. print(k, v) and iteritems() is items()

# Gribouillis
# python 3

table = {
    "Joe" : [ "MATH101", "COMP202", ],
    "Jenny" : [ "COMP202", "BIO101", ],
    "Tom" : [ "MATH101", "BIO101", ],
}

# print ()
print("The students in COMP202 are:", end='') #end=''
print(sorted(k for (k, v) in table.items() if "COMP202" in v)) #items()

""" my output -->
The students in COMP202 are: ['Jenny', 'Joe']
"""
snippsat 661 Master Poster

Its used to make web apps by people who think PERL is not verbose enough and ruby is a "toy" language.

Basically everyone has their own pet language and anything else is junk to them for any reason.

I use whatever language will get the job done, because in the end that's the whole point, accomplishing work of some sort.

He want to know how python is used in web development,that you use whatever language
do get the job done has nothing to with the question asked at all.

snippsat 661 Master Poster

CGI scripting is not used so much.
Most of web development in python done with web framework.
http://wiki.python.org/moin/WebFrameworks

There are many good like web2py,Django,TurboGear,Pylons.
Django is the most know.
Some web site made in django.
http://www.djangosites.org/

snippsat 661 Master Poster

Post your code,not only Traceback.

snippsat 661 Master Poster

Maybe thumbnailCtrl is better for this.
You can look at UltimateListCtrl.
Fire up wxpython demo an take a look.
http://img691.imageshack.us/img691/8753/listctrl1.jpg