<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Python Forum RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest threads from the 'Python' forum at Programmer's Heaven, excluding replies.</description>
    <language>en</language>
    <copyright>Copyright 2009 Programmers Heaven</copyright>
    <pubDate>Fri, 03 Jul 2009 20:14:32 -0700</pubDate>
    <lastBuildDate>Fri, 03 Jul 2009 20:14:32 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Free Python eBooks download for you</title>
      <link>http://www.programmersheaven.com/mb/python/392627/392627/free-python-ebooks-download-for-you/</link>
      <description>Here you can free download Free Python eBooks&lt;br /&gt;
&lt;a href="http://ebookhouse.org/category/programming/python/"&gt;http://ebookhouse.org/category/programming/python/&lt;/a&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/392627/392627/free-python-ebooks-download-for-you/</guid>
      <pubDate>Sun, 21 Jun 2009 19:25:03 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Parsing something with regex</title>
      <link>http://www.programmersheaven.com/mb/python/392266/392266/parsing-something-with-regex/</link>
      <description>I'm trying to parse some output of the program Nmap with regular expressions.&lt;br /&gt;
&lt;br /&gt;
From this output:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Starting Nmap 4.76 ( &lt;a href="http://nmap.org"&gt;http://nmap.org&lt;/a&gt; ) at 2009-06-12 22:53 CDT
Interesting ports on jb-Laptop (127.0.0.1):
Not shown: 984 closed ports
PORT      STATE SERVICE
21/tcp    open  ftp
22/tcp    open  ssh
25/tcp    open  smtp
110/tcp   open  pop3
139/tcp   open  netbios-ssn
143/tcp   open  imap
445/tcp   open  microsoft-ds
465/tcp   open  smtps
587/tcp   open  submission
631/tcp   open  ipp
993/tcp   open  imaps
995/tcp   open  pop3s
2020/tcp  open  xinupageserver
5222/tcp  open  unknown
5900/tcp  open  vnc
10000/tcp open  snet-sensor-mgmt

Interesting ports on 192.168.0.1:
Not shown: 999 closed ports
PORT   STATE SERVICE
80/tcp open  http
MAC Address: 00:09:5B:AA:7E:1A (Netgear)

Nmap done: 2 IP addresses (2 hosts up) scanned in 4.35 seconds
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
...I'd like to get this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
['21/tcp    open  ftp
22/tcp    open  ssh
25/tcp    open  smtp
110/tcp   open  pop3
139/tcp   open  netbios-ssn
143/tcp   open  imap
445/tcp   open  microsoft-ds
465/tcp   open  smtps
587/tcp   open  submission
631/tcp   open  ipp
993/tcp   open  imaps
995/tcp   open  pop3s
2020/tcp  open  xinupageserver
5222/tcp  open  unknown
5900/tcp  open  vnc
10000/tcp open  snet-sensor-mgmt',
'80/tcp open  http']
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Right now, I can do as follows:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
portdata = re.search("PORT\s+STATE\s+SERVICE.*\d/\S+\s+\S+\s+
\S+", data, re.DOTALL)
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This works when I'm getting the ports for just one host, but for more than one it won't match correctly.  Any htelp?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/392266/392266/parsing-something-with-regex/</guid>
      <pubDate>Fri, 12 Jun 2009 20:55:54 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Parsing HTML with RegExp: could you help me?</title>
      <link>http://www.programmersheaven.com/mb/python/391720/391720/parsing-html-with-regexp-could-you-help-me/</link>
      <description>File 1:&lt;br /&gt;
&lt;br /&gt;
import urllib     &lt;br /&gt;
                       &lt;br /&gt;
hdl = urllib.urlopen("file://localhost/D:/page.htm") &lt;br /&gt;
html = hdl.read()                            &lt;br /&gt;
hdl.close()&lt;br /&gt;
&lt;br /&gt;
text_file = open("file.txt", "w")&lt;br /&gt;
text_file.write(html)&lt;br /&gt;
text_file.close()&lt;br /&gt;
&lt;br /&gt;
File 2:&lt;br /&gt;
&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
text_file = open("file.txt", "r")&lt;br /&gt;
contents = text_file.read()&lt;br /&gt;
text_file.close()&lt;br /&gt;
&lt;br /&gt;
p = re.compile('(?&amp;lt;=starting_html_tag).*(?=ending_html
_tag)') &lt;br /&gt;
m = p.search(contents)&lt;br /&gt;
if m:&lt;br /&gt;
    print 'Match found: ', m.group()&lt;br /&gt;
else:&lt;br /&gt;
    print 'No match'&lt;br /&gt;
&lt;br /&gt;
The first script opens a particular web page and reads it into a txt file. The second script opens the txt file and looks for contents between tags 'starting_html_tag' and 'ending_html_tag'.&lt;br /&gt;
&lt;br /&gt;
The problem is that the second script doesn't find anything at all. It prints 'No match'. What's the matter? &lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;pre class="sourcecode"&gt;&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/391720/391720/parsing-html-with-regexp-could-you-help-me/</guid>
      <pubDate>Sat, 30 May 2009 02:37:43 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Help with lingo using cgi</title>
      <link>http://www.programmersheaven.com/mb/python/391331/391331/help-with-lingo-using-cgi/</link>
      <description>how do i choose a word from a list or a file or a website, and then save it in HTML hidden input, and then not chose a word again. Because everytime i run the program, it runs main, and therefore a new word gets chosen. Any ideas?</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/391331/391331/help-with-lingo-using-cgi/</guid>
      <pubDate>Thu, 21 May 2009 21:03:13 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Wing IDE</title>
      <link>http://www.programmersheaven.com/mb/python/391083/391083/wing-ide/</link>
      <description>I'M trying to learn Python and as you might expect, I start with "Hello World". But I can't get anything to happen. How do I execute and view the end result of my code?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/391083/391083/wing-ide/</guid>
      <pubDate>Sat, 16 May 2009 17:26:53 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Why Python</title>
      <link>http://www.programmersheaven.com/mb/python/390502/390502/why-python/</link>
      <description>I've tried in the past to learn C++ and now C#. In both cases I get so far into it and then things just start getting to complicated. Would python be a better place to start? And if so, why? Also, most of the jobs I see in the local adds are for C++, Java, and PHP (.NET). Is there a job market for python programmers?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/390502/390502/why-python/</guid>
      <pubDate>Wed, 06 May 2009 10:11:10 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Urgent - Python programmer needed for work $50-100+</title>
      <link>http://www.programmersheaven.com/mb/python/390259/390259/urgent---python-programmer-needed-for-work-50-100+/</link>
      <description>If anyone is interested in a quick project which due to some crazy time constraints needs to be done by monday evening, pm me and I'll give the details.&lt;br /&gt;
&lt;br /&gt;
Cheers&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/390259/390259/urgent---python-programmer-needed-for-work-50-100+/</guid>
      <pubDate>Sat, 02 May 2009 10:22:34 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Problem with python program pls helllllp</title>
      <link>http://www.programmersheaven.com/mb/python/388978/388978/problem-with-python-program-pls-helllllp/</link>
      <description>&lt;strong&gt;Hi..i need help in a program that im trying to write in pyhthon.I have 2 programs made.the first is this:&lt;br /&gt;
(The program converts temperatures , so u enter a number for ex. 4 celsius degrees and that is vonverted to 340 kelvin degrees(not correct!) ae a result)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print "Choose what you want to convert.....(type a number from 1 to 6)"&lt;br /&gt;
print "1 - Celsius-Kelvin"&lt;br /&gt;
print "2 - Celsius-Farenheit"&lt;br /&gt;
print "3 - Kelvin-Celsius"&lt;br /&gt;
print "4 - Kelvin-Farenheit"&lt;br /&gt;
print "5 - Farenheit-Celsius"&lt;br /&gt;
print "6 - Farenheit-Kelvin"&lt;br /&gt;
&lt;br /&gt;
deg = input("&amp;gt;: ")&lt;br /&gt;
&lt;br /&gt;
if deg == 1:&lt;br /&gt;
    celsius1 = input("Type the celsius degrees to convert them to kelvin: ")&lt;br /&gt;
    kel1 = celsius1+273.15&lt;br /&gt;
    print "The result is", kel1&lt;br /&gt;
    &lt;br /&gt;
if deg == 2:&lt;br /&gt;
    celsius2 = input("Type the celsius degrees to convert them to farenheit: ")&lt;br /&gt;
    far1 = celsius2*1.8+32&lt;br /&gt;
    print "The result is", far1&lt;br /&gt;
    &lt;br /&gt;
if deg == 3:&lt;br /&gt;
    kelvin1 = input("Type the kelvin degrees to convert them to celsius: ")&lt;br /&gt;
    cel1 = kelvin1-273.15&lt;br /&gt;
    print "The result is", cel1&lt;br /&gt;
    &lt;br /&gt;
if deg == 4:&lt;br /&gt;
    kelvin2 = input("Type the kelvin degrees to convert them to farenheit: ")&lt;br /&gt;
    far2 = (kelvin2-273.15)*(9/5)+32&lt;br /&gt;
    print "The result is", far2&lt;br /&gt;
    &lt;br /&gt;
if deg == 5:&lt;br /&gt;
farenheit1 = input("Type the farenheit degrees to convert them to celsius: ")&lt;br /&gt;
    cel2 = (farenheit1-32)/1.8&lt;br /&gt;
    print "The result is", cel2&lt;br /&gt;
    &lt;br /&gt;
if deg == 6:&lt;br /&gt;
farenheit2 = input("Type the farenheit degrees to convert them to kelvin: ")&lt;br /&gt;
    kel2 = (5/9)*(farenheit2-32)+273.15&lt;br /&gt;
    &lt;br /&gt;
input("press &amp;lt;enter&amp;gt; to quit")&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;the second makes a textbox around a typed sentence::&lt;/strong&gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
sentence = raw_input("Sentence: ")&lt;br /&gt;
&lt;br /&gt;
screen_width = 80&lt;br /&gt;
text_width   = len(sentence)&lt;br /&gt;
box_width    = text_width + 6&lt;br /&gt;
left_margin  = (screen_width - box_width) // 2&lt;br /&gt;
&lt;br /&gt;
print&lt;br /&gt;
print ' ' * left_margin + '+'   + '-' * (box_width-2) +   '+'&lt;br /&gt;
print ' ' * left_margin + '|  ' + ' ' * text_width    + '  |'&lt;br /&gt;
print ' ' * left_margin + '|  ' +       sentence      + '  |'&lt;br /&gt;
print ' ' * left_margin + '|  ' + ' ' * text_width    + '  |'&lt;br /&gt;
print ' ' * left_margin + '+'   + '-' * (box_width-2) +   '+'&lt;br /&gt;
print&lt;br /&gt;
input('Press &amp;lt;enter&amp;gt; to quit')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;the problem starts when i try to make these programs into one program and so the result of the first outputs in a textbox but i have a problem with the strings, tuples and so on.Im a begginer and i found these two programs in a tutorial and i dont know how to do this because i havent learned this yet &lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pls help this is urgent here is msn: boris.kaculacki(AT)hotmail.com for contact . THX very much!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/strong&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/388978/388978/problem-with-python-program-pls-helllllp/</guid>
      <pubDate>Sat, 11 Apr 2009 09:05:42 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>help on half adder python</title>
      <link>http://www.programmersheaven.com/mb/python/388402/388402/help-on-half-adder-python/</link>
      <description>need help on this question:&lt;br /&gt;
&lt;br /&gt;
Draw up the list of possible inputs for a half adder and the&lt;br /&gt;
outputs that you expect. Implement a half adder in a few lines of python, so that the&lt;br /&gt;
variables o1 and o2 are based on i1 and i2.&lt;br /&gt;
&lt;br /&gt;
i1= True&lt;br /&gt;
2 i2= False&lt;br /&gt;
3 ............................&lt;br /&gt;
o1 =?&lt;br /&gt;
5 o2 =?&lt;br /&gt;
&lt;br /&gt;
now i know the function should be something like this :h(i1, i2) =&amp;gt;o1, o2 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
i have come up with some coding but dont know the formula to put in and how to make all the coding work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def half_adder(i1, i2):&lt;br /&gt;
o1 = # need formula here&lt;br /&gt;
o2 = # need formula here&lt;br /&gt;
return o1, o2&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/388402/388402/help-on-half-adder-python/</guid>
      <pubDate>Wed, 01 Apr 2009 03:52:31 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>hello</title>
      <link>http://www.programmersheaven.com/mb/python/388401/388401/hello/</link>
      <description>hello.......................................</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/388401/388401/hello/</guid>
      <pubDate>Wed, 01 Apr 2009 03:51:45 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Programming in Python</title>
      <link>http://www.programmersheaven.com/mb/python/387817/387817/programming-in-python/</link>
      <description>Hi, I am trying to teach myself python (which is going very slowly) and I have an assignment to do.  Part of the assignment is asking me to read from a text file which contains a list of people's preferences for meals at a restaurant, eg. Bill - steak, fish, chicken;  Mary - fish, chicken, steak; Joe - steak, chicken, fish.  The assignment wants me to read from the file and then return the preferences as a dictionary.  If anyone can help me with writing the code for this, I would be grateful. &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/387817/387817/programming-in-python/</guid>
      <pubDate>Sun, 22 Mar 2009 17:21:59 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Need help with SOAPpy</title>
      <link>http://www.programmersheaven.com/mb/python/387580/387580/need-help-with-soappy/</link>
      <description>Hi everyone.&lt;br /&gt;
&lt;br /&gt;
I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and &lt;br /&gt;
&lt;br /&gt;
i'm not sure how to fix it so the server likes it.&lt;br /&gt;
&lt;br /&gt;
The request generated by php script looks like this (removed http's from links):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="marketing.ews.yahooapis.com/V4"
&amp;gt;
&amp;lt;SOAP-ENV:Header&amp;gt;
&amp;lt;ns1:username&amp;gt;*****&amp;lt;/ns1:username&amp;gt;
&amp;lt;ns1:password&amp;gt;*****&amp;lt;/ns1:password&amp;gt;
&amp;lt;ns1:masterAccountID&amp;gt;*****&amp;lt;/ns1:masterAccountID&amp;gt;
&amp;lt;ns1:accountID&amp;gt;6674262970&amp;lt;/ns1:accountID&amp;gt;
&amp;lt;ns1:license&amp;gt;*****&amp;lt;/ns1:license&amp;gt;
&amp;lt;/SOAP-ENV:Header&amp;gt;
&amp;lt;SOAP-ENV:Body&amp;gt;
&amp;lt;ns1:getCampaignsByAccountID&amp;gt;
&amp;lt;ns1:accountID&amp;gt;6674262970&amp;lt;/ns1:accountID&amp;gt;
&amp;lt;ns1:includeDeleted&amp;gt;false&amp;lt;/ns1:includeDeleted&amp;gt;
&amp;lt;/ns1:getCampaignsByAccountID&amp;gt;
&amp;lt;/SOAP-ENV:Body&amp;gt;
&amp;lt;/SOAP-ENV:Envelope&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
When trying to make the same using SOAPPy i get this request:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="schemas.xmlsoap.org/soap/encodi
ng/"
xmlns:xsi="w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="w3.org/1999/XMLSchema"
&amp;gt;
&amp;lt;SOAP-ENV:Header&amp;gt;
&amp;lt;username xsi:type="xsd:string"&amp;gt;*****&amp;lt;/username&amp;gt;
&amp;lt;masterAccountID xsi:type="xsd:string"&amp;gt;*****&amp;lt;/masterAccountID&amp;gt;
&amp;lt;license xsi:type="xsd:string"&amp;gt;*****&amp;lt;/license&amp;gt;
&amp;lt;accountID xsi:type="xsd:integer"&amp;gt;6674262970&amp;lt;/accountID&amp;gt;
&amp;lt;password xsi:type="xsd:string"&amp;gt;*****&amp;lt;/password&amp;gt;
&amp;lt;/SOAP-ENV:Header&amp;gt;
&amp;lt;SOAP-ENV:Body&amp;gt;
&amp;lt;ns1:getCampaignsByAccountID xmlns:ns1="marketing.ews.yahooapis.com/V4"&amp;gt;
&amp;lt;includeDeleted xsi:type="xsd:boolean"&amp;gt;False&amp;lt;/includeDeleted&amp;gt;
&amp;lt;accountID xsi:type="xsd:integer"&amp;gt;6674262970&amp;lt;/accountID&amp;gt;
&amp;lt;/ns1:getCampaignsByAccountID&amp;gt;
&amp;lt;/SOAP-ENV:Body&amp;gt;
&amp;lt;/SOAP-ENV:Envelope&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
A slightly different request but i guess it should work but i get an error from the server: "Account ID specified in the &lt;br /&gt;
&lt;br /&gt;
header does not match the one specified in the parameter."&lt;br /&gt;
&lt;br /&gt;
But they do match!&lt;br /&gt;
&lt;br /&gt;
The only thing i see is some difference in namespaces, but i have no idea what to do right now. Please help.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/387580/387580/need-help-with-soappy/</guid>
      <pubDate>Wed, 18 Mar 2009 02:01:07 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>HELP with Rock, Paper, Scissor Game</title>
      <link>http://www.programmersheaven.com/mb/python/387396/387396/help-with-rock-paper-scissor-game/</link>
      <description>&lt;span style="color: Blue;"&gt;This is the template that we are suppose to use while doing the program, I am a beginner to this programming language and really have no clue what I am doing&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
#table of winning plays&lt;br /&gt;
win_play_for = {’r’:’p’, ’p’:’s’, ’s’:’r’}&lt;br /&gt;
&lt;br /&gt;
#scoring results&lt;br /&gt;
player_score = 0&lt;br /&gt;
mach_score = 0&lt;br /&gt;
&lt;br /&gt;
#keep track of users’last plays&lt;br /&gt;
#assume initially an even distribution&lt;br /&gt;
hist = [’r’, ’p’, ’s’, ’r’, ’p’, ’s’, ’r’, ’p’, ’s’]&lt;br /&gt;
next = 0 #index of where to put next user play&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
#guess what user play will be based on past&lt;br /&gt;
#behavior. Pick a machine play to win based&lt;br /&gt;
#on guess&lt;br /&gt;
&lt;br /&gt;
#get user’s play&lt;br /&gt;
user_play = raw_input("what’s your play (r|p|s)? ")&lt;br /&gt;
#if the user does not respond with one of those break&lt;br /&gt;
&lt;br /&gt;
#otherwise&lt;br /&gt;
#update history of user plays&lt;br /&gt;
&lt;br /&gt;
#determine winner for current play or draw&lt;br /&gt;
#print results of current play and scores so far&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Red;"&gt;NOW THIS IS WHAT I HAVE SO FAR, AND THESE ARE ALL JUMBLE AROUND BECAUSE I HAVE NO CLUE WHERE THEY ARE SUPPOSE TO GO PLZ HELP&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
#table of winning plays&lt;br /&gt;
win_play_for = {'r':'p', 'p':'s', 's':'r'}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#scoring results&lt;br /&gt;
player_score = 0&lt;br /&gt;
mach_score = 0&lt;br /&gt;
&lt;br /&gt;
#kepp track of users' last plays&lt;br /&gt;
#assume initially an even distribution&lt;br /&gt;
hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']&lt;br /&gt;
next = 0 #index of where to put next user play&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']&lt;br /&gt;
    next = 0&lt;br /&gt;
    guess = random_choice(hist)&lt;br /&gt;
    len (hist)&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    #gets user's play&lt;br /&gt;
    user_play = raw_input("What's your play (r|p|s)?")&lt;br /&gt;
    hist[next] = user_play&lt;br /&gt;
    next = next + 1&lt;br /&gt;
    if next == len(hist):&lt;br /&gt;
        next = 0&lt;br /&gt;
        &lt;br /&gt;
    user_play == win_play_for(mach_play)&lt;br /&gt;
    mach_play == win_play_for(user_play)&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/387396/387396/help-with-rock-paper-scissor-game/</guid>
      <pubDate>Sun, 15 Mar 2009 19:31:17 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>FTP File streaming</title>
      <link>http://www.programmersheaven.com/mb/python/385222/385222/ftp-file-streaming/</link>
      <description>Hello,&lt;br /&gt;
&lt;br /&gt;
I have been asked to try to program a ftp file stream in python. Here's the complete story:&lt;br /&gt;
&lt;br /&gt;
There's a FTP server with a comma seperated file (csv) on it. A device writes log information in to the csv file whenever something log-worthy occures. This csv file is around 22 MB and keeps on growing. I want to read the latest csv entry that's gotten in to the file. So my question is:&lt;br /&gt;
&lt;br /&gt;
Is it possible to connect to the FTP server, open up a stream to the csv file and retrieve the latest data? I have to able to get a constant stream and always get the latest csv entry.&lt;br /&gt;
&lt;br /&gt;
If this is possible wont there be a conflict when the device is writing to the .csv file and i'm reading from it?&lt;br /&gt;
&lt;br /&gt;
If this isn't possible in python, do you have any idea if it is in another programming language?&lt;br /&gt;
&lt;br /&gt;
Hope i explained everything well enough.&lt;br /&gt;
&lt;br /&gt;
Thanks in advance.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/385222/385222/ftp-file-streaming/</guid>
      <pubDate>Wed, 04 Feb 2009 09:59:05 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Substring a file name</title>
      <link>http://www.programmersheaven.com/mb/python/385185/385185/substring-a-file-name/</link>
      <description>Hi All,&lt;br /&gt;
&lt;br /&gt;
I want to be able to rename a text file to a shorter version and different extension, for example, abc_123_d1.txt &amp;gt; a123d1.csv&lt;br /&gt;
&lt;br /&gt;
I am using python 2.5 on windows.&lt;br /&gt;
&lt;br /&gt;
Thank you in advance.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/385185/385185/substring-a-file-name/</guid>
      <pubDate>Tue, 03 Feb 2009 14:33:20 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>I need python Programmer</title>
      <link>http://www.programmersheaven.com/mb/python/383765/383765/i-need-python-programmer/</link>
      <description>I need a python programmer to complete an assignment.&lt;br /&gt;
If u r Good at work contact me&lt;br /&gt;
Budget: $80 - $100&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/383765/383765/i-need-python-programmer/</guid>
      <pubDate>Thu, 01 Jan 2009 22:03:21 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>starting with python</title>
      <link>http://www.programmersheaven.com/mb/python/383542/383542/starting-with-python/</link>
      <description>hi friends can you help me to start with python GUI based programming ...if found plz give me some tips</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/383542/383542/starting-with-python/</guid>
      <pubDate>Fri, 26 Dec 2008 08:32:49 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>incorporating python user input with a MySQL query</title>
      <link>http://www.programmersheaven.com/mb/python/383522/383522/incorporating-python-user-input-with-a-mysql-query/</link>
      <description>hi,&lt;br /&gt;
Im designing a python program that will use a barcode scanner to input barcodes and see if they are in a sql database that i have created.&lt;br /&gt;
For the moment, i want a user to manually input a barcode:&lt;br /&gt;
barcode = input("Please enter barcode and press Enter button:\n")&lt;br /&gt;
then i want to write a query:cursor.execute("select * where #userinput# = 'barcode'"):&lt;br /&gt;
where the #userinput# is the barcode that the user has inputted and the 'barocde' is the corresponding barcode in the database. My problem is that i dont know how to tell the program to use the barcode entered by the user in the sql query. &lt;br /&gt;
so i need to find the barcode that the user has inputted in a database with a list of barcodes and their corresponding products, using a query(or another method that will do the same thing), and then i want to print the the barcode along with its product.&lt;br /&gt;
can someone please help&lt;br /&gt;
thanks a million.&lt;br /&gt;
cheatlincoln&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/383522/383522/incorporating-python-user-input-with-a-mysql-query/</guid>
      <pubDate>Thu, 25 Dec 2008 17:10:59 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>generation of a logfile</title>
      <link>http://www.programmersheaven.com/mb/python/383434/383434/generation-of-a-logfile/</link>
      <description>Hi.. my requirement is that I have to generate the log of every step execution of a python script in a seperate file.. how can i achieve this in python ??&lt;br /&gt;
Thanks in advance..&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/383434/383434/generation-of-a-logfile/</guid>
      <pubDate>Mon, 22 Dec 2008 22:51:17 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Python for loop</title>
      <link>http://www.programmersheaven.com/mb/python/382955/382955/python-for-loop/</link>
      <description>Hey all&lt;br /&gt;
&lt;br /&gt;
I have read the tutorial for the for loop in python plenty of time but still can't get it. I know pascal, php, javascript and their for loops are like this(php,javascript) for(i = 0; i &amp;lt; 10 ; i++) which I understand but can someone please help me to understand the for loop of python better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thank you&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/382955/382955/python-for-loop/</guid>
      <pubDate>Sat, 13 Dec 2008 02:34:04 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Why does it return 0?</title>
      <link>http://www.programmersheaven.com/mb/python/381712/381712/why-does-it-return-0/</link>
      <description>&lt;pre class="sourcecode"&gt;def countErrors(secret, lettersGuessed, errors):

    if lettersGuessed == "":
        errors = errors + 0  
    else:
        subproblem = lettersGuessed[len(lettersGuessed)-1]
        others = lettersGuessed[0:len(lettersGuessed)-1]
        if subproblem in secret:
            errors = errors + 0
        else:
            errors = errors + 1
        print errors, secret, lettersGuessed, others, subproblem
        countErrors(secret, others, errors)
    return errors        
     
        
        

secret = "guinness"
lettersGuessed = "pnitwzg"
errors = 0
x = countErrors(secret, lettersGuessed, errors)
print x
           &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Here's what it outputs:&lt;br /&gt;
&lt;br /&gt;
0 guinness pnitwzg pnitwz g&lt;br /&gt;
1 guinness pnitwz pnitw z&lt;br /&gt;
2 guinness pnitw pnit w&lt;br /&gt;
3 guinness pnit pni t&lt;br /&gt;
3 guinness pni pn i&lt;br /&gt;
3 guinness pn p n&lt;br /&gt;
4 guinness p  p&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
I'm pretty new at this, but this just doesn't seem to make any sense. It does exactly what I want it to, except instead of returning 4, it returns 0.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/381712/381712/why-does-it-return-0/</guid>
      <pubDate>Mon, 10 Nov 2008 15:13:51 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>I'm pretty new to Python and i'm havin troubles</title>
      <link>http://www.programmersheaven.com/mb/python/381322/381322/im-pretty-new-to-python-and-im-havin-troubles/</link>
      <description>Ok I'm new to python since january.  i've read a intro book cover-to-cover and have written some code of my own, but i have a nerve-racking problem thats giving my a headache.  I can save a module just fine, but when i try to import it into another program it gives me a syntax error and highlights the middle "5" in the "Python 2.&lt;strong&gt;5&lt;/strong&gt;.5" at the top of the page.&lt;br /&gt;
&lt;br /&gt;
Please assist, what's going on and how can i fix it?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/381322/381322/im-pretty-new-to-python-and-im-havin-troubles/</guid>
      <pubDate>Thu, 23 Oct 2008 17:08:53 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Hi i have a question about the python.</title>
      <link>http://www.programmersheaven.com/mb/python/376753/376753/hi-i-have-a-question-about-the-python/</link>
      <description>You are required to write a Python program which will solve system of linear equations with 3 unknowns&lt;br /&gt;
(to be entered by the user).&lt;br /&gt;
Your program should display a menu which will allow the user to choose whether he wants to (1)&lt;br /&gt;
coefficients (2) check whether the linear system can be solved using iteration (3) calculate and display the&lt;br /&gt;
required results using Gauss-Seidel (4) calculate and display the required results using Gauss-Jacobi&lt;br /&gt;
Note that in all cases, the outcomes of the iterations should be displayed. Also if the values of the&lt;br /&gt;
unknowns are not converging, your program should stop at the 15th iteration.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/376753/376753/hi-i-have-a-question-about-the-python/</guid>
      <pubDate>Thu, 02 Oct 2008 06:55:30 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Source Code</title>
      <link>http://www.programmersheaven.com/mb/python/376371/376371/source-code/</link>
      <description>Hi &lt;br /&gt;
&lt;br /&gt;
Would anyone know where i can get the free source code for the python KeyLogger I want to study the code to create my own. Not to use as spyware.&lt;br /&gt;
&lt;br /&gt;
Thanks in advance.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/376371/376371/source-code/</guid>
      <pubDate>Mon, 29 Sep 2008 07:00:13 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Where can i find a free LISP software</title>
      <link>http://www.programmersheaven.com/mb/python/375363/375363/where-can-i-find-a-free-lisp-software/</link>
      <description>I was assigned to search for LISP software and make at least 5 programs.&lt;br /&gt;
&lt;br /&gt;
I have no idea with this. can anyone help me?&lt;br /&gt;
&lt;br /&gt;
thanks in adavance..&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/375363/375363/where-can-i-find-a-free-lisp-software/</guid>
      <pubDate>Tue, 16 Sep 2008 06:34:53 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>