<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community - Python</title>
		<link>http://www.daniweb.com/forums/</link>
		<description><![CDATA[Our Python forum is the place for Q&A-style discussions related to this interpreted OOP language.]]></description>
		<language>en-US</language>
		<lastBuildDate>Sat, 07 Nov 2009 23:28:43 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - Python</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>get microphone input?</title>
			<link>http://www.daniweb.com/forums/thread236875.html</link>
			<pubDate>Sat, 07 Nov 2009 22:04:40 GMT</pubDate>
			<description><![CDATA[hi everyone. Just out of curiosity more than anything; does anyone know of a library that can grab microphone input (on windows)? I'm looking into how to write a kind of VoIP (voice ip) program. I know how to use sockets for sending/receiving data, but I just need the microphone aspect. Any kind of...]]></description>
			<content:encoded><![CDATA[<div>hi everyone. Just out of curiosity more than anything; does anyone know of a library that can grab microphone input (on windows)? I'm looking into how to write a kind of VoIP (voice ip) program. I know how to use sockets for sending/receiving data, but I just need the microphone aspect. Any kind of info/resources would be greatly appreciated. Thank you!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>fallopiano</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236875.html</guid>
		</item>
		<item>
			<title>Maze solving</title>
			<link>http://www.daniweb.com/forums/thread236873.html</link>
			<pubDate>Sat, 07 Nov 2009 22:00:39 GMT</pubDate>
			<description><![CDATA[Working on program to solve a predefined maze. I'm thinking the strings of spaces and #s should be arranged as strings or lists w/in a list, but not sure how to define spatial relationships so program can "move" through the maze. Just looking to help get started.]]></description>
			<content:encoded><![CDATA[<div>Working on program to solve a predefined maze. I'm thinking the strings of spaces and #s should be arranged as strings or lists w/in a list, but not sure how to define spatial relationships so program can &quot;move&quot; through the maze. Just looking to help get started.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>luvsdabud</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236873.html</guid>
		</item>
		<item>
			<title><![CDATA[Cramer's Rule please]]></title>
			<link>http://www.daniweb.com/forums/thread236844.html</link>
			<pubDate>Sat, 07 Nov 2009 18:56:14 GMT</pubDate>
			<description><![CDATA[Hello does anyone have the codes to solve linear equations using cramer's rule]]></description>
			<content:encoded><![CDATA[<div>Hello does anyone have the codes to solve linear equations using cramer's rule</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>vickkeshav</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236844.html</guid>
		</item>
		<item>
			<title>sudoku solver problem</title>
			<link>http://www.daniweb.com/forums/thread236835.html</link>
			<pubDate>Sat, 07 Nov 2009 18:25:51 GMT</pubDate>
			<description><![CDATA[hi, i have to make a sudoku solver using python quickdraw, 
i've  started on it and this is what i got so far 
here is the link to the assignment http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A4/a4.pdf 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>hi, i have to make a sudoku solver using python quickdraw,<br />
i've  started on it and this is what i got so far<br />
here is the link to the assignment <a rel="nofollow" class="t" href="http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A4/a4.pdf" target="_blank">http://pages.cpsc.ucalgary.ca/~zongp...ents/A4/a4.pdf</a><br />
 <pre style="margin:20px; line-height:13px">def solveRows():<br />
&nbsp; &nbsp; &quot;&quot;&quot;eliminates solved numbers by row&quot;&quot;&quot;<br />
&nbsp; &nbsp; for x in range(0, 81, 9):<br />
&nbsp; &nbsp; &nbsp; &nbsp; row = puzzle[x : x+9]#loops through each row<br />
&nbsp; &nbsp; &nbsp; &nbsp; for space in row: #loops through each space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space) == 1: #space is solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for space2 in row: #loops through spaces again<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space2) != 1: #space isnt already solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if space[0] in space2: #the solved number is a possibility<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del space2[space2.index(space[0])] #deletes the number as a possiblbitly&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
def solveColumns():<br />
&nbsp; &nbsp; &quot;&quot;&quot;eliminates solved numbers by column&quot;&quot;&quot;<br />
&nbsp; &nbsp; rows = []#splits up the puzzle into rows<br />
&nbsp; &nbsp; for x in range(0, 81, 9):<br />
&nbsp; &nbsp; &nbsp; &nbsp; rows.append(puzzle[x:x+9])<br />
&nbsp; &nbsp; for n in range(0, 9):<br />
&nbsp; &nbsp; &nbsp; &nbsp; column = [x[n] for x in rows] #loops through each column<br />
&nbsp; &nbsp; &nbsp; &nbsp; #the next part is taken from solveRows()<br />
&nbsp; &nbsp; &nbsp; &nbsp; for space in column: #loops through each space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space) == 1: #space is solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for space2 in column: #loops through spaces again<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space2) != 1: #space isnt already solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if space[0] in space2: #the solved number is a possibility<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del space2[space2.index(space[0])] #deletes the number as a possiblbitly<br />
<br />
def solveBoxes():<br />
&nbsp; &nbsp; &quot;&quot;&quot;eliminates solved numbers by box&quot;&quot;&quot;<br />
&nbsp; &nbsp; rows = []#splits up the puzzle into rows<br />
&nbsp; &nbsp; for x in range(0, 81, 9):<br />
&nbsp; &nbsp; &nbsp; &nbsp; rows.append(puzzle[x:x+9])<br />
&nbsp; &nbsp; #this next part just splits the puzzle into boxes<br />
&nbsp; &nbsp; for x in range(0, 9, 3):<br />
&nbsp; &nbsp; &nbsp; &nbsp; for y in range(0, 9, 3):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempRows = rows[x:x+3]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempBox = [row[y:y+3] for row in tempRows]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #the next part just formats the box<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #basically it was a list of lists of lists<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #and i need it as a list of lists<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; box = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for row in tempBox:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for space in row:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; box.append(space)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #the next part is taken from solveRows()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for space in box: #loops through each space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space) == 1: #space is solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for space2 in box: #loops through spaces again<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(space2) != 1: #space isnt already solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if space[0] in space2: #the solved number is a possibility<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del space2[space2.index(space[0])] #deletes the number as a possiblbitly<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
def isSolved():<br />
&nbsp; &nbsp; &quot;&quot;&quot;Checks to see if the puzzle is solved&quot;&quot;&quot;<br />
&nbsp; &nbsp; for x in puzzle:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if len(x) != 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return False<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; return True<br />
&nbsp; &nbsp; <br />
def main():<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; temp = puzzle #used to see when puzzle is solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; solveBoxes()<br />
&nbsp; &nbsp; &nbsp; &nbsp; solveRows()<br />
&nbsp; &nbsp; &nbsp; &nbsp; solveColumns()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if isSolved():#puzzle is solved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return<br />
<br />
def display():<br />
&nbsp; &nbsp; &quot;&quot;&quot; displays the puzzle&quot;&quot;&quot;<br />
&nbsp; &nbsp; copy = puzzle #copy of the puzzle<br />
&nbsp; &nbsp; copy = map(str, [x[0] for x in copy]) #makes the ints strs so i can use S.join()<br />
&nbsp; &nbsp; #next part just displays the puzzle all nice and pretty<br />
&nbsp; &nbsp; for x in range(0, 9):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print ', '.join(copy[x:x+9])<br />
<br />
def getInput():<br />
&nbsp; &nbsp; &quot;&quot;&quot;gets a puzzle to be solved from the user&quot;&quot;&quot;<br />
&nbsp; &nbsp; puzzle = []<br />
&nbsp; &nbsp; for x in range(1, 10): #1 for each line of the puzzle<br />
&nbsp; &nbsp; &nbsp; &nbsp; puzzle.append(raw_input('enter one line of the puzzle '))<br />
&nbsp; &nbsp; puzStr = '\n'.join(puzzle)<br />
&nbsp; &nbsp; puzzle = []#a soon to be matrix holding possibilities for each space<br />
&nbsp; &nbsp; for letter in puzStr:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if letter == 'x':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puzzle.append(range(1, 10)) #adds all possibilities if square is blank<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif letter == '\n' or letter ==' ':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puzzle.append([int(letter)]) #adds the already given number<br />
&nbsp; &nbsp; return puzzle<br />
<br />
print &quot;&quot;&quot;This program will solve some suDoku puzzles<br />
If it can't it will just hang indefinately so give it a little<br />
while then if nothing happens assume that either you entered<br />
the puzzle incorrectly, it is not solvable, or this program<br />
can't solve it.<br />
<br />
Begin by entering the puzzle in line by line.<br />
Represent empty spaces by an 'x'. So a line<br />
migh look like '6x12x897x'. This program as of now<br />
will not catch your errors so try not to make mistakes.<br />
You can but do not have to add any spaces when entering the puzzle.<br />
<br />
Enjoy!<br />
&quot;&quot;&quot;<br />
puzzle = getInput()<br />
main()<br />
print 'The answer is:'<br />
print<br />
display()</pre>i don't know what to do next,i'[ve tried putting like<br />
 6x12x897x, x8x6x5x2x, x54xxxxx1, 4xx796xxx, x9xxxxx1x<br />
xxx182xx7, 3xxxxx75x,  x7x3x9x4x, x285x41x3<br />
didn't work and it said errno #22 close failed<br />
so, am i doing the assignment right</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>moazmizo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236835.html</guid>
		</item>
		<item>
			<title>Need Help on Reverse Polish Notation program code</title>
			<link>http://www.daniweb.com/forums/thread236825.html</link>
			<pubDate>Sat, 07 Nov 2009 17:05:50 GMT</pubDate>
			<description><![CDATA[I am having problems with my reverse polish calculator code.  The code is as follows: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code...]]></description>
			<content:encoded><![CDATA[<div>I am having problems with my reverse polish calculator code.  The code is as follows:<br />
<br />
 <pre style="margin:20px; line-height:13px">import operator<br />
<br />
OPERATORS = {<br />
&nbsp; &nbsp; &nbsp; &nbsp; '+': operator.add,<br />
&nbsp; &nbsp; &nbsp; &nbsp; '-': operator.sub,<br />
&nbsp; &nbsp; &nbsp; &nbsp; '*': operator.mul,<br />
&nbsp; &nbsp; &nbsp; &nbsp; '/': operator.div,<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
class Stack(object):<br />
&nbsp; &nbsp; &quot;Creates a stack to enter numbers or operators into&quot;<br />
<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.storage = [0,0,0,0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.sptn = -1&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; def push(self, item):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.sptn = self.sptn + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.storage[self.sptn] = item<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def pop(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.sptn = self.sptn -1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def top(self):&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return self.storage[self.sptn]<br />
<br />
&nbsp; &nbsp; def __rep__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; return self.storage[:self.sptn + 1]<br />
&nbsp; &nbsp; <br />
<br />
def get_input():<br />
<br />
&nbsp; &nbsp; equation = raw_input(&quot;Enter the equation in reverse polish notation: &quot;)<br />
&nbsp; &nbsp; return equation<br />
<br />
def evaluate_rpn(equation):<br />
<br />
&nbsp; &nbsp; s = Stack()<br />
<br />
&nbsp; &nbsp; try:<br />
&nbsp; &nbsp; &nbsp; &nbsp; for item in equation.split():<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = float(item)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.push(result)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except ValueError:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = s.pop()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = s.pop()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = OPERATORS[item](x, y)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.push(result)<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = s.top()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; except IndexError:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Please input at least two numbers before entering an operator.&quot;<br />
<br />
def main():<br />
&nbsp; &nbsp; equation = get_input()<br />
&nbsp; &nbsp; answer = evaluate_rpn(raw_input(&quot;Enter the equation in reverse polish notation: &quot;))<br />
&nbsp; &nbsp; print answer</pre><br />
The code trips up when it hits an operator for some reason.  The line is causing me trouble is the &quot;results = OPERATOR[item] (x, y)&quot;<br />
<br />
I would appreaciate any help!!!  Please!!!<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ljvasil</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236825.html</guid>
		</item>
		<item>
			<title>numpy array rows and columns</title>
			<link>http://www.daniweb.com/forums/thread236824.html</link>
			<pubDate>Sat, 07 Nov 2009 17:03:10 GMT</pubDate>
			<description><![CDATA[Hey. I'm importing an array in a text file via array=numpy.loadtxt("testdata.txt"). 
Is there an easy way to count the number of rows and columns? Maybe something like x=numpy.countrow(array)? 
I've had a look around and couldn't find anything suitable. 
Thanks, Alex]]></description>
			<content:encoded><![CDATA[<div>Hey. I'm importing an array in a text file via  <pre style="margin:20px; line-height:13px">array=numpy.loadtxt(&quot;testdata.txt&quot;)</pre>.<br />
Is there an easy way to count the number of rows and columns? Maybe something like  <pre style="margin:20px; line-height:13px">x=numpy.countrow(array)</pre>?<br />
I've had a look around and couldn't find anything suitable.<br />
Thanks, Alex</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Chromana</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236824.html</guid>
		</item>
		<item>
			<title>Need Help on Reverse Polish Notation program code</title>
			<link>http://www.daniweb.com/forums/thread236819.html</link>
			<pubDate>Sat, 07 Nov 2009 16:22:48 GMT</pubDate>
			<description>Hi there, 
I am having a problem with one line in my code.  I wrote a code for calculating expressions using reverse polish notation (for a class) using a classes.  Can someone help me figure out why: 
except ValueError: 
                x = s.pop() 
                y = s.pop() 
               ...</description>
			<content:encoded><![CDATA[<div>Hi there,<br />
I am having a problem with one line in my code.  I wrote a code for calculating expressions using reverse polish notation (for a class) using a classes.  Can someone help me figure out why:<br />
except ValueError:<br />
                x = s.pop()<br />
                y = s.pop()<br />
                result = OPERATORS[item](x, y)<br />
                s.push(result)<br />
is not working in the following code?<br />
<br />
Thanks for you help!<br />
<br />
import operator<br />
<br />
OPERATORS = {<br />
        '+': operator.add,<br />
        '-': operator.sub,<br />
        '*': operator.mul,<br />
        '/': operator.div,<br />
        }<br />
<br />
class Stack(object):<br />
    &quot;Creates a stack to enter numbers or operators into&quot;<br />
<br />
    def __init__(self):<br />
        self.storage = [0,0,0,0]<br />
        self.sptn = -1        <br />
<br />
    def push(self, item):<br />
        self.sptn = self.sptn + 1<br />
        self.storage[self.sptn] = item<br />
        <br />
    def pop(self):<br />
        self.sptn = self.sptn -1<br />
        <br />
    def top(self):        <br />
        return self.storage[self.sptn]<br />
<br />
    def __rep__(self):<br />
        return self.storage[:self.sptn + 1]<br />
    <br />
<br />
def get_input():<br />
<br />
    equation = raw_input(&quot;Enter the equation in reverse polish notation: &quot;)<br />
    return equation<br />
<br />
def evaluate_rpn(equation):<br />
<br />
    s = Stack()<br />
<br />
    try:<br />
        for item in equation.split():<br />
            try:<br />
                result = float(item)<br />
                s.push(result)<br />
            except ValueError:<br />
                x = s.pop()<br />
                y = s.pop()<br />
                result = OPERATORS[item](x, y)<br />
                s.push(result)<br />
        result = s.top()<br />
            <br />
    except IndexError:<br />
        print &quot;Please input at least two numbers before entering an operator.&quot;<br />
<br />
#def main():<br />
#    equation = get_input()<br />
#    answer = evaluate_rpn(raw_input(&quot;Enter the equation in reverse polish notation: &quot;))<br />
#    print answer</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ljvasil</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236819.html</guid>
		</item>
		<item>
			<title>WxGlade does not show value</title>
			<link>http://www.daniweb.com/forums/thread236797.html</link>
			<pubDate>Sat, 07 Nov 2009 15:07:15 GMT</pubDate>
			<description><![CDATA[If I run the following code the textCtrl's aren't updated, they stay empty, but if I do print self.extra201.GetValue()I get the value that is set with the code beneath. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>If I run the following code the textCtrl's aren't updated, they stay empty, but if I do  <pre style="margin:20px; line-height:13px">print self.extra201.GetValue()</pre>I get the value that is set with the code beneath.<br />
<br />
 <pre style="margin:20px; line-height:13px">self.extra101.SetValue(names[1])<br />
self.extra201.SetValue(names[2])<br />
self.extra111.SetValue(str(money[1]))<br />
self.extra211.SetValue(str(money[2]))</pre><br />
Why isn't it update !! :(</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Kruptein</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236797.html</guid>
		</item>
		<item>
			<title>Parse Logic/Code Need</title>
			<link>http://www.daniweb.com/forums/thread236755.html</link>
			<pubDate>Sat, 07 Nov 2009 09:43:02 GMT</pubDate>
			<description>------------------------------------ ----------- --------- ------------------------------------ ----------------------------- 
------- 
PRODUCT                              KIT TYPE    STATE     MAINTENANCE                          REFERENCED BY 
------------------------------------ -----------...</description>
			<content:encoded><![CDATA[<div>------------------------------------ ----------- --------- ------------------------------------ -----------------------------<br />
-------<br />
PRODUCT                              KIT TYPE    STATE     MAINTENANCE                          REFERENCED BY<br />
------------------------------------ ----------- --------- ------------------------------------ -----------------------------<br />
-------<br />
HP I64VMS ACUXE V6.40-11P09A         Full LP     Installed<br />
HP I64VMS AVAIL_MAN_BASE V8.3-1H1    Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS CDSA V2.3-306              Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS CSWS V2.1-1                Full LP     Installed HP I64VMS CSWS211_UPDATE V1.0<br />
HP I64VMS CSWS_PHP V1.3              Full LP     Installed HP I64VMS CSWS_PHP13_UPDATE V1.0<br />
HP I64VMS DECNET_PLUS V8.3-1H1       Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS DWMOTIF V1.6               Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS DWMOTIF_SUPPORT V8.3-1H1   Full LP     Installed                                      HP I64VMS VMS V8.3-1H1<br />
HP I64VMS KERBEROS V3.1-152          Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS OPENVMS V8.3-1H1           Platform    Installed<br />
HP I64VMS SMH V2.0-17                Full LP     Installed HP I64VMS SMHPAT V2.0-20<br />
HP I64VMS SSL V1.3-284               Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS TCPIP V5.6-9ECO2           Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS TDC_RT V2.3-1              Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS VMS V8.3-1H1               Oper System Installed                                      HP I64VMS CDSA V2.3-306<br />
                                                                                                HP I64VMS DECNET_PLUS V8.3-1H1  <br />
                                                                                                HP I64VMS DWMOTIF V1.6<br />
                                                                                                HP I64VMS KERBEROS V3.1-152<br />
                                                                                                HP I64VMS OPENVMS V8.3-1H1<br />
                                                                                                HP I64VMS TCPIP V5.6-9ECO2<br />
HP I64VMS WBEMCIM V2.61-A070728      Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
HP I64VMS WBEMPROVIDERS V1.5-31      Full LP     Installed                                      HP I64VMS OPENVMS V8.3-1H1<br />
------------------------------------ ----------- --------- ------------------------------------ -----------------------------<br />
-------<br />
<br />
Hi above is my output of one of my command I want to filter each column value seprately. Please help me I am bugging my head from last 5-6 hours.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>krishna_sicsr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236755.html</guid>
		</item>
		<item>
			<title>Working with files</title>
			<link>http://www.daniweb.com/forums/thread236716.html</link>
			<pubDate>Sat, 07 Nov 2009 06:24:36 GMT</pubDate>
			<description><![CDATA[I have a file like this: 
a,z,1 
b,y 
c,x,1 
d,w,1 
e,v 
f,u 
What I need to do is to create a dictionary that has the characters in the first column as keys and characters in the third column as values. The rest should be ignored, i.e. {a:1, c:1, d:1}. This is what I have so far: 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I have a file like this:<br />
a,z,1<br />
b,y<br />
c,x,1<br />
d,w,1<br />
e,v<br />
f,u<br />
What I need to do is to create a dictionary that has the characters in the first column as keys and characters in the third column as values. The rest should be ignored, i.e. {a:1, c:1, d:1}. This is what I have so far:<br />
 <pre style="margin:20px; line-height:13px">def create_dict(f):<br />
&nbsp; &nbsp; f = open(&quot;something.txt&quot;)<br />
&nbsp; &nbsp; d = {}<br />
&nbsp; &nbsp; for line in f:<br />
&nbsp; &nbsp; &nbsp; &nbsp; columns = line.split(&quot;,&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; letters = columns[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; numbers = columns[2]</pre><br />
I am confused about next steps. Please, help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pyprog</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236716.html</guid>
		</item>
		<item>
			<title>findall</title>
			<link>http://www.daniweb.com/forums/thread236706.html</link>
			<pubDate>Sat, 07 Nov 2009 04:52:17 GMT</pubDate>
			<description><![CDATA[hey guys, 
i have a problem.. i have this chunk of text like this..... 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>hey guys,<br />
i have a problem.. i have this chunk of text like this.....<br />
<br />
 <pre style="margin:20px; line-height:13px">No.&nbsp; &nbsp;  Time&nbsp; &nbsp; &nbsp; &nbsp; Source&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Destination&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Protocol Info<br />
&nbsp; &nbsp; &nbsp; 2 0.005318&nbsp; &nbsp; 192.168.110.33&nbsp; &nbsp; &nbsp; &nbsp; 192.168.110.44&nbsp; &nbsp; &nbsp; &nbsp; ICMP&nbsp; &nbsp;  Echo (ping) request<br />
<br />
Frame 2 (98 bytes on wire, 98 bytes captured)<br />
Ethernet II, Src: Cisco-Li_4d:e1:30 (00:1c:10:4d:e1:30), Dst: IntelCor_4d:77:83 (00:13:02:4d:77:83)<br />
Internet Protocol, Src: 192.168.110.33 (192.168.110.33), Dst: 192.168.110.44 (192.168.110.44)<br />
Internet Control Message Protocol<br />
<br />
No.&nbsp; &nbsp;  Time&nbsp; &nbsp; &nbsp; &nbsp; Source&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Destination&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Protocol Info<br />
&nbsp; &nbsp; &nbsp; 3 0.998730&nbsp; &nbsp; 192.168.110.33&nbsp; &nbsp; &nbsp; &nbsp; 192.168.110.44&nbsp; &nbsp; &nbsp; &nbsp; DHCP&nbsp; &nbsp;  DHCP Offer&nbsp; &nbsp; - Transaction ID 0x9e0e832<br />
<br />
Frame 3 (347 bytes on wire, 347 bytes captured)<br />
Ethernet II, Src: Cisco-Li_4d:e1:30 (00:1c:10:4d:e1:30), Dst: IntelCor_4d:77:83 (00:13:02:4d:77:83)<br />
Internet Protocol, Src: 192.168.110.33 (192.168.110.33), Dst: 192.168.110.44 (192.168.110.44)<br />
User Datagram Protocol, Src Port: bootps (67), Dst Port: bootpc (68)<br />
Bootstrap Protocol<br />
<br />
No.&nbsp; &nbsp;  Time&nbsp; &nbsp; &nbsp; &nbsp; Source&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Destination&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Protocol Info<br />
&nbsp; &nbsp; &nbsp; 4 0.998917&nbsp; &nbsp; 0.0.0.0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  255.255.255.255&nbsp; &nbsp; &nbsp;  DHCP&nbsp; &nbsp;  DHCP Request&nbsp; - Transaction ID 0x9e0e832<br />
<br />
Frame 4 (348 bytes on wire, 348 bytes captured)<br />
Ethernet II, Src: IntelCor_4d:77:83 (00:13:02:4d:77:83), Dst: Broadcast (ff:ff:ff:ff:ff:ff)<br />
Internet Protocol, Src: 0.0.0.0 (0.0.0.0), Dst: 255.255.255.255 (255.255.255.255)<br />
User Datagram Protocol, Src Port: bootpc (68), Dst Port: bootps (67)<br />
Bootstrap Protocol</pre><br />
basically i'm trying to extract the DHCP server and the the IP address its giving me... sp i want to look for the text between &quot;DHCP Offer&quot; and &quot;bootstrap&quot; and then from that chunk get the part between &quot;Internet Protocol) Src:&quot; and &quot;(&quot;<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; temp = re.findall(&quot;DHCP\s+Offer(.)Bootstrap&quot;, text)<br />
&nbsp; &nbsp; print (temp)<br />
&nbsp; &nbsp; name=re.findall(&quot;(Internet Protocol)\sSrc:.[(]&quot;, temp)<br />
&nbsp; &nbsp; print name</pre><br />
but i think its not reading past the 1st line between the srearch words</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>mitsuevo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236706.html</guid>
		</item>
		<item>
			<title>Complete newb needing help with drawing histograms.</title>
			<link>http://www.daniweb.com/forums/thread236700.html</link>
			<pubDate>Sat, 07 Nov 2009 03:45:30 GMT</pubDate>
			<description>Hello all. My name is Younis, I am a computer science newb. I occasionally browse this website reading some fascinating threads. I have a simple project at hand which i am finding the extra credit portion to be somewhat difficult.  
 
The project is very simple,  
the project takes a number from...</description>
			<content:encoded><![CDATA[<div>Hello all. My name is Younis, I am a computer science newb. I occasionally browse this website reading some fascinating threads. I have a simple project at hand which i am finding the extra credit portion to be somewhat difficult. <br />
<br />
The project is very simple, <br />
the project takes a number from the user and <br />
- if the number is one, it quits<br />
-if the number is even, we cut it in half<br />
-if the number is odd, multiply is by 3 and add 1<br />
<br />
so if we look at the number 13 it goes like this:<br />
13 -&gt; 40 -&gt; 20 -&gt; 10 -&gt; 5 -&gt; 16 -&gt; 8 -&gt; 4 -&gt; 2 -&gt; 1 <br />
<br />
so the length of the chain would be 10.<br />
<br />
So our job is to print a menu to the user.<br />
If the user enters &quot;I&quot;, ask the user for a number, print the chain and length of the chain for that number<br />
<br />
if the user enters &quot;R&quot;, ask the user for a range of numbers, and print the length and chain of each number<br />
<br />
If the user enters &quot;L&quot;, ask the user for a range of numbers, and print the number with the longest chain length. <br />
<br />
If the user enters &quot;Q&quot;, then quit. <br />
<br />
I have all of that working. now i the extra credit says:<br />
if the user enters a number, and the next 10 numbers after that and draw a histograms. <br />
<br />
so the x axis would be each of the number, and the y axis would be the chain length of that number. <br />
<br />
I can get the number and length of each number in a list. but i am a newb as to how to draw  this. <br />
so if the user entered 2, we would draw a histogram of 2-11 and each bar of the number would reach up to the chain length of that number.  <br />
<br />
here is my code:<br />
 <pre style="margin:20px; line-height:13px"># Filename:&nbsp; &nbsp; hw6.py<br />
# Date:&nbsp; &nbsp; &nbsp; &nbsp; 10/16/09<br />
# Section #:&nbsp;  06<br />
# Description:<br />
# This file contains python code for hailstone sequence.<br />
# It follows the rules, if a number is even, it will divide the<br />
# next number by two, if the number is odd, it will multiply the next<br />
# number by three and then add 1. This will continuie forming a chain<br />
# until the last number is 1. <br />
<br />
# this function prints the chain of numbers using the rules<br />
# also adds up the length chain<br />
# Inputs : n<br />
# Outputs : none<br />
<br />
import string<br />
# from graphics import *<br />
from graphics import *<br />
<br />
#Constant<br />
MAX = 10000<br />
<br />
# printing functions<br />
<br />
# this function prints a brief description of the program to the user<br />
# Inputs: none<br />
# Outputs : none<br />
def printGreeting():<br />
&nbsp; &nbsp; print &quot;&quot;<br />
&nbsp; &nbsp; print &quot; This program finds hailstones sequences of numbers&quot;<br />
&nbsp; &nbsp; print &quot; you choose. The next number in the sequence if found by&quot;<br />
&nbsp; &nbsp; print &quot; either dividing it by two(if even) or multiplying by 3&quot;<br />
&nbsp; &nbsp; print &quot; and adding 1(if odd).The program quits when the last&quot;<br />
&nbsp; &nbsp; print &quot; number in the sequence is 1\n&quot;<br />
<br />
# this functions prints the menu for the user <br />
# Inputs: none<br />
# Outputs : none<br />
def printMenu():<br />
&nbsp; &nbsp; print &quot;\n\tHere are your menu choices:&quot;<br />
&nbsp; &nbsp; print &quot;\n\tI - view squence for an individual value\n&quot;<br />
&nbsp; &nbsp; print &quot;\tR - veiw sequence for range of values\n&quot;<br />
&nbsp; &nbsp; print &quot;\tL - Find the longest chain\n&quot;<br />
&nbsp; &nbsp; print &quot;\tH - Print out the histogram\n&quot;<br />
&nbsp; &nbsp; print &quot;\tQ - Quit\n\n&quot;<br />
<br />
# end of printing funtions<br />
<br />
<br />
# hailstone(number) prints the hailstone sequence<br />
# Inputs: number<br />
# Outputs: none<br />
def hailstone(n):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; length = 1<br />
&nbsp; &nbsp; print n,<br />
&nbsp; &nbsp; # checks if n is not sential <br />
&nbsp; &nbsp; while n != 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # if even, divide by 2 (rule). add 1 to length<br />
&nbsp; &nbsp; &nbsp; &nbsp; if n % 2 == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = n / 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;-&gt;&quot;,n,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = length + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # if odd, multiply by 3, add 1 (rule). add 1 to length<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif n % 2 != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = ( 3 * n ) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;-&gt;&quot;,n,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = length + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; # print the length at the end of each chain<br />
&nbsp; &nbsp; print &quot;; length =&quot;,length<br />
&nbsp; &nbsp; print &quot;----------------------------------------------------------------&quot;,<br />
&nbsp; &nbsp; print &quot;--------------\n&quot;<br />
&nbsp; &nbsp; return length<br />
<br />
# this function returns the length of each chain from the starting number, n<br />
# Inputs : n<br />
# Outputs : none<br />
def chain(n):<br />
&nbsp;  <br />
&nbsp; &nbsp; length = 1<br />
&nbsp; &nbsp; while n != 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # if even, divide by 2 (rule). add 1 to length<br />
&nbsp; &nbsp; &nbsp; &nbsp; if n % 2 == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = n / 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length&nbsp; = length + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # if even, divide by 2 (rule). add 1 to length<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif n % 2 != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = ( 3 * n ) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = length + 1<br />
&nbsp; &nbsp; return length<br />
<br />
# getValidInt() prompts the user to enter an integer in the specified range,<br />
# rejects values not in that range by requiring new input, and only returns<br />
# a valid integer.<br />
# Inputs: the question of the prompt,<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  the minimum value in the range<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  and the maximum value in the range<br />
# Output: an integer in the specified range<br />
def getValidInt(question, min, max):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; # use a bad value to enter the loop<br />
&nbsp; &nbsp; value = max + 1<br />
<br />
&nbsp; &nbsp; # compose the prompt <br />
&nbsp; &nbsp; prompt = question + &quot; (&quot; + str(min) + &quot;-&quot; + str(max) + &quot;): &quot;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; # continue to get values until the user enters a valid one<br />
&nbsp; &nbsp; while value == &quot;&quot; or value &lt; min or value &gt; max:<br />
&nbsp; &nbsp; &nbsp; &nbsp; value = raw_input(prompt)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if len(value) != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value = int(value)<br />
<br />
&nbsp; &nbsp; # return a valid value<br />
&nbsp; &nbsp; return value<br />
<br />
<br />
# this function finds the longest chain<br />
# Inputs: none<br />
# Outputs : none<br />
def longChain():<br />
&nbsp; &nbsp;  begin = &quot;Please enter the begining integer for the range&quot;<br />
&nbsp; &nbsp;  end = &quot;Please enter the ending integer for the range&quot;<br />
<br />
&nbsp; &nbsp;  # calls to getValidInt for starting and ending values<br />
&nbsp; &nbsp;  beginNum = getValidInt(begin, 1, MAX)<br />
&nbsp; &nbsp;  endNum = getValidInt(end, beginNum + 1, MAX)<br />
<br />
&nbsp; &nbsp;  largestChain = beginNum<br />
<br />
&nbsp; &nbsp;  for i in range(beginNum, endNum+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if largestChain &lt;= chain(i):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  largestChain = i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  length = chain(i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp;  print largestChain, &quot; had the longest chain &quot;, length<br />
<br />
# this function finds the longest chain***************************8<br />
# Inputs: none*************<br />
# Outputs : none&nbsp; &nbsp; <br />
def histogram():<br />
&nbsp; &nbsp; # initialize variables&nbsp; <br />
&nbsp; &nbsp; longestLength = 1<br />
&nbsp; &nbsp; list = []<br />
<br />
&nbsp; &nbsp; start = input(&quot;Please enter the begining integer for the range: &quot;)<br />
&nbsp; &nbsp; for n in range (start, start + 10):<br />
&nbsp; &nbsp; &nbsp; &nbsp; length = chain(n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; list.append(length)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if longestLength &lt;= chain(n):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; longestLength = n<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = chain(n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print longestLength<br />
&nbsp; &nbsp; &nbsp; &nbsp; print list<br />
<br />
def main():<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; # prints the greeting to the user<br />
&nbsp; &nbsp; printGreeting()<br />
<br />
&nbsp; &nbsp; # prints the menu to the user<br />
&nbsp; &nbsp; printMenu()<br />
<br />
&nbsp; &nbsp; # asks user the menu choice<br />
&nbsp; &nbsp; choice = raw_input(&quot;Please enter your choice : &quot;).upper()<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; # checks to see if choice entered is from the menu<br />
&nbsp; &nbsp; while choice != 'Q': <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if choice is &quot;I&quot; or &quot;i&quot;, proceeds to follow the individual steps<br />
&nbsp; &nbsp; &nbsp; &nbsp; if choice == 'I':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = input(&quot;Please enter your integer (1-10000):&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hailstone(n)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if choice is &quot;R&quot; or &quot;r&quot;, proceds print each number and its sequence<br />
&nbsp; &nbsp; &nbsp; &nbsp; # until the last number is 1, uses getValidInt to get valid integers<br />
&nbsp; &nbsp; &nbsp; &nbsp; # for the function<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'R':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin = &quot;Please enter the begining integer for the range&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end = &quot;Please enter the ending integer for the range&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # calls to getValidInt for starting and ending values<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; beginNum = getValidInt(begin, 1, MAX)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; endNum = getValidInt(end, beginNum + 1, MAX)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # for loop to get the values between starting and ending value<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for n in range(beginNum,endNum+1):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #call to the hailstone function<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hailstone(n)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if choice is &quot;L&quot; or &quot;l&quot;, proceeds to use getValidInt again to get the<br />
&nbsp; &nbsp; &nbsp; &nbsp; # range, error checks on the range, and then calls the function chain<br />
&nbsp; &nbsp; &nbsp; &nbsp; # to determine the length. <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'L':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # call to function longchain<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; longChain()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'H':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; histogram()<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # if niether of the menu choices, then it prints that the<br />
&nbsp; &nbsp; &nbsp; &nbsp; # entered text is not a valid choices<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print choice, &quot;is not a valid choice&quot;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # prints the menu to the user<br />
&nbsp; &nbsp; &nbsp; &nbsp; printMenu()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # asks user the menu choice<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = raw_input(&quot;Please enter your choice : &quot;).upper()<br />
&nbsp; &nbsp; &nbsp; <br />
main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>truekid</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236700.html</guid>
		</item>
		<item>
			<title>I require help with making 3 simple program/functions</title>
			<link>http://www.daniweb.com/forums/thread236680.html</link>
			<pubDate>Sat, 07 Nov 2009 01:46:33 GMT</pubDate>
			<description><![CDATA[1. I need to make a program that creates a list that contains the first n perfect squares. All I know is that it starts with 
 
n = int(raw_input("How many squares? ")) 
 
and ends with 
 
print squares 
 
An example of how this program should work is:]]></description>
			<content:encoded><![CDATA[<div>1. I need to make a program that creates a list that contains the first n perfect squares. All I know is that it starts with<br />
<br />
n = int(raw_input(&quot;How many squares? &quot;))<br />
<br />
and ends with<br />
<br />
print squares<br />
<br />
An example of how this program should work is:<br />
<br />
How many squares? 5<br />
[1, 4, 9, 16, 25]<br />
<br />
2. I need to create a function that takes a list as its only argument. It's needs to return a new list containing all (and only) the elements of 1 which are divisible by 2. The original list needs to remain the same.<br />
<br />
Example of how this works is:<br />
<br />
even_only([1, 3, 6, 10, 15, 21, 28])       should return<br />
[6, 10, 28]<br />
<br />
3. I need a function that translates a single English sentence into pig latin.<br />
<br />
I honestly have no idea how to start any of these and any help would be greatly appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Judgment</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236680.html</guid>
		</item>
		<item>
			<title>Editing Textfiles</title>
			<link>http://www.daniweb.com/forums/thread236672.html</link>
			<pubDate>Sat, 07 Nov 2009 00:46:07 GMT</pubDate>
			<description>Hey 
im new here to excuse the nubneess 
i wanted to make a family tree thingy and wanted to do it in python  
i wanted to make a way so that it could read a text file and auto add a new entry called summary which would include the initials,yr of birth and the childnum could any one help me out? at...</description>
			<content:encoded><![CDATA[<div>Hey<br />
im new here to excuse the nubneess<br />
i wanted to make a family tree thingy and wanted to do it in python <br />
i wanted to make a way so that it could read a text file and auto add a new entry called summary which would include the initials,yr of birth and the childnum could any one help me out? at the moment ive gotten it to add the summary field but i cant figure out how to do the rest<br />
[exampletxt]<br />
Fname,LName,DOB,childnum<br />
bob,smith,17/08/99/1</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Jewsy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236672.html</guid>
		</item>
		<item>
			<title>Password Generator</title>
			<link>http://www.daniweb.com/forums/thread236655.html</link>
			<pubDate>Fri, 06 Nov 2009 23:03:19 GMT</pubDate>
			<description><![CDATA[I know Remembering secure passwords is difficult. So I made this. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I know Remembering secure passwords is difficult. So I made this.<br />
 <pre style="margin:20px; line-height:13px">import random, os<br />
a= ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','{',':','&gt;','?','}','|','!','@','#','$','%','^','&amp;','*','(',')','-','+']<br />
<br />
z = int(raw_input(&quot;How many words in your password?: &quot;))<br />
os.system(&quot;clear&quot;)<br />
List = []<br />
for x in xrange(z):<br />
&nbsp; &nbsp; &nbsp; &nbsp; List.append(random.choice(a))<br />
print &quot;&quot;.join(List) <br />
print &quot;1) Yes&quot;<br />
print &quot;2) No&quot;<br />
b = int(raw_input(&quot;Would you like to save this password to a text file?: &quot;))<br />
if b == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; c = raw_input(&quot;What is this password for?: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = open(&quot;%s.txt&quot; % c, &quot;w&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; y = &quot;&quot;.join(List)<br />
&nbsp; &nbsp; &nbsp; &nbsp; x.write(y)<br />
&nbsp; &nbsp; &nbsp; &nbsp; x.close<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = open(&quot;%s.txt&quot; % c, &quot;r&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; x.read<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Saved!&quot;<br />
elif b == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; raw_input(&quot;Press Enter To Continue&quot;)</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>nevets04</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236655.html</guid>
		</item>
		<item>
			<title><![CDATA[several questions about Glade & pygtk]]></title>
			<link>http://www.daniweb.com/forums/thread236581.html</link>
			<pubDate>Fri, 06 Nov 2009 15:00:23 GMT</pubDate>
			<description>1. Is it possible to draw a border line around a table and/or a cell 
2. Is it possible to draw a color to the background of a label. 
2bis If not, is there an other element that can have background colors 
3 How can I set the default height and width from a window(toplevel). 
   I tried to use...</description>
			<content:encoded><![CDATA[<div>1. Is it possible to draw a border line around a table and/or a cell<br />
2. Is it possible to draw a color to the background of a label.<br />
2bis If not, is there an other element that can have background colors<br />
3 How can I set the default height and width from a window(toplevel).<br />
   I tried to use default height and default width<br />
    (sounds quit logic) but the window always stays in the same<br />
     small format<br />
<br />
I hope someone knows the answer at one of these questions.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Kruptein</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236581.html</guid>
		</item>
		<item>
			<title>loops and parameters?</title>
			<link>http://www.daniweb.com/forums/thread236553.html</link>
			<pubDate>Fri, 06 Nov 2009 11:54:14 GMT</pubDate>
			<description><![CDATA[I need to write a function which has 2 parameters height and width and outputs a rectangle of "#" ssmbol of the appropriate dimensions. so for 93, 4) should result in the output 
#### 
#### 
#### 
 
but i dnt unserstand how to use the loop in this. I have only done loops once til nw and i tried...]]></description>
			<content:encoded><![CDATA[<div>I need to write a function which has 2 parameters height and width and outputs a rectangle of &quot;#&quot; ssmbol of the appropriate dimensions. so for 93, 4) should result in the output<br />
####<br />
####<br />
####<br />
<br />
but i dnt unserstand how to use the loop in this. I have only done loops once til nw and i tried using that code for this one but i get error everytime, probably coz the whole code is wrong. This is my first code i did using loop which is correct. But i cant seem to know how to do the second one?. I know the code i have done for the second one is not very much and probably wrong, If you guys could atleast provide me with a example it would do, if you think i am asking you to do the h/w for me thing..<br />
<br />
 <pre style="margin:20px; line-height:13px">word=raw_input(&quot;please enter the word for the song :&quot;)<br />
repeat=input(&quot;how many times should the song be repeated? :&quot;)<br />
lines=input(&quot;how many lines should the song be for? :&quot;)<br />
for i in range(lines):<br />
&nbsp; &nbsp;  print word*repeat</pre><br />
 <pre style="margin:20px; line-height:13px">def drawBlock(height, width):<br />
&nbsp; &nbsp; x=&quot;#&quot;<br />
&nbsp; &nbsp; for i in range(drawBlock):<br />
&nbsp; &nbsp;  print x</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>jaison2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236553.html</guid>
		</item>
		<item>
			<title>List convert to string</title>
			<link>http://www.daniweb.com/forums/thread236526.html</link>
			<pubDate>Fri, 06 Nov 2009 09:35:03 GMT</pubDate>
			<description><![CDATA[Hi everyone, 
 
hope someone can give me some hints about my problem. 
I write a program that read users input through command line(args).  
This input i put it as a list. User type number that they want separated with comma 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone,<br />
<br />
hope someone can give me some hints about my problem.<br />
I write a program that read users input through command line(args). <br />
This input i put it as a list. User type number that they want separated with comma<br />
 <pre style="margin:20px; line-height:13px">--number 1,2,3,4</pre>The next process is to read the file and and use those numbers above to determine which part of the file will be outputted.<br />
The file is a 2 row file which 1st row represented the user's input<br />
 <pre style="margin:20px; line-height:13px">1&nbsp;  20<br />
2&nbsp;  56<br />
3&nbsp;  42<br />
4&nbsp;  53<br />
5&nbsp;  90<br />
6&nbsp;  33</pre>So based on the user input, the system should display<br />
 <pre style="margin:20px; line-height:13px">1&nbsp;  20<br />
2&nbsp;  56<br />
3&nbsp;  42<br />
4&nbsp;  53</pre>My problem is because the user input i put as lists, python complains that it should be integer.<br />
Can anyone gives me a hint? still stuck in this problem :(<br />
Many thanks before<br />
feli</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Felicidas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236526.html</guid>
		</item>
		<item>
			<title>1 digit number 2 to 3 digit number 002</title>
			<link>http://www.daniweb.com/forums/thread236467.html</link>
			<pubDate>Fri, 06 Nov 2009 04:08:26 GMT</pubDate>
			<description>Hi all, I have found some examples on the net but was not able to use the technique.. 
 
here is what I would like to do. 
 
tst = 2 
numOfDigits = 3 
# change this to 
tst2 = 002 
 
Any help is appreciated.</description>
			<content:encoded><![CDATA[<div>Hi all, I have found some examples on the net but was not able to use the technique..<br />
<br />
here is what I would like to do.<br />
<br />
tst = 2<br />
numOfDigits = 3<br />
# change this to<br />
tst2 = 002<br />
<br />
Any help is appreciated.<br />
Thank you.<br />
<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  <a rel="nofollow" class="t" href="http://www.webdotdev.com/nvd/content/view/938/99999999/1/2/" target="_blank">http://www.webdotdev.com/nvd/content.../99999999/1/2/</a><br />
&gt;&gt;&gt; print “z is (%6d)” % 175<br />
z is ( 175)<br />
&gt;&gt;&gt; print “z is (%06d)” % 175<br />
z is (000175)  <hr /> </td> </tr> </table> </div></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>efecto</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236467.html</guid>
		</item>
		<item>
			<title>OS X default save path</title>
			<link>http://www.daniweb.com/forums/thread236432.html</link>
			<pubDate>Fri, 06 Nov 2009 00:30:43 GMT</pubDate>
			<description><![CDATA[For whatever reason, Python on OS X sets the default file directory to the "~/Documents/ " folder. It's a bit annoying because it makes my documents folder massively cluttered with python files as well as files from my computer. 
 
I'd like to change it simply by adding a "Python" folder within the...]]></description>
			<content:encoded><![CDATA[<div>For whatever reason, Python on OS X sets the default file directory to the &quot;~/Documents/ &quot; folder. It's a bit annoying because it makes my documents folder massively cluttered with python files as well as files from my computer.<br />
<br />
I'd like to change it simply by adding a &quot;Python&quot; folder within the documents folder, and then changing line 8 in idlemain.py to : os.chdir(os.path.expanduser('~/Documents/Python/'))<br />
<br />
However, I keep getting an &quot;[Errno 13] Permission Denied: '/Applications/Python 2.6/IDLE.app/Contents/Resources/idlemain.py' &quot; whenever I attempt to save the file.<br />
<br />
I'm logged in as Admin on my comp and I've tried changed the file in TextEdit with IDLE closed resulting in the same error..... Any ideas?<br />
<br />
Also, if anyone knows how to get the two-finger scroll to work in Python that would be extremely appreciated as well.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>math743</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236432.html</guid>
		</item>
		<item>
			<title>Alphabetizer</title>
			<link>http://www.daniweb.com/forums/thread236413.html</link>
			<pubDate>Thu, 05 Nov 2009 23:16:18 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>Python Syntax</strong>...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">#Credits:<br />
#Nevets04<br />
#Fallen<br />
#Uber1337<br />
#Farout<br />
import os<br />
List = []<br />
z = int(raw_input(&quot;How many words in your list?: &quot;))<br />
os.system(&quot;clear&quot;)<br />
for x in xrange(z): List.append(raw_input(&quot;&quot;))<br />
List.sort(),os.system(&quot;clear&quot;)<br />
print &quot;\n&quot;.join(List)</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>nevets04</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236413.html</guid>
		</item>
		<item>
			<title>How can I make a loop that changes?</title>
			<link>http://www.daniweb.com/forums/thread236400.html</link>
			<pubDate>Thu, 05 Nov 2009 22:44:18 GMT</pubDate>
			<description><![CDATA[How do I make something like 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div>...]]></description>
			<content:encoded><![CDATA[<div>How do I make something like<br />
<br />
 <pre style="margin:20px; line-height:13px">x = 5<br />
while 0 &lt; x<br />
&nbsp; &nbsp; b&nbsp; = raw_input(&quot;something: &quot;)</pre><br />
However each time it loops, I want it to change, like:<br />
first loop - b  = raw_input(&quot;something: &quot;)<br />
second loops - c  = raw_input(&quot;something: &quot;)<br />
third loop - d  = raw_input(&quot;something: &quot;)<br />
and so on.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>nevets04</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236400.html</guid>
		</item>
		<item>
			<title>Drwaing Circles?</title>
			<link>http://www.daniweb.com/forums/thread236397.html</link>
			<pubDate>Thu, 05 Nov 2009 22:30:04 GMT</pubDate>
			<description>hi, i want to be able to draw two eyes with are exactly the same in radius and colour etc next to eachother. So when i open the window the pair of eyes are there in the centre. I have managed to get one eye but i dnt have a clue to how to get one beside it, i am not sure hw to.. here is my code for...</description>
			<content:encoded><![CDATA[<div>hi, i want to be able to draw two eyes with are exactly the same in radius and colour etc next to eachother. So when i open the window the pair of eyes are there in the centre. I have managed to get one eye but i dnt have a clue to how to get one beside it, i am not sure hw to.. here is my code for the first eye and function should be calling the drawCircle six times.<br />
please help<br />
 <pre style="margin:20px; line-height:13px">from graphics import *<br />
import math<br />
def drawCircle(win, centre, radius, colour):<br />
circle = Circle(centre, radius)<br />
circle.setFill(colour)<br />
circle.setWidth(2)<br />
circle.draw(win)<br />
<br />
def drawTarget():<br />
win = GraphWin()<br />
centre = Point(100,100)<br />
drawCircle(win, centre, 40, &quot;white&quot;)<br />
drawCircle(win, centre, 20, &quot;blue&quot;)<br />
drawCircle(win, centre, 10, &quot;black&quot;)</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>jaison2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236397.html</guid>
		</item>
		<item>
			<title>while loop in python</title>
			<link>http://www.daniweb.com/forums/thread236362.html</link>
			<pubDate>Thu, 05 Nov 2009 20:00:27 GMT</pubDate>
			<description>I am totally new to programming and could use some help. 
 
I am trying to write a while loop in python that could execute this equation but in a while loop type function. 
 
the equation is n * (n + 1) / 2 
 
any ideas?</description>
			<content:encoded><![CDATA[<div>I am totally new to programming and could use some help.<br />
<br />
I am trying to write a while loop in python that could execute this equation but in a while loop type function.<br />
<br />
the equation is n * (n + 1) / 2<br />
<br />
any ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>laxter17</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236362.html</guid>
		</item>
		<item>
			<title>decimal help</title>
			<link>http://www.daniweb.com/forums/thread236355.html</link>
			<pubDate>Thu, 05 Nov 2009 19:28:40 GMT</pubDate>
			<description><![CDATA[I want to be able to output the area of the circle and the cirumference of the circle to the user. so the output is to be "the area of the circle is... and the circumference of the circle is..." and it has to be to 2dp. the question says i will have to call the circumferenceofCircle and...]]></description>
			<content:encoded><![CDATA[<div>I want to be able to output the area of the circle and the cirumference of the circle to the user. so the output is to be &quot;the area of the circle is... and the circumference of the circle is...&quot; and it has to be to 2dp. the question says i will have to call the circumferenceofCircle and areaOfCircle functions. is this the right way to go?<br />
 <pre style="margin:20px; line-height:13px">import math<br />
radius= input(&quot;please enter the radius of the cirle: &quot;)<br />
area= float(math.pi*radius**2)<br />
circumference= float(2*math.pi*radius)<br />
print &quot;The area of the circle is,/&quot;&quot;area is %.2f and circumference is %.2f. &quot; (radius, circumference)</pre><br />
and can you tell me if this return function is correct?.. the function has to have radius as the parameter and returns the area of circle..<br />
<br />
 <pre style="margin:20px; line-height:13px">def AreaOfCircle(radius):<br />
&nbsp; &nbsp; return math.pi * radius**2</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>gangster88</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236355.html</guid>
		</item>
		<item>
			<title>Ack... drowning... in... parentheses...</title>
			<link>http://www.daniweb.com/forums/thread236278.html</link>
			<pubDate>Thu, 05 Nov 2009 13:53:22 GMT</pubDate>
			<description><![CDATA[I swear, those things are like shurikens in these masses... 
I'm trying to make a loan calculator in python, as part of an assignment. I'm basing it off of two things. 
1: This website, which contains 3 different calculators. (http://www.efunda.com/formulae/finance/loan_calculator.cfm) 
2: The link...]]></description>
			<content:encoded><![CDATA[<div>I swear, those things are like shurikens in these masses...<br />
I'm trying to make a loan calculator in python, as part of an assignment. I'm basing it off of two things.<br />
1: <a rel="nofollow" class="t" href="http://www.efunda.com/formulae/finance/loan_calculator.cfm" target="_blank">This website, which contains 3 different calculators.</a><br />
2: <a rel="nofollow" class="t" href="http://www.efunda.com/math/num_rootfinding/num_rootfinding.cfm#Newton_Raphson" target="_blank">The link from the second calculator (my current pain)</a><br />
I'm going to have a panic attack, I swear... So many parentheses.<br />
I had to manually derive for the Newton-Raphson portion... and of course, now I have so many frekaing parentheses that I can't tell what the heck I'm doing... I mean, sure, I might be a little parenthesis-happy, but I'm new to this and I want to make sure my groupings are all correct...<br />
 <pre style="margin:20px; line-height:13px">def findInterestRate():<br />
&nbsp; &nbsp; loanAmount = raw_input(&quot;Please enter the loan amount: &quot;)<br />
&nbsp; &nbsp; monthlyPayment = raw_input(&quot;Please enter the monthly payment: &quot;)<br />
&nbsp; &nbsp; numberMonths = raw_input(&quot;Please enter the number of months: &quot;)<br />
&nbsp; &nbsp; # YAY complications.<br />
&nbsp; &nbsp; finderGuess = (2((numberMonths*monthlyPayment)-loanAmount))/(numberMonths*monthlyPayment)<br />
&nbsp; &nbsp; while zeroFindings != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; zeroFindings = ((finderGuess*((1+finderGuess)^numberMonths))/(((1+finderGuess)^numberMonths)-1))-(monthlyPayment/loanAmount)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ziggy == 1 and zeroFindings != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # now to show off the x~k+1 = x~k - f(x~k)/f`(x~k)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Yes, the ~ denotes the subscript with the k.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finderGuess = finderGuess - ((((finderGuess*((1+finderGuess)^numberMonths))/(((1+finderGuess)^numberMonths)-1))-<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (monthlyPayment/loanAmount))/(((((1+finderGuess)^numberMonths)-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (finderguess*(numberMonths*((1+finderGuess)^(numberMonths-1)))+<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (1+finderGuess)^((finderGuess*(1+finderGuess)^numberMonths)*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (numberMonths*((1+finderGuess)^(numberMonths-1)))))/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ((((1+finderGuess)^numberMonths)-1)^2))))<br />
&nbsp; &nbsp; &nbsp; &nbsp; ziggy = 1<br />
&nbsp; &nbsp; answer = finderGuess<br />
&nbsp; &nbsp; print &quot;Your interest rate should be: &quot; + str(answer)</pre>Rabblerousers I hate this whole enters thing with parentheses... only way I can see it all in the window...<br />
Takes up a whole freaking lot...<br />
Does little to soothe my pains...<br />
...<br />
Can I get at least one person to help me double-check this, I feel like I'm missing things.<br />
Especially after realizing that I had accidentally hit control+backspace at one point and it erased a small portion at one spot... which means I might have done it multiple times...<br />
<br />
And of course, I'm hoping and praying that I get this fixed as I know this will bite my rear in the end if I messed this part up of all things.<br />
<br />
Edit: It would be nice if the GUI had color-coded parentheses, to show groupings... or better yet, shading of a similar method...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>PixelHead777</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236278.html</guid>
		</item>
		<item>
			<title>Can Python do this?</title>
			<link>http://www.daniweb.com/forums/thread236214.html</link>
			<pubDate>Thu, 05 Nov 2009 09:31:04 GMT</pubDate>
			<description>Hi, 
 
I am reading data from a file. The data is mostly text, but has a small bit of binary in it, as well as a linefeed at the end of every block of text. Can Python read all of it and write it to another file, while not changing the binary or the linefeed? 
 
I have tried looking around online,...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am reading data from a file. The data is mostly text, but has a small bit of binary in it, as well as a linefeed at the end of every block of text. Can Python read all of it and write it to another file, while not changing the binary or the linefeed?<br />
<br />
I have tried looking around online, but couldn't find the answer. Daniweb is on of the best Forums out there, so I am asking it here.<br />
:|<br />
<br />
Also, is there anyway in Python that you can test whether or not a line of data is binary?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P00dle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236214.html</guid>
		</item>
		<item>
			<title>Interesting dilemma - See if you can help.</title>
			<link>http://www.daniweb.com/forums/thread236165.html</link>
			<pubDate>Thu, 05 Nov 2009 07:02:19 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I have stumbled on an interesting problem. I have thought 'n' thought, but haven't come up with any good ideas of how to handle this. 
 
I have a text file that contains many records, but without the records being seperated. I need to figure out how to seperate these files, or at least how...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have stumbled on an interesting problem. I have thought 'n' thought, but haven't come up with any good ideas of how to handle this.<br />
<br />
I have a text file that contains many records, but without the records being seperated. I need to figure out how to seperate these files, or at least how to write a program that recognizes different records and can then seperate them.<br />
<br />
I don't expect anyone to write my program for me, but I need help seperating the records.<br />
<br />
The beginning of every record looks like this:  MSUBUGA JIMSON<br />
                                                                        P O BOX 21273<br />
                                                                        GABORONE<br />
(Obviously they are all different, but always have 3 values on 3 lines.)<br />
The end looks like this:<br />
P107.17         P0.00       P225.08        P0.00       P332.25<br />
(The numbers always vary, but there are always 5)<br />
<br />
Any help will be greatly appreciated, Thank you.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P00dle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236165.html</guid>
		</item>
		<item>
			<title>Number 1 most possible frustrating situation</title>
			<link>http://www.daniweb.com/forums/thread236122.html</link>
			<pubDate>Thu, 05 Nov 2009 02:55:58 GMT</pubDate>
			<description><![CDATA[Okay, the encryption algorithm idea was stupid. But I still made an encryption program. I got the absolute most possible frustrating situation. The program doesn't work in the console window. It spits out a giant error (probably recursion judging how many errors it got), but it DOES work in IDLE....]]></description>
			<content:encoded><![CDATA[<div>Okay, the encryption algorithm idea was stupid. But I still made an encryption program. I got the absolute most possible frustrating situation. The program doesn't work in the console window. It spits out a giant error (probably recursion judging how many errors it got), but it DOES work in IDLE. So the only way to fix it is manually see the error, which I've tried to do again and again with no success. So, the error comes after you input the message. So here's the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">import os<br />
import random<br />
<br />
if os.name == &quot;nt&quot;:<br />
&nbsp; &nbsp; os.system(&quot;color 48&quot;)<br />
&nbsp; &nbsp; os.system(&quot;title Encryptor/Decryptor&quot;)<br />
&nbsp; &nbsp; def clear():<br />
&nbsp; &nbsp; &nbsp; &nbsp; os.system(&quot;cls&quot;)<br />
else:<br />
&nbsp; &nbsp; def clear():<br />
&nbsp; &nbsp; &nbsp; &nbsp; os.system(&quot;clear&quot;)<br />
<br />
def menu():<br />
&nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; print (&quot;Encryptor/Decryptor&quot;)<br />
&nbsp; &nbsp; print (&quot;-------------------&quot;)<br />
&nbsp; &nbsp; print (&quot;1) Encrypt Message &quot;)<br />
&nbsp; &nbsp; print (&quot;2) Decrypt Message &quot;)<br />
&nbsp; &nbsp; print (&quot;-------------------&quot;)<br />
&nbsp; &nbsp; menu_choice = input (&quot;Choose one: &quot;)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; if menu_choice != &quot;1&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if menu_choice != &quot;2&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Please type a valid choice!&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menu()<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; if menu_choice == &quot;1&quot;: encrypt()<br />
&nbsp; &nbsp; if menu_choice == &quot;2&quot;: decrypt()<br />
&nbsp; &nbsp; <br />
def encrypt():<br />
&nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; print (&quot;------------------------------------&quot;)<br />
&nbsp; &nbsp; print (&quot;1) Use computer generated number key&quot;)<br />
&nbsp; &nbsp; print (&quot;2) Manually key&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;)<br />
&nbsp; &nbsp; print (&quot;------------------------------------&quot;)<br />
&nbsp; &nbsp; encrypt_choice = input (&quot;Choose one: &quot;)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; if encrypt_choice == &quot;1&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; key = list(str(random.random()).split(&quot;.&quot;)[1])<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; key = list(str(input(&quot;Please type key: &quot;)))<br />
<br />
&nbsp; &nbsp; show = &quot;&quot;<br />
&nbsp; &nbsp; while 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (show)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Type S to show key, H to hide key&nbsp; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Type R to change key&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;-----------------------------------&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; message = list(input (&quot;Please type a message to be encrypted: &quot;))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if &quot;&quot;.join(message).lower() == &quot;s&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show = str(&quot;Key is: &quot; + str(&quot;&quot;.join(key)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue<br />
&nbsp; &nbsp; &nbsp; &nbsp; if &quot;&quot;.join(message).lower() == &quot;r&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encrypt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if &quot;&quot;.join(message).lower() == &quot;h&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show = &quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; break<br />
<br />
<br />
&nbsp; &nbsp; while len(key) &lt; len(message):<br />
&nbsp; &nbsp; &nbsp; &nbsp; key += key<br />
<br />
&nbsp; &nbsp; spaces = 0<br />
&nbsp; &nbsp; encrypt_list = []<br />
&nbsp; &nbsp; shift = 1<br />
&nbsp; &nbsp; for loop in range((len(message))):<br />
&nbsp; &nbsp; &nbsp; &nbsp; shift += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; if str(message[loop]) == ' ':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spaces += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if str(message[loop]) == '&nbsp; ':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spaces += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ''<br />
&nbsp; &nbsp; &nbsp; &nbsp; if str(message[loop]) != ' ':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if str(message[loop]) != '&nbsp; ':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if str(message[loop]) == str(key[loop-spaces]):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encrypt_list.append(message[loop])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (shift % 2) == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop_ord = str(chr(ord(key[loop-spaces])+ord(message[loop])))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ord(str(message[loop])) &lt; ord(str(key[loop-spaces])):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop_ord = &quot;9u&quot; + str(chr(ord(key[loop-spaces])-ord(message[loop])))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop_ord = chr(ord(message[loop])-ord(key[loop-spaces]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encrypt_list.append(loop_ord)<br />
<br />
&nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; print (&quot;Encrypted message is: &quot;, &quot;&quot;.join(encrypt_list))<br />
&nbsp; &nbsp; if show == &quot;&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; ask = input (&quot;Show key before leaving(Y/N): &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ask.lower() == &quot;y&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print (&quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Key is: &quot; + str(&quot;&quot;.join(key)))<br />
&nbsp; &nbsp; input ()<br />
&nbsp; &nbsp; menu()<br />
<br />
def decrypt():<br />
&nbsp; &nbsp; menu()<br />
<br />
menu()</pre><br />
Help would GREATLY be appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>AutoPython</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236122.html</guid>
		</item>
		<item>
			<title>Importing Graphics Module</title>
			<link>http://www.daniweb.com/forums/thread236120.html</link>
			<pubDate>Thu, 05 Nov 2009 02:54:00 GMT</pubDate>
			<description>Greetings!   
 
I am in need of some techincal assistance.  My problem is as follows: 
 
In my Programming class, we are starting to use the graphics package in Python.  We are using a module called graphics.py   
 
In order to use this module, we have to save it to the desktop and import it in our...</description>
			<content:encoded><![CDATA[<div>Greetings!  <br />
<br />
I am in need of some techincal assistance.  My problem is as follows:<br />
<br />
In my Programming class, we are starting to use the graphics package in Python.  We are using a module called graphics.py  <br />
<br />
In order to use this module, we have to save it to the desktop and import it in our program (i.e., from graphics import *).  However, this only works on the computers at school; when I attempt to import the graphics module on my personal computer, an error message appears stating that the graphics module cannot be found.<br />
<br />
When asked, my Prof. stated that I need to place it some place that Python can find it.  Needless-to-say, it's not working.  <br />
<br />
Can anybody who is more savvy with Python tell me how to do this?  I am at a lose and about to pull my hair out.<br />
<br />
Thank you.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>SMIFMD</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236120.html</guid>
		</item>
		<item>
			<title>Help with beginner question</title>
			<link>http://www.daniweb.com/forums/thread236084.html</link>
			<pubDate>Wed, 04 Nov 2009 23:33:29 GMT</pubDate>
			<description>I am interested in learning python and picked up a friends textbook to try and work through it. I have no cs experience so am pretty clueless. I am having difficulty with one of the problems in the first chapter lol. i am trying to make the program spit out a loop of 8 numbers based on a simple...</description>
			<content:encoded><![CDATA[<div>I am interested in learning python and picked up a friends textbook to try and work through it. I have no cs experience so am pretty clueless. I am having difficulty with one of the problems in the first chapter lol. i am trying to make the program spit out a loop of 8 numbers based on a simple algorithm. Here is the code:<br />
<br />
def main():<br />
    print &quot;This program illustrates a chaotic function.&quot;<br />
    print &quot;Please enter two numbers between 0 and 1.&quot;<br />
    x = input (&quot;Enter first number: &quot;)<br />
    y = input (&quot;Enter second number: &quot;)<br />
    print<br />
    print &quot;input&quot;, x, y<br />
    print &quot;-----------------&quot;<br />
<br />
    for i in range (8):<br />
        x = 3.9 * x * (1 - x)<br />
    for i in range(8):<br />
        y = 3.9 * y * (1 - y) <br />
        print x, y<br />
<br />
main()<br />
<br />
output:<br />
<br />
This program illustrates a chaotic function.<br />
Please enter two numbers between 0 and 1.<br />
Enter first number: .25<br />
Enter second number: .25<br />
<br />
input 0.25 0.25<br />
-----------------<br />
0.540417912062 0.73125<br />
0.540417912062 0.76644140625<br />
0.540417912062 0.698135010439<br />
0.540417912062 0.82189581879<br />
0.540417912062 0.570894019197<br />
0.540417912062 0.955398748364<br />
0.540417912062 0.166186721954<br />
0.540417912062 0.540417912062<br />
&gt;&gt;&gt; <br />
<br />
the first loop is only spitting out the last calculation repeatedly whereas the second is computing correctly so im a bit confused... any help would be appreciated<br />
thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>newportking</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236084.html</guid>
		</item>
		<item>
			<title>Limiting mouse movement</title>
			<link>http://www.daniweb.com/forums/thread236081.html</link>
			<pubDate>Wed, 04 Nov 2009 23:17:00 GMT</pubDate>
			<description>How would I limit mouse movement in python?  For example I have a 480x480 grid where each block is 30.  If I click on a block I would like to only be able to click in an area of one block around the block that I placed.</description>
			<content:encoded><![CDATA[<div>How would I limit mouse movement in python?  For example I have a 480x480 grid where each block is 30.  If I click on a block I would like to only be able to click in an area of one block around the block that I placed.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>nerdagent</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236081.html</guid>
		</item>
		<item>
			<title>Converting a dictionary into a list of (key, value) tuples</title>
			<link>http://www.daniweb.com/forums/thread236071.html</link>
			<pubDate>Wed, 04 Nov 2009 22:35:33 GMT</pubDate>
			<description><![CDATA[Ideally I'd like to do it with a list comprehension. Something like this   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>Ideally I'd like to do it with a list comprehension. Something like this  <pre style="margin:20px; line-height:13px">result = [(key, value)for key in dict.keys(), value in dict.values()]</pre> but clearly that isn't the right format. Any suggestions?<br />
<br />
EDIT:<br />
<br />
This seems like what I want to do, but it doesn't work:<br />
 <pre style="margin:20px; line-height:13px">result = [(dict.keys[i], dict.values[i]) for i in range(1, len(dict))]</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>tdeck</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236071.html</guid>
		</item>
		<item>
			<title><![CDATA[Vpython error won't run any programs]]></title>
			<link>http://www.daniweb.com/forums/thread236055.html</link>
			<pubDate>Wed, 04 Nov 2009 21:01:42 GMT</pubDate>
			<description><![CDATA[I have downloaded vpython and try to run one of the examples included with the program.   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code...]]></description>
			<content:encoded><![CDATA[<div>I have downloaded vpython and try to run one of the examples included with the program.  <pre style="margin:20px; line-height:13px">from visual import *<br />
<br />
floor = box(length=4, height=0.5, width=4, color=color.blue)<br />
<br />
ball = sphere(pos=(0,4,0), color=color.red)<br />
ball.velocity = vector(0,-1,0)<br />
<br />
dt = 0.01<br />
while 1:<br />
&nbsp; &nbsp; rate(100)<br />
&nbsp; &nbsp; ball.pos = ball.pos + ball.velocity*dt<br />
&nbsp; &nbsp; if ball.y &lt; 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; ball.velocity.y = -ball.velocity.y<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; ball.velocity.y = ball.velocity.y - 9.8*dt</pre> but this is the error I get <br />
 <pre style="margin:20px; line-height:13px">Traceback (most recent call last):<br />
&nbsp; File &quot;C:\Python26\Lib\site-packages\visual\examples\bounce.py&quot;, line 1<br />
&nbsp; &nbsp; from visual import *<br />
&nbsp; File &quot;C:\Python26\lib\site-packages\visual\__init__.py&quot;, line 59<br />
&nbsp; &nbsp; import cvisual<br />
AttributeError: 'Boost.Python.StaticProperty' object attribute '__doc__' is read-only<br />
&gt;&gt;&gt;</pre>, when I run it on my dell inspiron 1525 laptop with windows vista. I have tried it on another computer and have seen it work, but would like it to work on my laptop. I have the relatively latest 2.6.3 python installed on the laptop. And have tried uninstalling python and vpython a couple of times but the error continues does anyone have any ideas how to fix this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>johndb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236055.html</guid>
		</item>
		<item>
			<title>HELP! Return URLs in redirect chain</title>
			<link>http://www.daniweb.com/forums/thread236048.html</link>
			<pubDate>Wed, 04 Nov 2009 19:53:40 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I'm stuck with a certain problem. I'm using URLLIB2 to get the end url of a list of links. This was pretty straightforward. Some of the links I'm probing pass through 1 or more other urls before landing the user at the end destination. 
 
For example, the start url might be 1, but then you...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I'm stuck with a certain problem. I'm using URLLIB2 to get the end url of a list of links. This was pretty straightforward. Some of the links I'm probing pass through 1 or more other urls before landing the user at the end destination.<br />
<br />
For example, the start url might be 1, but then you only end up at 3 after a quick and probably unnoticeable redirect to 2:<br />
<br />
 <pre style="margin:20px; line-height:13px">1. http://click.someurl.net/script?query=somedata<br />
2. http://bridge.url.net/redirect?url=http://thenewurl.com<br />
3. http://thenewurl.com</pre><br />
In my code url 1 is passed to my function, and url 3 is returned, but how do I capture/return any URL in between the start and end points?<br />
<br />
Thanks in advance for any help!<br />
<br />
LB</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>LB22</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236048.html</guid>
		</item>
		<item>
			<title>python cgi?</title>
			<link>http://www.daniweb.com/forums/thread236031.html</link>
			<pubDate>Wed, 04 Nov 2009 18:54:19 GMT</pubDate>
			<description><![CDATA[Hi, i currently have these 2 files: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>Hi, i currently have these 2 files:<br />
<br />
 <pre style="margin:20px; line-height:13px">#!C:\Python26\python.exe<br />
<br />
#index.py<br />
print 'Content-type: text/html\n\n'<br />
print '&lt;html&gt;&lt;head&gt;'<br />
print '&lt;title&gt;My Page&lt;/title&gt;'<br />
print '&lt;/head&gt;&lt;body&gt;'<br />
print '&lt;h1&gt;Powers of two&lt;/h1&gt;\n&lt;ol&gt;'<br />
print '&lt;form action=&quot;sqr.py&quot; method=&quot;post&quot;&gt;'<br />
print '&lt;label&gt;How many numbers?&lt;/label&gt;'<br />
print '&lt;input type=&quot;text&quot; name=&quot;b&quot;/&gt;'<br />
print '&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;'</pre><br />
and<br />
<br />
 <pre style="margin:20px; line-height:13px">#!C:\Python26\python.exe<br />
#sqr.py<br />
import cgi<br />
a = cgi.FieldStorage()<br />
b = a[&quot;b&quot;]<br />
print 'Content-type: text/html\n\n'<br />
print '&lt;html&gt;&lt;head&gt;'<br />
print '&lt;title&gt;My Page&lt;/title&gt;'<br />
print '&lt;/head&gt;&lt;body&gt;'<br />
print '&lt;h1&gt;Powers of two&lt;/h1&gt;\n&lt;ol&gt;'<br />
for n in range(1,b):<br />
&nbsp; &nbsp; print '&lt;li&gt;'+str(2**n)+'&lt;/li&gt;'<br />
print '&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;'</pre><br />
and it produces reasonable responses, except for when i press enter the page only shows the powers of two part, what can I do to fix this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>leegeorg07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236031.html</guid>
		</item>
		<item>
			<title>Generating random nos without using random module</title>
			<link>http://www.daniweb.com/forums/thread235986.html</link>
			<pubDate>Wed, 04 Nov 2009 15:01:28 GMT</pubDate>
			<description>I have to write a code for generating random numbers without using random module and its function. 
How do I do it? I tried using the system time as it keeps on changing (importing milli seconds) but with tht I am able to get random nos in the range of thousand only.</description>
			<content:encoded><![CDATA[<div>I have to write a code for generating random numbers without using random module and its function.<br />
How do I do it? I tried using the system time as it keeps on changing (importing milli seconds) but with tht I am able to get random nos in the range of thousand only.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>sanchitgarg</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235986.html</guid>
		</item>
		<item>
			<title>Comparing two files line by line</title>
			<link>http://www.daniweb.com/forums/thread235938.html</link>
			<pubDate>Wed, 04 Nov 2009 11:26:59 GMT</pubDate>
			<description>Hi, 
I am comparing 2000 files with one other file. I want the program to go through each line in both files and compare. If the line is present, then it has to write to another file. What I tried was to open both the files and use readlines() to read into an list. Then I used for loop like this: 
...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
I am comparing 2000 files with one other file. I want the program to go through each line in both files and compare. If the line is present, then it has to write to another file. What I tried was to open both the files and use readlines() to read into an list. Then I used for loop like this:<br />
 <pre style="margin:20px; line-height:13px">chain_sep=[]<br />
complex_file=open (&quot;1complex.txt&quot;, &quot;r&quot;) <br />
complex_lines = complex_file.readlines()<br />
complex_lines = map(string.strip, complex_lines)<br />
splitter = [s.split('\t') for s in complex_lines]<br />
complex_file.close()&nbsp; &nbsp; &nbsp; <br />
<br />
for file in os.listdir(&quot;.&quot;):<br />
&nbsp; &nbsp; basename=os.path.basename(file)<br />
&nbsp; &nbsp; if basename.endswith(&quot;.pd&quot;):<br />
&nbsp; &nbsp; &nbsp; &nbsp; chain_sep.append(basename)<br />
for (i,s) in izip(chain_sep,splitter):<br />
&nbsp; &nbsp; fhandle_6 =open (i, &quot;r&quot;)<br />
&nbsp; &nbsp; from_pd = fhandle_6.readlines()<br />
&nbsp; &nbsp; from_pd = map(string.strip,from_pd)<br />
&nbsp; &nbsp; fhandle_6.close()<br />
&nbsp; &nbsp; fhandle_13 = open(s[0]+&quot;.cr&quot;, 'r')<br />
&nbsp; &nbsp; fhandle_13_l = fhandle_13.readlines()<br />
&nbsp; &nbsp; fhandle_13_l = map(string.strip, fhandle_13_l)<br />
&nbsp; &nbsp; fhandle_13.close()<br />
&nbsp; &nbsp; fopen_7=open (i+&quot;r.pdb&quot;, &quot;w&quot;)<br />
&nbsp; &nbsp; fopen_8=open (i+&quot;l.pdb&quot;, &quot;w&quot;)<br />
&nbsp; &nbsp; for (a,y) in izip(from_pd,fhandle_13_l): #from_pd and fhandle_13_l is not of the same length :(<br />
&nbsp; &nbsp; if a[0:4]==&quot;ATOM&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if a[21] == &quot;R&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &gt;&gt;fopen_7, a<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if a[7:13]==y[7:13]:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &gt;&gt;fopen_8, a<br />
fopen_7.close()<br />
fopen_8.close()</pre>The above code is only a chunk btw. My problem is that both the files are not of the same size so I feel using zip or izip is not ideal in this situation. A part or the file I have to deal with is below:<br />
 <pre style="margin:20px; line-height:13px">file-1<br />
ATOM&nbsp;  2197&nbsp; <span style="font-weight:bold">CB&nbsp; CYS I&nbsp; 51</span>&nbsp; &nbsp; &nbsp; 38.091 -13.002&nbsp;  6.320&nbsp; 1.00 20.12<br />
ATOM&nbsp;  2198&nbsp; <span style="font-weight:bold">SG&nbsp; CYS I&nbsp; 51</span>&nbsp; &nbsp; &nbsp; 39.781 -12.827&nbsp;  5.691&nbsp; 1.00 26.67<br />
ATOM&nbsp;  2199&nbsp; <span style="font-weight:bold">N&nbsp;  MET I&nbsp; 52</span>&nbsp; &nbsp; &nbsp; 37.845 -15.766&nbsp;  5.722&nbsp; 1.00 33.08<br />
ATOM&nbsp;  2200&nbsp; <span style="font-weight:bold">CA&nbsp; MET I&nbsp; 52</span>&nbsp; &nbsp; &nbsp; 38.312 -17.144&nbsp;  5.674&nbsp; 1.00 33.08</pre> <pre style="margin:20px; line-height:13px">file-2<br />
ATOM&nbsp;  2197&nbsp; <span style="font-weight:bold">O&nbsp;  ASP L&nbsp; 50</span>&nbsp; &nbsp; &nbsp; 18.653&nbsp; 89.329&nbsp; 84.802&nbsp; 1.00&nbsp; 0.00<br />
ATOM&nbsp;  2198&nbsp; <span style="font-weight:bold">CB&nbsp; ASP L&nbsp; 50</span>&nbsp; &nbsp; &nbsp; 16.004&nbsp; 87.278&nbsp; 84.523&nbsp; 1.00&nbsp; 0.00<br />
ATOM&nbsp;  2199&nbsp; <span style="font-weight:bold">CG&nbsp; ASP L&nbsp; 50</span>&nbsp; &nbsp; &nbsp; 15.349&nbsp; 86.109&nbsp; 85.277&nbsp; 1.00&nbsp; 0.00<br />
ATOM&nbsp;  2200&nbsp; <span style="font-weight:bold">OD1 ASP L&nbsp; 50</span>&nbsp; &nbsp; &nbsp; 15.347&nbsp; 85.935&nbsp; 86.514&nbsp; 1.00&nbsp; 0.00</pre>The only part that is common to both files is the one in bold (the above is just a chunk of a code). So ideally I am supposed to compare the bold data from file 1 and if it exists in file 2, I have to retain it and remove the remaining data.<br />
For e.g.:<br />
 <pre style="margin:20px; line-height:13px"><span style="font-weight:bold">CB&nbsp; CYS I&nbsp; 51</span><br />
<span style="font-weight:bold">CB&nbsp; CYS I&nbsp; 51</span></pre>If the above entry is there in both files then I gotto retain it in file-2 and remove all other entries. I tried to add the required list position to the sample code you gave me but I failed to get the results. Please let me know if I can differentiate the above data and if so how can I do it? I tried the same in perl and I am able to do it very easily but the same in python is becoming tougher for me as I am very new to python (learning for the past week or so)<br />
Cheers,<br />
Chav</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>chavanak</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235938.html</guid>
		</item>
		<item>
			<title>Please help me get past this problem</title>
			<link>http://www.daniweb.com/forums/thread235933.html</link>
			<pubDate>Wed, 04 Nov 2009 10:40:22 GMT</pubDate>
			<description><![CDATA[Hi.  
 
First, I'll explain my task: 
I have 4 text files. 3 of the files contain xml tags and content. The 4th is empty. 
I need to read the 3 files, and write them to the 4th file. The reason for having 3 files is that the first and the last files both only have to be used once. The 2nd file has...]]></description>
			<content:encoded><![CDATA[<div>Hi. <br />
<br />
First, I'll explain my task:<br />
I have 4 text files. 3 of the files contain xml tags and content. The 4th is empty.<br />
I need to read the 3 files, and write them to the 4th file. The reason for having 3 files is that the first and the last files both only have to be used once. The 2nd file has to be repeated a user-specified amount of times. <br />
<br />
Initially my problem was that I had \'s in the text, and didnt know how to use regular expressions to escape them. That as been solved via DaniWeb :)<br />
<br />
I have since advanced the code a bit, but am now stuck again. The body(2nd text file) needs to be repeated a certain amount of times. This can be done with a counter. Easy. The problem is that the xml in the text file contains an &quot;id&quot; tag that needs to hold the count value for every repition, in order to be unique. I can't figure out how to use regular expressions to find that tag and give it the value. Let's pretend the tag looks like this: &lt;%%&gt;CNT1&lt;/%%&gt;<br />
<br />
I need to replace &lt;%%&gt;CNt1&lt;/%%&gt; with <br />
&lt;id&gt;&quot;value of count&quot;&lt;/id&gt;<br />
<br />
My code, so far, looks like this:<br />
 <pre style="margin:20px; line-height:13px">import re<br />
special = re.compile(r&quot;\\&quot;)<br />
<br />
# This section writes the prefix to the text file<br />
foo = open(&quot;PREFIX.txt&quot;, &quot;r+&quot;)<br />
text = foo.read()<br />
foo.close()<br />
<br />
def escape(match):<br />
&nbsp; &nbsp; return &quot;\\&quot; + match.group(0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
#if __name__ == &quot;__main__&quot;: &lt;-- might need this in the future<br />
out = open(&quot;2Bxml.txt&quot;, &quot;w&quot;)<br />
out.writelines(special.sub(escape, text))<br />
out.writelines(&quot;\n&quot;)<br />
out.close()<br />
<br />
count1 = int(raw_input(&quot;Specify the number of repitations(e.g. \&quot;1000\&quot; will count from 1 to 999)&quot;))<br />
<br />
# This sections writes the suffix to the text file<br />
foo3 = open(&quot;SUFFIX.txt&quot;, &quot;r+&quot;)<br />
text3 = foo3.read()<br />
foo3.close()<br />
<br />
def escape(match):<br />
&nbsp; &nbsp; return &quot;\\&quot; + match.group(0)<br />
<br />
out3 = open(&quot;2Bxml.txt&quot;, &quot;a&quot;) # This must append, not just write<br />
out3.writelines(special.sub(escape, text3))<br />
out3.close()</pre>Its works just fine. Can I use the existing regular expression code to do what I need to? Please help!<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P00dle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235933.html</guid>
		</item>
		<item>
			<title>Array Index Issue</title>
			<link>http://www.daniweb.com/forums/thread235895.html</link>
			<pubDate>Wed, 04 Nov 2009 09:02:28 GMT</pubDate>
			<description>Hi, Below is my output: 
 
 
 
FF      0 CMA:       0 IPMI port 
DE   15E0 TTA:    1 Generic Com port 
DD   15D0 TTB:    2 Generic Com port 
DC   15C0 SEA:   3 ACPI System Event 
FF      0               1 MFPCI 
DB   15B0 DQA:   2 CMD 649 IDE/ATA Controller</description>
			<content:encoded><![CDATA[<div>Hi, Below is my output:<br />
<br />
<br />
<br />
FF      0 CMA:       0 IPMI port<br />
DE   15E0 TTA:    1 Generic Com port<br />
DD   15D0 TTB:    2 Generic Com port<br />
DC   15C0 SEA:   3 ACPI System Event<br />
FF      0               1 MFPCI<br />
DB   15B0 DQA:   2 CMD 649 IDE/ATA Controller<br />
DA   15A0 EIA:    3 Intel 82557 LOM (Fast Ethernet)<br />
D9   1590 OHA:  1 NEC OHCI USB Controller<br />
D8   1580 OHB:   1 NEC OHCI USB Controller<br />
D7   1570 EHA:   1 NEC EHCI USB Controller<br />
FF      0               1 MFPCI<br />
D6   1560 EWA:  2 BCM5701 LOM (Gigabit Ethernet)<br />
D5   1550 PKA:   1 LSI Logic 1030 U320<br />
D4   1540 PKB:   1 LSI Logic 1030 U320<br />
D3   1530 PKC:   4 Smart Array 6400 series<br />
D2   1520 PKD:   5 Smart Array 6400 series<br />
FF      0               1 MFPCI<br />
D1   1510 GHA:  2 ATI Radeon 7000<br />
DF   15F0           1 1291103C.1290103C (&lt;...&lt;...)<br />
DF   15F0 SRA:   1 Console Serial Line Driver<br />
<br />
From this output I want get only 0,1,2,3,1,2,3,1,1,1,1,2,1,1,4,5,1,2,1,1 only when I am printing 3 array index then some cases I am getting MFPCI and 1291103C.1290103C. Please let me know how can I get this value??????</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>krishna_sicsr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235895.html</guid>
		</item>
		<item>
			<title><![CDATA[I don't know what is causing this error...please help]]></title>
			<link>http://www.daniweb.com/forums/thread235893.html</link>
			<pubDate>Wed, 04 Nov 2009 08:44:58 GMT</pubDate>
			<description><![CDATA[Hi 
 
I am ery new to Python. I've only started using it yesterday. Please keep that in mind, as the error might seem simple to you, but I can't understand it. 
 
I am trying to run the following piece of code: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>Hi<br />
<br />
I am ery new to Python. I've only started using it yesterday. Please keep that in mind, as the error might seem simple to you, but I can't understand it.<br />
<br />
I am trying to run the following piece of code:<br />
 <pre style="margin:20px; line-height:13px">import re<br />
<br />
foo = open(&quot;PREFIX.txt&quot;, &quot;r+&quot;)<br />
text = foo.read&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  # Read in from file<br />
foo.close()<br />
<br />
special = re.compile(r&quot;[etn]&quot;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Not sure what this does. <br />
<br />
def escape(match):&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Specifies that any \ has to be escaped<br />
&nbsp; &nbsp; return &quot;\\&quot; + match.group(0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; out = open(&quot;WRITE.txt&quot;, &quot;w&quot;)<br />
&nbsp; &nbsp; out.write(special.sub(escape, text))&nbsp; &nbsp; &nbsp; &nbsp;  # Write to file<br />
&nbsp; &nbsp; out.close()</pre><br />
When I check the code using Python's built-in checker, everyhitng checks out fine. However, when I use the console to run the code, the following text is all that appears(It doesnt write to the file):<br />
<br />
Traceback (most recent call last):<br />
    File &quot;advanced.py&quot;, line 14, in (module)<br />
        out.write(special.sub(escape, text))<br />
TypeError: expected string of buffer<br />
<br />
I don't know if this is vital information: the file I am reading from contains XML, but it is in a text file, so I assumed it would handle everything as text. The goal of the code is to escape the backslashes in the XML.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P00dle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235893.html</guid>
		</item>
		<item>
			<title>Help with string formatting</title>
			<link>http://www.daniweb.com/forums/thread235880.html</link>
			<pubDate>Wed, 04 Nov 2009 07:37:07 GMT</pubDate>
			<description>Hi, 
 
I need to read input from 2 different files, take text from both, combine it, then print it to a third file. That part is easy. What I have a problem with is that some of the text I read in have special characters that need to be escaped. 
 
How can I handle those characters? 
 
Any help...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I need to read input from 2 different files, take text from both, combine it, then print it to a third file. That part is easy. What I have a problem with is that some of the text I read in have special characters that need to be escaped.<br />
<br />
How can I handle those characters?<br />
<br />
Any help would be appreciated, but I would obviously prefer a snippet of code I could use.<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P00dle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235880.html</guid>
		</item>
		<item>
			<title>problem in installing wxwidgets...</title>
			<link>http://www.daniweb.com/forums/thread235862.html</link>
			<pubDate>Wed, 04 Nov 2009 05:45:23 GMT</pubDate>
			<description><![CDATA[Hello friends, 
                     I've tried to install wxwidgets in my mandriva 2009 spring for GUI interaction with python. In the installation instruction it said that i need gtk+ library. So i downloaded GTK+. When i configured GTK+ i got the message 
 
checking for BASE_DEPENDENCIES......]]></description>
			<content:encoded><![CDATA[<div>Hello friends,<br />
                     I've tried to install wxwidgets in my mandriva 2009 spring for GUI interaction with python. In the installation instruction it said that i need gtk+ library. So i downloaded GTK+. When i configured GTK+ i got the message<br />
<br />
checking for BASE_DEPENDENCIES... configure: error: Package requirements (glib-2.0 &gt;= 2.21.3    atk &gt;= 1.13.0    pango &gt;= 1.20    cairo &gt;= 1.6) were not met:<br />
<br />
Requested 'glib-2.0 &gt;= 2.21.3' but version of GLib is 2.20.1<br />
<br />
Consider adjusting the PKG_CONFIG_PATH environment variable if you<br />
installed software in a non-standard prefix.<br />
<br />
Alternatively, you may set the environment variables BASE_DEPENDENCIES_CFLAGS<br />
and BASE_DEPENDENCIES_LIBS to avoid the need to call pkg-config.<br />
See the pkg-config man page for more details.<br />
<br />
Then i downloaded glib2.21.3,atk 1.13.0,pango 1.20 and cairo 1.6. I installed all the packages using the following commands.<br />
<br />
tar xvzf filename.tar.gz<br />
cd folder<br />
./configure<br />
make<br />
make install<br />
<br />
I've not specified any options like --prefix and i installed in the folder itself.<br />
when i tried to install gtk+ after installing all this it showed the same error. What should i do to install wxwidgets? Thanks and regards...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>python.noob</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235862.html</guid>
		</item>
		<item>
			<title>Help with Pascal Triangle Program Please</title>
			<link>http://www.daniweb.com/forums/thread235843.html</link>
			<pubDate>Wed, 04 Nov 2009 03:53:46 GMT</pubDate>
			<description><![CDATA[I need to write a program that uses the following function 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help...]]></description>
			<content:encoded><![CDATA[<div>I need to write a program that uses the following function<br />
<br />
 <pre style="margin:20px; line-height:13px">def pascnext( L ):<br />
&nbsp; &nbsp; currentrow = []<br />
&nbsp; &nbsp; if len( L ) == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [1]<br />
&nbsp; &nbsp; if len( L ) == 1 and L[ 0 ] == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [ 1, 1 ]<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentrow += [ 1 ]<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in range( 0, len( L ) - 1 ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentrow += [ L[ i ] + L[ i + 1 ] ]<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentrow += [ 1 ]<br />
&nbsp; &nbsp; &nbsp; &nbsp; return currentrow</pre><br />
I need to write another function pascrow(n) where n is a row number in the triangle and returns what that row is in a list.  I need pascrow(n) to use the pascnext function though to find it.  Any suggestions or help is appreciated!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>frank_albers123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235843.html</guid>
		</item>
		<item>
			<title>Back with more dumb questions!</title>
			<link>http://www.daniweb.com/forums/thread235808.html</link>
			<pubDate>Wed, 04 Nov 2009 00:14:53 GMT</pubDate>
			<description>Is there a method that, say, for example... you open a file, and usually the cursor would be at the end right? Is there a function or method that would set the cursor back to the beginning of the file?  
 
Thanks!</description>
			<content:encoded><![CDATA[<div>Is there a method that, say, for example... you open a file, and usually the cursor would be at the end right? Is there a function or method that would set the cursor back to the beginning of the file? <br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Kolz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235808.html</guid>
		</item>
		<item>
			<title>Need help please!</title>
			<link>http://www.daniweb.com/forums/thread235807.html</link>
			<pubDate>Wed, 04 Nov 2009 00:10:35 GMT</pubDate>
			<description><![CDATA[I'm having trouble with my lab for a computer class. The problem is as stated:  
Design a program that generates 100 random numbers, and keeps a count of how many of those random numbers are even and how many are odd. 
 
Can someone please help me out with this?]]></description>
			<content:encoded><![CDATA[<div>I'm having trouble with my lab for a computer class. The problem is as stated: <br />
Design a program that generates 100 random numbers, and keeps a count of how many of those random numbers are even and how many are odd.<br />
<br />
Can someone please help me out with this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Norua</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235807.html</guid>
		</item>
		<item>
			<title>python tic tac toe game.</title>
			<link>http://www.daniweb.com/forums/thread235772.html</link>
			<pubDate>Tue, 03 Nov 2009 21:38:17 GMT</pubDate>
			<description>i am a beginner. i have no idea how i can make Tic Tac Toe game. 
 
please help me. 
 
Question #1 
Extend program  
To use arrays 
For a 5*5 Tic Tac Toe game. 
(wins are 5 Horizontal, 5 Vertical, 5 Diagonal)</description>
			<content:encoded><![CDATA[<div>i am a beginner. i have no idea how i can make Tic Tac Toe game.<br />
<br />
please help me.<br />
<br />
Question #1<br />
Extend program <br />
To use arrays<br />
For a 5*5 Tic Tac Toe game.<br />
(wins are 5 Horizontal, 5 Vertical, 5 Diagonal)<br />
<br />
Question #2<br />
Extend to 4*4 array<br />
(But wins are any 3 Horizontal, 3 Vertical, 3 Diagonal)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>logon84</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235772.html</guid>
		</item>
		<item>
			<title>With with Pascals Triangle Program</title>
			<link>http://www.daniweb.com/forums/thread235765.html</link>
			<pubDate>Tue, 03 Nov 2009 21:22:39 GMT</pubDate>
			<description><![CDATA[I am writing a program in python where in the function I input a row in Pascals triangle and the function returns the NEXT row in the triangle.  Below is what I have so far and am getting really frustrate...I'm new at this and bad at iterating things.  Can you help me finish my program? 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I am writing a program in python where in the function I input a row in Pascals triangle and the function returns the NEXT row in the triangle.  Below is what I have so far and am getting really frustrate...I'm new at this and bad at iterating things.  Can you help me finish my program?<br />
<br />
 <pre style="margin:20px; line-height:13px">def pascnext(L):<br />
&nbsp; &nbsp; currentrow = []<br />
&nbsp; &nbsp; if L == []:<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [1]<br />
&nbsp; &nbsp; if L == [1]:<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [1,1]<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in L:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentrow[i] = L[i] + L[i-1]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return currentrow</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>frank_albers123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235765.html</guid>
		</item>
		<item>
			<title>Py_INCREF / Py_DECREF</title>
			<link>http://www.daniweb.com/forums/thread235756.html</link>
			<pubDate>Tue, 03 Nov 2009 20:40:21 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I have a problem because I did not realy get yet when do Py_INCREF or to Py_DECREF.  
I build a class type that covers a PyObject*-Array. Now I wrote a function like that: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have a problem because I did not realy get yet when do Py_INCREF or to Py_DECREF. <br />
I build a class type that covers a PyObject*-Array. Now I wrote a function like that:<br />
 <pre style="margin:20px; line-height:13px">static PyObject *<br />
get_first(MyObject *self) {<br />
&nbsp; &nbsp; PyObject *res = NULL;<br />
&nbsp; &nbsp; if (!self-&gt;size)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return NULL;<br />
<br />
&nbsp; &nbsp; res = self-&gt;items[0];<br />
&nbsp; &nbsp; // Py_INCREF(res);<br />
&nbsp; &nbsp; return res;<br />
}</pre><br />
I don't really know why I should use Py_INCREF(res) but if I don't do it I'll get a segmentation fault after calling the function several times. This doesn't happen if i put in a Py_INCREF(res).<br />
I thought I don't have to care about what the user does with the result. Do I always have to Py_INCREF my results???</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>sneek</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235756.html</guid>
		</item>
		<item>
			<title>File to dictionary</title>
			<link>http://www.daniweb.com/forums/thread235727.html</link>
			<pubDate>Tue, 03 Nov 2009 18:40:03 GMT</pubDate>
			<description><![CDATA[If I have a file that has a content of this kind: 
a,b 
c,d 
e,f 
g,h 
 
I need to make a list of the letters in the first column, i.e., [a, c, e, g]. I wrote some code which prints these letters but I don't know how to put them into a list. Here is the code: 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>If I have a file that has a content of this kind:<br />
a,b<br />
c,d<br />
e,f<br />
g,h<br />
<br />
I need to make a list of the letters in the first column, i.e., [a, c, e, g]. I wrote some code which prints these letters but I don't know how to put them into a list. Here is the code:<br />
 <pre style="margin:20px; line-height:13px">def file_to_dict(f):<br />
&nbsp; &nbsp; for line in f:<br />
&nbsp; &nbsp; &nbsp; &nbsp; columns = line.split(&quot;,&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print columns[0]</pre><br />
Your help is appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pyprog</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235727.html</guid>
		</item>
		<item>
			<title>File size is increased after pickle</title>
			<link>http://www.daniweb.com/forums/thread235635.html</link>
			<pubDate>Tue, 03 Nov 2009 11:31:04 GMT</pubDate>
			<description><![CDATA[I'm reading in a file and sending the data (once encrypted) to a dictionary, with a hash of the data before and after encryption. I then pickle the dictionary but find the file size is massive compared to the source file size. If I write the encrypted data straight to a file the size is identical...]]></description>
			<content:encoded><![CDATA[<div>I'm reading in a file and sending the data (once encrypted) to a dictionary, with a hash of the data before and after encryption. I then pickle the dictionary but find the file size is massive compared to the source file size. If I write the encrypted data straight to a file the size is identical to the source. Any idea why my pickled file is so large?<br />
<br />
 <pre style="margin:20px; line-height:13px">#Encrypt data and get hashes&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def encryptAndExportFile(self, key, inFile, outFile):<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; openInFile = open(inFile,&quot;rb&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFileSize = os.path.getsize(inFile)<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFileData = openInFile.readlines()<br />
&nbsp; &nbsp; &nbsp; &nbsp; openInFile.close()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot; initialise cipher &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cipher = AES.new(key, AES.MODE_CFB)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot; initialise MD5 &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; m = hashlib.md5() #hash<br />
&nbsp; &nbsp; &nbsp; &nbsp; h = hashlib.md5() #hash of encrypted dataq<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; encryptedData = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for data in inFileData:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m.update(data) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encData = cipher.encrypt(data)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; h.update(encData)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encryptedData.append(encData)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; hashResult = m.digest()<br />
&nbsp; &nbsp; &nbsp; &nbsp; encHashResult = h.digest()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return hashResult, encryptedData, encHashResult</pre><br />
 <pre style="margin:20px; line-height:13px">def storeEncryptedObject(self, obj, path):<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; outFile = open(path, 'wb')<br />
&nbsp; &nbsp; &nbsp; &nbsp; pickle.dump(obj, outFile)<br />
&nbsp; &nbsp; &nbsp; &nbsp; outFile.close()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>zyrus001</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235635.html</guid>
		</item>
		<item>
			<title>Parsing Problem</title>
			<link>http://www.daniweb.com/forums/thread235634.html</link>
			<pubDate>Tue, 03 Nov 2009 11:27:51 GMT</pubDate>
			<description><![CDATA[f = \ 
  ''' 
Product:  DECNET        Node:  ALETHA               Address(es):  1.1 
Product:  TCP/IP        Node:  aletha.ind.hp.com    Address(es):  15.146.239.174 
''' 
lines = f.split('\n') 
i = 1 
  
###### To get the IP Address(es) 
adapter_config = True]]></description>
			<content:encoded><![CDATA[<div>f = \<br />
  '''<br />
Product:  DECNET        Node:  ALETHA               Address(es):  1.1<br />
Product:  TCP/IP        Node:  aletha.ind.hp.com    Address(es):  15.146.239.174<br />
'''<br />
lines = f.split('\n')<br />
i = 1<br />
 <br />
###### To get the IP Address(es)<br />
adapter_config = True<br />
for line in lines:<br />
    if adapter_config:<br />
       # print line<br />
        import re<br />
        if (re.match(&quot;^Product:\s+&quot;,line)):<br />
            line1=re.split(&quot;\s+&quot;,line)<br />
            print line1[5]<br />
<br />
<br />
I want to parse IP Address (15.146.239.174) from the above output,  but in my script in line1[5] I am getting 1.1 and 15.146.239.174 both. How can I get only 15.146.239.174 thru my script.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>krishna_sicsr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235634.html</guid>
		</item>
		<item>
			<title>Pumpkin Weight Help</title>
			<link>http://www.daniweb.com/forums/thread235566.html</link>
			<pubDate>Tue, 03 Nov 2009 05:26:02 GMT</pubDate>
			<description><![CDATA[Could someone lend me their brain? :D I thought I had most of it done, until I got an error saying that my 'calcAverage' definition was not defined.. x.x here is the prompt for the program:  
 
Write a program that asks the user how many pumpkin weights they have, and then reads that many pumpkin...]]></description>
			<content:encoded><![CDATA[<div>Could someone lend me their brain? :D I thought I had most of it done, until I got an error saying that my 'calcAverage' definition was not defined.. x.x here is the prompt for the program: <br />
<br />
Write a program that asks the user how many pumpkin weights they have, and then reads that many pumpkin weights, printing each weight with a comment (heavy is 70 pounds or higher, light is below 50, normal is everything inbetween), averages them, and displays the average with three decimal places. Use functions, one of which must be calcAverage(totalWeight, numPumpkins) to average the input values. <br />
<br />
 <pre style="margin:20px; line-height:13px">def main():<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; intro()<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; pumpkinData()<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; calcAverage(totalWeight, numPumpkins)<br />
<br />
&nbsp; &nbsp; printResults(numPumpkins, avgWeight)<br />
<br />
main()<br />
<br />
def intro():<br />
&nbsp; &nbsp; print &quot;Program to calculate the average of a&quot;<br />
&nbsp; &nbsp; print &quot;group of pumpkin weights.&quot;<br />
&nbsp; &nbsp; print &quot;You will be asked to enter the number of&quot;<br />
&nbsp; &nbsp; print &quot;pumpkins, followed by each pumpkin weight.&quot;<br />
&nbsp; &nbsp; print &quot;Written by Kristy Barner.&quot;<br />
&nbsp; &nbsp; print<br />
<br />
def pumpkinData():<br />
&nbsp; &nbsp; numPumpkins = input(&quot;Enter the number of pumpkins: &quot;)<br />
&nbsp; &nbsp; print<br />
&nbsp; &nbsp; print<br />
&nbsp; &nbsp; totalWeight = 0<br />
&nbsp; &nbsp; count = 0<br />
&nbsp; &nbsp; for i in range(numPumpkins):<br />
&nbsp; &nbsp; &nbsp; &nbsp; count = count + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; pumpkinWeight = input(&quot;Enter the weight for pumpkin &quot;+str(count)+&quot;: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; totalWeight = total + pumpkinWeight<br />
&nbsp; &nbsp; &nbsp; &nbsp; if pumpkinWeight &lt; 50.000:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print str(pumpkinWeight)+&quot; is light&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if pumpkinWeight &lt; 70.000:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print str(pumpkinWeight)+&quot; is normal&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print str(pumpkinWeight)+&quot; is heavy&quot;<br />
&nbsp; &nbsp; return numPumpkins<br />
&nbsp; &nbsp; return totalWeight<br />
<br />
def calcAverage(totalWeight, numPumpkins):<br />
&nbsp; &nbsp; avgWeight = float(totalWeight) / float(numPumpkins)<br />
&nbsp; &nbsp; return avgWeight<br />
<br />
def printResults(numPumpkins, avgWeight):<br />
&nbsp; &nbsp; print &quot;The average weight for &quot;+str(numPumpkins)+&quot; is &quot;+str(avgWeight)</pre><br />
<br />
<br />
Thanks very much in advance!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>topcat712</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235566.html</guid>
		</item>
		<item>
			<title>Pygame question2</title>
			<link>http://www.daniweb.com/forums/thread235539.html</link>
			<pubDate>Tue, 03 Nov 2009 03:17:08 GMT</pubDate>
			<description><![CDATA[Python beginner try to learn pygame. Here is a program I made for random color circles popping out.  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>Python beginner try to learn pygame. Here is a program I made for random color circles popping out. <br />
<br />
 <pre style="margin:20px; line-height:13px">import pygame, random<br />
pygame.init()<br />
X = 680<br />
Y = 460<br />
def main():<br />
&nbsp; &nbsp; screen = pygame.display.set_mode((X,Y))<br />
&nbsp; &nbsp; pygame.display.set_caption('circles')<br />
&nbsp; &nbsp; background = pygame.Surface(screen.get_size())<br />
&nbsp; &nbsp; background = background.convert()<br />
&nbsp; &nbsp; background.fill(pygame.color.Color('white'))<br />
&nbsp; &nbsp; run = True<br />
&nbsp; &nbsp; clock = pygame.time.Clock()<br />
&nbsp; &nbsp; while run:<br />
&nbsp; &nbsp; &nbsp; &nbsp; clock.tick(30)<br />
&nbsp; &nbsp; &nbsp; &nbsp; for event in pygame.event.get():&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.QUIT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run = False<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif event.type == pygame.KEYDOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == pygame.K_q:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run = False<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for count in range(50):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r = random.randint(1,40)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = random.randint(1,X)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b = random.randint(1, Y)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = random.randint(1, 255)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = random.randint(1, 255)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e = random.randint(1, 255)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pygame.draw.circle(background, (c,d,e), (a,b), r, 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(background, (0,0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pygame.display.flip()&nbsp; &nbsp; &nbsp; &nbsp; <br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; main()</pre><br />
It is pretty, I was excited. Now I want to make all circle fly, my goal is, to make random color circles randomly pop out and then fly toward the top of the window. So of course it will include the code that y -= something. However I tried different ways, none worked out, so here is my code for only one circle going up. Please give me some advice on how to make a lot of these circles pop out from random place and then go up.<br />
<br />
Thanks. Here is my code for one sucessful flying circle.<br />
<br />
 <pre style="margin:20px; line-height:13px">import pygame, random<br />
pygame.init()<br />
X = 680<br />
Y = 460<br />
def main():<br />
&nbsp; &nbsp; screen = pygame.display.set_mode((X,Y))<br />
&nbsp; &nbsp; pygame.display.set_caption('circles')<br />
&nbsp; &nbsp; background = pygame.Surface(screen.get_size())<br />
&nbsp; &nbsp; background = background.convert()<br />
&nbsp; &nbsp; background.fill(pygame.color.Color('white'))<br />
&nbsp; &nbsp; run = True<br />
&nbsp; &nbsp; clock = pygame.time.Clock()<br />
<br />
&nbsp; &nbsp; a = random.randint(1,X)<br />
&nbsp; &nbsp; b = random.randint(1, Y)<br />
&nbsp; &nbsp; color1 = random.randint(1, 255)<br />
&nbsp; &nbsp; color2 = random.randint(1, 255)<br />
&nbsp; &nbsp; color3 = random.randint(1, 255)<br />
&nbsp; &nbsp; radius = random.randint(10,40)<br />
<br />
&nbsp; &nbsp; while run:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; clock.tick(30)<br />
&nbsp; &nbsp; &nbsp; &nbsp; background.fill(pygame.color.Color('white'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for event in pygame.event.get():&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.QUIT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run = False<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif event.type == pygame.KEYDOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == pygame.K_q:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run = False<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; pygame.draw.circle(background, (color1,color2,color3),\<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (a,b), radius, 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; b-=10<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; screen.blit(background, (0,0))&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; pygame.display.flip()&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>FengG</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235539.html</guid>
		</item>
		<item>
			<title>Need helping writing Prime number code</title>
			<link>http://www.daniweb.com/forums/thread235518.html</link>
			<pubDate>Tue, 03 Nov 2009 01:22:59 GMT</pubDate>
			<description><![CDATA[Newbie Here  
 
Edit: This is not homework, I am a chemical engineering student and a math minor. I'm doing programming on the side to help me automate certain calculations later in my career. Also always had a healthy interest in programming. I just read the not doing homework for people sticky at...]]></description>
			<content:encoded><![CDATA[<div>Newbie Here <br />
<br />
Edit: This is not homework, I am a chemical engineering student and a math minor. I'm doing programming on the side to help me automate certain calculations later in my career. Also always had a healthy interest in programming. I just read the not doing homework for people sticky at the top and want to throw out there i'm not a computer programming student.<br />
<br />
I'm creating a program to create list of prime numbers code. It has taught me a good amount about recursions statements and how while statements can be used to maximize performance for given recursion limits.<br />
<br />
My problem is I can only search a range of ~ 1000 numbers before the recursion limit is reached. I know there is some basic improvements I can do but my current concerns:<br />
<br />
1. The program recurs the program Prime(x) with program Prime(x+1) to check the next x value across the interval [x,x+970]. Finding all prime numbers over that interval. However, I can't find out how to define the upper bound x+970 since recurring Prime(x+1) increases the upper bound. <br />
So how can I create a fixed upper bound with only one variable being inputted, x.<br />
<br />
2. Is their a way to have the program run for the interval clear the stack, than run the next interval [x+971,x+970+971] if an interval greater than the recursion limit was desired? Till a single number is too large for the platform I would expect there to be a way around the recursion limit.<br />
<br />
This is one of my first independent programs and I just couldn't find good answers to these questions. <br />
 <pre style="margin:20px; line-height:13px">def Prime(x):<br />
&nbsp; n=2<br />
&nbsp;<span style="font-weight:bold"> if x &gt; 972:</span> #My upper limit is 972 and my lower limit is x,&nbsp; <br />
&nbsp; &nbsp; &nbsp; print &quot;end&quot;&nbsp; &nbsp; &nbsp; &nbsp; #how do I make the upper limit a function of x<br />
&nbsp; elif x == 1:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # when I have to recur Prime(x+1)?<br />
&nbsp; &nbsp; Prime(x+1)<br />
&nbsp; elif x == 2:<br />
&nbsp; &nbsp; print (2)<br />
&nbsp; &nbsp; Prime(x+1) <br />
&nbsp; elif x &lt;= 0:<br />
&nbsp; &nbsp; print (&quot;Number must be a positive integer&quot;)<br />
&nbsp; else:<br />
&nbsp; &nbsp; while n &lt; n+1:<br />
&nbsp; &nbsp; &nbsp; if n &gt; int(x/n):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print(x)<br />
&nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; elif x%n==0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; n=n+1<br />
&nbsp; &nbsp; Prime(x+1)</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ChaseRLewis</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235518.html</guid>
		</item>
		<item>
			<title>loop problem</title>
			<link>http://www.daniweb.com/forums/thread235513.html</link>
			<pubDate>Tue, 03 Nov 2009 00:59:27 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>Python Syntax</strong>...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px"># Reading the .csv file<br />
<br />
energyFile = open(&quot;EnergySources.csv&quot;,&quot;r&quot;)<br />
<br />
stateDict = {}<br />
for line in energyFile:<br />
&nbsp; &nbsp; line = line.strip()<br />
&nbsp; &nbsp; fields = line.split(&quot;,&quot;)<br />
&nbsp; &nbsp; if fields[0] == &quot;State&quot; or fields[0] == &quot;&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; continue<br />
&nbsp; &nbsp; state = fields[0]<br />
&nbsp; &nbsp; total = fields[-1]<br />
&nbsp; &nbsp; float(''.join(total))<br />
&nbsp; &nbsp; coal = fields[1]<br />
&nbsp; &nbsp; float(''.join(coal))<br />
&nbsp; &nbsp; naturalgas = fields[2]<br />
&nbsp; &nbsp; float(''.join(naturalgas))<br />
&nbsp; &nbsp; petroleum = fields[3]<br />
&nbsp; &nbsp; float(''.join(petroleum))<br />
&nbsp; &nbsp; nuclear = fields[4]<br />
&nbsp; &nbsp; float(''.join(nuclear))<br />
&nbsp; &nbsp; hydroelectric = fields[5]<br />
&nbsp; &nbsp; float(''.join(hydroelectric))<br />
&nbsp; &nbsp; biomass = fields[6]<br />
&nbsp; &nbsp; float(''.join(biomass))<br />
&nbsp; &nbsp; geothermal = fields[7]<br />
&nbsp; &nbsp; float(''.join(geothermal))<br />
&nbsp; &nbsp; interstate = fields[8]<br />
&nbsp; &nbsp; float(''.join(interstate))<br />
&nbsp; &nbsp; other = fields[9]<br />
&nbsp; &nbsp; float(''.join(other))<br />
&nbsp; &nbsp; Statename = state<br />
&nbsp; &nbsp; stateDict[Statename] = coal,naturalgas,petroleum,nuclear,hydroelectric,biomass,geothermal,interstate,other<br />
while True:<br />
&nbsp; &nbsp; query = raw_input('''<br />
1:Coal<br />
2:Natural gas<br />
3:Petroleum<br />
4:Nuclear<br />
5:Hydroelectric<br />
6:Biomass<br />
7:Geothermal<br />
8:Interstate imports<br />
\nPick an energy source (ex.2): ''')<br />
<span style="font-weight:bold">&nbsp; &nbsp; if query not in (&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Not a valid choice&quot;)<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; query2=int(query)</span><br />
<br />
&nbsp; &nbsp; query1 = raw_input(&quot;Pick a state (ex.California): &quot;)&nbsp; <br />
&nbsp; &nbsp; # Check to see if it's coal<br />
&nbsp; &nbsp; if query1 in stateDict and query2==1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Coal:&quot;,stateDict[query1][0]<br />
&nbsp; &nbsp; #Check to see if it's natural gas<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Natural Gas:&quot;,stateDict[query1][1]<br />
&nbsp; &nbsp; #Check to see if it's petroleum<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][2]<br />
&nbsp; &nbsp; #Check to see if it's nuclear<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][3]<br />
&nbsp; &nbsp; #Check to see if it's hydroelectric<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][4]<br />
&nbsp; &nbsp; #Check to see if it's biomass<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==6:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][5]<br />
&nbsp; &nbsp; #Check to see if it's geothermal<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==7:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][6]<br />
&nbsp; &nbsp; #Check to see if it's interstate<br />
&nbsp; &nbsp; elif query1 in stateDict and query2==8:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # extract the data from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; print stateDict[query1][7]<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;\nNot Valid Input. Please Try Again!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
energyFile.close()</pre><br />
at the part where it's bolded im trying to make it loop back to ask the question of the user does not input the numbers 1-9 but when user input 10 it just says not a valid input and  it just goes down to the next loop. can someone help me fix this probelm so that it goes back up and ask the same question until it gets 1-9?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>vnproduktionz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235513.html</guid>
		</item>
		<item>
			<title>palindrome</title>
			<link>http://www.daniweb.com/forums/thread235485.html</link>
			<pubDate>Mon, 02 Nov 2009 22:04:43 GMT</pubDate>
			<description>how to check if the string is pallindrome or not in python??</description>
			<content:encoded><![CDATA[<div>how to check if the string is pallindrome or not in python??</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>kisan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235485.html</guid>
		</item>
		<item>
			<title>Removing a substring from string</title>
			<link>http://www.daniweb.com/forums/thread235467.html</link>
			<pubDate>Mon, 02 Nov 2009 20:46:56 GMT</pubDate>
			<description><![CDATA[I am trying to remove a specific substring from a string... Here are the doctests. I'm just absolutely stumped. Can someone point me in the right direction on where to start? 
 
def remove(sub, s): 
     
    """ 
      >>> remove('an', 'banana') 
      'bana' 
      >>> remove('cyc', 'bicycle') 
 ...]]></description>
			<content:encoded><![CDATA[<div>I am trying to remove a specific substring from a string... Here are the doctests. I'm just absolutely stumped. Can someone point me in the right direction on where to start?<br />
<br />
def remove(sub, s):<br />
    <br />
    &quot;&quot;&quot;<br />
      &gt;&gt;&gt; remove('an', 'banana')<br />
      'bana'<br />
      &gt;&gt;&gt; remove('cyc', 'bicycle')<br />
      'bile'<br />
      &gt;&gt;&gt; remove('iss', 'Mississippi')<br />
      'Mippi'<br />
    &quot;&quot;&quot;<br />
<br />
<br />
def remove_all(sub, s):<br />
    &quot;&quot;&quot;<br />
      &gt;&gt;&gt; remove('an', 'banana')<br />
      'ba'<br />
      &gt;&gt;&gt; remove('cyc', 'bicycle')<br />
      'bile'<br />
      &gt;&gt;&gt; remove('iss', 'Mississippi')<br />
      'Mippi'<br />
    &quot;&quot;&quot;<br />
<br />
<br />
if __name__ == '__main__':<br />
    import doctest<br />
    doctest.testmod()</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>wrobl1rt</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235467.html</guid>
		</item>
		<item>
			<title>Need help with a 3d exporter</title>
			<link>http://www.daniweb.com/forums/thread235340.html</link>
			<pubDate>Mon, 02 Nov 2009 12:35:15 GMT</pubDate>
			<description>If anyone is interested in helping with creating a mesh exporter I could really use the help.  Willing to pay royalties that the exporter will receive when released for purchase.   
Please email for more information. 
seth at vandigital dot com 
 
Thanks, 
Seth Richardson</description>
			<content:encoded><![CDATA[<div>If anyone is interested in helping with creating a mesh exporter I could really use the help.  Willing to pay royalties that the exporter will receive when released for purchase.  <br />
Please email for more information.<br />
seth at vandigital dot com<br />
<br />
Thanks,<br />
Seth Richardson</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>vandigital</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235340.html</guid>
		</item>
		<item>
			<title>i would pay money for the help</title>
			<link>http://www.daniweb.com/forums/thread235293.html</link>
			<pubDate>Mon, 02 Nov 2009 08:54:54 GMT</pubDate>
			<description><![CDATA[hi, i have an assignment due after 4 hours 
i'm willng to pay money for solving the assignment  
here is the assignment link 
SNIP 
row data: SNIP 
i'm serious about paying money  
and here's my email: SNIP]]></description>
			<content:encoded><![CDATA[<div>hi, i have an assignment due after 4 hours<br />
i'm willng to pay money for solving the assignment <br />
here is the assignment link<br />
SNIP<br />
row data: SNIP<br />
i'm serious about paying money <br />
and here's my email: SNIP</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>tototo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235293.html</guid>
		</item>
		<item>
			<title>problem with some functions</title>
			<link>http://www.daniweb.com/forums/thread235291.html</link>
			<pubDate>Mon, 02 Nov 2009 08:40:51 GMT</pubDate>
			<description><![CDATA[Hi  
 
I'm trying to write some functions.  
 
This first function is suppose to help shuffle two strings which are the same length into the correct word. 
So the output would be something like: 
 
After shuffling the first string som and the second string trs the word is storms. 
 
Here is my code...]]></description>
			<content:encoded><![CDATA[<div>Hi <br />
<br />
I'm trying to write some functions. <br />
<br />
This first function is suppose to help shuffle two strings which are the same length into the correct word.<br />
So the output would be something like:<br />
<br />
After shuffling the first string som and the second string trs the word is storms.<br />
<br />
Here is my code now:<br />
I don't know if I'm starting this correctly, hopefully I am though. Problem with this is that I don't know how to rearrange the a[] and b[] to reorder it in order from [0] onwards.<br />
 <pre style="margin:20px; line-height:13px">def reorder(a, b):<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; returns a &quot;shuffled&quot; version of a + b: <br />
&nbsp; &nbsp; something like a[0] + b[0] + a[1] + b[1] + a[2] + b[2] + so on...<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
<br />
&nbsp; &nbsp; reorder_str = a + b<br />
&nbsp; &nbsp; for i in range(len(reorder_str)):<br />
&nbsp; &nbsp; &nbsp; &nbsp; reorder_str = a[i] + b[i]<br />
&nbsp; &nbsp; return reorder_str<br />
<br />
<br />
#Testing function:<br />
<br />
first_str = &quot;som&quot;<br />
second_str = &quot;trs&quot;<br />
<br />
final = reorder(a, b)<br />
<br />
print &quot;After shuffling the first string &quot; +str(first_str) + &quot; and the second string&quot; + &quot; &quot; +&nbsp; str(second_str) + &quot; the word is&quot; + &quot; &quot; + str(reorder) + &quot;.&quot;</pre><br />
<br />
The second function I'm trying to create is to find even numbers within a list and return a new list that only gives the elements divisible by 2.<br />
The original list itself should not be changed though.<br />
So for example:<br />
<br />
lista = [1,2,5,6,7]<br />
evenlist = even_list(lista) <br />
<br />
print lista<br />
print evenlist<br />
<br />
[1,2,5,6,7]<br />
[2, 6]<br />
<br />
My code right now is: <br />
(The problem I have here is that I don't know how to output the new list with only even numbers)<br />
 <pre style="margin:20px; line-height:13px">def even_list(a):<br />
&nbsp; &nbsp; &quot;&quot;&quot; <br />
&nbsp; &nbsp; original list will remain unchanged and the new list will only<br />
&nbsp; &nbsp; return the integers that are even<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
<br />
&nbsp; &nbsp; lista = []<br />
&nbsp; &nbsp; for i in range(len(lista)):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if i % 2 == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lista = lista % 2<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; return lista<br />
<br />
<br />
#Testing the function<br />
<br />
lista = [1,2,5,6,7]<br />
evenlist = even_list(lista) <br />
<br />
print lista<br />
print evenlist</pre><br />
<br />
Thanks for any help/hints/explanation/suggestions.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>saikeraku</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235291.html</guid>
		</item>
		<item>
			<title>some help please. (still learning)</title>
			<link>http://www.daniweb.com/forums/thread235263.html</link>
			<pubDate>Mon, 02 Nov 2009 06:28:42 GMT</pubDate>
			<description><![CDATA[here's what i currently got 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div>...]]></description>
			<content:encoded><![CDATA[<div>here's what i currently got<br />
 <pre style="margin:20px; line-height:13px"># Reading the .csv file<br />
<br />
energyFile = open(&quot;EnergySources.csv&quot;,&quot;r&quot;)<br />
<br />
stateDict = {}<br />
for line in energyFile:<br />
&nbsp; &nbsp; line = line.strip()<br />
&nbsp; &nbsp; fields = line.split(&quot;,&quot;)<br />
&nbsp; &nbsp; if fields[0] == &quot;State&quot; or fields[0] == &quot;&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; continue<br />
&nbsp; &nbsp; state = fields[0]<br />
<br />
&nbsp; &nbsp; total = fields[-1]<br />
&nbsp; &nbsp; float(''.join(total))<br />
&nbsp; &nbsp; coal = fields[1]<br />
&nbsp; &nbsp; float(''.join(coal))<br />
&nbsp; &nbsp; naturalgas = fields[2]<br />
&nbsp; &nbsp; float(''.join(naturalgas))<br />
&nbsp; &nbsp; petroleum = fields[3]<br />
&nbsp; &nbsp; float(''.join(petroleum))<br />
&nbsp; &nbsp; nuclear = fields[4]<br />
&nbsp; &nbsp; float(''.join(nuclear))<br />
&nbsp; &nbsp; hydroelectric = fields[5]<br />
&nbsp; &nbsp; float(''.join(hydroelectric))<br />
&nbsp; &nbsp; biomass = fields[6]<br />
&nbsp; &nbsp; float(''.join(biomass))<br />
&nbsp; &nbsp; geothermal = fields[7]<br />
&nbsp; &nbsp; float(''.join(geothermal))<br />
&nbsp; &nbsp; interstate = fields[8]<br />
&nbsp; &nbsp; float(''.join(interstate))<br />
&nbsp; &nbsp; other = fields[9]<br />
&nbsp; &nbsp; float(''.join(other))<br />
<br />
for i in range(10):<br />
&nbsp; &nbsp; state1=state[i]<br />
<br />
while True:<br />
&nbsp; &nbsp; answer= raw_input(&quot;Pick a state&quot;)<br />
&nbsp; &nbsp; if answer == &quot;&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; if answer in stateDict:<br />
&nbsp; &nbsp; &nbsp; &nbsp; dataList=state1<br />
&nbsp; &nbsp; &nbsp; &nbsp; state=dataList[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; print state<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not valid&quot; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<br />
<br />
&nbsp;  <br />
energyFile.close()<br />
j</pre><br />
here is the assignment<br />
 <pre style="margin:20px; line-height:13px">In this project we will do a data analysis and visualization project, producing maps like the one in the picture above. The map shows millions of BTUs of energy per capits produced by coal in each state in 2007. Why the heck do they burn so much coal in Wyoming?<br />
<br />
The data comes from two Web sites. The Energy Information Administration is a Federal agency that keeps statistics on energy. The file we're using comes from their overview page. To correct for the populations of the different states, we'll also use the list of state populations from Wikipedia.<br />
<br />
Finally, we'll actually make the map using IBM's Many Eyes visualization service. This cool Web site lets up upload a table of data, and then choose different ways of visualizing it.<br />
<br />
The two files we are using are: <br />
EnergySources.csv <br />
StatePopulations.txt <br />
We've taken a preliminary look at both files in class. You do not need to hand in these two files, the TAs will have them when they grade the programs.<br />
<br />
Your program should read the data from the two files, and write out a third file, sources.tsv, which you should upload to Many Eyes to make the visualization.<br />
<br />
Working in Pairs<br />
<br />
You may do this program with a partner. Both you and your partner should hand in the same program. Your partner may be in a different section. Be sure that your program identifies BOTH partners at the top of the file, by name and student ID number. You may do the program by yourself if you want.<br />
If you work with a partner, you should get together, sit down, and work at the same computer. That way you'll both learn the things you'll need to know to pass the tests. If you let your partner do all the work, you will end up failing the midterm (and, probably, your partner will be very annoyed).<br />
<br />
Steps in the Project<br />
<br />
We'll do this project in eight steps. After the first four, you'll have a program that is partially working, and you will hand that in on Tues, Nov. 3. On Tues. Nov 10, the whole program, together with your map, will be due. We will only grade the whole program, but if you failed to hand in the partial program, it will cost you points, and if you hand in the partial but not the final program, you can get some partial credit.<br />
The basic structure of the program is the two-loop &quot;build a data structure and do something with it&quot; structure we have been considering in the last two lectures. In these steps, I recommend that you print things out as you go along; none of this printing should appear in the final program, but it will help you figure out whether you have the pieces working as you go along.<br />
<br />
Step 1: Read in the energy data. Open the file EnergySources.csv, read through it using a for loop (see the example from the 10/26 lecture on the lectures and readings page), print out each line, and then close it.<br />
Step 2: Break each line up and print out first the name of the state, and then each energy source with labels, for instance: <br />
<br />
Alabama: Coal, 888.4; Natuarl Gas, 431.4; ... <br />
<br />
Convert the numbers to floating point before printing them out.<br />
Step 3: Modify your program so that instead of printing out the data it puts it into a dictionary. Use the name of the state as the key, and for the data, have a list containing all the sources of energy, and the total. Have your program print out the dictionary, and check it.<br />
Step 4: Write a loop that lets the user ask questions. Offer the user this menu: <br />
<br />
Pick an energy source:<br />
1: Coal<br />
2: Natural gas<br />
3: Petroleum<br />
4: Nuclear<br />
5: Hydroelectric<br />
6: Biomass<br />
7: Geothermal<br />
8: Interstate imports<br />
<br />
<br />
Then have them enter the name of a state. In both cases, the program should loop until the user gives a good input.<br />
Step 4: Answer the user's question by looking up the item in the dictionary. Find the list for the requested state, and then the right item in the list.</pre><br />
 <pre style="margin:20px; line-height:13px">http://www.cs.ucdavis.edu/~amenta/f09/StatePopulations.txt<br />
http://www.cs.ucdavis.edu/~amenta/f09/ecs10.html</pre><br />
im creating a program that will use my data and organize it in a way that allow user to input something and come up with the answer. i know that i need to make a dictionary list but im not sure how. can i just get some input of where to go and some help</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>vnproduktionz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235263.html</guid>
		</item>
		<item>
			<title>Pygame question</title>
			<link>http://www.daniweb.com/forums/thread235247.html</link>
			<pubDate>Mon, 02 Nov 2009 04:42:16 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>Python Syntax</strong>...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">import pygame<br />
<br />
pygame.init()<br />
<br />
<br />
<br />
<br />
def main():<br />
<br />
&nbsp; &nbsp; screen = pygame.display.set_mode((640, 480))<br />
&nbsp; &nbsp; pygame.display.set_caption('game')<br />
<br />
&nbsp; &nbsp; background = pygame.Surface(screen.get_size())<br />
&nbsp; &nbsp; background = background.convert()<br />
&nbsp; &nbsp; background.fill(pygame.color.Color('yellow'))<br />
<br />
<br />
&nbsp; &nbsp; box = pygame.Surface((100,100))<br />
&nbsp; &nbsp; box = box.convert()<br />
&nbsp; &nbsp; box.fill(pygame.color.Color('red'))<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; t = True<br />
&nbsp; &nbsp; clock = pygame.time.Clock()<br />
<br />
&nbsp; &nbsp; while t:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for event in pygame.event.get():<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.QUIT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = False<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif event.type == pygame.MOUSEBUTTONDOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; posi = pygame.mouse.get_pos()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'mous down', posi<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(box,posi)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif event.type == pygame.MOUSEBUTTONUP:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'mouse up', pygame.mouse.get_pos()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; screen.blit(background, (0,0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; pygame.display.flip()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
main()</pre><br />
<br />
I just start to learn pygame. I want to make a box when I click mouse in the background, but I don't see a box from this code. also in this statement :  for event in pygame.event.get():  how many event will actually be taken every time in this for loop? This is where I got confused the most. Thank you in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>FengG</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235247.html</guid>
		</item>
		<item>
			<title>Python CGI vs PHP</title>
			<link>http://www.daniweb.com/forums/thread235243.html</link>
			<pubDate>Mon, 02 Nov 2009 04:17:31 GMT</pubDate>
			<description><![CDATA[I am currently reading two books, one on PHP and one on Python. Not that I'M good at ether. I'M about half way through the book on PHP or less and almost done with the one on Python. Though I haven't actually read anything web related in this particular Python book, I am aware that it can do web...]]></description>
			<content:encoded><![CDATA[<div>I am currently reading two books, one on PHP and one on Python. Not that I'M good at ether. I'M about half way through the book on PHP or less and almost done with the one on Python. Though I haven't actually read anything web related in this particular Python book, I am aware that it can do web programming. My question is, which is better. Could I should I go ahead and drop the book on PHP considering that Python can do web programming as well as regular computer programming? Or does PHP have enough of an advantage to keep it up as well? Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Garrett85</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235243.html</guid>
		</item>
		<item>
			<title>Ceasar Cipher</title>
			<link>http://www.daniweb.com/forums/thread235219.html</link>
			<pubDate>Mon, 02 Nov 2009 02:41:58 GMT</pubDate>
			<description><![CDATA[Can anybody help me out on creating the ceasar cipher.  I am attempting to create the program with several functions, including a function for a password.  I think that it adds a few more "bells and whistles" by adding this feature.  When I run the script below, what is being printed is the...]]></description>
			<content:encoded><![CDATA[<div>Can anybody help me out on creating the ceasar cipher.  I am attempting to create the program with several functions, including a function for a password.  I think that it adds a few more &quot;bells and whistles&quot; by adding this feature.  When I run the script below, what is being printed is the location of memory that it is being kept in.<br />
<br />
Although I have yet to finish writing this script, i.e. for the decoding function, I can't seem correctly encrypt the string and have yet to get that far.<br />
<br />
Any assistance would be greatly appreciated.<br />
<br />
<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">######CEASAR CIPHER##########<br />
<br />
from string import *<br />
<br />
<br />
<br />
def message():<br />
&nbsp; &nbsp; print &quot;Type in a message to encrypt:&quot;<br />
&nbsp; &nbsp; return raw_input()<br />
<br />
def key():<br />
&nbsp; &nbsp; print &quot;What numerical value should the text be encrypted?&quot;<br />
&nbsp; &nbsp; return int(raw_input())<br />
<br />
def password():<br />
&nbsp; &nbsp; print &quot;Please enter a password to protect this message:&quot;<br />
&nbsp; &nbsp; return raw_input()<br />
&nbsp; &nbsp; print &quot;Your message is now password protected.&quot;<br />
<br />
def encrypted_message():<br />
&nbsp; &nbsp; char = message<br />
&nbsp; &nbsp; encrypted_message = &quot;&quot;<br />
&nbsp; &nbsp; for char in encrypted_message:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = ord(char)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if char.isalpha():<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = x + key<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset = 65<br />
&nbsp; &nbsp; &nbsp; &nbsp; if char.islower():<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset = 97<br />
&nbsp; &nbsp; &nbsp; &nbsp; while x &lt; offset:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x += 26<br />
&nbsp; &nbsp; &nbsp; &nbsp; while x &gt; offset+25:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x -= 26<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encrypted_message += chr(x+key)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print encrypted_message<br />
&nbsp; &nbsp; <br />
def user_key():<br />
&nbsp; &nbsp; user_key = raw_input(&quot;Please enter the password: \t&quot;)<br />
&nbsp; &nbsp; if user_key==password:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print message<br />
&nbsp; &nbsp; while user_key != password:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;The password is incorrect.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; user_key = raw_input(&quot;Please enter the password: \t&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if user_key == password:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print message<br />
<br />
def decoder():<br />
&nbsp; &nbsp; user_key()<br />
&nbsp; &nbsp; if user_key == password:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print message&nbsp; &nbsp; <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
&nbsp; &nbsp; <br />
def main():<br />
&nbsp; &nbsp; print 5*&quot;\n&quot;<br />
&nbsp; &nbsp; repeat = &quot;y&quot;<br />
&nbsp; &nbsp; while repeat == &quot;y&quot; or repeat == &quot;Y&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print 5*&quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; message()<br />
&nbsp; &nbsp; &nbsp; &nbsp; key()<br />
&nbsp; &nbsp; &nbsp; &nbsp; password ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; encrypted_message()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; print encrypted_message<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; repeat = raw_input(&quot;Would you like to repeat the program?&nbsp; Press &lt;y or n&gt;&quot;)<br />
<br />
&nbsp; &nbsp; ans = raw_input(&quot;Press &lt;Enter&gt; to QUIT. &quot;)<br />
&nbsp; &nbsp; <br />
main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>SMIFMD</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235219.html</guid>
		</item>
		<item>
			<title>neeed help!!!</title>
			<link>http://www.daniweb.com/forums/thread235174.html</link>
			<pubDate>Sun, 01 Nov 2009 22:07:38 GMT</pubDate>
			<description><![CDATA[hi, i'm new in python programming 
i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) . ...]]></description>
			<content:encoded><![CDATA[<div>hi, i'm new in python programming<br />
i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) . <br />
<a rel="nofollow" class="t" href="http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A3/a3.pdf" target="_blank">http://pages.cpsc.ucalgary.ca/~zongp...ents/A3/a3.pdf</a><br />
any help would be appreciated<br />
txt file <a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12416" target="_blank">Attachment 12416</a></div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/txt.gif" alt="File Type: txt" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12416&amp;d=1257113147">grades1.txt</a> (9.5 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Ri0o</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235174.html</guid>
		</item>
		<item>
			<title>Another solution for my graphics window</title>
			<link>http://www.daniweb.com/forums/thread235163.html</link>
			<pubDate>Sun, 01 Nov 2009 20:28:23 GMT</pubDate>
			<description><![CDATA[I recently posted a very small program the uses pygame and the livewires package but was unable to get the program to run. I think the Title for that posting was Graphics Window or something close to that anyway. Since I can't resolve that problem, does anyone have any suggestions as to another way...]]></description>
			<content:encoded><![CDATA[<div>I recently posted a very small program the uses pygame and the livewires package but was unable to get the program to run. I think the Title for that posting was Graphics Window or something close to that anyway. Since I can't resolve that problem, does anyone have any suggestions as to another way I could use pygame along with the livewires packege to accomplish that task? Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Garrett85</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235163.html</guid>
		</item>
		<item>
			<title>Drawing stick figure?</title>
			<link>http://www.daniweb.com/forums/thread235155.html</link>
			<pubDate>Sun, 01 Nov 2009 19:58:15 GMT</pubDate>
			<description><![CDATA[well basically i have to draw a stick figure for which is my first question... i cant figure out how to draw a horizontal line and also a line at a angle for the legs... here is the code for the first one 
 
def drawStickFigure(): 
from graphics import * 
win = GraphWin("Stick figure") 
head =...]]></description>
			<content:encoded><![CDATA[<div>well basically i have to draw a stick figure for which is my first question... i cant figure out how to draw a horizontal line and also a line at a angle for the legs... here is the code for the first one<br />
<br />
def drawStickFigure():<br />
from graphics import *<br />
win = GraphWin(&quot;Stick figure&quot;)<br />
head = Circle(Point(100, 60), 20)<br />
head.draw(win)<br />
body = Line(Point(100, 80), Point(100, 120))<br />
body.draw(win)<br />
arms= Line(Point(0, 100), Point(0, 100))<br />
arms.draw(win)<br />
<br />
for the second question i have to draw a circle which is at the centre of the graphics window. the user inputs the radius of the circle and the circle should come. But for some reasn my code doesnt seem to be working please help<br />
<br />
def drawCircle():<br />
x = input(&quot;please enter the radius of the circle: &quot;)<br />
centre= Point(100, 100)<br />
circle1 = Circle(centre, x)<br />
circle1.draw(win)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>jaison2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235155.html</guid>
		</item>
		<item>
			<title>Cartesian product</title>
			<link>http://www.daniweb.com/forums/thread235137.html</link>
			<pubDate>Sun, 01 Nov 2009 17:53:10 GMT</pubDate>
			<description><![CDATA[I want make a program that calculates the cartesian products of two sets. e.g.: 
 
This is how i would like the result to look like: 
>>> 
Enter two sets to calculate the cartesian product: set([7,9]), set([1,5]) 
set([(7,1),(9,1),(7,5),(9,5)]) 
 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>I want make a program that calculates the cartesian products of two sets. e.g.:<br />
<br />
This is how i would like the result to look like:<br />
&gt;&gt;&gt;<br />
Enter two sets to calculate the cartesian product: set([7,9]), set([1,5])<br />
set([(7,1),(9,1),(7,5),(9,5)])<br />
<br />
 <pre style="margin:20px; line-height:13px">def main():<br />
&nbsp; &nbsp; userinput = input('Enter two sets to calculate the cartesian product: ')<br />
&nbsp; &nbsp; set1, set2 = userinput.split(',')<br />
&nbsp; &nbsp; myset1 = eval(set1.strip())<br />
&nbsp; &nbsp; myset2 = eval(set2.strip())<br />
&nbsp; &nbsp; ...?<br />
<br />
main()</pre><br />
I've now made a function who you now can insert two sets in the function and the function will make the two sets from being two 'str' to two 'set'. Now I would like the first element in the first set to pair up with the first element in the second set, then the second element in the first set to pair up with the first element in the second set and so forth.. I think you get the point. The problem is that I dont know how to make python do this.<br />
 :X Please help me</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>simpatar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235137.html</guid>
		</item>
		<item>
			<title>multiple sets</title>
			<link>http://www.daniweb.com/forums/thread235112.html</link>
			<pubDate>Sun, 01 Nov 2009 15:02:23 GMT</pubDate>
			<description><![CDATA[This is my program: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div>...]]></description>
			<content:encoded><![CDATA[<div>This is my program:<br />
<br />
 <pre style="margin:20px; line-height:13px">def main():<br />
&nbsp; &nbsp; print('This is a program to calculate the setprod')<br />
&nbsp; &nbsp; print()<br />
&nbsp; &nbsp; userinput = input('Enter two sets separated by a comma: ')<br />
&nbsp; &nbsp; value1, value2 = userinput.split(',')<br />
&nbsp; &nbsp; mylist1 = eval(value1.strip())<br />
&nbsp; &nbsp; mylist2 = eval(value2.strip())<br />
&nbsp; &nbsp; print(mylist1 + mylist2)<br />
<br />
main()</pre><br />
If I enter following:<br />
 <pre style="margin:20px; line-height:13px">&gt;&gt;&gt; <br />
This is a program to calculate the setprod<br />
<br />
Enter two sets separated by a comma: set([2]), set([3])</pre>I get this error:<br />
<span style="color:Red">print(mylist1 + mylist2)<br />
TypeError: unsupported operand type(s) for +: 'set' and 'set'</span><br />
<br />
How do I fix this problem?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>simpatar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235112.html</guid>
		</item>
		<item>
			<title>Querying date when a photo was taken.</title>
			<link>http://www.daniweb.com/forums/thread235037.html</link>
			<pubDate>Sun, 01 Nov 2009 08:46:21 GMT</pubDate>
			<description>I wouldl like to query a date of when a photo was taken.. how may I do that?</description>
			<content:encoded><![CDATA[<div>I wouldl like to query a date of when a photo was taken.. how may I do that?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>efecto</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235037.html</guid>
		</item>
		<item>
			<title>Input /variable...</title>
			<link>http://www.daniweb.com/forums/thread235030.html</link>
			<pubDate>Sun, 01 Nov 2009 07:24:59 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am new at Python..i have been asked to create a code for the following item. 
 
A user needs to input the 'room number' and 'date' to equal a answer. 
 
Room Number: R1, R2, R3, R4, R5 
 
R1 = Dates: 1/01/2000, 01/02/2000, 01/03/2000  
R2 = Dates: 01/01/2000, 01/03/2000]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am new at Python..i have been asked to create a code for the following item.<br />
<br />
A user needs to input the 'room number' and 'date' to equal a answer.<br />
<br />
Room Number: R1, R2, R3, R4, R5<br />
<br />
R1 = Dates: 1/01/2000, 01/02/2000, 01/03/2000 <br />
R2 = Dates: 01/01/2000, 01/03/2000<br />
R3 = Dates: 0/01/2000, 0/01/2000, 0/01/2000<br />
R4 = Dates: 0/01/2000, 0/01/2000, 0/01/2000<br />
R5 = Dates: 0/01/2000, 0/01/2000<br />
<br />
R1	01/01/2000	Library1<br />
R1	01/02/2000	Library2<br />
R1	01/03/2000	Class1<br />
		<br />
R2	01/01/2000	Library2<br />
R2	01/02/2000	Library1<br />
R2	01/03/2000	Class2<br />
		<br />
R3	01/02/2000	Library3<br />
R3	01/03/2000	Class3<br />
		<br />
R4	01/03/200	Class4<br />
		<br />
R5	01/01/2000	Class4<br />
R5	01/02/2000	Library4<br />
<br />
What do you start doing first the Input, Define method first??</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>python123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235030.html</guid>
		</item>
		<item>
			<title>Need help!!!!</title>
			<link>http://www.daniweb.com/forums/thread235028.html</link>
			<pubDate>Sun, 01 Nov 2009 07:15:59 GMT</pubDate>
			<description><![CDATA[hi, i'm new in python programming 
i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) and here is the text file link...]]></description>
			<content:encoded><![CDATA[<div>hi, i'm new in python programming<br />
i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) and here is the text file link<br />
<a rel="nofollow" class="t" href="http://pages.cpsc.ucalgary.ca/~zongpeng" target="_blank">http://pages.cpsc.ucalgary.ca/~zongpeng</a> ... rades1.txt<br />
any help would be appreciated</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Ri0o</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235028.html</guid>
		</item>
		<item>
			<title>Unclear control flow variables?</title>
			<link>http://www.daniweb.com/forums/thread235001.html</link>
			<pubDate>Sun, 01 Nov 2009 02:17:11 GMT</pubDate>
			<description><![CDATA[Sorry if this is a really easy question, but I've been going through control flows in the python documentation and something confuses me that it doesn't address. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Sorry if this is a really easy question, but I've been going through control flows in the python documentation and something confuses me that it doesn't address.<br />
<br />
 <pre style="margin:20px; line-height:13px">a = ['Mary', 'had', 'a', 'little', 'lamb']<br />
for i in range(len(a)):<br />
&nbsp; &nbsp;  print i, a[i]</pre><br />
When I type that in, it prints the result;<br />
0 Mary<br />
1 had<br />
2 a<br />
3 little<br />
4 lamb<br />
<br />
Something also odd was that when I typed &quot;a[i]&quot;, I get 'lamb'. <br />
<br />
What my question here is that 'i' was never defined here. When I try another letter, or assign 'i' as a variable, I just get an error. What exactly is this and is there anything else like that I should know?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>npn_</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235001.html</guid>
		</item>
		<item>
			<title>Simple Graphics Window</title>
			<link>http://www.daniweb.com/forums/thread235000.html</link>
			<pubDate>Sun, 01 Nov 2009 02:10:00 GMT</pubDate>
			<description><![CDATA[I have installed pygame and livewires but am getting the following error with the following short program that I got from my python book. 
 
AttributeError: 'module' object has no attribute 'init' 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I have installed pygame and livewires but am getting the following error with the following short program that I got from my python book.<br />
<br />
<span style="color:Red">AttributeError: 'module' object has no attribute 'init'</span><br />
<br />
 <pre style="margin:20px; line-height:13px"># New Graphics Window<br />
# Demonstrates creating a graphics window<br />
<br />
from livewires import games<br />
<br />
games.init(screen_width = 640, screen_height = 480, fps = 50)<br />
<br />
games.Screen.mainloop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Garrett85</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235000.html</guid>
		</item>
		<item>
			<title>update namespace</title>
			<link>http://www.daniweb.com/forums/thread234990.html</link>
			<pubDate>Sun, 01 Nov 2009 00:19:48 GMT</pubDate>
			<description><![CDATA[Here's my problem. I wx application that works great until I close it (leaving the idle editing session open) and then restart it. Then parts of the program see variables that should be things like 'wx.panel' as PyDeadObj .... Once I restart the idle session and re-run the program it works fine....]]></description>
			<content:encoded><![CDATA[<div>Here's my problem. I wx application that works great until I close it (leaving the idle editing session open) and then restart it. Then parts of the program see variables that should be things like 'wx.panel' as PyDeadObj .... Once I restart the idle session and re-run the program it works fine. I've tried reload(wx), I've tried deleting all wx variables from sys.modules ... Any more ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ihatehippies</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234990.html</guid>
		</item>
		<item>
			<title>Comma Separated keys to dict reference</title>
			<link>http://www.daniweb.com/forums/thread234959.html</link>
			<pubDate>Sat, 31 Oct 2009 19:30:04 GMT</pubDate>
			<description><![CDATA[Ok, lets say I have a string 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div>...]]></description>
			<content:encoded><![CDATA[<div>Ok, lets say I have a string<br />
 <pre style="margin:20px; line-height:13px">str = &quot;main,sub,sub_sub&quot;</pre>how could I use that to edit the value inside the dict<br />
 <pre style="margin:20px; line-height:13px">dicx = {'main':{'sub':{'sub_sub':'value to change'}}}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pdxwebdev</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234959.html</guid>
		</item>
		<item>
			<title>simple question</title>
			<link>http://www.daniweb.com/forums/thread234955.html</link>
			<pubDate>Sat, 31 Oct 2009 18:29:11 GMT</pubDate>
			<description><![CDATA[I'm just wondering what do I have to add to the code 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with...]]></description>
			<content:encoded><![CDATA[<div>I'm just wondering what do I have to add to the code<br />
<br />
 <pre style="margin:20px; line-height:13px">print &quot;Hello World&quot;</pre><br />
to output<br />
<br />
H e l l o  W o r l d<br />
<br />
like there's spaces in between each letter?<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>saikeraku</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234955.html</guid>
		</item>
		<item>
			<title>Schooling scripts</title>
			<link>http://www.daniweb.com/forums/thread234931.html</link>
			<pubDate>Sat, 31 Oct 2009 15:01:31 GMT</pubDate>
			<description>I am a complete newbie to python but know some c++  Was wondering where i can get my hands on a 3D script for schooling(like fish)  
 
BattlingMaxo</description>
			<content:encoded><![CDATA[<div>I am a complete newbie to python but know some c++  Was wondering where i can get my hands on a 3D script for schooling(like fish) <br />
<br />
BattlingMaxo</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>BattlingMaxo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234931.html</guid>
		</item>
		<item>
			<title>Code Snippet ToolTip box</title>
			<link>http://www.daniweb.com/code/snippet234888.html</link>
			<pubDate>Sat, 31 Oct 2009 12:25:31 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>Python Syntax</strong>...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">from Tkinter import *<br />
root = Tk()<br />
<br />
tipwindow = None<br />
<br />
# Creates a tooptip box for a widget.<br />
def createToolTip( widget, text ):<br />
&nbsp; &nbsp; def enter( event ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; global tipwindow<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = y = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; if tipwindow or not text:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return<br />
&nbsp; &nbsp; &nbsp; &nbsp; x, y, cx, cy = widget.bbox( &quot;insert&quot; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; x += widget.winfo_rootx() + 27<br />
&nbsp; &nbsp; &nbsp; &nbsp; y += widget.winfo_rooty() + 27<br />
&nbsp; &nbsp; &nbsp; &nbsp; # Creates a toplevel window<br />
&nbsp; &nbsp; &nbsp; &nbsp; tipwindow = tw = Toplevel( widget )<br />
&nbsp; &nbsp; &nbsp; &nbsp; # Leaves only the label and removes the app window<br />
&nbsp; &nbsp; &nbsp; &nbsp; tw.wm_overrideredirect( 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; tw.wm_geometry( &quot;+%d+%d&quot; % ( x, y ) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; label = Label( tw, text = text, justify = LEFT,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  background = &quot;#ffffe0&quot;, relief = SOLID, borderwidth = 1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  font = ( &quot;tahoma&quot;, &quot;8&quot;, &quot;normal&quot; ) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; label.pack( ipadx = 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def close( event ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; global tipwindow<br />
&nbsp; &nbsp; &nbsp; &nbsp; tw = tipwindow<br />
&nbsp; &nbsp; &nbsp; &nbsp; tipwindow = None<br />
&nbsp; &nbsp; &nbsp; &nbsp; if tw:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tw.destroy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; widget.bind( &quot;&lt;Enter&gt;&quot;, enter )<br />
&nbsp; &nbsp; widget.bind( &quot;&lt;Leave&gt;&quot;, close )<br />
<br />
b = Button( root, text = &quot;Mouse over&quot; ); b.pack()<br />
createToolTip( b, &quot;Mouse is over the button&quot; )<br />
<br />
mainloop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>masterofpuppets</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234888.html</guid>
		</item>
		<item>
			<title>Events are always one Event behind</title>
			<link>http://www.daniweb.com/forums/thread234846.html</link>
			<pubDate>Sat, 31 Oct 2009 07:55:35 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>Python Syntax</strong>...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">def doKey(e):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print(e.widget.get(&quot;1.0&quot;,&quot;end&quot;))<br />
root= Tk()<br />
root.title('yada')<br />
txta = Text(root, width=40, height=10)<br />
txta.bind(&quot;&lt;Key&gt;&quot;, doKey)<br />
txta.pack(side=LEFT)<br />
root.mainloop()</pre><br />
Pressing a key in this text area will always output the string prior to your pressing the key.  Am I missing something?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pdxwebdev</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234846.html</guid>
		</item>
		<item>
			<title>Line number in Tkinter Text field</title>
			<link>http://www.daniweb.com/forums/thread234799.html</link>
			<pubDate>Sat, 31 Oct 2009 02:20:19 GMT</pubDate>
			<description><![CDATA[hi all, 
I am designing a text editor program in Python using Tkinter and I was wondering if there's any way to get the current line number when the mouse is clicked somewhere on the text field, i.e the mouse position should determine the current line, like in the python editor window... for the...]]></description>
			<content:encoded><![CDATA[<div>hi all,<br />
I am designing a text editor program in Python using Tkinter and I was wondering if there's any way to get the current line number when the mouse is clicked somewhere on the text field, i.e the mouse position should determine the current line, like in the python editor window... for the text field I am using a ScrolledText widget. <br />
Any help or hint is appreciated :) thx in advance :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>masterofpuppets</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234799.html</guid>
		</item>
		<item>
			<title>Server with gui interface</title>
			<link>http://www.daniweb.com/forums/thread234790.html</link>
			<pubDate>Sat, 31 Oct 2009 00:30:49 GMT</pubDate>
			<description>Hey guys, I got a little bored and thought I would to make some of the basic Client/Server applications I have a little bit flashier with a gui interface.  So far I have just been working with the server and the main problem that I run into is when the program has to enter a loop while waiting for...</description>
			<content:encoded><![CDATA[<div>Hey guys, I got a little bored and thought I would to make some of the basic Client/Server applications I have a little bit flashier with a gui interface.  So far I have just been working with the server and the main problem that I run into is when the program has to enter a loop while waiting for a response the gui starts to hang.  The work around I have been using so far which quite frankly sucks, is to print a response while the exeption is being raised.  It keeps the gui from hanging but it's quite annoying.  The other thing I tried was to have it sleep for a short period of time but the gui seems to really hate that.  Is there a more common or better way to handle this?  Here is the code I'm working with at the moment, sorry I do relize it's pretty sloppy right now.  I promise to clean it up a bit once I can get it functioning a little better :).<br />
<br />
 <pre style="margin:20px; line-height:13px">from tkinter import *<br />
from threading import Thread<br />
from time import sleep<br />
import socket<br />
<br />
class Gui():<br />
&nbsp; &nbsp; def __init__(self, master):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.running = 0&nbsp; &nbsp; #not listening<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.addr = &quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.conn = &quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.frame = Frame(master)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.frame.pack(side = LEFT, anchor = N)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.startb = Button(self.frame, text = &quot;Start&quot;, command = self.startc)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.startb.pack(side = LEFT, anchor = N)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.stopb = Button(self.frame, text = &quot;Stop&quot;, command = self.stopc)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.stopb.pack(side = LEFT, anchor = N)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.connectionl = Label(self.frame, text = &quot;not connected&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.connectionl.pack(side = LEFT, anchor = SW)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def startc(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.running == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.running += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.ls = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; port = 9999<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.ls.bind(('', port))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;Server listening on port %s&quot; %port)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.ls.listen(1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.ls.settimeout(.05)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while self.running != 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (self.conn, self.addr) = self.ls.accept()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;client is at&quot;, self.addr&#91;0&#93;, &quot;on port&quot;, self.addr&#91;1&#93;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.running = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;attempting to connect&quot;)#hangs without this<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if self.conn != &quot;&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.rc = &quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while self.rc != &quot;done&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.rc = self.conn.recv(100).decode('utf-8')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;got command&quot;, self.rc)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(.05)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;no info sent yet&quot;)#hangs without this<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.conn.close()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.running = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;Server not listening&quot;)<br />
<br />
&nbsp; &nbsp; def stopc(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.running = 0<br />
<br />
<br />
<br />
<br />
<br />
<br />
root = Tk()<br />
gui = Gui(root)<br />
root.mainloop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>willygstyle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234790.html</guid>
		</item>
		<item>
			<title>Python - writing to file</title>
			<link>http://www.daniweb.com/forums/thread234781.html</link>
			<pubDate>Fri, 30 Oct 2009 22:57:14 GMT</pubDate>
			<description><![CDATA[I have written a script for scraping a web site, and it works fine. What does not work fine, is when I try to use the write function, to write the results to a txt-file. 
 
I am trying to run this: 
 
import BeautifulSoup, urllib2, re, time 
import codecs 
 
path='C:/Users/Me/Documents/Python' 
...]]></description>
			<content:encoded><![CDATA[<div>I have written a script for scraping a web site, and it works fine. What does not work fine, is when I try to use the write function, to write the results to a txt-file.<br />
<br />
I am trying to run this:<br />
<br />
import BeautifulSoup, urllib2, re, time<br />
import codecs<br />
<br />
path='C:/Users/Me/Documents/Python'<br />
<br />
outfile=open(r'C:/Users/Steinar/Documents/Python/Vegvesen/vegresultat.txt', 'a')<br />
<br />
start_url = &quot;http://www.vegvesen.no/Om+Statens+vegvesen/Aktuelt/Offentlig+journal?dokumenttyper=&amp;dato=10.02.2003&amp;journalenhet=&amp;utforSok=S%C3%B8k&amp;submitButton=S%C3%B8k&quot;<br />
<br />
datos = (<br />
'01.11.2008',<br />
'02.11.2008',<br />
<br />
)<br />
<br />
for dato in datos:<br />
    search_url = &quot;http://www.vegvesen.no/Om+Statens+vegvesen/Aktuelt/Offentlig+journal?dokumenttyper=&amp;dato=%s&amp;journalenhet=&amp;utforSok=S%%C3%%B8k&amp;submitButton=S%%C3%%B8k&quot; % dato<br />
    page = urllib2.urlopen(search_url)<br />
    html = page.read()<br />
    soup = BeautifulSoup.BeautifulSoup(html)<br />
    divs = soup.findAll(&quot;div&quot;, {&quot;class&quot;: &quot;treff&quot;})<br />
    for div in divs:<br />
        outfile.write (dato + '|' + div.p.contents[0])<br />
    <br />
        pass<br />
   <br />
    outfile.close()<br />
<br />
<br />
I get this error message:<br />
<br />
outfile.write (dato + '|' + div.p.contents[0])<br />
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 25: ordinal not in range(128)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>figved</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234781.html</guid>
		</item>
		<item>
			<title>Code Snippet Building argv from command line</title>
			<link>http://www.daniweb.com/code/snippet234768.html</link>
			<pubDate>Fri, 30 Oct 2009 20:47:21 GMT</pubDate>
			<description><![CDATA[Some time ago, I was writing a small command line interpreter, with the help of the standard module cmd (http://docs.python.org/library/cmd.html#module-cmd) which offers minimal support for such tasks, and I had the problem that this module doesn't have a function to parse a command line to produce...]]></description>
			<content:encoded><![CDATA[<div>Some time ago, I was writing a small command line interpreter, with the help of <a rel="nofollow" class="t" href="http://docs.python.org/library/cmd.html#module-cmd" target="_blank">the standard module cmd</a> which offers minimal support for such tasks, and I had the problem that this module doesn't have a function to parse a command line to produce a list argv which can be passed to <a rel="nofollow" class="t" href="http://docs.python.org/library/optparse.html#module-optparse" target="_blank">optparse</a> for example.<br />
I found a first solution with the third party module <a rel="nofollow" class="t" href="http://pygments.org/" target="_blank">pygments</a> which contains parsers for different languages, and I parsed the command line using pygment's bash parser.<br />
However, I was not completely happy with this solution and I started looking for the C function wich builds argv for C programs. I finally found such a function in <a rel="nofollow" class="t" href="http://gcc.gnu.org/onlinedocs/libiberty/" target="_blank">GNU libiberty</a> library which is used by the gcc compiler.<br />
This function was simple enough and I decided to write a pure python implementation of this function, using python's regular expressions and following closely the syntax rules used in libiberty's buildargv function (a 100% compatibility is not at all guaranteed)<br />
This snippet is the result of this coding. The class Argv, which subclasses list, contains methods to transform a command line into a list of arguments with a behaviour similar to that of a C compiler. It also contains methods to write the argument list to a response file and read files to extract command arguments.<br />
<br />
Here is the code, enjoy :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Gribouillis</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234768.html</guid>
		</item>
		<item>
			<title>Class testing</title>
			<link>http://www.daniweb.com/forums/thread234763.html</link>
			<pubDate>Fri, 30 Oct 2009 19:59:49 GMT</pubDate>
			<description><![CDATA[So I want to make a class based RPG, as a project to help me understand how classes work. Unfortunately, I didn't get far.  
The below code is intended to make an instance of a character and have info in it like name, health, gold, exp, and the like. I am just testing the simplest of stuff right...]]></description>
			<content:encoded><![CDATA[<div>So I want to make a class based RPG, as a project to help me understand how classes work. Unfortunately, I didn't get far. <br />
The below code is intended to make an instance of a character and have info in it like name, health, gold, exp, and the like. I am just testing the simplest of stuff right now, and I *think* that I got the name of the character to go into the instance but I can't get it back out.<br />
<br />
 <pre style="margin:20px; line-height:13px">class char:<br />
&nbsp; &nbsp; def __init__(self,name):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.name = name<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
a = raw_input(&quot;Name: &quot;)<br />
char(a)<br />
print char(a)</pre><br />
Whenever I try to print the name of the instance, this comes out:<br />
&lt;__main__.char instance at 0x02B91F30&gt;</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Zaffron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234763.html</guid>
		</item>
		<item>
			<title>Using Functions</title>
			<link>http://www.daniweb.com/forums/thread234737.html</link>
			<pubDate>Fri, 30 Oct 2009 17:12:30 GMT</pubDate>
			<description><![CDATA[How do you know when to use a function by wraping the content between parentheses "function(x) or through dot notation x.function() 
? thanks.]]></description>
			<content:encoded><![CDATA[<div>How do you know when to use a function by wraping the content between parentheses &quot;function(x) or through dot notation x.function()<br />
? thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Garrett85</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234737.html</guid>
		</item>
		<item>
			<title>Encrypting binary data with AES crashes</title>
			<link>http://www.daniweb.com/forums/thread234677.html</link>
			<pubDate>Fri, 30 Oct 2009 12:33:32 GMT</pubDate>
			<description><![CDATA[Having worked with txt files, I'm learning about binary now. My code below works for a while then bombs out, can you point me towards a method or module to read binary data line by line? The crypto module requires a buffer (don't know how to create one of those) or a string. 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Having worked with txt files, I'm learning about binary now. My code below works for a while then bombs out, can you point me towards a method or module to read binary data line by line? The crypto module requires a buffer (don't know how to create one of those) or a string.<br />
<br />
 <pre style="margin:20px; line-height:13px">from Crypto.Cipher import AES<br />
<br />
USEFILE = 'picture.bmp'<br />
<br />
class encryptData():<br />
&nbsp; &nbsp; &nbsp; &nbsp; def __init__(self, file):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blockSize = 32<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.file = file<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; secretKey = os.urandom(blockSize) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.dataFile = open(file, &quot;rb&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cipher = AES.new(secretKey, AES.MODE_CFB)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if self.dataFile:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newFile = self.dataFile.readlines()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for lines in newFile:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print cipher.encrypt(lines)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print secretKey<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
run = encryptData(USEFILE)</pre><br />
I'm looking to read a binary file and encrypt it. Many thx.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>zyrus001</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234677.html</guid>
		</item>
		<item>
			<title>Problems with a leet speak converter</title>
			<link>http://www.daniweb.com/forums/thread234665.html</link>
			<pubDate>Fri, 30 Oct 2009 10:57:14 GMT</pubDate>
			<description><![CDATA[I tried to make a leet speak converter, but it outputs characters that I don't even tell it to.. 
 
This is what I mean: 
 
(Test run) 
Enter something to convert to L337 5P34K: Hi, how are you? 
L337 5P34K equivilent: hi,@H0w 4R3 Y0u? 
 
I don't know why it's got the '@' there.]]></description>
			<content:encoded><![CDATA[<div>I tried to make a leet speak converter, but it outputs characters that I don't even tell it to..<br />
<br />
This is what I mean:<br />
<br />
(Test run)<br />
Enter something to convert to L337 5P34K: Hi, how are you?<br />
L337 5P34K equivilent: hi,@H0w 4R3 Y0u?<br />
<br />
I don't know why it's got the '@' there.<br />
<br />
This is the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#L33TSP34K Converter.<br />
<br />
import random as rnd<br />
<br />
def toUpper(string):<br />
&nbsp; &nbsp; string_upper = &quot;&quot;<br />
&nbsp; &nbsp; for char in string :<br />
&nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; ord(char) &lt; 97 :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string_upper += char<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif ord(char) &gt;= 97 :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string_upper += chr(ord(char) - 32)<br />
&nbsp; &nbsp; return string_upper<br />
<br />
def toLower(string):<br />
&nbsp; &nbsp; string_lower = &quot;&quot;<br />
&nbsp; &nbsp; for char in string :<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ord(char) &gt; 97 :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string_lower += char<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif ord(char) &lt;= 97:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string_lower += chr(ord(char) + 32 )<br />
&nbsp; &nbsp; return string_lower<br />
<br />
def convertToLeetSpeak(src):<br />
&nbsp; &nbsp; string = src<br />
&nbsp; &nbsp; for c in src:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if c == 'e' or c == 'E':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += '3'<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif c == 'a' or c == 'A':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += '4'<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif c == 't' or c == 'T':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += '7'<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif c == 's' or c == 'S':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += '5'<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif c == 'o' or c == 'O':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += '0'<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = rnd.randrange(1,3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if i == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += toUpper(c)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif i == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string += toLower(c)<br />
&nbsp; &nbsp; return string<br />
<br />
def main():<br />
&nbsp; &nbsp; choice = raw_input(&quot;Enter something to convert to L337 5P34K: &quot;)<br />
&nbsp; &nbsp; choice = convertToLeetSpeak(choice).replace(choice, '')<br />
&nbsp; &nbsp; print 'L337 5P34K equivilent:',choice<br />
<br />
if __name__ == '__main__':<br />
&nbsp; &nbsp; main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>tomtetlaw</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234665.html</guid>
		</item>
		<item>
			<title>Reasons to extend Python with C</title>
			<link>http://www.daniweb.com/forums/thread234629.html</link>
			<pubDate>Fri, 30 Oct 2009 08:34:21 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I've read the python doc (C-API) and was wondering about the two reasons to extend python with C. The first reason is to implement new build-in object types and the second one is to call C-Library functions and system calls. 
Ok, I think i got the second one but what's about the new...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I've read the python doc (C-API) and was wondering about the two reasons to extend python with C. The first reason is to implement new build-in object types and the second one is to call C-Library functions and system calls.<br />
Ok, I think i got the second one but what's about the new build-in objects? Does that mean that I am able to mix my written c-modules with the existing python source files and recompile the interpreter so I'm using static binding to create my &quot;own/new&quot; python-interpreter including my own types? <br />
If I just use dynamic binding (e.g. using distutils to create a library and than &quot;import myLib&quot;) I think I got the same behavior like writing a python class in a separate module file and use it afterwards. In both cases I will have new type.<br />
Probably I don't understand what they want to tell me with build-in objects. May anybody help me with that? Thanks a lot.<br />
<br />
Jonny</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>sneek</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234629.html</guid>
		</item>
		<item>
			<title>import error in Tkinter(python 3.1 in mandriva 2009 spring)</title>
			<link>http://www.daniweb.com/forums/thread234607.html</link>
			<pubDate>Fri, 30 Oct 2009 06:52:27 GMT</pubDate>
			<description><![CDATA[Hai guys, 
        A very good morning to you.Currently i'm using python3 in linux. In windows tkinter is working fine but in mandriva linux spring 2009 it fails to import. Can you please tell me step-by-step on how to fix this issue? In python3.1 home page the 
description is not clear or it can't...]]></description>
			<content:encoded><![CDATA[<div>Hai guys,<br />
        A very good morning to you.Currently i'm using python3 in linux. In windows tkinter is working fine but in mandriva linux spring 2009 it fails to import. Can you please tell me step-by-step on how to fix this issue? In python3.1 home page the<br />
description is not clear or it can't be understood by the beginner. As<br />
i'm a beginner for programming python in linux please help me out. I<br />
want to know what is the thing i missed during installation. I've done<br />
the things correctly as mentioned in the python readme text inside the<br />
python3.1 tarball file.what should i do now?<br />
 <pre style="margin:20px; line-height:13px">import _tkinter # If this fails your Python may not be configured for Tk</pre>                    This community is really helpful...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>python.noob</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234607.html</guid>
		</item>
		<item>
			<title>Need help on hangman game on python</title>
			<link>http://www.daniweb.com/forums/thread234556.html</link>
			<pubDate>Fri, 30 Oct 2009 01:50:10 GMT</pubDate>
			<description><![CDATA[I have no idea how to do this. Please help. 
 
This week's lab is to design a hangman game. Your program should be able to open a text file which contains a list of words (one word on each line of the text file) and read the words into a list to contain all of the possible words.  
 
Your program...]]></description>
			<content:encoded><![CDATA[<div>I have no idea how to do this. Please help.<br />
<br />
This week's lab is to design a hangman game. Your program should be able to open a text file which contains a list of words (one word on each line of the text file) and read the words into a list to contain all of the possible words. <br />
<br />
Your program should then prompt the user to play a game, please provide at least 3 difficultly levels for the user to choose from. (Difficulty applies to the number of wrong answers allowed before the user loses the game) <br />
<br />
Once the user has selected a difficulty, a word from the word list should be chosen randomly using python's random library (example of how to use random at bottom of assignment page). <br />
<br />
The program should then display stars to screen so the user knows how many letters are in the word (I suggest making a list of stars). Then the user should be prompted for a guess. After each guess, the program should determine if the guess is valid (ie, it should check to see if the guess has been used before....This means you will need to keep track of what letters have been guessed). If the guess is invalid, a message should be displayed telling the user that they have already guessed that letter and prompting the user to try another letter. If the guess is valid, the program should check to see if the letter is in the word. <br />
<br />
If the letter is in the word, the list containing stars should be updated so that correct letters are displayed where required. If the letter is not in the word, then the user should be credited with an incorrect guess. <br />
<br />
After the guess has been evaluated, a hangman picture should be displayed (based on number of wrong answers and difficulty level...You may use ASCII art or turtle graphics for the picture), the list of incorrect guesses, and current status of the word. The pattern of guessing should continue until the user is able to correctly solve the puzzle, or is &quot;hung&quot; (runs out of incorrect guesses). <br />
<br />
Once the game is complete, the user should be asked if they wish to play again. Example of a working hangman game to be demonstrated in lab.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>henks83</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234556.html</guid>
		</item>
		<item>
			<title>Catching Clicks on Icons</title>
			<link>http://www.daniweb.com/forums/thread234532.html</link>
			<pubDate>Thu, 29 Oct 2009 22:33:42 GMT</pubDate>
			<description>My issue is essentially spelled out in the title. I want to be able to catch clicks (more specifically double clicks) on icons on the desktop or in folders or wherever, and tell where the click was on the icon (the coordinates of the click along with the whole size of where they could have...</description>
			<content:encoded><![CDATA[<div>My issue is essentially spelled out in the title. I want to be able to catch clicks (more specifically double clicks) on icons on the desktop or in folders or wherever, and tell where the click was on the icon (the coordinates of the click along with the whole size of where they could have clicked).<br />
<br />
What I'm trying to do is make it so that you can open a file with different programs easily by clicking on different parts of the icon. For example, I want to be able to double click on a python file on the left side to open it with a certain text editor I like to use, and on the right to open it with the python interpreter.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Mathhax0r</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234532.html</guid>
		</item>
		<item>
			<title>Distinct Vlaues</title>
			<link>http://www.daniweb.com/forums/thread234531.html</link>
			<pubDate>Thu, 29 Oct 2009 22:29:41 GMT</pubDate>
			<description><![CDATA[Write a function called NumDistinctDict that takes a single parameter alist that determines the number of distinct values in alist. For example, the list [1,2,4,2,7] contains 3 unique values (namely 1,2,4 and 7).]]></description>
			<content:encoded><![CDATA[<div>Write a function called NumDistinctDict that takes a single parameter alist that determines the number of distinct values in alist. For example, the list [1,2,4,2,7] contains 3 unique values (namely 1,2,4 and 7).</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>kenmeck03</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234531.html</guid>
		</item>
		<item>
			<title>How to integrate vumeter</title>
			<link>http://www.daniweb.com/forums/thread234528.html</link>
			<pubDate>Thu, 29 Oct 2009 21:36:16 GMT</pubDate>
			<description>Hi I have made a small program to record sound. I have a TK window  with a record button. I would like to add a vumeter to this TK window. I use ubuntu and pulseaudio. If I type pavumeter in the terminal window I see a (pa) vumeter on my desktop. I can I actually include such a vumeter in my TK...</description>
			<content:encoded><![CDATA[<div>Hi I have made a small program to record sound. I have a TK window  with a record button. I would like to add a vumeter to this TK window. I use ubuntu and pulseaudio. If I type pavumeter in the terminal window I see a (pa) vumeter on my desktop. I can I actually include such a vumeter in my TK window to be able to monitor the sound that I am recording.<br />
Thanks <br />
Michael</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>m.albert</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234528.html</guid>
		</item>
		<item>
			<title>Find largest file in directory</title>
			<link>http://www.daniweb.com/forums/thread234497.html</link>
			<pubDate>Thu, 29 Oct 2009 18:38:30 GMT</pubDate>
			<description><![CDATA[I'm working on a cleanup script for tv shows that I download.  Right now I'm just looking for a file greater than 50mb, but there should be a better way. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I'm working on a cleanup script for tv shows that I download.  Right now I'm just looking for a file greater than 50mb, but there should be a better way.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; import os<br />
&nbsp; &nbsp; import shutil<br />
<br />
&nbsp; &nbsp; dir = &quot;C:\Users\Bobe\Downloads\TV\\&quot;<br />
<br />
&nbsp; &nbsp; for folder in os.listdir(dir):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if os.path.isdir(os.path.join(dir,folder)):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for file in os.listdir(dir + folder):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filelocation = dir+folder+&quot;\\&quot;+file<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if os.path.getsize(filelocation) &gt; 50000000:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shutil.move(filelocation, dir + folder + &quot;.avi&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; os.remove(filelocation)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shutil.rmtree(dir + folder)</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>keyoh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234497.html</guid>
		</item>
		<item>
			<title>Suggestion needed from python geeks.. Help please...</title>
			<link>http://www.daniweb.com/forums/thread234458.html</link>
			<pubDate>Thu, 29 Oct 2009 15:59:50 GMT</pubDate>
			<description><![CDATA[Hello geeks, 
 
            First of all thanks to the members of this forum for their active participation, contribution and willingness to help. 
 
           Now i'm in need of your valuable suggestions for my project in python. 
 
1) I want to have GUI interface in my project and now i'm using...]]></description>
			<content:encoded><![CDATA[<div>Hello geeks,<br />
<br />
            First of all thanks to the members of this forum for their active participation, contribution and willingness to help.<br />
<br />
           Now i'm in need of your valuable suggestions for my project in python.<br />
<br />
1) I want to have GUI interface in my project and now i'm using python 3.1.1. When i googled around i found out that several tools like Qt, wxPython etc., supports python version upto 2.6 only. My ques. is if i want to develop GUI in &quot;python 3.1.1&quot; what are all the tools available? what would you recommend? <span style="color:Red">&quot;would it support python 3.1.1?</span>If possible give me some links for tutorials for the same...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>python.noob</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234458.html</guid>
		</item>
		<item>
			<title>passing double char pointer to C function</title>
			<link>http://www.daniweb.com/forums/thread234404.html</link>
			<pubDate>Thu, 29 Oct 2009 11:34:08 GMT</pubDate>
			<description>Hello, 
 
I would like to know hot to pass address reference to ‘c’ function through python. I am using swig for ‘c’ anf python interfacing 
 
 
 
Interface file :  stud.i 
*************************************************** 
 
%module stud</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I would like to know hot to pass address reference to ‘c’ function through python. I am using swig for ‘c’ anf python interfacing<br />
<br />
<br />
<br />
Interface file :  stud.i<br />
***************************************************<br />
<br />
%module stud<br />
<br />
%header%{<br />
#include &quot;stud.h&quot;<br />
%}<br />
<br />
%include &quot;stud.h&quot;<br />
<br />
%array_functions(char *,charp );<br />
<br />
%inline %{<br />
extern int parse1(char *,char *,char **);<br />
%}<br />
<br />
%inline %{<br />
  int print_args(char **argv) {<br />
    int i = 0;<br />
    for(i=0;i&lt;=180;i++) {<br />
      printf(&quot;argv[%d] = %c\n&quot;, i,*(argv[i]));<br />
      i++;<br />
    }<br />
    return i;<br />
  }<br />
%}<br />
<br />
**********************************************************<br />
<br />
Stud.c<br />
======================================<br />
#include&lt;string.h&gt;<br />
#include&lt;stdio.h&gt;<br />
#include &quot;stud.h&quot;<br />
<br />
int parse1(char *s, char *p,char **t)<br />
{<br />
  strcat(p,s);<br />
  *t=&amp;p[0];<br />
}<br />
<br />
**********************************************************<br />
Stud.h<br />
===================================<br />
<br />
int parse1(char *,char *,char **);<br />
<br />
**************************************************<br />
&gt;&gt;&gt; from stud import *<br />
&gt;&gt;&gt; a='rajashree'<br />
&gt;&gt;&gt; c='thoratf'<br />
&gt;&gt;&gt; d=new_charp(1000)<br />
&gt;&gt;&gt; parse1(a,c,d)<br />
2300188<br />
&gt;&gt;&gt; d<br />
&lt;Swig Object of type 'char **' at 0x28aca0&gt;<br />
<br />
<br />
Now I want read  value of  d in python… How do I do it.<br />
Any type of help is appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>yateenjoshi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234404.html</guid>
		</item>
		<item>
			<title>noob question about strings</title>
			<link>http://www.daniweb.com/forums/thread234290.html</link>
			<pubDate>Thu, 29 Oct 2009 03:53:01 GMT</pubDate>
			<description><![CDATA[I want to create a string like this: 
(just theoretically:-)) 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help...]]></description>
			<content:encoded><![CDATA[<div>I want to create a string like this:<br />
(just theoretically:-))<br />
 <pre style="margin:20px; line-height:13px">import random<br />
<br />
list1 = [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]<br />
string1 = random.choice(list1)<br />
string2 = &quot;Random Number is&quot; + string1</pre><br />
but I want string2 to show up formatted like this:<br />
<br />
<br />
Random Number is<blockquote> 2</blockquote><br />
But, for the life of me I cant figure out how to create a new line and a tab, without writing string2 like this<br />
<br />
 <pre style="margin:20px; line-height:13px">&quot;&quot;&quot;Random Number is<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2&quot;&quot;&quot;</pre><br />
<br />
I spent 30 minutes in the documentation and on google, and all i found was &quot;\t&quot; and &quot;\n&quot;, but I cant even figure out how to make them work! Any help would be greatly appreciated, Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>mishu5770l</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234290.html</guid>
		</item>
		<item>
			<title>Hi from Python noob :D</title>
			<link>http://www.daniweb.com/forums/thread234263.html</link>
			<pubDate>Thu, 29 Oct 2009 02:19:08 GMT</pubDate>
			<description>I just started to learn Python before a week or so and i found this example and rewrited it in Notepad++ (btw it was really painfull to figure out how to connect Notepad++ with python.exe but i like notepad++ more than Python GUI) 
and this program just wont work nor in the Notepad++ nor in the...</description>
			<content:encoded><![CDATA[<div>I just started to learn Python before a week or so and i found this example and rewrited it in Notepad++ (btw it was really painfull to figure out how to connect Notepad++ with python.exe but i like notepad++ more than Python GUI)<br />
and this program just wont work nor in the Notepad++ nor in the Python GUI (i use 2.6 btw)<br />
 <pre style="margin:20px; line-height:13px">#&nbsp; Calculator Program (Page 17 Python Tutorial)<br />
<br />
# NO CODE IS REALLY RUN HERE,ITS ONLY TELLING US WHAT WE WILL DO LATTER<br />
<br />
# Here we will define our functions<br />
# This prints the main menu,and prompts for a choice<br />
import time # Import time module - Its needed to pause program to see result<br />
<br />
def menu():<br />
&nbsp; &nbsp; &nbsp; &nbsp; # print what options we have<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Welcome to the calculator.py&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Your options are:&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot; &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;1) Addition&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;2) Substraction&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;3) Multiplication&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;4) Division&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;5) Quit Calculatory.py&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot; &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return raw_input(&quot;Choose your option: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
# This add two numbers given<br />
def add(a,b):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print a ,&quot;+&quot;, b , &quot;=&quot; , a + b<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
# This substracts two numbers<br />
def sub(a,b):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print a ,&quot;-&quot; , b ,&quot;=&quot; , a-b<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
# This multiplies two numbers<br />
def mul(a,b):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print a ,&quot;*&quot;, b , &quot;=&quot; , a*b<br />
<br />
# This divides two numbers<br />
def div(a,b):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print a , &quot;/&quot; , b ,&quot;=&quot; , a/b<br />
<br />
# NOW THE PROGRAM REALLY STARTS,AS CODE IS RUN<br />
<br />
loop = 1 <br />
choice = 0<br />
<br />
while loop == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = menu()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if choice == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; add(raw_input(&quot;Add this: &quot;),raw_input(&quot;to this: &quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; sub(raw_input(&quot;Subdivide this: &quot;),raw_input(&quot;by this: &quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; mul(raw_input(&quot;Multiply this: &quot;),raw_input(&quot;by this: &quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; div(raw_input(&quot;Divide this: &quot;),raw_input(&quot;by this: &quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; loop = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Thank you for using Calculator.py&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
raw_input(&quot;Press ENTER to exit&quot;)<br />
time.sleep(5)</pre>i get error message at add(raw_input(&quot;Add this: &quot;),raw_input(&quot;to this: &quot;))<br />
<br />
The code is exactly as in tutorial :/<br />
thx in advance<br />
regards Perun</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>P3run</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234263.html</guid>
		</item>
	</channel>
</rss>
