<?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>Thu, 24 Dec 2009 20:39:35 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>Code Snippet Python doing exact match on string</title>
			<link>http://www.daniweb.com/code/snippet248806.html</link>
			<pubDate>Thu, 24 Dec 2009 20:30:44 GMT</pubDate>
			<description><![CDATA[I want to replace 'nf' with 1.0, so that the resulting string should be: 
'(1.0+nfpermult+1.0)' 
 
I tried various approaches using find(), re.sub but I am not able to make it work. 
 
eg. re.sub('nf', '1.0', str) replaces all occurrences of nf. also re.sub('\bnf\b', '1.0', str) does 
not work...]]></description>
			<content:encoded><![CDATA[<div>I want to replace 'nf' with 1.0, so that the resulting string should be:<br />
'(1.0+nfpermult+1.0)'<br />
<br />
I tried various approaches using find(), re.sub but I am not able to make it work.<br />
<br />
eg. re.sub('nf', '1.0', str) replaces all occurrences of nf. also re.sub('\bnf\b', '1.0', str) does<br />
not work either as 'nf' can be anywhere in the string.<br />
<br />
any ideas?<br />
<br />
- Kaushik</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>kbalamuk</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248806.html</guid>
		</item>
		<item>
			<title>8 Directional Movement</title>
			<link>http://www.daniweb.com/forums/thread248803.html</link>
			<pubDate>Thu, 24 Dec 2009 20:11:04 GMT</pubDate>
			<description><![CDATA[Hi everyone, 
 
having trouble coming up with the right code for 8 directional movement [ up, upright, right, downright, down, downleft, left, upleft] 
 
My keypress handling is: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone,<br />
<br />
having trouble coming up with the right code for 8 directional movement [ up, upright, right, downright, down, downleft, left, upleft]<br />
<br />
My keypress handling is:<br />
<br />
 <pre style="margin:20px; line-height:13px">if event.type == KEYDOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_LEFT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveLeft = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveRight = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_RIGHT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveRight = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveLeft = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_UP:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveUp = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveDown = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_DOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveDown = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveUp = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; if event.type == KEYUP:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_LEFT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveLeft = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_RIGHT:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveRight = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_UP:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveUp = False<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == K_DOWN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.moveDown = False</pre><br />
<br />
And my directional checking is:<br />
 <pre style="margin:20px; line-height:13px">if self.moveRight == True and self.moveUp == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE UPRIGHT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveRight == True and self.moveDown == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE DOWNRIGHT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveRight == True and self.moveUp == False and self.moveDown == False:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE RIGHT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveLeft == True and self.moveUp == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE UPLEFT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveLeft == True and self.moveDown == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE DOWNLEFT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveLeft == True and self.moveUp == False and self.moveDown == False:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE LEFT&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveUp == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE UP&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.moveDown == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;MOVE DOWN&quot;</pre><br />
It worked fine until I added the last two statements for moving up and down:  It fires off MOVE UP and MOVE UPRIGHT at the same time, for example.<br />
<br />
This also seems more complicated than it needs to be. Can you help make this work, and if possible, help me find a more efficient, easier solution?<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>BlackPhoenix</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248803.html</guid>
		</item>
		<item>
			<title>wxwdiget version conflict</title>
			<link>http://www.daniweb.com/forums/thread248758.html</link>
			<pubDate>Thu, 24 Dec 2009 14:00:07 GMT</pubDate>
			<description><![CDATA[hi 
currently on my ubuntu i have both wx-2.6-gtk2-unicode & wx-2.8-gtk2-unicode installed, but when i use this code in python 2.6 : 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>hi<br />
currently on my ubuntu i have both wx-2.6-gtk2-unicode &amp; wx-2.8-gtk2-unicode installed, but when i use this code in python 2.6 :<br />
 <pre style="margin:20px; line-height:13px">import wx</pre>always wxwidget 2.6 was imported.<br />
is there any solution to have both or it's better to uninstall version 2.6 ?<br />
thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>mehdi0016</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248758.html</guid>
		</item>
		<item>
			<title>onclick screenshot</title>
			<link>http://www.daniweb.com/forums/thread248725.html</link>
			<pubDate>Thu, 24 Dec 2009 12:23:35 GMT</pubDate>
			<description><![CDATA[Hello everybody, 
 
I am having trouble to create the following script: I would like a screenshot been taken each time a click is detected. Also (if possible) to be able to modify the x and y of the size of the screenshot. 
There is my code (doesn't work yet): 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hello everybody,<br />
<br />
I am having trouble to create the following script: I would like a screenshot been taken each time a click is detected. Also (if possible) to be able to modify the x and y of the size of the screenshot.<br />
There is my code (doesn't work yet):<br />
 <pre style="margin:20px; line-height:13px">import pyHook<br />
import pythoncom<br />
import ImageGrab<br />
<br />
def onclick(event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; img = ImageGrab.grab()<br />
&nbsp; &nbsp; &nbsp; &nbsp; img.save(&quot;screenImage1.jpg&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return true<br />
<br />
hm = pyHook.HookManager()<br />
hm.SubscribeMouseAllButtonsDown(onclick)<br />
hm.HookMouse()<br />
pythoncom.PumpMessages()<br />
hm.UnhookMouse()</pre><br />
Thanks a lot :).<br />
<br />
Benou</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Benou</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248725.html</guid>
		</item>
		<item>
			<title>My First web programing</title>
			<link>http://www.daniweb.com/forums/thread248689.html</link>
			<pubDate>Thu, 24 Dec 2009 08:36:17 GMT</pubDate>
			<description><![CDATA[Hi dears.I want start making a web with python but I know nothing a bout web.and so don't know from where a have to start. 
I need a point to start and a few knowledge about webs programing  foundation.please introduce me a suitable source for beginning. 
 
Thanks.]]></description>
			<content:encoded><![CDATA[<div>Hi dears.I want start making a web with python but I know nothing a bout web.and so don't know from where a have to start.<br />
I need a point to start and a few knowledge about webs programing  foundation.please introduce me a suitable source for beginning.<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>funfullson</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248689.html</guid>
		</item>
		<item>
			<title>References or Ebooks</title>
			<link>http://www.daniweb.com/forums/thread248666.html</link>
			<pubDate>Thu, 24 Dec 2009 05:47:19 GMT</pubDate>
			<description><![CDATA[I'm not sure this is the correct forum for this, but it's at least relative. I was wondering if anyone knew of some decent references and ebooks for a beginning Django user.Yes, I know djangoproject has tutorials, but there decently hard to understand. If someone could either help or steer me in...]]></description>
			<content:encoded><![CDATA[<div>I'm not sure this is the correct forum for this, but it's at least relative. I was wondering if anyone knew of some decent references and ebooks for a beginning Django user.Yes, I know djangoproject has tutorials, but there decently hard to understand. If someone could either help or steer me in the right direction would be great! I would prefer free, I cannot afford a book or ebook at this moment. Christmas and other issues.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Democles</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248666.html</guid>
		</item>
		<item>
			<title>Access method of class instance that assigned class</title>
			<link>http://www.daniweb.com/forums/thread248627.html</link>
			<pubDate>Thu, 24 Dec 2009 01:04:14 GMT</pubDate>
			<description><![CDATA[Okay python gurus, this one has me stumped.  Is it possible to introspect and obtain the instance of a class that assigned a class? 
 
I have a simple sample that demonstrates what I'm looking for, but doesn't make any sense why you would do it. 
 
 
class One(object): 
    def...]]></description>
			<content:encoded><![CDATA[<div>Okay python gurus, this one has me stumped.  Is it possible to introspect and obtain the instance of a class that assigned a class?<br />
<br />
I have a simple sample that demonstrates what I'm looking for, but doesn't make any sense why you would do it.<br />
<br />
 <pre style="margin:20px; line-height:13px">class One(object):<br />
&nbsp; &nbsp; def print_parent_hw(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; ?????????<br />
&nbsp; &nbsp; &nbsp; &nbsp; ?????????.print_hw()<br />
<br />
class Two(object):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.cls = One()<br />
&nbsp; &nbsp; def print_hw(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Hello World from One&quot;<br />
&nbsp; &nbsp; def have_one_print_two(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.cls.printparent_hw()<br />
<br />
a = Two()<br />
a.have_one_print_two()</pre><br />
<br />
I could do it by rewriting some code, but this situation could be cleaner and quicker (even though the sample doesn't make much logical sense).  I realize I could do it like this, but it doesn't seem right, and you end up with a circular attribute (i.e. a.cls.parent.cls.parent.cls.parent.cls.......)<br />
<br />
 <pre style="margin:20px; line-height:13px">class One(object):<br />
&nbsp; &nbsp; def __init__(self, parent):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.parent = parent<br />
&nbsp; &nbsp; def print_parent_hw(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.parent.print_hw()<br />
<br />
class Two(object):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.cls = One(self)<br />
&nbsp; &nbsp; def print_hw(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;Hello World from One&quot;<br />
&nbsp; &nbsp; def have_one_print_two(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.cls.print_parent_hw()<br />
<br />
a = Two()<br />
a.have_one_print_two()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>xvalentinex</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248627.html</guid>
		</item>
		<item>
			<title>- web scraping using python</title>
			<link>http://www.daniweb.com/forums/thread248580.html</link>
			<pubDate>Wed, 23 Dec 2009 17:56:34 GMT</pubDate>
			<description><![CDATA[Hi ,  
Im trying  to extract the number 7.2 from the html string below using python: 
 
'''<a href="/ratings_explained">weighted average</a> vote of <a href="/List?ratings=7">7.2</a> / 10</p><p>''' 
 
I thought this would be code to do this .But  how come this doesnt work ? 
 
averageget =...]]></description>
			<content:encoded><![CDATA[<div>Hi , <br />
Im trying  to extract the number 7.2 from the html string below using python:<br />
<br />
'''&lt;a href=&quot;/ratings_explained&quot;&gt;weighted average&lt;/a&gt; vote of &lt;a href=&quot;/List?ratings=7&quot;&gt;7.2&lt;/a&gt; / 10&lt;/p&gt;&lt;p&gt;'''<br />
<br />
I thought this would be code to do this .But  how come this doesnt work ?<br />
<br />
averageget = re.compile('&lt;a href=&quot;/List?ratings=7&quot;&gt;(.*?)&lt;/a&gt;')<br />
average = averageget.findall(htmlr)<br />
<br />
Could it be that there some special structures in the html file which I missed out ?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>masterinex</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248580.html</guid>
		</item>
		<item>
			<title>wxPython + turbogears ? is possible?</title>
			<link>http://www.daniweb.com/forums/thread248535.html</link>
			<pubDate>Wed, 23 Dec 2009 13:29:39 GMT</pubDate>
			<description>Hi, 
 
I wonder how to use wx.FileDialog with turbogears . 
 
I have this turbogears project, and i have a form which add new employees, and for each employee i need to let the person who is adding them to pick a photo from his filesystem. 
 
And all wxPython guides already start with the hello...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I wonder how to use wx.FileDialog with turbogears .<br />
<br />
I have this turbogears project, and i have a form which add new employees, and for each employee i need to let the person who is adding them to pick a photo from his filesystem.<br />
<br />
And all wxPython guides already start with the hello world app, and a lot of code snippets.. but i cant find nothing to do with turbogears. <br />
<br />
im very newbie to wxPython and as english its not my native language .. i missunderstand a lot of things.<br />
<br />
first of all .. its possible to use turbogears + wxPython to do what i need to do?<br />
<br />
if not... any tip ?!!??<br />
<br />
thanks in advance !</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>fferrandini</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248535.html</guid>
		</item>
		<item>
			<title>Pack Unicode String</title>
			<link>http://www.daniweb.com/forums/thread248499.html</link>
			<pubDate>Wed, 23 Dec 2009 10:43:25 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am trying to pack a unicode string of 40 bytes using the pack method. 
 
 
data = pack('<8sB40s', 
                    asc_time, 
                    language_id, 
                    message)]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am trying to pack a unicode string of 40 bytes using the pack method.<br />
<br />
 <pre style="margin:20px; line-height:13px">data = pack('&lt;8sB40s',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; asc_time,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; language_id,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message)</pre><br />
it throws the following error:<br />
struct.error: argument for 's' must be a string<br />
<br />
What is the argument for a unicode string?<br />
Thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>vsagarmb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248499.html</guid>
		</item>
		<item>
			<title>wxpython 2.8 demos code help required</title>
			<link>http://www.daniweb.com/forums/thread248497.html</link>
			<pubDate>Wed, 23 Dec 2009 10:40:57 GMT</pubDate>
			<description><![CDATA[hello, 
 
i want to utilize the  demo code given in the wxpython 2.8 documentation & demos. 
can any one guide me how can i do that??? 
when i try to copy that code to editor to change it according to my requirements ..it gives me an error message and close the editor without giving any message......]]></description>
			<content:encoded><![CDATA[<div>hello,<br />
<br />
i want to utilize the  demo code given in the wxpython 2.8 documentation &amp; demos.<br />
can any one guide me how can i do that???<br />
when i try to copy that code to editor to change it according to my requirements ..it gives me an error message and close the editor without giving any message...<br />
<br />
any onw ho knows how to edit those demo codes please let me know..your help will be highly appreciated...<br />
Regards,<br />
punter</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>punter999</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248497.html</guid>
		</item>
		<item>
			<title>help for matrices  in pyhton</title>
			<link>http://www.daniweb.com/forums/thread248448.html</link>
			<pubDate>Wed, 23 Dec 2009 07:38:56 GMT</pubDate>
			<description>hello Seniors, 
i am new to python development.i have started my internship in that language. 
 
can any one provide me the code that show me how to add subtract and multiply matrices in python.??? 
 
what will be the code if i want to take input from the user to enter the value of the matrix and...</description>
			<content:encoded><![CDATA[<div>hello Seniors,<br />
i am new to python development.i have started my internship in that language.<br />
<br />
can any one provide me the code that show me how to add subtract and multiply matrices in python.???<br />
<br />
what will be the code if i want to take input from the user to enter the value of the matrix and on that base it will add,subtract or multiply the two matrices??<br />
<br />
any one who knows about it please help me...<br />
i will really appreciate that.<br />
Thank You<br />
Punter</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>punter999</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248448.html</guid>
		</item>
		<item>
			<title>decoding arbitrary byte data</title>
			<link>http://www.daniweb.com/forums/thread248422.html</link>
			<pubDate>Wed, 23 Dec 2009 04:41:00 GMT</pubDate>
			<description><![CDATA[Hello, I'm trying to deal a bit with IRC and Python 3. The decoding from bytes to Unicode create quite a dilemma. 
 
1. Somehow it works to convert the å character from utf-8 to bytes, but the received bytes seem to often be encoded in latin-1, or at least they can be decoded correctly as that....]]></description>
			<content:encoded><![CDATA[<div>Hello, I'm trying to deal a bit with IRC and Python 3. The decoding from bytes to Unicode create quite a dilemma.<br />
<br />
1. Somehow it works to convert the å character from utf-8 to bytes, but the received bytes seem to often be encoded in latin-1, or at least they can be decoded correctly as that. Does this mean that on IRC servers the data being transmitted can be encoded characters of any arbitrary set (utf-8, latin-1, etc)?<br />
<br />
2. If that is the case, is there then some way to figure out what the encoding is? Because the utf-8 codec cannot decode the character \xe5, which latin-1 decodes to å. utf-8 decodes \xc3\xa5 to å. Seemingly, there is no way then to know what encoding is being done on IRC?<br />
<br />
3. My approach to this problem is that I can take the OS default charset. For example, using tkinter, there must be some charset being used in the text widget. How can I find this out? At least then, for an IRC client, the language used by the system will be decoded properly when chatting.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ribot</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248422.html</guid>
		</item>
		<item>
			<title>how do I extract data from html file ?</title>
			<link>http://www.daniweb.com/forums/thread248377.html</link>
			<pubDate>Tue, 22 Dec 2009 21:25:23 GMT</pubDate>
			<description><![CDATA[Hi, 
I want write a program which  
extract 'Rated PG for some scary moments and mild language'  from the  following   html file and return it as a list .   
 
html file: 
<div class="info"> 
<h5><a href="/mpaa">MPAA</a>:</h5> 
 
<div class="info-content"> 
Rated PG for some scary moments and mild...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I want write a program which <br />
extract 'Rated PG for some scary moments and mild language'  from the  following   html file and return it as a list .  <br />
<br />
html file:<br />
&lt;div class=&quot;info&quot;&gt;<br />
&lt;h5&gt;&lt;a href=&quot;/mpaa&quot;&gt;MPAA&lt;/a&gt;:&lt;/h5&gt;<br />
<br />
&lt;div class=&quot;info-content&quot;&gt;<br />
Rated PG for some scary moments and mild language. (also 2009 extended version)<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
<br />
Why wouldnt this code work ? <br />
mpaaget = re.compile('&lt;h5&gt;&lt;a href=&quot;/mpaa&quot;&gt;MPAA&lt;/a&gt;:&lt;/h5&gt;&lt;div class=&quot;info-content&quot;&gt;(.*?)&lt;/div&gt;')<br />
 mpaa = mpaaget.findall(htmlr)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>masterinex</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248377.html</guid>
		</item>
		<item>
			<title>try-except</title>
			<link>http://www.daniweb.com/forums/thread248369.html</link>
			<pubDate>Tue, 22 Dec 2009 20:36:13 GMT</pubDate>
			<description>How can I use try-except to deal with an error? 
 
Thank you :)</description>
			<content:encoded><![CDATA[<div>How can I use try-except to deal with an error?<br />
<br />
Thank you :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>eva yang</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248369.html</guid>
		</item>
		<item>
			<title>object.attribute</title>
			<link>http://www.daniweb.com/forums/thread248365.html</link>
			<pubDate>Tue, 22 Dec 2009 20:27:39 GMT</pubDate>
			<description>what can i get from object.attribute? what does it do? 
 
 
Thank you :)</description>
			<content:encoded><![CDATA[<div>what can i get from object.attribute? what does it do?<br />
<br />
<br />
Thank you :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>eva yang</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248365.html</guid>
		</item>
		<item>
			<title>Python login-logout-sending email</title>
			<link>http://www.daniweb.com/forums/thread248352.html</link>
			<pubDate>Tue, 22 Dec 2009 19:28:42 GMT</pubDate>
			<description><![CDATA[I really need help because of my senior project. 
I don't know the Python syntax and how I write. So please help me...! 
 
I have a prototype presentation on monday and I have to show login, logout and sending a mail code parts... 
 
Can you help meee???? pleaseeeee=((((]]></description>
			<content:encoded><![CDATA[<div>I really need help because of my senior project.<br />
I don't know the Python syntax and how I write. So please help me...!<br />
<br />
I have a prototype presentation on monday and I have to show login, logout and sending a mail code parts...<br />
<br />
Can you help meee???? pleaseeeee=((((</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>gzm_e</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248352.html</guid>
		</item>
		<item>
			<title>Colour picker problem</title>
			<link>http://www.daniweb.com/forums/thread248294.html</link>
			<pubDate>Tue, 22 Dec 2009 14:25:29 GMT</pubDate>
			<description><![CDATA[Im trying to write a code for a colour picker, so a user can pick 4 different colours and then it would return them so i can use them in a different par tof the program, but its not working properly and i can work out why. any ideas? 
 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Im trying to write a code for a colour picker, so a user can pick 4 different colours and then it would return them so i can use them in a different par tof the program, but its not working properly and i can work out why. any ideas?<br />
<br />
 <pre style="margin:20px; line-height:13px">def colourpicker():<br />
&nbsp; &nbsp; print &quot;pick four different colours from; red, green, blue, yellow, orange, pink, brown&quot;<br />
&nbsp; &nbsp; colourList = [&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;yellow&quot;, &quot;orange&quot;, &quot;pink&quot;, &quot;brown&quot;]<br />
&nbsp; &nbsp; coloursPicked = []<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour1 = raw_input(&quot;pick first colour: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour1 in colourList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour1 = raw_input(&quot;not in list, pick agin: &quot;)<br />
&nbsp; &nbsp; coloursPicked.append(colour1)<br />
&nbsp; &nbsp; return coloursPicked<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour2 = raw_input(&quot;pick second colour: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour2 in coloursPicked:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour2 = raw_input(&quot;colour already picked, pick again: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour2 in colourList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour2 = raw_input(&quot;not in list, pick agin: &quot;)<br />
&nbsp; &nbsp; coloursPicked.append(colour2)<br />
&nbsp; &nbsp; return coloursPicked<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour3 = raw_input(&quot;pick third colour: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour3 in coloursPicked:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour3 = raw_input(&quot;colour already picked, pick again: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour3 in colourList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour3 = raw_input(&quot;not in list, pick agin: &quot;)<br />
&nbsp; &nbsp; coloursPicked.append(colour3)<br />
&nbsp; &nbsp; return coloursPicked<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour4 = raw_input(&quot;pick fouth colour: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour4 in coloursPicked:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour4 = raw_input(&quot;colour already picked, pick again: &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if colour4 in colourList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<br />
&nbsp; &nbsp; &nbsp; &nbsp; colour4 = raw_input(&quot;not in list, pick agin: &quot;)<br />
&nbsp; &nbsp; coloursPicked.append(colour4)<br />
&nbsp; &nbsp; return coloursPicked</pre><br />
i think some of the loops might not be working how i want them too, but i cant seem to work it out.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pyguy420</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248294.html</guid>
		</item>
		<item>
			<title>Get Keys from a dictionary of a dictionary</title>
			<link>http://www.daniweb.com/forums/thread248240.html</link>
			<pubDate>Tue, 22 Dec 2009 09:16:09 GMT</pubDate>
			<description><![CDATA[I have read some documentation about python, but no examples on how could you can extract Keys from a double dictionary. 
To understand better here is an example: 
 
Let's say we have the following dictionary: 
{'AAA':  {'KEY1':'text1', 'KEY2':'text2', 'KEY3:' 'text3', 'KEY4': 'text4'}, 
'BBB':  ...]]></description>
			<content:encoded><![CDATA[<div>I have read some documentation about python, but no examples on how could you can extract Keys from a double dictionary.<br />
To understand better here is an example:<br />
<br />
Let's say we have the following dictionary:<br />
{'AAA':  {'KEY1':'text1', 'KEY2':'text2', 'KEY3:' 'text3', 'KEY4': 'text4'},<br />
'BBB':   {'BBB1':{'KEY1':'text1', 'KEY2':'text2', 'KEY3:' 'text3', 'KEY4': 'text4'},<br />
            'BBB2':{'KEY1':'text1', 'KEY2':'text2', 'KEY3:' 'text3', 'KEY4': 'text4'},<br />
            'BBB3':{'KEY1':'text1', 'KEY2':'text2', 'KEY3:' 'text3', 'KEY4': 'text4'}}}<br />
<br />
How can i extract KEY1, KEY2 and KEY 4 from AAA and KEY3 KEY4 from BBB1, BBB2, BBB3 in BBB?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>playonlcd</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248240.html</guid>
		</item>
		<item>
			<title>Random Numbers (lotto)</title>
			<link>http://www.daniweb.com/forums/thread248277.html</link>
			<pubDate>Tue, 22 Dec 2009 07:00:28 GMT</pubDate>
			<description><![CDATA[---Quote (Originally by vegaseat)--- 
This little code shows 6 random integer numbers from 1 to 50 ... 
  <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><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 />  <div> Originally Posted by <strong>vegaseat</strong> (Post 250820) </div> <div style="font-style:italic">This little code shows 6 random integer numbers from 1 to 50 ...<br />
 <pre style="margin:20px; line-height:13px">import random<br />
<br />
print &quot;show 6 random integers from 1 to 50:&quot;<br />
for k in range(6):<br />
&nbsp; r = random.randint(1, 50)<br />
&nbsp; print r,<br />
print</pre>Rewrite the code to make sure there are no duplicate numbers amongst the six numbers displayed.<br />
<br />
Now let the user enter six unique numbers from 1 to 50 and then count how many tries it takes the computer to match 3, 4, 5 or 6 of the user's numbers, using the above random number example.  You might recognize this as a way to figure out the chances to win a lotto game.</div>  <hr /> </td> </tr> </table> </div>Not sure if this is the place to ask but I want to write a similar program that list all possible combinations and have it displayed in the Notepad program. Where do I start? And how do I write a search program (with parameters that I set) that filters the results?<br />
<br />
Thanks!<br />
<br />
Editor's Note:<br />
This question has been moved to the forum from Projects for Beginners.<br />
Sorry, the title should really be <span style="font-weight:bold">combinations</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>badboy00z</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248277.html</guid>
		</item>
		<item>
			<title>Creating a tuple from file</title>
			<link>http://www.daniweb.com/forums/thread248183.html</link>
			<pubDate>Tue, 22 Dec 2009 05:29:25 GMT</pubDate>
			<description><![CDATA[Okay, so I have a tuple for a game, and this is it: ['Hondros', {'Equiped': [['none', [], 0], ['Rags', [0, 1, 0, 0], 1, 1], ['Mocassins', [0, 0, 1, 0], 1, 1], ['Gauntlets', [0, 0, 0, 1], 6, 5]], 'Equipment': [0, 1, 1, 1], 'Stats': {'AC': 14, 'Strength': 15, 'Constitution': 14, 'Level': 1, 'HP': 12,...]]></description>
			<content:encoded><![CDATA[<div>Okay, so I have a tuple for a game, and this is it:  <pre style="margin:20px; line-height:13px">['Hondros', {'Equiped': [['none', [], 0], ['Rags', [0, 1, 0, 0], 1, 1], ['Mocassins', [0, 0, 1, 0], 1, 1], ['Gauntlets', [0, 0, 0, 1], 6, 5]], 'Equipment': [0, 1, 1, 1], 'Stats': {'AC': 14, 'Strength': 15, 'Constitution': 14, 'Level': 1, 'HP': 12, 'Experience': 0, 'Dexterity': 12, 'Intelligence': 12, 'Base AC': 8, 'Wisdom': 11, 'HP max': 12}, 'Inventory': [], 'Gold': 0}]</pre> Anything inside it can change, including number of tuples inside the dictionaries. Anyways, this is how my program stores the character's information. There might be more added on. Now, this is what I want to do. I want to open a file, convert the tuple to a long integer, through use of the ord(). I've already done this, and saved it as character.sav, where character is the character's name. Now, when I open it, and convert it back, I now have a string of the above tuple. How do I go about reconverting it? Doing a tuple of it just makes it weird...<br />
<br />
EDIT: Er... I seem to have my definitions of tuple and list confused... these are lists, not tuples. Oh well... same difference really</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>hondros</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248183.html</guid>
		</item>
		<item>
			<title>Small directory management project.</title>
			<link>http://www.daniweb.com/forums/thread248102.html</link>
			<pubDate>Mon, 21 Dec 2009 19:39:39 GMT</pubDate>
			<description><![CDATA[I'm thinking about writing a small command line directory management program in Python. The most basic functionality I want is to be able to compare the the files in a directory and sub-directory, and if there are any duplicates then delete the lower most duplicate. 
 
I all ready have a basic idea...]]></description>
			<content:encoded><![CDATA[<div>I'm thinking about writing a small command line directory management program in Python. The most basic functionality I want is to be able to compare the the files in a directory and sub-directory, and if there are any duplicates then delete the lower most duplicate.<br />
<br />
I all ready have a basic idea of how to accomplish that. Merely hash both files and compare the hash values. If the hash values are equivalent, then they are the same. However, I'm not sure on the specifics of how to accomplish it. I know the data has to be read from each file and then hashed to do the comparison. However, what is the best method for reading the data? I'll be dealing with large files, possibly upwards of 4GB, so the program needs to be able to handle this.<br />
<br />
What are some other good tools to include? I'm thinking about writing some file renaming tools as well.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>lrh9</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248102.html</guid>
		</item>
		<item>
			<title>Multiplication program help</title>
			<link>http://www.daniweb.com/forums/thread248007.html</link>
			<pubDate>Mon, 21 Dec 2009 12:05:17 GMT</pubDate>
			<description><![CDATA[I made this 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 Code Tags</a> </div> <div>...]]></description>
			<content:encoded><![CDATA[<div>I made this code:<br />
 <pre style="margin:20px; line-height:13px">import random<br />
wish = &quot;j&quot;<br />
max_multiplications = 10<br />
while wish == &quot;j&quot;:<br />
&nbsp; &nbsp; multi = 0<br />
&nbsp; &nbsp; right_answer = 0<br />
&nbsp; &nbsp; while max_multiplications != multi:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; randomint1 = random.randint(1, 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; randomint2 = random.randint(1, 10)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; print randomint1, &quot;*&quot;, randomint2, &quot;=&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ik = float(raw_input (&quot;Insert your answer &quot;))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; multi += 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; answer = randomint1 * randomint2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ik == answer:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right_answer += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Correct!Good Job!&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Wrong answer!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;  <br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; wish = raw_input(&quot;You want to try again? [j/e]&quot;)</pre><br />
But maybe someone can help me now. How can I put into the beginning ,that the user can choose how many multiplications he wants to solve(not 10) AND if the user inserts a wrong answer he can try again.<br />
<br />
Thanks! :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>teenspirits</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread248007.html</guid>
		</item>
		<item>
			<title><![CDATA[Help with "setting the path".]]></title>
			<link>http://www.daniweb.com/forums/thread247962.html</link>
			<pubDate>Mon, 21 Dec 2009 08:53:51 GMT</pubDate>
			<description><![CDATA[Hi everyone. I'm new to Python and programming in general. I'm currently reading this (http://www.dickbaldwin.com/tocpyth.htm) tutorial. In the scripts section he mentions "setting the path" and that it needs to be done in order for scripts to work.  
 
How do I set the path in Windows XP? 
...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone. I'm new to Python and programming in general. I'm currently reading <a rel="nofollow" class="t" href="http://www.dickbaldwin.com/tocpyth.htm" target="_blank">this</a> tutorial. In the scripts section he mentions &quot;setting the path&quot; and that it needs to be done in order for scripts to work. <br />
<br />
How do I set the path in Windows XP?<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>badboy00z</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247962.html</guid>
		</item>
		<item>
			<title>importing scripts</title>
			<link>http://www.daniweb.com/forums/thread247882.html</link>
			<pubDate>Sun, 20 Dec 2009 20:43:28 GMT</pubDate>
			<description><![CDATA[Okay, I am in the middle of creating a rather large console RPG. It'll include ability to equip armor, weapons, interacting with NPC's, battles, saving/loading characters, etc. I don't want to save all of my classes and functions in the same file, for easier readability. I have a few questions: 
1)...]]></description>
			<content:encoded><![CDATA[<div>Okay, I am in the middle of creating a rather large console RPG. It'll include ability to equip armor, weapons, interacting with NPC's, battles, saving/loading characters, etc. I don't want to save all of my classes and functions in the same file, for easier readability. I have a few questions:<br />
1) Can I import .py files that are in the same folder to a separate .py file?<br />
2) How does this change py2exe? Do I just setup the script for the main one, or all?<br />
<br />
Thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>hondros</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247882.html</guid>
		</item>
		<item>
			<title>Derived Classes</title>
			<link>http://www.daniweb.com/forums/thread247866.html</link>
			<pubDate>Sun, 20 Dec 2009 18:53:34 GMT</pubDate>
			<description><![CDATA[In the program below, I have two questions. First, the first object, card1 passes the strings A & c to it's master class. What I want to know is, what do these two strings have to do with the A & c in RANKS & SUITS? If the class had been based the number of the element in RANKS & SUITS I wouldn't...]]></description>
			<content:encoded><![CDATA[<div>In the program below, I have two questions. First, the first object, card1 passes the strings A &amp; c to it's master class. What I want to know is, what do these two strings have to do with the A &amp; c in RANKS &amp; SUITS? If the class had been based the number of the element in RANKS &amp; SUITS I wouldn't be confused right now but I don't see RANKS or SUITS being used.<br />
<br />
Secondly, why is there an __init__ method inside the Positionable_Card class with rank and suit, but is then instructed to use rank and suit from it's base class? Thanks for any and all replies.<br />
<br />
 <pre style="margin:20px; line-height:13px"># Playing Cards 3.0<br />
# Demonstrates inheritance - overriding methods<br />
<br />
class Card(object):<br />
&nbsp; &nbsp; &quot;&quot;&quot; A playing card. &quot;&quot;&quot;<br />
&nbsp; &nbsp; RANKS = [&quot;A&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;8&quot;, &quot;9&quot;, &quot;10&quot;, &quot;J&quot;, &quot;Q&quot;, &quot;K&quot;]<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; SUITS = [&quot;c&quot;, &quot;d&quot;, &quot;h&quot;, &quot;s&quot;]<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; def __init__(self, rank, suit):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.rank = rank<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.suit = suit<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def __str__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; rep = self.rank + self.suit<br />
&nbsp; &nbsp; &nbsp; &nbsp; return rep<br />
&nbsp;<br />
<br />
class&nbsp;  Unprintable_Card(Card):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;A Card that won't reveal it's ran or suit when printed. &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; def __str__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;&lt;unprintable&gt;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
class Positionable_Card(Card):<br />
&nbsp; &nbsp; &quot;&quot;&quot; A Card that can be face up or face down. &quot;&quot;&quot;<br />
&nbsp; &nbsp; def __init__(self, rank, suit, face_up = True):<br />
&nbsp; &nbsp; &nbsp; &nbsp; super(Positionable_Card, self).__init__(rank, suit)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.is_face_up = face_up<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def __str__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.is_face_up:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rep = super(Positionable_Card, self).__str__()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rep = &quot;XX&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return rep<br />
<br />
&nbsp; &nbsp; def flip(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.is_face_up = not self.is_face_up<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
# main<br />
card1 = Card(&quot;A&quot;, &quot;c&quot;)<br />
card2 = Unprintable_Card(&quot;A&quot;, &quot;d&quot;)<br />
card3 = Positionable_Card(&quot;A&quot;, &quot;h&quot;)<br />
<br />
print &quot;Printing a Card object:&quot;<br />
print card1<br />
<br />
print &quot;\nPrinting an Unprintable_Card object:&quot;<br />
print card2<br />
<br />
print &quot;\nPrinting a Positionable_Card object:&quot;<br />
print card3<br />
<br />
print &quot;Flipping the Positionable_Card object.&quot;<br />
card3.flip()<br />
<br />
print &quot;Printing the Positionable_Card object:&quot;<br />
print card3<br />
<br />
raw_input(&quot;\n\nPress the enter key to exit.&quot;)</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/thread247866.html</guid>
		</item>
		<item>
			<title>web application using python</title>
			<link>http://www.daniweb.com/forums/thread247812.html</link>
			<pubDate>Sun, 20 Dec 2009 13:05:25 GMT</pubDate>
			<description>I need to know more about turbogears as one tools used to develop web by python (rapid development ). 
if any person know more information about this topic</description>
			<content:encoded><![CDATA[<div>I need to know more about turbogears as one tools used to develop web by python (rapid development ).<br />
if any person know more information about this topic</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>mdawaina</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247812.html</guid>
		</item>
		<item>
			<title>IronPython Question</title>
			<link>http://www.daniweb.com/forums/thread247819.html</link>
			<pubDate>Sun, 20 Dec 2009 08:56:05 GMT</pubDate>
			<description><![CDATA[This code is IronPython! 
Won't work with CPython. 
 
IronPython - Hello World 
  <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>This code is IronPython!<br />
Won't work with CPython.<br />
<br />
IronPython - Hello World<br />
 <pre style="margin:20px; line-height:13px">import clr<br />
clr.AddReference('System.Windows.Forms')<br />
<br />
from System.Windows.Forms import Application, Form, Label<br />
<br />
form = Form(Text=&quot;Hello World Form&quot;)<br />
label = Label(Text=&quot;Hello World!&quot;)<br />
<br />
form.Controls.Add(label)<br />
<br />
Application.Run(form)</pre>Editor's note:<br />
This post moved from Python GUI Programming sticky thread.<br />
Please follow the rules of this thread and don't clutter it with questions!<br />
Start your own thread and title it &quot;IronPython Question&quot; or something.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>jcao219</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247819.html</guid>
		</item>
		<item>
			<title>simple function help</title>
			<link>http://www.daniweb.com/forums/thread247760.html</link>
			<pubDate>Sun, 20 Dec 2009 05:52:35 GMT</pubDate>
			<description><![CDATA[lets say i want to make a function that accepts a single argument that is supposed to be a number. 
 
lets say the function displays the range between 0 and the argument.  
 
Normally I'd do something like this: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>lets say i want to make a function that accepts a single argument that is supposed to be a number.<br />
<br />
lets say the function displays the range between 0 and the argument. <br />
<br />
Normally I'd do something like this:<br />
<br />
 <pre style="margin:20px; line-height:13px">def range_display(integer):<br />
&nbsp; &nbsp;  set = []<br />
&nbsp; &nbsp;  for num in range(0, integer):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; range_list = set.append(num)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return range_list</pre><br />
But I don't know if thats how functions accept arguments. Just a guess.<br />
<br />
How exactly do you make functions accept arguments? I don't quite get it...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ffs82defxp</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247760.html</guid>
		</item>
		<item>
			<title>Updating a wx.listbox from a different class</title>
			<link>http://www.daniweb.com/forums/thread247757.html</link>
			<pubDate>Sun, 20 Dec 2009 05:27:04 GMT</pubDate>
			<description>Hi there daniweb, im looking for some help. I have two classes MainWindow(wx.Frame), and AddTask(wx.Dialog). MainWindow contains a listbox called task_list. When AddTask is created I want the user to fill out the required info and and then click a button activating an on_click event. In that event...</description>
			<content:encoded><![CDATA[<div>Hi there daniweb, im looking for some help. I have two classes MainWindow(wx.Frame), and AddTask(wx.Dialog). MainWindow contains a listbox called task_list. When AddTask is created I want the user to fill out the required info and and then click a button activating an on_click event. In that event I want to update the list in MainWindow. How ever when I try to do so I get and error: 'MainWindow' object has no attribute task_list.<br />
<br />
Here is what I have tried so far (not full code):<br />
 <pre style="margin:20px; line-height:13px">class MainWindow(wx.Frame):<br />
&nbsp;  <br />
&nbsp; &nbsp; def __init__(self, *args, **kwds):<br />
&nbsp; &nbsp; &nbsp; &nbsp; kwds[&quot;style&quot;] = wx.DEFAULT_FRAME_STYLE<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.Frame.__init__(self, *args, **kwds)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.create_tasklist()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.create_toolbar()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.set_properties()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.do_layout()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.bind_events()<br />
<br />
&nbsp; &nbsp; def create_tasklist(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice_list = [&quot;TaskOne&quot;, &quot;TaskTwo&quot;, &quot;TaskThree&quot;]<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.task_list = wx.ListBox(self, -1, choices = choice_list)<br />
......<br />
<br />
&nbsp; &nbsp; def on_add(self, event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; '''Adds new task to task_list.'''<br />
&nbsp; &nbsp; &nbsp; &nbsp; add_task = AddTask(None, -1, &quot;Add Task&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; add_task.ShowModal()<br />
&nbsp; &nbsp; &nbsp; &nbsp; add_task.Destroy()<br />
<br />
......<br />
<br />
class AddTask(wx.Dialog):<br />
&nbsp; &nbsp; '''Custom dialog to add tasks to task list.'''<br />
<br />
&nbsp; &nbsp; def __init__(self, *args, **kwds):<br />
&nbsp; &nbsp; &nbsp; &nbsp; kwds[&quot;style&quot;] = wx.DEFAULT_DIALOG_STYLE<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.Dialog.__init__(self, *args, **kwds)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.create_widgets()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.set_properties()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.do_layout()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.bind_events()<br />
......<br />
<br />
&nbsp; &nbsp; def on_add_button_click(self, event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; # Adds task_name to task_list<br />
&nbsp; &nbsp; &nbsp; &nbsp; MainWindow.task_list.Insert(self.task_name_text.GetValue())</pre><br />
I have also tried other variations though I think this one shows what I am trying to do the best.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ShadyTyrant</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247757.html</guid>
		</item>
		<item>
			<title>Creating Generic Python Variables</title>
			<link>http://www.daniweb.com/forums/thread247699.html</link>
			<pubDate>Sat, 19 Dec 2009 18:32:08 GMT</pubDate>
			<description><![CDATA[I'm working with Tkinter and I need to  make 600 buttons in a grid of 6x100. Is there a way to produce generic variables by going through a for loop? Or do I have to type all 600?]]></description>
			<content:encoded><![CDATA[<div>I'm working with Tkinter and I need to  make 600 buttons in a grid of 6x100. Is there a way to produce generic variables by going through a for loop? Or do I have to type all 600?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Destray</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247699.html</guid>
		</item>
		<item>
			<title>Back to Linux - Good IDE?</title>
			<link>http://www.daniweb.com/forums/thread247644.html</link>
			<pubDate>Sat, 19 Dec 2009 12:16:40 GMT</pubDate>
			<description><![CDATA[Duh! I'm now using Linux from my external HDD again.  
Please suggest a good IDE for me 
Thanks]]></description>
			<content:encoded><![CDATA[<div>Duh! I'm now using Linux from my external HDD again. <br />
Please suggest a good IDE for me<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>evstevemd</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247644.html</guid>
		</item>
		<item>
			<title>Install modules in Mandriva 2010</title>
			<link>http://www.daniweb.com/forums/thread247643.html</link>
			<pubDate>Sat, 19 Dec 2009 12:14:25 GMT</pubDate>
			<description>Hi, 
Iam now using Mandriva from external HDD and want to install my development tools. I need to install wxPython, Matplotlib,  and some other packages. How to do that in Mandriva?</description>
			<content:encoded><![CDATA[<div>Hi,<br />
Iam now using Mandriva from external HDD and want to install my development tools. I need to install wxPython, Matplotlib,  and some other packages. How to do that in Mandriva?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>evstevemd</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247643.html</guid>
		</item>
		<item>
			<title>python newb help (functions and while loop)</title>
			<link>http://www.daniweb.com/forums/thread247565.html</link>
			<pubDate>Sat, 19 Dec 2009 03:23:45 GMT</pubDate>
			<description><![CDATA[need help correcting! first day,first 2 hours, first python program,(only had a little dark basic) 
  <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...]]></description>
			<content:encoded><![CDATA[<div>need help correcting! first day,first 2 hours, first python program,(only had a little dark basic)<br />
 <pre style="margin:20px; line-height:13px">active=&quot;on&quot;<br />
def ondamenu():<br />
&nbsp; &nbsp; print &quot;&quot;<br />
&nbsp; &nbsp; print &quot;enter integer 1 or 2&quot;<br />
&nbsp; &nbsp; print &quot;&quot;<br />
&nbsp; &nbsp; print &quot;opt.1 find the circumference&quot;<br />
&nbsp; &nbsp; print &quot;opt.2 find the radius&quot;<br />
&nbsp; &nbsp; print &quot;opt.3 quit calculator.py&quot;<br />
&nbsp; &nbsp; print &quot;&quot;<br />
&nbsp; &nbsp; return input (&quot;enter your choice: &quot;)<br />
def whatsdaradius(circval):<br />
&nbsp; &nbsp; pie=3.14159265358979323846264338327950288<br />
&nbsp; &nbsp; total=circval/pie<br />
&nbsp; &nbsp; print circval,&quot;÷&quot;,pie,&quot; = &quot;,total<br />
def radius2pie(radval):<br />
&nbsp; &nbsp; pie=3.14159265358979323846264338327950288<br />
&nbsp; &nbsp; total=radval**2*pie&nbsp; &nbsp; <br />
&nbsp; &nbsp; print radval,&quot;^2&quot;,&quot;x&quot;,pie,&quot; = &quot;,total<br />
while active==&quot;on&quot;:<br />
&nbsp; &nbsp; print &quot;welcome to circle pro calculator.py&quot;<br />
&nbsp; &nbsp; print &quot;&quot;<br />
&nbsp; &nbsp; ondamenu()<br />
&nbsp; &nbsp; option=ondamenu()<br />
&nbsp; &nbsp; if option==1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; whatsdaradius(input(input(&quot;enter a circumference: &quot;))<br />
&nbsp; &nbsp; if option==2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; radius2pie(input(&quot;enter a radius (ie.half diametre): &quot;))<br />
&nbsp; &nbsp; if option==3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; active&lt;&gt;&quot;on&quot;<br />
&nbsp; &nbsp; if option&lt;&gt;1 or option&lt;&gt;2 or option&lt;&gt;3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; ondamenu()<br />
&nbsp; &nbsp; print &quot;thank you!&quot;<br />
&nbsp; &nbsp; print &quot;&quot;</pre><br />
ts pretty readable, but its supposed to be a calculator for finding radius or circumference and loops with a while active is on</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>monstercameron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247565.html</guid>
		</item>
		<item>
			<title>help open()</title>
			<link>http://www.daniweb.com/forums/thread247564.html</link>
			<pubDate>Sat, 19 Dec 2009 03:12:38 GMT</pubDate>
			<description><![CDATA[>>> from os import * 
>>> a = [] 
>>> a = listdir('.') 
>>> f = open(a[0],'r') 
 
Traceback (most recent call last): 
  File "<pyshell#4>", line 1, in <module> 
    f = open(a[0],'r') 
TypeError: an integer is required]]></description>
			<content:encoded><![CDATA[<div>&gt;&gt;&gt; from os import *<br />
&gt;&gt;&gt; a = []<br />
&gt;&gt;&gt; a = listdir('.')<br />
&gt;&gt;&gt; f = open(a[0],'r')<br />
<br />
Traceback (most recent call last):<br />
  File &quot;&lt;pyshell#4&gt;&quot;, line 1, in &lt;module&gt;<br />
    f = open(a[0],'r')<br />
TypeError: an integer is required<br />
<br />
doesn't work, please help me</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>WOPR</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247564.html</guid>
		</item>
		<item>
			<title>error using wx.AuiManager</title>
			<link>http://www.daniweb.com/forums/thread247535.html</link>
			<pubDate>Fri, 18 Dec 2009 23:32:39 GMT</pubDate>
			<description>Hi Gentlemen, 
 
I have an error, which was non existant when i used wxpython 2.8.7.1. When i upgraded to 2.8.10.1, basically the GUI got messed up.I am using Python 2.52 environment. 
 
The error seems to be from the fact that the parent, in this case  
MyFrame(wx.aui.AuiMDIParentFrame), is the...</description>
			<content:encoded><![CDATA[<div>Hi Gentlemen,<br />
<br />
I have an error, which was non existant when i used wxpython 2.8.7.1. When i upgraded to 2.8.10.1, basically the GUI got messed up.I am using Python 2.52 environment.<br />
<br />
The error seems to be from the fact that the parent, in this case <br />
MyFrame(wx.aui.AuiMDIParentFrame), is the default frame, which means i did not have to have a wx.window passed as the argument, while, auimanager seems to look for a panel to attach too? Please take a look at the self running code below. Any comment is appreciated.<br />
<br />
Thank you very much<br />
<br />
 <pre style="margin:20px; line-height:13px">import wx<br />
import wx.aui<br />
#----------------------------------------------------------------------<br />
class MyFrame(wx.aui.AuiMDIParentFrame):<br />
&nbsp; &nbsp; def __init__(self, parent):<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.aui.AuiMDIParentFrame.__init__(self, parent, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=&quot;AuiMDIParentFrame&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; size=(640,480),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style=wx.DEFAULT_FRAME_STYLE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.x=0<br />
&nbsp; &nbsp; &nbsp; &nbsp; self._mgr = wx.aui.AuiManager(self)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self._mgr.AddPane(self.CreateTreeCtrl(), wx.aui.AuiPaneInfo().<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name(&quot;test8&quot;).Caption(&quot;BIST OVERVIEW&quot;).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Left().Layer(1).Position(1).CloseButton(True).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MaximizeButton(True))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self._mgr.AddPane(self.OnNewChild(), wx.aui.AuiPaneInfo().<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Caption(&quot;HTML Content&quot;).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Float().FloatingPosition(self.GetStartPosition()).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FloatingSize(wx.Size(300, 200)).CloseButton(True).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MaximizeButton(True))<br />
&nbsp; &nbsp; &nbsp; &nbsp; self._mgr.Update()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def CreateTreeCtrl(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.tree = wx.TreeCtrl(self,-1,wx.Point(0,0),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wx.Size(130,100),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wx.TR_DEFAULT_STYLE|wx.NO_BORDER)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return self.tree<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; def OnNewChild(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; child = ChildFrame(self,wx.DefaultPosition, wx.Size(400, 300))<br />
&nbsp; &nbsp; &nbsp; &nbsp; child.Show()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def GetStartPosition(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.x = self.x + 20<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = self.x<br />
&nbsp; &nbsp; &nbsp; &nbsp; pt = self.ClientToScreen(wx.Point(0, 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; return wx.Point(pt.x + x, pt.y + x)<br />
#----------------------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; <br />
class ChildFrame(wx.aui.AuiMDIChildFrame):<br />
&nbsp; &nbsp; def __init__(self, parent, pos,size):<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.aui.AuiMDIChildFrame.__init__(self, parent, -1,title='bist')<br />
&nbsp; &nbsp; &nbsp; &nbsp; p = wx.Panel(self,-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(p, -1, &quot;This is child &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; p.SetBackgroundColour('light blue')<br />
&nbsp; &nbsp; &nbsp; &nbsp; sizer = wx.BoxSizer()<br />
&nbsp; &nbsp; &nbsp; &nbsp; sizer.Add(p, 1, wx.EXPAND)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.SetSizer(sizer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.CallAfter(self.Layout)<br />
#----------------------------------------------------------------------#&nbsp; &nbsp; &nbsp; &nbsp; <br />
class MainApp(wx.App):<br />
&nbsp; &nbsp; def OnInit(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.frame =MyFrame(None)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.frame.Show(True)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.frame.Maximize()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.SetTopWindow(self.frame)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return True<br />
<br />
if __name__ == '__main__':<br />
&nbsp; &nbsp; app = MainApp(0)<br />
&nbsp; &nbsp; app.MainLoop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Indran</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247535.html</guid>
		</item>
		<item>
			<title>RPG Armor System</title>
			<link>http://www.daniweb.com/forums/thread247512.html</link>
			<pubDate>Fri, 18 Dec 2009 20:00:44 GMT</pubDate>
			<description>I have been teaching myself python for several months and have started working on an rpg project. Right now I am trying to code an armor class for a basic character. I am not sure if my approach is even a correct way to go about implementing this class. The armor list items consist of a name, armor...</description>
			<content:encoded><![CDATA[<div>I have been teaching myself python for several months and have started working on an rpg project. Right now I am trying to code an armor class for a basic character. I am not sure if my approach is even a correct way to go about implementing this class. The armor list items consist of a name, armor location, it's stopping power, weight penalty, and its cost.I managed to get the code to keep track of things then I realized if I append a new armor it will of course add it to the end of the list and I really want 3 designated slots to assign to. I would really appreciate some help with the code or even a thought process to help me rework this code. Any help would be appreciated. Thanks in advance.<br />
<br />
 <pre style="margin:20px; line-height:13px"># Armor<br />
# An armor class<br />
# 12/10/09<br />
<br />
import random<br />
<br />
# Armor Lists<br />
<br />
body_armor = [(&quot;Light Leather&quot;, &quot;Limbs and Torso&quot;, 0, 0, 25),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Heavy Leather&quot;, &quot;Limbs and Torso&quot;, 4, 0, 50),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Kevlar Vest&quot;, &quot;Torso&quot;, 10, 0, 100),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Steel Helmet&quot;, &quot;Head&quot;, 14, 0, 25),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Light Armor Jacket&quot;, &quot;Limbs and Torso&quot;, 14, 0, 150),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Medium Armor Jacket&quot;, &quot;Limbs and Torso&quot;, 1, 1, 200),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Flack Vest&quot;, &quot;Torso&quot;, 20, 1, 200),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Flack Pants&quot;, &quot;Legs&quot;, 20, 1, 200),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Nylon Helmet&quot;, &quot;Head&quot;, 20, 0, 100),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Heavy Armor Jacket&quot;, &quot;Limbs and Torso&quot;, 20, 2, 250),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Door Gunner's Vest&quot;, &quot;Torso&quot;, 25, 3, 275),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;Full Metal&quot;, &quot;Whole Body&quot;, 25, 2, 600)]<br />
<br />
class Character(object):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.armor = Armor()<br />
<br />
&nbsp; &nbsp; def Get_Armor_Report(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; print self.armor.armor_list<br />
&nbsp; &nbsp; &nbsp; &nbsp; print self.armor.current_armor<br />
&nbsp; &nbsp; &nbsp; &nbsp; print self.armor.EV_Total()<br />
<br />
# NEEDS ---&gt; 3 current armor places need to remain body in 0, body2 in 1, and helmet in 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
class Armor(object):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.armor_list = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.current_armor = []<br />
<br />
&nbsp; &nbsp; def Add_Armor(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; new_armor = body_armor[number]<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.armor_list.append(new_armor)<br />
<br />
&nbsp; &nbsp; def Equip_Armor(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; max_check = self.Max_Armor()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if max_check == 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Max Armor - Cannot Equip New Armor&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; armor_name = self.armor_list[number][0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; armor_sp = self.armor_list[number][2]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; armor_ev = self.armor_list[number][3]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_armor = (armor_name, armor_sp, armor_ev)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.current_armor.append(current_armor)<br />
<br />
&nbsp; &nbsp; def Remove_Armor(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; remove_armor = self.current_armor[number]<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.current_armor.remove(remove_armor)<br />
<br />
&nbsp; &nbsp; def Get_SP(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; stop_power = self.current_armor[number][1]<br />
&nbsp; &nbsp; &nbsp; &nbsp; return stop_power<br />
<br />
&nbsp; &nbsp; def Get_EV(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; encumberance = self.current_armor[number][2]<br />
&nbsp; &nbsp; &nbsp; &nbsp; return encumberance<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; def Get_Cover(self, number):<br />
&nbsp; &nbsp; &nbsp; &nbsp; cover = self.armor_list[number][1]<br />
&nbsp; &nbsp; &nbsp; &nbsp; return cover<br />
<br />
&nbsp; &nbsp; def EV_Total(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; ev_total = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; list_count = self.current_armor<br />
&nbsp; &nbsp; &nbsp; &nbsp; list_count = len(list_count)<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in range(list_count):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number = i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ev = self.current_armor[number][2]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ev_total += ev<br />
&nbsp; &nbsp; &nbsp; &nbsp; return ev_total<br />
<br />
&nbsp; &nbsp; def Max_Armor(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; all_armor = self.current_armor<br />
&nbsp; &nbsp; &nbsp; &nbsp; armor_total = len(all_armor)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if armor_total &gt;= 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>cnuzzo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247512.html</guid>
		</item>
		<item>
			<title>File searching problems</title>
			<link>http://www.daniweb.com/forums/thread247473.html</link>
			<pubDate>Fri, 18 Dec 2009 17:59:07 GMT</pubDate>
			<description>hi there got a couple of probs, say in my text file i have: 
 
abase  
abased 
abasement 
abasements  
abases 
 
--------</description>
			<content:encoded><![CDATA[<div>hi there got a couple of probs, say in my text file i have:<br />
<br />
abase <br />
abased<br />
abasement<br />
abasements <br />
abases<br />
<br />
--------<br />
<br />
This coding below is meant to find a word in a file and print all the lines to the end of the file. But it doesnt, it only prints out my search term and not the rest of the file.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; search_term = r'\b%s\b' % search_term<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for line in open(f, 'r'):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if re.match(search_term, line):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if search_term in line:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print line,</pre>Say i searched for abasement, i would like the output to be:<br />
<br />
abasement<br />
abasements<br />
abases<br />
<br />
<br />
----------<br />
<br />
My final problem is, i would like to search a file a print the lines my search term is in and a number of lines befer and after the searchterm. If i searched the text example above with 'abasement' and i defined the number of lines to print either side as 1 my output would be:<br />
<br />
abased<br />
abasement<br />
abasements<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; numb = ' the number of lines to print either side of the search line '<br />
&nbsp; &nbsp; search_term = 'what i search'<br />
&nbsp; &nbsp; f=open(&quot;file&quot;)<br />
&nbsp; &nbsp; d={}<br />
&nbsp; &nbsp; for n,line in enumerate(f):<br />
&nbsp; &nbsp; &nbsp; &nbsp; d[n%numb]=line.rstrip()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if search_term in line:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i in range(n+1,n+1+numb):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print d[i%numb]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i in range(1,numb):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print f.next().rstrip()</pre><br />
But i get a i get a Typeerror: unsupported operand type(s) for %: 'int' and 'str' which occurs at: d[n%numb] = line.rstrip() <br />
<br />
<br />
Help please?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>harpalss</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247473.html</guid>
		</item>
		<item>
			<title>how to receive thread notifications in pyqt..</title>
			<link>http://www.daniweb.com/forums/thread247460.html</link>
			<pubDate>Fri, 18 Dec 2009 17:00:07 GMT</pubDate>
			<description><![CDATA[Can you please tell me why i can't run this sample test 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"...]]></description>
			<content:encoded><![CDATA[<div>Can you please tell me why i can't run this sample test program??<br />
<br />
 <pre style="margin:20px; line-height:13px">from PyQt4 import QtGui<br />
class testui(QtGui.QTabWidget):&nbsp; &nbsp; <br />
&nbsp; &nbsp; def __init__(self,parent=None):<br />
&nbsp; &nbsp; &nbsp; &nbsp; QtGui.QTabWidget.__init__(self)<br />
&nbsp; &nbsp; def test(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; QtGui.QMessageBox.warning(self,&quot;Hello&quot;,&quot;This is a test message&quot;)<br />
<br />
def frun(objec):<br />
&nbsp; &nbsp; time.sleep(8)<br />
&nbsp; &nbsp; print('hello')<br />
&nbsp; &nbsp; objec.test()<br />
&nbsp;  <br />
app=QtGui.QApplication(sys.argv)<br />
obj=testui()<br />
obj.show()<br />
threading.Thread(target=frun,args=(obj,)).start()<br />
app.exec_()</pre><br />
But in real i want to receive messages from the threads running in other python modules and display or process in my pyqt application.. If any of you ever did that share with me.. Thanks..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>explorepython</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247460.html</guid>
		</item>
		<item>
			<title>URGENT help for python needed PLZZZ!!!!</title>
			<link>http://www.daniweb.com/forums/thread247393.html</link>
			<pubDate>Fri, 18 Dec 2009 10:21:26 GMT</pubDate>
			<description>hello, 
i am new to python and i want to do development in python now. 
 
my problem is that: 
 
tell me what should be install in the system to start python development? 
tell me which is the best editor that can help to edit and run python code efficiently? 
 
tell me how can i modify or edit the...</description>
			<content:encoded><![CDATA[<div>hello,<br />
i am new to python and i want to do development in python now.<br />
<br />
my problem is that:<br />
<br />
tell me what should be install in the system to start python development?<br />
tell me which is the best editor that can help to edit and run python code efficiently?<br />
<br />
tell me how can i modify or edit the example codes given in wxpython doc &amp; demos 2.8 and utilize them for my own sake??<br />
<br />
any one that can help me out i am in this problem from last two days.<br />
please help me out....<br />
Regards<br />
Punter</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>punter999</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247393.html</guid>
		</item>
		<item>
			<title>Help Coding Battleship</title>
			<link>http://www.daniweb.com/forums/thread247339.html</link>
			<pubDate>Fri, 18 Dec 2009 05:59:29 GMT</pubDate>
			<description><![CDATA[For my project I am coding battleship. I don't know how i should go about 
 
1. mapping the board spots (dictionaries?) 
2. randomizing ship placement 
 
any advice would be greatly appreciated 
 
PS. I am using pygame as well.]]></description>
			<content:encoded><![CDATA[<div>For my project I am coding battleship. I don't know how i should go about<br />
<br />
1. mapping the board spots (dictionaries?)<br />
2. randomizing ship placement<br />
<br />
any advice would be greatly appreciated<br />
<br />
PS. I am using pygame as well.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>thenewguy111</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247339.html</guid>
		</item>
		<item>
			<title>While Loop Program</title>
			<link>http://www.daniweb.com/forums/thread247333.html</link>
			<pubDate>Fri, 18 Dec 2009 04:45:41 GMT</pubDate>
			<description><![CDATA[How can I write a definition for a function that is passed a list of numbers and returns the sum of the numbers in that list using a while loop? 
 
I'm trying this, but it's not working 
 
def sumList(): 
	num = [1,2,3] 
	sum = 0 
	while num != str: 
		for i in num: 
			sum += i]]></description>
			<content:encoded><![CDATA[<div>How can I write a definition for a function that is passed a list of numbers and returns the sum of the numbers in that list using a while loop?<br />
<br />
I'm trying this, but it's not working<br />
<br />
def sumList():<br />
	num = [1,2,3]<br />
	sum = 0<br />
	while num != str:<br />
		for i in num:<br />
			sum += i<br />
	print(sum)<br />
<br />
Is there a way to not even use for?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>JuvenileMango</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247333.html</guid>
		</item>
		<item>
			<title>Starting CD Writing Wizard in Windows</title>
			<link>http://www.daniweb.com/forums/thread247278.html</link>
			<pubDate>Fri, 18 Dec 2009 00:00:52 GMT</pubDate>
			<description><![CDATA[I have written code to use the automatic CD-Burn routine inside WinXP and above. 
 
But I cannot start the CD Writing Wizard by python code. Has anybody any idea how to do it? 
This is my code so far: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I have written code to use the automatic CD-Burn routine inside WinXP and above.<br />
<br />
But I cannot start the CD Writing Wizard by python code. Has anybody any idea how to do it?<br />
This is my code so far:<br />
 <pre style="margin:20px; line-height:13px">#!/usr/bin/env python<br />
# -*- coding: utf-8 -*-<br />
<br />
import os, sys<br />
import win32com.client<br />
import win32file<br />
from ctypes import *<br />
from time import sleep<br />
from win32com.shell import shell, shellcon<br />
<br />
MAX_PATH = 260 <br />
HICON = c_int<br />
<br />
class SHFILEINFO(Structure): _fields_ = [(&quot;hIcon&quot;, HICON), (&quot;iIcon&quot;, c_int), (&quot;dwAttributes&quot;, c_uint), (&quot;szDisplayName&quot;, c_char * MAX_PATH), (&quot;szTypeName&quot;, c_char * 80)]<br />
<br />
SHGFI_ICON = 0x000000100 <br />
SHGFI_DISPLAYNAME = 0x000000200 <br />
SHGFI_TYPENAME = 0x000000400 <br />
SHGFI_ATTRIBUTES = 0x000000800 <br />
SHGFI_ICONLOCATION = 0x000001000 <br />
SHGFI_EXETYPE = 0x000002000 <br />
SHGFI_SYSICONINDEX = 0x000004000 <br />
SHGFI_LINKOVERLAY = 0x000008000 <br />
SHGFI_SELECTED = 0x000010000 <br />
SHGFI_ATTR_SPECIFIED = 0x000020000 <br />
SHGFI_LARGEICON = 0x000000000 <br />
SHGFI_SMALLICON = 0x000000001 <br />
SHGFI_OPENICON = 0x000000002 <br />
SHGFI_SHELLICONSIZE = 0x000000004 <br />
SHGFI_PIDL = 0x000000008 <br />
SHGFI_USEFILEATTRIBUTES = 0x000000010<br />
<br />
shfileinfo = SHFILEINFO()<br />
shflags = SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES<br />
<br />
<br />
def find_drives():<br />
&nbsp; &nbsp; &nbsp; &nbsp; drivebits=win32file.GetLogicalDrives()<br />
&nbsp; &nbsp; &nbsp; &nbsp; # print drivebits<br />
&nbsp; &nbsp; &nbsp; &nbsp; not_removable_drives_no_cd = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; removable_drives = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; cd_rom = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; cd_rom_type = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; cd_writer = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; cd_dvd = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; for d in range(0,26):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask=1 &lt;&lt; d<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if drivebits &amp; mask:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # here if the drive is at least there<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drname='%c:\\' % chr(ord('A')+d)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # print drname, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=win32file.GetDriveType(drname)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if t == win32file.DRIVE_REMOVABLE:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # print &quot;is removable&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removable_drives.append(drname.split(&quot;\\&quot;)[0])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # print &quot;is not removable&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if t == win32file.DRIVE_CDROM:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # print &quot;and is a CDROM drive&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cd_rom.append(drname.split(&quot;\\&quot;)[0])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; windll.shell32.SHGetFileInfo(drname, 0, byref(shfileinfo), sizeof(shfileinfo), shflags)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cd_rom_type.append(shfileinfo.szDisplayName)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cd_rom_type[-1].find(&quot;RW&quot;)&gt;-1 or cd_rom_type[-1].find(&quot;RAM&quot;)&gt;-1 or cd_rom_type[-1].find(&quot;Writer&quot;)&gt;-1 or cd_rom_type[-1].find(&quot;WRITER&quot;)&gt;-1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cd_writer.append(True)<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; cd_writer.append(False)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cd_rom_type[-1].find(&quot;DVD&quot;)&gt;-1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cd_dvd.append(&quot;DVD&quot;)<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; cd_dvd.append(&quot;CD&quot;)<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; # print &quot;and is not a CDROM drive&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; not_removable_drives_no_cd.append(drname.split(&quot;\\&quot;)[0])<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [not_removable_drives_no_cd,removable_drives,cd_rom,cd_rom_type,cd_writer,cd_dvd]<br />
<br />
drives = find_drives()<br />
<br />
print &quot;CD-ROM letters/labels:&quot;,drives[2]<br />
print &quot;CD-ROM-Type:&quot;,drives[3]<br />
print &quot;CD-Writer:&quot;,drives[4]<br />
print &quot;CD or DVD:&quot;,drives[5]<br />
<br />
cdburn_pidl = shell.SHGetFolderLocation (0, shellcon.CSIDL_CDBURN_AREA, 0, 0)<br />
CDBurnStageArea = shell.SHGetPathFromIDList (cdburn_pidl)<br />
# print &quot;1st way to get folder:&quot;,CDBurnStageArea<br />
<br />
# copy a file to CD Burn Stage Area<br />
win32file.CopyFile (sys.executable, os.path.join(CDBurnStageArea,os.path.basename(sys.executable)), 0)<br />
<br />
shell = win32com.client.Dispatch(&quot;WScript.Shell&quot;)<br />
# strBurnDirectory = shell.RegRead(&quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\CD Burning&quot;)<br />
# print &quot;2nd way to get folder:&quot;,strBurnDirectory<br />
<br />
objShell = win32com.client.Dispatch(&quot;Shell.Application&quot;)<br />
<br />
drive = &quot;&quot;<br />
<br />
for d in range(len(drives[2])):<br />
&nbsp; &nbsp; if drives[4][d] == True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; drive = drive + drives[2][d] + &quot;\\&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; break<br />
<br />
if drive == &quot;&quot;:<br />
&nbsp; &nbsp; raise IOError, &quot;No CD Writer found&quot;<br />
<br />
# show the CD writer drive and its contents supposed to be written<br />
shell.Run(&quot;explorer.exe &quot; + drive)<br />
sleep(2)<br />
windll.user32.MessageBoxA(None, &quot;Please click onto:\nWrite these files to CD.\nThe CD Writing Wizard will start immediately.&quot;, &quot;How to proceed&quot;, 0)<br />
<br />
# this unfortunately not working:<br />
&quot;&quot;&quot;<br />
shell.AppActivate (&quot;CD Writing Wizard&quot;)<br />
while not shell.AppActivate(&quot;CD Writing Wizard&quot;):<br />
&nbsp; &nbsp; print &quot;waiting&quot;<br />
&nbsp; &nbsp; sleep(1)<br />
&quot;&quot;&quot;</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>bunkus</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247278.html</guid>
		</item>
		<item>
			<title>Need help with pygame to exe</title>
			<link>http://www.daniweb.com/forums/thread247249.html</link>
			<pubDate>Thu, 17 Dec 2009 20:26:00 GMT</pubDate>
			<description><![CDATA[So i made a small game using pygame, and I want to be able to give it out to some friends who don't have python, so I want to make it into an EXE. i've been trying for several hours using several different methods, but nothings seems to be working. I would REALLY appreciate any help. 
 
So after...]]></description>
			<content:encoded><![CDATA[<div>So i made a small game using pygame, and I want to be able to give it out to some friends who don't have python, so I want to make it into an EXE. i've been trying for several hours using several different methods, but nothings seems to be working. I would REALLY appreciate any help.<br />
<br />
So after all this time I think py2exe appears to be the best tool to use. I have it installed, I just can't get it to work correctly on my game. After looking for many different setup.py file thingys, this is the one i've been using most recently:<br />
<br />
 <pre style="margin:20px; line-height:13px">try:<br />
&nbsp; &nbsp; from distutils.core import setup<br />
&nbsp; &nbsp; import py2exe, pygame<br />
&nbsp; &nbsp; from modulefinder import Module<br />
&nbsp; &nbsp; import glob, fnmatch<br />
&nbsp; &nbsp; import sys, os, shutil<br />
except ImportError, message:<br />
&nbsp; &nbsp; raise SystemExit,&nbsp; &quot;Unable to load module. %s&quot; % message<br />
&nbsp;<br />
class pygame2exe(py2exe.build_exe.py2exe): #This hack make sure that pygame default font is copied: no need to modify code for specifying default font<br />
&nbsp; &nbsp; def copy_extensions(self, extensions):<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Get pygame default font<br />
&nbsp; &nbsp; &nbsp; &nbsp; pygamedir = os.path.split(pygame.base.__file__)[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Add font to list of extension to be copied<br />
&nbsp; &nbsp; &nbsp; &nbsp; extensions.append(Module(&quot;pygame.font&quot;, pygame_default_font))<br />
&nbsp; &nbsp; &nbsp; &nbsp; py2exe.build_exe.py2exe.copy_extensions(self, extensions)<br />
&nbsp;<br />
class BuildExe:<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Name of starting .py<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.script = &quot;game.py&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Name of program<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.project_name = &quot;MyApps&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Project url<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.project_url = &quot;about<b></b>:none&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Version of program<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.project_version = &quot;0.0&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #License of the program<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.license = &quot;MyApps License&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Auhor of program<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.author_name = &quot;Me&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.author_email = &quot;example@example.com&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.copyright = &quot;Copyright (c) 2009 Me.&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Description<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.project_description = &quot;MyApps Description&quot;<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Icon file (None will use pygame default icon)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.icon_file = None<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Extra files/dirs copied to game<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.extra_datas = ['background.mid','background.png','bonus.png','cowbell.wav','highscore.txt']<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Extra/excludes python modules<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.extra_modules = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.exclude_modules = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; #DLL Excludes<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.exclude_dll = ['']<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Zip file name (None will bundle files in exe instead of zip file)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.zipfile_name = None<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #Dist directory<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.dist_dir ='dist'<br />
&nbsp;<br />
&nbsp; &nbsp; ## Code from DistUtils tutorial at http://wiki.python.org/moin/Distutils/Tutorial<br />
&nbsp; &nbsp; ## Originally borrowed from wxPython's setup and config files<br />
&nbsp; &nbsp; def opj(self, *args):<br />
&nbsp; &nbsp; &nbsp; &nbsp; path = os.path.join(*args)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return os.path.normpath(path)<br />
&nbsp;<br />
&nbsp; &nbsp; def find_data_files(self, srcdir, *wildcards, **kw):<br />
&nbsp; &nbsp; &nbsp; &nbsp; # get a list of all files under the srcdir matching wildcards,<br />
&nbsp; &nbsp; &nbsp; &nbsp; # returned in a format to be used for install_data<br />
&nbsp; &nbsp; &nbsp; &nbsp; def walk_helper(arg, dirname, files):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if '.svn' in dirname:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lst, wildcards = arg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for wc in wildcards:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wc_name = self.opj(dirname, wc)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for f in files:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename = self.opj(dirname, f)<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if fnmatch.fnmatch(filename, wc_name) and not os.path.isdir(filename):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names.append(filename)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if names:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lst.append( (dirname, names ) )<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; file_list = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; recursive = kw.get('recursive', True)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if recursive:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; os.path.walk(srcdir, walk_helper, (file_list, wildcards))<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; walk_helper((file_list, wildcards),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; srcdir,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [os.path.basename(f) for f in glob.glob(self.opj(srcdir, '*'))])<br />
&nbsp; &nbsp; &nbsp; &nbsp; return file_list<br />
&nbsp;<br />
&nbsp; &nbsp; def run(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if os.path.isdir(self.dist_dir): #Erase previous destination dir<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shutil.rmtree(self.dist_dir)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; #Use the default pygame icon, if none given<br />
&nbsp; &nbsp; &nbsp; &nbsp; if self.icon_file == None:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path = os.path.split(pygame.__file__)[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.icon_file = os.path.join(path, 'pygame.ico')<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; #List all data files to add<br />
&nbsp; &nbsp; &nbsp; &nbsp; extra_datas = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; for data in self.extra_datas:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if os.path.isdir(data):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extra_datas.extend(self.find_data_files(data, '*'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extra_datas.append(('.', [data]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; setup(<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmdclass = {'py2exe': pygame2exe},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version = self.project_version,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description = self.project_description,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name = self.project_name,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url = self.project_url,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; author = self.author_name,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; author_email = self.author_email,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; license = self.license,<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # targets to build<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; windows = [{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'script': self.script,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'icon_resources': [(0, self.icon_file)],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'copyright': self.copyright<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options = {'py2exe': {'optimize': 2, 'bundle_files': 1, 'compressed': True, \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'excludes': self.exclude_modules, 'packages': self.extra_modules, \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'dll_excludes': self.exclude_dll} },<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zipfile = self.zipfile_name,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_files = extra_datas,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dist_dir = self.dist_dir<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if os.path.isdir('build'): #Clean up build dir<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shutil.rmtree('build')<br />
&nbsp;<br />
if __name__ == '__main__':<br />
&nbsp; &nbsp; &nbsp; &nbsp; if len(sys.argv):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.argv.append('py2exe')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BuildExe().run()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw_input(&quot;Press any key to continue&quot;) #Pause to let user see that things ends</pre><br />
When I try this however, I get the error:<br />
NotImplementedError: font module not available<br />
(ImportError: MemoryLoadLibrary failed loading pygame\font.pyd)<br />
<br />
In my actual code, I'm loading font using:<br />
font = pygame.font.SysFont(&quot;freesansbold&quot;, 48)<br />
<br />
as I heard this is the better way to do it.<br />
<br />
I've tried many different setup.py files, but each gives me a different error, whether it be missing DLL's, or font, or something else. If I could get any help with this, i would appreciate it.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>sinisterduke</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247249.html</guid>
		</item>
		<item>
			<title>Opening Files Question</title>
			<link>http://www.daniweb.com/forums/thread247222.html</link>
			<pubDate>Thu, 17 Dec 2009 18:10:40 GMT</pubDate>
			<description><![CDATA[What is the difference between 
 
  <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>...]]></description>
			<content:encoded><![CDATA[<div>What is the difference between<br />
<br />
 <pre style="margin:20px; line-height:13px">file = open(&quot;name.txt&quot;)</pre>and<br />
 <pre style="margin:20px; line-height:13px">file = open(&quot;name.txt&quot;, 'r')</pre>?<br />
<br />
I can still use the methods: read(n), readline(n), and readlines(n) without adding the &quot;r&quot; in the open method.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>JuvenileMango</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247222.html</guid>
		</item>
		<item>
			<title>py2exe and tkSnack</title>
			<link>http://www.daniweb.com/forums/thread247207.html</link>
			<pubDate>Thu, 17 Dec 2009 16:51:58 GMT</pubDate>
			<description><![CDATA[Hello everybody, 
 
I made a wonderfull software, using Windows / python26 / tkinter / tkSnack. 
As long as I'm on my computer, it works fine. 
I try to distribute it, using py2exe. And I've not found the way to include tkSnack in the distribution. 
I tried also with pyInstaller, with the same...]]></description>
			<content:encoded><![CDATA[<div>Hello everybody,<br />
<br />
I made a wonderfull software, using Windows / python26 / tkinter / tkSnack.<br />
As long as I'm on my computer, it works fine.<br />
I try to distribute it, using py2exe. And I've not found the way to include tkSnack in the distribution.<br />
I tried also with pyInstaller, with the same result.<br />
<br />
I guess there is something to write in the setup file, like packages=&quot;tkSnack&quot;.<br />
<br />
Does someone have an idea ?<br />
<br />
<span style="font-style:italic">nb : sorry for my poor english</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>yvos91</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247207.html</guid>
		</item>
		<item>
			<title>Help with my code</title>
			<link>http://www.daniweb.com/forums/thread247196.html</link>
			<pubDate>Thu, 17 Dec 2009 16:08:18 GMT</pubDate>
			<description>Hello good day guys. I just want to ask for help in my java python. I am just new in this language. 
MY first java language is java. However, for me to make it easier to code in python,  i need to code it in java first and then convert after. But i am confused working with arrays in python, help me...</description>
			<content:encoded><![CDATA[<div>Hello good day guys. I just want to ask for help in my java python. I am just new in this language.<br />
MY first java language is java. However, for me to make it easier to code in python,  i need to code it in java first and then convert after. But i am confused working with arrays in python, help me guys. Thank you.<br />
<br />
 <pre style="margin:20px; line-height:13px">import java.util.*;<br />
<br />
public class sample {<br />
&nbsp; &nbsp; &nbsp; &nbsp; static Scanner scan = new Scanner(System.in);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main (String args&#91;&#93;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sample();<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void sample(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Enter numbers : &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String input&#91;&#93; = new String&#91;5&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( int i = 0 ; i &lt; input.length; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input&#91;i&#93; = scan.nextLine();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( int i = 0 ; i &lt; input.length; i++){&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(input&#91;i&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>letlet_pogs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247196.html</guid>
		</item>
		<item>
			<title>I need your view on this project</title>
			<link>http://www.daniweb.com/forums/thread247174.html</link>
			<pubDate>Thu, 17 Dec 2009 14:41:28 GMT</pubDate>
			<description><![CDATA[Hi guys, 
I have always wanted to write MP3 encoder in Python. I heard of Py-lame but I have never had hands on it and it is, to me a myth.  
 
Ok after trying thinking in ctypes, I thought the best way would be using lame.exe and subprocess. But as I'm thinking of it, I hate black screen. I want...]]></description>
			<content:encoded><![CDATA[<div>Hi guys,<br />
I have always wanted to write MP3 encoder in Python. I heard of Py-lame but I have never had hands on it and it is, to me a myth. <br />
<br />
Ok after trying thinking in ctypes, I thought the best way would be using lame.exe and subprocess. But as I'm thinking of it, I hate black screen. I want to use my own GUI using wxPython. So, is it possible to use subprocess without having black screen? Also getting encoding progress and nicely display it on progress bar?<br />
<br />
What do  you suggest buddies? Thanks alot ;)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>evstevemd</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247174.html</guid>
		</item>
		<item>
			<title>Help with Python</title>
			<link>http://www.daniweb.com/forums/thread247162.html</link>
			<pubDate>Thu, 17 Dec 2009 14:07:24 GMT</pubDate>
			<description><![CDATA[Hello, I need help with editing this 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...]]></description>
			<content:encoded><![CDATA[<div>Hello, I need help with editing this program:<br />
<br />
 <pre style="margin:20px; line-height:13px">#!/usr/bin/env python<br />
&quot;&quot;&quot;<br />
Monte Carlo simulation for the Monty Hall Problem:<br />
http://en.wikipedia.org/wiki/Monty_Hall_problem.<br />
&quot;&quot;&quot;<br />
import sys<br />
from random import randrange, shuffle, choice<br />
<br />
DOORS = ['car', 'goat', 'goat']<br />
<br />
def pick_door():<br />
&nbsp; &nbsp; &quot;&quot;&quot;Return a number representing the player's first choice.&quot;&quot;&quot;<br />
&nbsp; &nbsp; return randrange(3)<br />
<br />
def reveal_door(pick):<br />
&nbsp; &nbsp; &quot;&quot;&quot;Return the index of the door opened by the host.<br />
&nbsp; &nbsp; This cannot be a door hiding a car or the player's chosen door.<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; all_doors = set([0, 1, 2])<br />
&nbsp; &nbsp; unavailable_doors = set([DOORS.index('car'), pick])<br />
&nbsp; &nbsp; available_doors = list(all_doors - unavailable_doors)<br />
&nbsp; &nbsp; return choice(available_doors)<br />
<br />
def staying_wins(pick):<br />
&nbsp; &nbsp; &quot;&quot;&quot;Return True if the player won by staying<br />
&nbsp; &nbsp; with their first choice, False otherwise.<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; return won(pick)<br />
<br />
def switching_wins(pick, open_door):<br />
&nbsp; &nbsp; &quot;&quot;&quot;Return True if the player won by switching,<br />
&nbsp; &nbsp; False otherwise.<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; other_doors = set([pick, open_door])<br />
&nbsp; &nbsp; switched_pick = (set([0, 1, 2]) - other_doors).pop()<br />
&nbsp; &nbsp; return won(switched_pick)<br />
<br />
def won(pick):<br />
&nbsp; &nbsp; &quot;&quot;&quot;Return True if the player's final pick hides a car,<br />
&nbsp; &nbsp; False otherwise.<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; return (DOORS[pick] == 'car')<br />
<br />
def main(iterations=1000000):<br />
&nbsp; &nbsp; &quot;&quot;&quot;Run the main simulation as many<br />
&nbsp; &nbsp; times as specified by the function argument.<br />
&nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; shuffle(DOORS)<br />
<br />
&nbsp; &nbsp; switching = 0<br />
&nbsp; &nbsp; staying = 0<br />
<br />
&nbsp; &nbsp; for dummy in xrange(iterations):<br />
&nbsp; &nbsp; &nbsp; &nbsp; picked = pick_door()<br />
&nbsp; &nbsp; &nbsp; &nbsp; revealed = reveal_door(picked)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if staying_wins(picked):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; staying += 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; if switching_wins(picked, revealed):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switching += 1<br />
<br />
&nbsp; &nbsp; staying_rate = (float(staying) / iterations) * 100<br />
&nbsp; &nbsp; switching_rate = (float(switching) / iterations) * 100<br />
<br />
&nbsp; &nbsp; print &quot;Staying: %f%%&quot; % staying_rate<br />
&nbsp; &nbsp; print &quot;Switching: %f%%&quot; % switching_rate<br />
<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; if len(sys.argv) == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; main(int(sys.argv[1]))<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; main()</pre>You can probably tell what this program does so I shall not elaborate. However, how can I edit the program so that it works for (for example) 4 goats and 1 car? Of course  <pre style="margin:20px; line-height:13px">DOORS = ['car', 'goat', 'goat']</pre> needs to be changed but I'm not sure what else. Also, what does  <pre style="margin:20px; line-height:13px">return randrange(3)</pre> do?<br />
<br />
Thanks  :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>pith</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247162.html</guid>
		</item>
		<item>
			<title>Image Problem with Tkinter</title>
			<link>http://www.daniweb.com/forums/thread247161.html</link>
			<pubDate>Thu, 17 Dec 2009 14:04:46 GMT</pubDate>
			<description><![CDATA[Hello pals. 
 
We're having a project to make a Backup and Restore program in Python. As we think that making a GUI is of course very important, we started using Tkinter after initially trying wxPython which was kind of difficult given the time we had. 
 
Either way, we made a Class where the main...]]></description>
			<content:encoded><![CDATA[<div>Hello pals.<br />
<br />
We're having a project to make a Backup and Restore program in Python. As we think that making a GUI is of course very important, we started using Tkinter after initially trying wxPython which was kind of difficult given the time we had.<br />
<br />
Either way, we made a Class where the main window is. Inside this Class, there is another Class defined, which contains the code of the another Window, where one can chose the options of the backup proccess. So, here's the thing. While we have made two text entries and two buttons, when trying to load an image, or any label for all it matters, it just won't appear, and we get the following error in Python Shell.<br />
<br />
 <pre style="margin:20px; line-height:13px">Exception in Tkinter callback<br />
Traceback (most recent call last):<br />
&nbsp; File &quot;C:\Python25\lib\lib-tk\Tkinter.py&quot;, line 1414, in __call__<br />
&nbsp; &nbsp; return self.func(*args)<br />
&nbsp; File &quot;C:\Users\Ash_Pokemaster\Desktop\project_e31\kuygku.py&quot;, line 110, in backup_window<br />
&nbsp; &nbsp; back = Backup(buwind)<br />
&nbsp; File &quot;C:\Users\Ash_Pokemaster\Desktop\project_e31\kuygku.py&quot;, line 94, in __init__<br />
&nbsp; &nbsp; self.labelcho = Button(framebu, image= photocho)<br />
&nbsp; File &quot;C:\Python25\lib\lib-tk\Tkinter.py&quot;, line 2012, in __init__<br />
&nbsp; &nbsp; Widget.__init__(self, master, 'button', cnf, kw)<br />
&nbsp; File &quot;C:\Python25\lib\lib-tk\Tkinter.py&quot;, line 1942, in __init__<br />
&nbsp; &nbsp; (widgetName, self._w) + extra + self._options(cnf))<br />
TclError: image &quot;pyimage8&quot; doesn't exist</pre><br />
Here is the code along with the images.<br />
<a rel="nofollow" class="t" href="http://rapidshare.com/files/321658197/project_e31.zip.html" target="_blank">http://rapidshare.com/files/32165819...t_e31.zip.html</a><br />
<br />
We would appeciate it if you could try create an image inside the Backup Class, and figure out what the problem is.<br />
<br />
So far, this is what we type between the two text entry eidgets, and of course doesn't work:<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; photocho = PhotoImage(file=choose.gif&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.labelcho = Button(framebu, image= photocho)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.labelcho.image = photocho<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.labelcho.pack()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.labelcho.grid(row=2, column=0)</pre><br />
Image &quot;choose.gif&quot; is not inside the zip, but I guess any image would work...<br />
<br />
Thanks for your time.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Ash_Pokemaster</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247161.html</guid>
		</item>
		<item>
			<title>append one file to another</title>
			<link>http://www.daniweb.com/forums/thread247137.html</link>
			<pubDate>Thu, 17 Dec 2009 12:15:19 GMT</pubDate>
			<description>Hi all, 
 
How to write one file to the end of other file using python.</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
How to write one file to the end of other file using python.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>rajeshwari_ib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247137.html</guid>
		</item>
		<item>
			<title><![CDATA[[pyqt]QTabbar beginner question..help plz..]]></title>
			<link>http://www.daniweb.com/forums/thread247127.html</link>
			<pubDate>Thu, 17 Dec 2009 11:29:16 GMT</pubDate>
			<description><![CDATA[Hello all, 
    One simple question.. We can set Tab bar for the tab widget in pyqt...  
I want to place a push button on tab1.. In what way i can do that??? Should i have to add this in the first tab in tab bar or in the tab widget directly..  If i'm not clear, in QTabWidget we will add the...]]></description>
			<content:encoded><![CDATA[<div>Hello all,<br />
    One simple question.. We can set Tab bar for the tab widget in pyqt... <br />
I want to place a push button on tab1.. In what way i can do that??? Should i have to add this in the first tab in tab bar or in the tab widget directly..  If i'm not clear, in QTabWidget we will add the components in this sequence <br />
CreateWidget--&gt;Add it to the tab(addTab)---&gt;Add it to the QTabWidget.. <br />
<br />
          In the same manner how should i use QTabbar..<br />
CreateWidget---&gt;Add to TabBar---&gt;Add it to the Tab(in Tab Widget)<br />
                                           or<br />
CreateTabBar----&gt;SetTabBar and CreateWidget----&gt;Add to the TabWidget ...<br />
Explain me in detail...</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/thread247127.html</guid>
		</item>
		<item>
			<title>Python Socket Programming Client and Server</title>
			<link>http://www.daniweb.com/forums/thread247081.html</link>
			<pubDate>Thu, 17 Dec 2009 07:10:00 GMT</pubDate>
			<description>Sockets are one of the most popular means of network communication and they follow client-server architecture. I have created two programs, one to run on a client computer and 
 
the other on the server computer. In my program I am showing how using a sockets client program can communicate to a...</description>
			<content:encoded><![CDATA[<div>Sockets are one of the most popular means of network communication and they follow client-server architecture. I have created two programs, one to run on a client computer and<br />
<br />
the other on the server computer. In my program I am showing how using a sockets client program can communicate to a server. The client program is run at the client-side while<br />
<br />
the server program runs in the Internet. I am using a socket module which is provided by Python. When the client runs the echo-client.py program it is prompted to enter the<br />
<br />
address to the server which could either be a domain name which I used for the testing or an IP address. Keep in mind that the server side program echo-server.py has to be running<br />
<br />
in order for the connection to be established.  Once the user enters the address to the server it’s prompted to enter a message for the server. Once he enters the message and presses<br />
<br />
enter the message is send to the server. The server side program gets the message and displays it and also returns it back to the client. The final step for the server is to close itself<br />
<br />
once that one cycle is complete. The client on the other side displays a message that the message has been received by the user and even shows it just to so the user is sure of it and<br />
<br />
finally closes itself.<br />
<br />
<a rel="nofollow" class="t" href="http://erunways.com/python-socket-programming-client-and-server/" target="_blank">CLIENT SCRIPT<br />
<br />
SERVER SCRIPT<br />
<br />
DEMO RESULTS</a></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>erunways</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247081.html</guid>
		</item>
		<item>
			<title>python with CGI</title>
			<link>http://www.daniweb.com/forums/thread247073.html</link>
			<pubDate>Thu, 17 Dec 2009 06:56:22 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I want ask something about Python CGI 
 
How can i use python on web application to run commands on the server 
 
For example :  
like in php when you will use "exec" function 
 
#!/usr/bin/python]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I want ask something about Python CGI<br />
<br />
How can i use python on web application to run commands on the server<br />
<br />
For example : <br />
like in php when you will use &quot;exec&quot; function<br />
<br />
#!/usr/bin/python<br />
import os<br />
print &quot;Content-Type: text/html\n&quot;<br />
os.mkdir(&quot;/root/folder&quot;)<br />
print &quot;done&quot;<br />
<br />
<br />
this simple script working good if you run it from SSH &quot;server root&quot; but when i use it web application not working <br />
<br />
any one can help me about this issue ?<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>zoro007</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247073.html</guid>
		</item>
		<item>
			<title>Problem in zipping folder using PYTHON</title>
			<link>http://www.daniweb.com/forums/thread247065.html</link>
			<pubDate>Thu, 17 Dec 2009 06:03:49 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am zipping a folder and an error occurred in below code which says : 
  ==> AttributeError: 'builtin_function_or_method' object has no attribute 'tell' 
 
*zipfile.py:* 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am zipping a folder and an error occurred in below code which says :<br />
  ==&gt; AttributeError: 'builtin_function_or_method' object has no attribute 'tell'<br />
<br />
<span style="font-weight:bold">zipfile.py:</span><br />
 <pre style="margin:20px; line-height:13px">def write(self, filename, arcname=None, compress_type=None):<br />
...<br />
zinfo.header_offset = self.fp.tell()&nbsp; &nbsp; # Start of header bytes<br />
...<br />
...</pre><br />
FYI:I have tried using &quot;from zipfile import *&quot; instead of &quot;import zipfile&quot;, but of no avail.<br />
<br />
What is causing this problem?<br />
<br />
Regards,<br />
Zia<br />
<br />
<br />
<span style="font-weight:bold">My code to zip a folder:</span><br />
<br />
 <pre style="margin:20px; line-height:13px">import zipfile&nbsp; <span style="font-weight:bold">## i've tried with &quot;from zipfile import *&quot;</span><br />
import os<br />
<br />
def main():<br />
&nbsp; &nbsp; zip = &quot;help3.zip&quot;<br />
&nbsp; &nbsp; directory = &quot;C:\MYDIR&quot;<br />
&nbsp; &nbsp; toZip(directory)<br />
<br />
<br />
def toZip(directory):<br />
&nbsp; &nbsp; zippedHelp = zipfile.ZipFile(zip, &quot;w&quot;, compression=zipfile.ZIP_DEFLATED )<br />
<br />
&nbsp; &nbsp; zipfile.debug = 3<br />
&nbsp; &nbsp; list = os.listdir(directory)<br />
<br />
&nbsp; &nbsp; for entity in list:<br />
&nbsp; &nbsp; &nbsp; &nbsp; each = os.path.join(directory,entity)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if os.path.isfile(each):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print each<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print os.path.basename(each)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zippedHelp.write(each, os.path.basename(each), zipfile.ZIP_DEFLATED)<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addFolderToZip(zippedHelp,entity)<br />
<br />
&nbsp; &nbsp; zippedHelp.close()<br />
<br />
def addFolderToZip(zippedHelp,folder):<br />
<br />
&nbsp; &nbsp; for file in folder:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if os.path.isfile(file):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zippedHelp.write(file, os.path.basename(file), zipfile.ZIP_DEFLATED)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif os.path.isdir(file):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addFolderToZip(zippedHelp,file)<br />
<br />
main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ziashahid</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread247065.html</guid>
		</item>
		<item>
			<title>Rock Paper Scissors Game with GUI</title>
			<link>http://www.daniweb.com/forums/thread246963.html</link>
			<pubDate>Wed, 16 Dec 2009 20:57:41 GMT</pubDate>
			<description><![CDATA[I made this Rock Paper Scissors Game with GUI. 
It works fine. But what can I do to make it simpler? Anybody? 
 
  <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>I made this Rock Paper Scissors Game with GUI.<br />
It works fine. But what can I do to make it simpler? Anybody?<br />
<br />
 <pre style="margin:20px; line-height:13px">import random<br />
<br />
class RPC:<br />
<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.comChoice = ''<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.choices = ['Rock','Paper','Scissors']<br />
<br />
&nbsp; &nbsp; def chooseCom(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.comChoice = self.choices[random.randint(0,2)]<br />
&nbsp; &nbsp; &nbsp; &nbsp; return self.comChoice<br />
<br />
&nbsp; &nbsp; def player(self, choice, Com):<br />
&nbsp; &nbsp; &nbsp; &nbsp; if choice == 'rock' and Com == 'Scissors':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ('You won!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'paper' and Com == 'Rock':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ('You won!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'scissors' and Com == 'Paper':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return('You won!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'scissors' and Com == 'Rock':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ('You lost!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'rock' and Com== 'Paper':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return('You lost!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 'paper' and Com == 'Scissors':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ('You lost!')<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ('Tie!')</pre> <pre style="margin:20px; line-height:13px">from tkinter import *<br />
import RPCclass<br />
<br />
def ComputerChoice():<br />
&nbsp; &nbsp; game = RPCclass.RPC()<br />
&nbsp; &nbsp; c = game.chooseCom()<br />
&nbsp; &nbsp; return c<br />
<br />
def winner(choice, Com):<br />
&nbsp; &nbsp; game = RPCclass.RPC()<br />
&nbsp; &nbsp; w = game.player(choice, Com)<br />
&nbsp; &nbsp; return w<br />
<br />
def numWin(self, choice, Com):<br />
&nbsp; &nbsp; game = RPCclass.RPC()<br />
&nbsp; &nbsp; a = game.player(choice, Com)<br />
&nbsp; &nbsp; if a == 'You won!':<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numPlayerWin +=1<br />
&nbsp; &nbsp; elif a == 'You lost!':<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numComWin +=1<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numPlayerWin += 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numComWin +=0<br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; self.message4.config(text = 'Player won ' + \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str(self.numPlayerWin) + ' times.')<br />
&nbsp; &nbsp; self.message5.config(text = 'Computer won ' + \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str(self.numComWin) + ' times.')<br />
&nbsp; &nbsp; <br />
<br />
class GUI: <br />
&nbsp; &nbsp; def __init__(self): <br />
&nbsp; &nbsp; &nbsp; &nbsp; root = Tk() <br />
&nbsp; &nbsp; &nbsp; &nbsp; root.title('Welcome to Rock Paper Scissors')<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numComWin = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numPlayerWin = 0<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.label = Label(root, text='&quot;Choose Rock, Paper, or Scissors.&quot;', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  fg='Black', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bd=10) <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.label.grid(row=5, columnspan = 3) <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button1 =&nbsp; Button(root, text='Rock', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bg='Blue', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fg='white', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padx=10, pady=5, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; command=self.buttonAction1) <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button1.grid(row=7, column=0, rowspan=2)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button2 =&nbsp; Button(root, text='Paper', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bg='Blue', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fg='white', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padx=10, pady=5, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; command=self.buttonAction2) <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button2.grid(row=7, column =1, rowspan =2)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button3 =&nbsp; Button(root, text='Scissors', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bg='blue', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fg='white', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padx=10, pady=5, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; command=self.buttonAction3) <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button3.grid(row=7, column =2, rowspan=2)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button4 =&nbsp; Button(root, text='Reset', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bg='black', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fg='white', <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padx=10, pady=5, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; command=self.buttonAction4) <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button4.grid(row=12, column =1, rowspan=2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1 = Label(root, text='',fg='Black')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1.grid(row=9, columnspan=3)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2 = Label(root, text='',fg='Black')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2.grid(row=10, columnspan=3)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3 = Label(root, text='',fg='Red', font=('Times',16,'bold'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3.grid(row=11, columnspan=3)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message4 = Label(root, text='',fg='black')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message4.grid(row=12, column=0, rowspan=2)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message5 = Label(root, text='',fg='black')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message5.grid(row=12, column=2, rowspan=2)<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; root.mainloop()<br />
<br />
<br />
&nbsp; &nbsp; def buttonAction1(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = 'rock'<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1.config(text= 'You choose Rock.')<br />
&nbsp; &nbsp; &nbsp; &nbsp; Com = ComputerChoice() <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2.config(text= 'Computer has chosen %s.' % Com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3.config(text = winner(choice, Com))<br />
&nbsp; &nbsp; &nbsp; &nbsp; numWin(self,choice, Com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def buttonAction2(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = 'paper'<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1.config(text= 'You choose Paper.')<br />
&nbsp; &nbsp; &nbsp; &nbsp; Com = ComputerChoice()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2.config(text= 'Computer has chosen %s.' % Com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3.config(text = winner(choice, Com))<br />
&nbsp; &nbsp; &nbsp; &nbsp; numWin(self,choice, Com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; def buttonAction3(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = 'scissors'<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1.config(text= 'You choose Scissors.')<br />
&nbsp; &nbsp; &nbsp; &nbsp; Com = ComputerChoice()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2.config(text= 'Computer has chosen %s.' % Com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3.config(text = winner(choice, Com))<br />
&nbsp; &nbsp; &nbsp; &nbsp; numWin(self,choice, Com)<br />
<br />
&nbsp; &nbsp; def buttonAction4(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message1.config(text= '')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message2.config(text= '')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message3.config(text= '')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numComWin = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.numPlayerWin = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; numWin(self,0, 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message4.config(text = '')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message5.config(text = '')<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
GUI()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>manathisbest</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246963.html</guid>
		</item>
		<item>
			<title>check letters</title>
			<link>http://www.daniweb.com/forums/thread246929.html</link>
			<pubDate>Wed, 16 Dec 2009 18:02:07 GMT</pubDate>
			<description>Hi again, 
 
I am trying a competition entry (its old, purely to test myself) and I have come against a problem, this is the description for the competition: 
 
In a word game each letter has a score based on its position in the alphabet, A scoring 1 through to Z scoring 26. The object of the game...</description>
			<content:encoded><![CDATA[<div>Hi again,<br />
<br />
I am trying a competition entry (its old, purely to test myself) and I have come against a problem, this is the description for the competition:<br />
<br />
In a word game each letter has a score based on its position in the alphabet, A scoring 1 through to Z scoring 26. The object of the game is to split the letters of a word into two groups so that the total score of the letters in each group is the same. For example, LIONHEAD can be split into LIHAD and ONE, both scoring 34.<br />
<br />
and I currently have this code:<br />
 <pre style="margin:20px; line-height:13px">import cword<br />
running=1<br />
while running==1:<br />
&nbsp; &nbsp; poss=[]<br />
&nbsp; &nbsp; print&quot;&quot;&quot;<br />
do you want to:<br />
1)enter a word?<br />
2)quit?<br />
&quot;&quot;&quot;<br />
&nbsp; &nbsp; menu=int(raw_input(''))<br />
&nbsp; &nbsp; if menu==1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; word=raw_input(&quot;what is the word to check?&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if cword.check_word(word):#checks is word is a word<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for pword in cword.dicta:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if len(pword)&lt;len(word):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for letter in word:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if letter in pword:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cword.val_word(pword)==cword.val_word(word)/2:#gets value of possible and current word, /2 bc new word value will always be half of the original.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if pword in poss:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; poss.append(pword)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print poss<br />
&nbsp; &nbsp; elif menu==2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; running=0<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;that was not a proper command&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;please enter a new one.&quot;<br />
&nbsp; &nbsp; <br />
raw_input()</pre>When running this with 'tiger' as the word, I get these possibles:<br />
<br />
 <pre style="margin:20px; line-height:13px">['ais', 'aria', 'awe', 'bags', 'beau', 'bind', 'bred', 'cate', 'ceil', 'cepe', 'crag', 'cue', 'dike', 'dip', 'ecu', 'ell', 'ex', 'fard', 'feme', 'fend', 'fer', 'fin', 'gabs', 'gang', 'gape', 'glee', 'glia', 'haik', 'hat', 'held', 'hep', 'it', 'jar', 'kale', 'lake', 'leak', 'lice', 'mig', 'page', 'peag', 'peh', 'pica', 'raia', 'raj', 'ref', 'rib', 'sade', 'see', 'tace', 'ted', 'ti', 'wae']</pre><br />
but how can I go through these words so that only the correct amount of each letter is used?<br />
<br />
Many thanks in advance.</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/thread246929.html</guid>
		</item>
		<item>
			<title>Howto change def. everytime its called?</title>
			<link>http://www.daniweb.com/forums/thread246922.html</link>
			<pubDate>Wed, 16 Dec 2009 16:57:23 GMT</pubDate>
			<description><![CDATA[Hi, I want to change a variable in a definition everytime it is called. 
for example:  
when I click on button, it will print 1 
when I click on button again, it will print 2  
Is this possible? 
I have written this code but it doesnt work :) 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, I want to change a variable in a definition everytime it is called.<br />
for example: <br />
when I click on button, it will print 1<br />
when I click on button again, it will print 2 <br />
Is this possible?<br />
I have written this code but it doesnt work :)<br />
 <pre style="margin:20px; line-height:13px">k=0<br />
<br />
def n():<br />
&nbsp; &nbsp; print k<br />
<br />
if n:<br />
&nbsp; &nbsp; k=k+1<br />
&nbsp; &nbsp; <br />
from Tkinter import * <br />
o=Tk()<br />
Button(text=&quot;N&quot;,command=n).pack(side=LEFT,fill=Y)<br />
mainloop()</pre>(apologise for my english) thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>d8m9</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246922.html</guid>
		</item>
		<item>
			<title>Need to simplify a loop thing</title>
			<link>http://www.daniweb.com/forums/thread246910.html</link>
			<pubDate>Wed, 16 Dec 2009 15:27:26 GMT</pubDate>
			<description><![CDATA[Okay, so what I want to do, is to take the following code, and make it so that way it keeps continuning for all of the word. 
  <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"...]]></description>
			<content:encoded><![CDATA[<div>Okay, so what I want to do, is to take the following code, and make it so that way it keeps continuning for all of the word.<br />
 <pre style="margin:20px; line-height:13px">keycode = raw_input()<br />
matrix = [0, 0, 0, 0]<br />
for x in range(0, len(keycode)):<br />
&nbsp; &nbsp; y = ord(keycode[x])<br />
&nbsp; &nbsp; if x &gt; 3 and x &lt;= 7:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = x -4<br />
&nbsp; &nbsp; if x &gt; 7 and x &lt;= 11:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = x -8<br />
&nbsp; &nbsp; if x &gt; 11 and x &lt;= 15:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = x -12<br />
&nbsp; &nbsp; if x &gt; 15 and x &lt;= 19:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = x -16<br />
&nbsp; &nbsp; matrix[x] = matrix[x] + y</pre><br />
The part I want to continue is the if statements... I'm thinking maybe using the len(keycode) somehow, but I'm a bit confused on where to go from here. Any help would be appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>hondros</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246910.html</guid>
		</item>
		<item>
			<title><![CDATA[Threading & Thread:  speed performance between modules]]></title>
			<link>http://www.daniweb.com/forums/thread246886.html</link>
			<pubDate>Wed, 16 Dec 2009 13:51:11 GMT</pubDate>
			<description>I have two questions on python threading: 
1: is there is any speed performance or difference  between Thread module and Threading module? 
 
2: Is there is any other major difference between Thread module and threading module? 
 
I used thread module for my download manager project.  
i think this...</description>
			<content:encoded><![CDATA[<div>I have two questions on python threading:<br />
1: is there is any speed performance or difference  between Thread module and Threading module?<br />
<br />
2: Is there is any other major difference between Thread module and threading module?<br />
<br />
I used thread module for my download manager project. <br />
i think this thread module does not doing parallel works. is this correct ?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>baskar007</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246886.html</guid>
		</item>
		<item>
			<title>tkinter: not mapped instantly after grid()</title>
			<link>http://www.daniweb.com/forums/thread246880.html</link>
			<pubDate>Wed, 16 Dec 2009 13:09:55 GMT</pubDate>
			<description>Hello! 
 
My application is crashing randomly, and I thought it might have to do with it manipulating widgets that are not yet mapped, despite them being already gridded. Have you experienced this problem? 
 
I supply some code that shows that the print function happens before tkinter recognizes...</description>
			<content:encoded><![CDATA[<div>Hello!<br />
<br />
My application is crashing randomly, and I thought it might have to do with it manipulating widgets that are not yet mapped, despite them being already gridded. Have you experienced this problem?<br />
<br />
I supply some code that shows that the print function happens before tkinter recognizes the button being mapped, even though it is already gridded. I couldn't find a way to wait for the button being properly mapped before the print function is executed.<br />
<br />
 <pre style="margin:20px; line-height:13px">from tkinter import *<br />
<br />
class fb( Frame ):<br />
&nbsp; &nbsp; def fastbuttons( self ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; b = Button(self)<br />
&nbsp; &nbsp; &nbsp; &nbsp; b.grid()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print( b.winfo_ismapped() )<br />
<br />
&nbsp; &nbsp; def __init__( self, master=None ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; Frame.__init__( self, master )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.grid( sticky='nsew' )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button = Button( self, text='Start', command=self.fastbuttons )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.button.grid()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
if __name__ == '__main__':<br />
&nbsp; &nbsp; root = Tk()<br />
&nbsp; &nbsp; app = fb( master=root )<br />
&nbsp; &nbsp; app.mainloop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ribot</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246880.html</guid>
		</item>
		<item>
			<title>Iptables And Range problem</title>
			<link>http://www.daniweb.com/forums/thread246874.html</link>
			<pubDate>Wed, 16 Dec 2009 12:34:42 GMT</pubDate>
			<description>hi everyone 
my rule ıs  /sbin/iptables -A INPUT -p tcp --dport 111 -j DROP 
 and ı want to forbıd tıll the port no 800.and ı donw want to wirte ıt down one by one. 
so ı want to make a loop that wıll change port adress(whıch ıs 111) add port num  
 
so far ı trıed slıcıng and counter=0 and counter...</description>
			<content:encoded><![CDATA[<div>hi everyone<br />
my rule ıs  /sbin/iptables -A INPUT -p tcp --dport 111 -j DROP<br />
 and ı want to forbıd tıll the port no 800.and ı donw want to wirte ıt down one by one.<br />
so ı want to make a loop that wıll change port adress(whıch ıs 111) add port num <br />
<br />
so far ı trıed slıcıng and counter=0 and counter +1 ın the loop<br />
ıt gave me error <br />
algorıtm ı treıd ıs<br />
 <pre style="margin:20px; line-height:13px">for x in range(800):<br />
for x in iptables:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter +=x[39:4]<br />
&nbsp; &nbsp; &nbsp;  print counter</pre><br />
and ıt gıves me error normally<br />
<br />
so how can ı make ıt happen<br />
<br />
out put should be<br />
<br />
<br />
 /sbin/iptables -A INPUT -p tcp --dport 111 -j DROP<br />
 /sbin/iptables -A INPUT -p tcp --dport 112 -j DROP<br />
 /sbin/iptables -A INPUT -p tcp --dport 113 -j DROP<br />
 /sbin/iptables -A INPUT -p tcp --dport 114 -j DROP<br />
and so on<br />
<br />
thanks for your hep</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>rehber344</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246874.html</guid>
		</item>
		<item>
			<title>merging 2 jpeg file into one file</title>
			<link>http://www.daniweb.com/forums/thread246860.html</link>
			<pubDate>Wed, 16 Dec 2009 11:49:12 GMT</pubDate>
			<description>Hi all, 
 
I have 2 jpeg files. I want to merge them into single file. 
How to achieve this using python. please help me</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I have 2 jpeg files. I want to merge them into single file.<br />
How to achieve this using python. please help me</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>rajeshwari_ib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246860.html</guid>
		</item>
		<item>
			<title>IDLE in snow leopard</title>
			<link>http://www.daniweb.com/forums/thread246742.html</link>
			<pubDate>Wed, 16 Dec 2009 03:19:37 GMT</pubDate>
			<description><![CDATA[I haven't been able to get my version of IDLE to open 
since I upgraded to snow leopard. Is this my unique problem? 
Or does snow leopard require a special version of IDLE? 
 
Thanks for any help. 
 
Don Jones (donjones77)]]></description>
			<content:encoded><![CDATA[<div>I haven't been able to get my version of IDLE to open<br />
since I upgraded to snow leopard. Is this my unique problem?<br />
Or does snow leopard require a special version of IDLE?<br />
<br />
Thanks for any help.<br />
<br />
Don Jones (donjones77)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>donjones77</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246742.html</guid>
		</item>
		<item>
			<title>Yet again, one more recursive problem!</title>
			<link>http://www.daniweb.com/forums/thread246725.html</link>
			<pubDate>Wed, 16 Dec 2009 01:29:35 GMT</pubDate>
			<description><![CDATA[Hey, I'm sorry for being such a python newb, but thanks for helping me out with the last one!  Hopefully you guys will help a newb out again :) 
 
This time, I need to use a recursive function to basically do the same thing that the .replace function for strings in python does.  Problem here is,...]]></description>
			<content:encoded><![CDATA[<div>Hey, I'm sorry for being such a python newb, but thanks for helping me out with the last one!  Hopefully you guys will help a newb out again :)<br />
<br />
This time, I need to use a recursive function to basically do the same thing that the .replace function for strings in python does.  Problem here is, yet again, I have no idea how to attack this problem.<br />
<br />
My idea is to maybe shorten the original string by one index with each recursive call and add the replacement string once the old string has been cut out, but the problem is, I don't know how to save any letters prior to the substring to not permanently get rid of the pieces I need to put the string back together with the new string in place of where the old string used to be. <br />
<br />
I wish I could provide atleast some sort of code, but I honestly have absolutely no idea how to even start this one, with the exception of the base condition:<br />
<br />
if string==&quot;&quot;<br />
    return<br />
<br />
any help would be greatly appreciated!  Thank you!<br />
<br />
PS a sample run and desired output should look something like this:<br />
<br />
% replace_recursion(&quot;stringproblem&quot;,&quot;problem&quot;,&quot;solution&quot;)<br />
% &quot;stringsolution&quot;<br />
<br />
Once again, thanks for any input or help!  Ideas are appreciated greatly too!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>johni12</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246725.html</guid>
		</item>
		<item>
			<title>Help! Python problems</title>
			<link>http://www.daniweb.com/forums/thread246723.html</link>
			<pubDate>Wed, 16 Dec 2009 00:47:03 GMT</pubDate>
			<description><![CDATA[Hey Guys, I have a test tomorrow and this question is going to be dead similar to my test question, and I'm a mech.E major but for some damned reason Python is a mandatory course for us. Please if any one could solve this I would be very grateful. Please Help me....]]></description>
			<content:encoded><![CDATA[<div>Hey Guys, I have a test tomorrow and this question is going to be dead similar to my test question, and I'm a mech.E major but for some damned reason Python is a mandatory course for us. Please if any one could solve this I would be very grateful. Please Help me.<br />
_______X__X_X_X_X_X_X_X_X_X_X__X_X_X_X_X_X_X_X_X_X _X_X_X_X_X_X_X_X_X_X_X_X_X_X_X_X__X_X_X_X_X_X_X_X_ _X_X_X_X_X_X_X__X_X_X_XX_X_X_<br />
<br />
<br />
A family unit consists of one guardian and zero or more babies.<br />
A baby has a name and an age.<br />
Define classes for family unit and baby. (You will get more points if you make the data members private.)<br />
<br />
All the family unit data are stored in a file named familiartxt. You are guaranteed that this file exists.<br />
In the data file, a family unit is stored on at least one line - the guardian. After the guardian (well actually just the name) there are lines for each baby – their name and their age in parentheses.<br />
<br />
Here is a sample data file showing the internal format of the data:<br />
<br />
<span style="color:Red">Ralph The Magnificent Mangler<br />
Quizzlechomps (32)<br />
Miki (24)<br />
END REC<br />
Mary the Meek<br />
Middendorf (812)<br />
Muddle (10)<br />
Makrryrlr (232)<br />
END REC<br />
Buster<br />
END REC</span><br />
<br />
Write a function that will return a container of all the family units from this file. The file should be opened and closed in this function.<br />
Write a function to display all the family units in a list of family units in descending alphabetical order by guardian..<br />
Babies must be in the order of youngest to oldest. (This is not necessarily the order they are in in the file.<br />
<br />
Finish Part ONE before going on to Part TWO<br />
<br />
<br />
Part TWO --- Adding and removing babies.<br />
Anyone who has a valid password can change things. A valid password here, is really in the range [33.55] or (457.993].<br />
For now, be infinitely patient with the password entry<br />
Once validated, they can choose to remove a guardian or a baby - but only one at a time – their password will have to validated after each change..<br />
<br />
A family unit is chosen at random. The user decides to remove a guardian or a baby. If they choose baby, a random baby under the chose guardian's care is chosen. If they choose a guardian, all the babies under that guardian are also gone.<br />
<br />
One of the rules of this world is that no guardians can be removed if their name is the same as a baby under another guardian. Your code must enforce this – just ignore any attempt in this case.<br />
<br />
For processing&quot;<br />
Display all the family units and then go through the process of letting people validate their passwords and make changes.<br />
Be sure to show all the family units after each person removes someone.<br />
<br />
It's also possible that someone might decide to change the name of a guardian instead of removing them. When a guardian's name is changed, all of the baby under his care have their names changed to the new name also.<br />
<br />
There is a special password that allows anyone who knows it to stop processing. When this happens, the number of babies still in the system is displayed (and then the program ends).<br />
<br />
<br />
Here is a sample run of Part TWO. Remember to solve problems, not examples.<br />
We are using the data shown above to start with.<br />
<br />
<br />
<span style="color:Red">Ralph The Magnificent Mangler<br />
1.) Miki (24)<br />
2.) Quizzlechomps (32)<br />
Mary the Meek<br />
1.) Makrryrlr (232)<br />
2.) Middendorf (812)<br />
3.) Muddle (10)<br />
Buster<br />
[no babies]<br />
<br />
Enter password<br />
3<br />
Sorry, try again:<br />
44<br />
Which to delete – Guardian or Baby?<br />
baby<br />
<br />
Ralph The Magnificent Mangler<br />
1.) Miki (24)<br />
2.) Quizzlechomps (32)<br />
Mary the Meek<br />
1.) Makrryrlr (232)<br />
2.) Muddle (10)<br />
Buster<br />
[no babies]<br />
<br />
<br />
Enter password<br />
900<br />
Which to delete – Guardian or Baby?<br />
guardian<br />
Would you rather rename?<br />
y<br />
What's the new name?<br />
Bizzy<br />
<br />
<br />
Mary the Meek<br />
1.) Makrryrlr (232)<br />
2.) Muddle (10)<br />
Buster<br />
[no babies]<br />
Bizzy<br />
1.) Bizzy (24)<br />
2.) Bizzy (32)<br />
<br />
Enter password<br />
STOP THIS MESS!<br />
<br />
4 babies left</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>HalpMe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246723.html</guid>
		</item>
		<item>
			<title>Basic Stamp</title>
			<link>http://www.daniweb.com/forums/thread246697.html</link>
			<pubDate>Tue, 15 Dec 2009 22:48:00 GMT</pubDate>
			<description>Is there a way to grab values from a basic stamp with python? 
 
I just bought a Accelerometer  and want to read the values with python.</description>
			<content:encoded><![CDATA[<div>Is there a way to grab values from a basic stamp with python?<br />
<br />
I just bought a Accelerometer  and want to read the values with python.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Tech B</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246697.html</guid>
		</item>
		<item>
			<title>String Methods</title>
			<link>http://www.daniweb.com/forums/thread246686.html</link>
			<pubDate>Tue, 15 Dec 2009 21:19:40 GMT</pubDate>
			<description><![CDATA[Hi all, 
 
I have this dilemma, if I receive strings on the form of: 
 
<Ranking: AA (John)> 
<Ranking: CA (Peter)> 
<Ranking: TA-A (Samantha)> 
 
And I want to take the ranking only from the strings  (i.e. AA, CA, TA-A)]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I have this dilemma, if I receive strings on the form of:<br />
<br />
&lt;Ranking: AA (John)&gt;<br />
&lt;Ranking: CA (Peter)&gt;<br />
&lt;Ranking: TA-A (Samantha)&gt;<br />
<br />
And I want to take the ranking only from the strings  (i.e. AA, CA, TA-A)<br />
<br />
How can I do it using string methods like split or strip if those can do it ?<br />
<br />
Notice that the first characters until the &quot;:&quot;  are common between all (&lt;Ranking: ), yet the ranking length and the name length may differ.<br />
<br />
Thanks in Advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>El Duke</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246686.html</guid>
		</item>
		<item>
			<title>Recursion help!</title>
			<link>http://www.daniweb.com/forums/thread246670.html</link>
			<pubDate>Tue, 15 Dec 2009 20:12:51 GMT</pubDate>
			<description>Hi, I am a newbie here and a python newbie as well :)  I am having trouble implementing a program in which you must use only recursive functions and no built-in python functions other than the len function in order to determine if there are duplicates of an item in a given list.  The function...</description>
			<content:encoded><![CDATA[<div>Hi, I am a newbie here and a python newbie as well :)  I am having trouble implementing a program in which you must use only recursive functions and no built-in python functions other than the len function in order to determine if there are duplicates of an item in a given list.  The function returns True if there is and False if there isn't.  The base condition would be if there is nothing in the list (hence the use of the len function).  What I am having trouble with here, is how do you take an item and compare it to the other items in the list to see if they are equal, and if not, discard that item and continue this type of searching?  Using only recursive functions?  Or is there something else I must do to check for duplicates?<br />
<br />
I suppose the general question here would be for example:<br />
<br />
Given a list L that is [1,2,3,4,5,1,6], how could I use recursive functions to check if the first index of the list (in this case, 1) is equal to any other indexed item in this list?  And if not, discard the first index and make the next index the first index (index 0)?  If this is not possible, what is a workaround that provides the result im looking for?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>johni12</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246670.html</guid>
		</item>
		<item>
			<title>syntax for using style sheet in pyqt...</title>
			<link>http://www.daniweb.com/forums/thread246668.html</link>
			<pubDate>Tue, 15 Dec 2009 19:59:14 GMT</pubDate>
			<description><![CDATA[hello all,  
          Can you tell me the syntax for setting stylesheets for tabs (sub-control) in tab bar like here http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar  
I've searched everywhere for the solution.. But no luck.. Can you please help me in this...]]></description>
			<content:encoded><![CDATA[<div>hello all, <br />
          Can you tell me the syntax for setting stylesheets for tabs (sub-control) in tab bar like here <a rel="nofollow" class="t" href="http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar" target="_blank">http://doc.trolltech.com/4.3/stylesh...et-and-qtabbar</a> <br />
I've searched everywhere for the solution.. But no luck.. Can you please help me in this regard.. Thanks in advance..</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/thread246668.html</guid>
		</item>
		<item>
			<title>FTP or SSH in python</title>
			<link>http://www.daniweb.com/forums/thread246663.html</link>
			<pubDate>Tue, 15 Dec 2009 19:21:26 GMT</pubDate>
			<description><![CDATA[hey guys, first post. 
 
I have a program that takes a file from a windows box, and FTP's it to a unix/linux box.  The program works fine, however there is something i want to add to it.  I want the program to send 2 commands to the unix box while im still connected to it: 
 
1) a concatonate...]]></description>
			<content:encoded><![CDATA[<div>hey guys, first post.<br />
<br />
I have a program that takes a file from a windows box, and FTP's it to a unix/linux box.  The program works fine, however there is something i want to add to it.  I want the program to send 2 commands to the unix box while im still connected to it:<br />
<br />
1) a concatonate command [cat MASTERLOGFILE.txt newlogfile &gt;temp] and<br />
2) a copy command [cp temp MASTERLOGFILE.txt].  <br />
<br />
I have read that there is a ftp.sendcmd(<span style="font-style:italic">command</span>) command that transfers a command to the box that its connected to, however i get errors when running the above mentioned commands.  Is it possible to do this?  Should I create a new program that ssh's into the desired unix box and throws commands that way?  Thanks for any help!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>afireinside7710</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246663.html</guid>
		</item>
		<item>
			<title>wxPython and PDF</title>
			<link>http://www.daniweb.com/forums/thread246632.html</link>
			<pubDate>Tue, 15 Dec 2009 16:40:59 GMT</pubDate>
			<description>Hi,  
I am working currently with wxPython. 
I want to read out pdf pages(seperated files) and display them in wxPython and print them with win32print and win32ui. 
 
Is there the possibility to readout a pdf file and convert it to a wx.Bitmap or a wx.Image? 
please help.</description>
			<content:encoded><![CDATA[<div>Hi, <br />
I am working currently with wxPython.<br />
I want to read out pdf pages(seperated files) and display them in wxPython and print them with win32print and win32ui.<br />
<br />
Is there the possibility to readout a pdf file and convert it to a wx.Bitmap or a wx.Image?<br />
please help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>richardtreier</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246632.html</guid>
		</item>
		<item>
			<title>Plot density</title>
			<link>http://www.daniweb.com/forums/thread246529.html</link>
			<pubDate>Tue, 15 Dec 2009 08:55:09 GMT</pubDate>
			<description><![CDATA[Hi everyone! 
 
I have difficulties solving a plot issue: 
I have these two datas in an array: np.array([Q-value, length]) 
Q-value......length 
A.................60 
B.................40 
C.................90 
B................150 
C................230]]></description>
			<content:encoded><![CDATA[<div>Hi everyone!<br />
<br />
I have difficulties solving a plot issue:<br />
I have these two datas in an array: np.array([Q-value, length])<br />
Q-value......length<br />
A.................60<br />
B.................40<br />
C.................90<br />
B................150<br />
C................230<br />
A................220<br />
<br />
I want to plot these like:<br />
Q-value..........total length  <br />
A...................280<br />
B...................190<br />
C...................230<br />
<br />
Though it seems easy above my &quot;real&quot; array contains a lot more values.<br />
<br />
Thankful for any help!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>dinfadi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246529.html</guid>
		</item>
		<item>
			<title>How do you make sprites appear on top of others?</title>
			<link>http://www.daniweb.com/forums/thread246518.html</link>
			<pubDate>Tue, 15 Dec 2009 07:51:22 GMT</pubDate>
			<description>I am writing a pygame program that has a moving background which is a sprite. I was wondering if/how you can make sprites appear on top of others (some kind of priority in what appears on top of what). I know the order they appear on top of one another is based on which one is added to the screen...</description>
			<content:encoded><![CDATA[<div>I am writing a pygame program that has a moving background which is a sprite. I was wondering if/how you can make sprites appear on top of others (some kind of priority in what appears on top of what). I know the order they appear on top of one another is based on which one is added to the screen first but I am wondering if I can change this.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>etypaldo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246518.html</guid>
		</item>
		<item>
			<title>Fill In The Blank (Homework help) (urgent)</title>
			<link>http://www.daniweb.com/forums/thread246442.html</link>
			<pubDate>Tue, 15 Dec 2009 00:30:38 GMT</pubDate>
			<description><![CDATA[My teacher gives a review sheet which is a lot like the exam if not the exam but with some minor changes. I'm stuck with these fill in the blanks. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>My teacher gives a review sheet which is a lot like the exam if not the exam but with some minor changes. I'm stuck with these fill in the blanks.<br />
<br />
 <pre style="margin:20px; line-height:13px">Fill-In-The-Blank&nbsp; &nbsp; &nbsp;  Word Frequency<br />
The following program gets the name of a file as a command-line argument, opens that file, reads from it and creates a dictionary of the words in the file and the number of times each word occurred.<br />
import _______________<br />
import sys<br />
<br />
NUM_ARGS = ___________<br />
<br />
words = {}<br />
<br />
if len(sys.argv) != ______________:<br />
&nbsp; &nbsp; print &quot;This program needs a command-line argument&quot;<br />
&nbsp; &nbsp; print &quot;that is the name of the file to evaluate.&quot;<br />
<br />
&nbsp; &nbsp; sys._______________<br />
<br />
<br />
file = open(_______________, 'r')<br />
<br />
for line in ____________:<br />
<br />
&nbsp; &nbsp; string.strip(___________)<br />
<br />
&nbsp; &nbsp; _____________&nbsp; = string.split(line)<br />
<br />
&nbsp; &nbsp; for word in wordList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # change word to be in all lower-case<br />
&nbsp; &nbsp; &nbsp; &nbsp; word = string.lower(word)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if the word has punctuation after it<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ord(____________) &lt; ord('a') or ord(____________) &gt; ord('z'):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # remove the punctuation mark from the word<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word = word[: ___________ ]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # put the word in the dictionary and/or increment the word counter<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; count = words.___________(word, 0)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; words[ ____________ ] = count + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
file.______________<br />
<br />
print _____________</pre><br />
this is what I have so far, I have no idea how to fill in the last two blanks.<br />
<br />
 <pre style="margin:20px; line-height:13px">import string<br />
import sys<br />
<br />
NUM_ARG = 2<br />
<br />
words = {}<br />
<br />
if len(sys.argv) != NUM_ARG:<br />
&nbsp; &nbsp; print &quot;This program needs a command-line argument&quot;<br />
&nbsp; &nbsp; print &quot;that is the name of the file to evaluate.&quot;<br />
<br />
&nbsp; &nbsp; sys.close<br />
<br />
<br />
file = open(sys.argv[1], 'r')<br />
<br />
for line in file:<br />
<br />
&nbsp; &nbsp; string.strip(file)<br />
<br />
&nbsp; &nbsp; wordList&nbsp; = string.split(line)<br />
<br />
&nbsp; &nbsp; for word in wordList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # change word to be in all lower-case<br />
&nbsp; &nbsp; &nbsp; &nbsp; word = string.lower(word)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # if the word has punctuation after it<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ord(word) &lt; ord('a') or ord(word) &gt; ord('z'):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # remove the punctuation mark from the word<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word = word[: ___________ ]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # put the word in the dictionary and/or increment the word counter<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; count = words.get(word, 0)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; words[ word ] = count + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
file.close<br />
<br />
print _____________</pre><br />
Then the other one I am having trouble with.<br />
<br />
 <pre style="margin:20px; line-height:13px">Fill-In-The-Blank&nbsp; &nbsp; &nbsp;  Sieve of Eratosthenes<br />
The Sieve of Eratosthenes is an elegant well-known algorithm for finding the primes up to a specified n.<br />
# sieve() implements the Sieve of Eratosthenes algorithm<br />
# that finds the prime numbers up to n.<br />
#<br />
# Inputs: n, the ending value<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  primes, a list to hold the primes<br />
# Output: None, but the list of primes will be modified<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  by the function to hold the primes less than<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  or equal to n.&nbsp; The list doesn't need to be<br />
#&nbsp; &nbsp; &nbsp; &nbsp;  returned, since lists are mutable.<br />
<br />
________ sieve( _____________, primes):<br />
<br />
&nbsp; &nbsp; numbers = _______________<br />
<br />
&nbsp; &nbsp; # make a list of integers from 2 to n, inclusive<br />
<br />
&nbsp; &nbsp; for i in range(______________):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numbers.append(______________)<br />
<br />
&nbsp; &nbsp; del(numbers[ _____________ ])<br />
<br />
&nbsp; &nbsp; del(numbers[ _____________ ])<br />
<br />
<br />
&nbsp; &nbsp; # while there are still numbers in the list<br />
<br />
&nbsp; &nbsp; while len(numbers) &gt; _____________:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # the first number is always a prime<br />
&nbsp; &nbsp; &nbsp; &nbsp; prime = numbers[0]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; primes.append(______________)<br />
&nbsp; &nbsp; &nbsp; &nbsp; del(numbers[0])<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # make a list of indices where there are<br />
&nbsp; &nbsp; &nbsp; &nbsp; # multiples of the current prime number<br />
&nbsp; &nbsp; &nbsp; &nbsp; indices = []&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in range(len(______________)):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if numbers[i] % _____________ == 0:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; indices.append(_____________)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # reverse the indices for easy deletes<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; indices._____________<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # delete these multiples since they're not primes<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for index in _____________:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del(numbers[ ________________ ])</pre><br />
what I was able to figure out<br />
<br />
 <pre style="margin:20px; line-height:13px">def sieve( n, primes):<br />
<br />
&nbsp; &nbsp; numbers = []<br />
<br />
&nbsp; &nbsp; # make a list of integers from 2 to n, inclusive<br />
<br />
&nbsp; &nbsp; for i in range(2, n + 1):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numbers.append(i)<br />
<br />
&nbsp; &nbsp; del(numbers[ _____________ ])<br />
<br />
&nbsp; &nbsp; del(numbers[ _____________ ])<br />
<br />
<br />
&nbsp; &nbsp; # while there are still numbers in the list<br />
<br />
&nbsp; &nbsp; while len(numbers) &gt; -1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; # the first number is always a prime<br />
&nbsp; &nbsp; &nbsp; &nbsp; prime = numbers[0]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; primes.append(______________)<br />
&nbsp; &nbsp; &nbsp; &nbsp; del(numbers[0])<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # make a list of indices where there are<br />
&nbsp; &nbsp; &nbsp; &nbsp; # multiples of the current prime number<br />
&nbsp; &nbsp; &nbsp; &nbsp; indices = []&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in range(len(______________)):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if numbers[i] % ____________ == 0:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; indices.append(_____________)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # reverse the indices for easy deletes<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; indices._____________<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # delete these multiples since they're not primes<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for index in _____________:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del(numbers[ ________________ ])</pre><br />
I'm really stumped on the last one.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>scrace89</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246442.html</guid>
		</item>
		<item>
			<title>help on calculator</title>
			<link>http://www.daniweb.com/forums/thread246439.html</link>
			<pubDate>Tue, 15 Dec 2009 00:21:52 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">class calculator:<br />
&nbsp; &nbsp; def __init__(self, num, operator):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.__num = num<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.__operator = operator<br />
<br />
&nbsp; &nbsp; def changeNum(self, newNum):<br />
&nbsp; &nbsp; &nbsp; &nbsp; a = newNum<br />
&nbsp; &nbsp; &nbsp; &nbsp; return a<br />
<br />
&nbsp; &nbsp; def getNum(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; return self.__num</pre><br />
<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">def click(num):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if num == &quot;one&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;1&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;two&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;2&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;three&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;3&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;four&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;4&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;five&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;5&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;six&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;6&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;seven&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;7&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;eight&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v =&nbsp; &quot;8&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif num == &quot;nine&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v = &quot;9&quot;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.__num1 = self.__num1+v<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calculator = calculatorClass.calculator(self.__num1, self.__sign)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num1 = calculator.getNum()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num2 = calculator.changeNum(self.__num1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(num1, num2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.display.config(text = &quot;a&quot;)</pre><br />
<br />
i trying to define two number<br />
but when num1 = 3 ...num2 is = 3...how can i solve this problem <br />
how can i make them into two separate number; <br />
<br />
also i require to define a class for this calculator..can sum1 help me or give me sum hints how i going to define the class?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>wildplace</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246439.html</guid>
		</item>
		<item>
			<title>Code Snippet DIY animated desktop</title>
			<link>http://www.daniweb.com/code/snippet246415.html</link>
			<pubDate>Mon, 14 Dec 2009 21:34:56 GMT</pubDate>
			<description><![CDATA[Thought someone might like this little script. Its an animated wallpaper.  
You'll need to draw the frames though. I used Windows paint to make the frames. I drew two stick people fighting. You'll need to know the basics about animation. I saved each picture as .bmp It worked with .jpg but had a...]]></description>
			<content:encoded><![CDATA[<div>Thought someone might like this little script. Its an animated wallpaper. <br />
You'll need to draw the frames though. I used Windows paint to make the frames. I drew two stick people fighting. You'll need to know the basics about animation. I saved each picture as .bmp It worked with .jpg but had a little lag. <br />
<br />
The original background will appear upon logging off or shutting down. To avoid this you'll need to use ActiveDesktop extensions. Or put this script in the startup folder.<br />
<br />
It can be used as a slide show too, by changing the time.sleep()<br />
<br />
<br />
Any questions feel free to reply.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Tech B</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246415.html</guid>
		</item>
		<item>
			<title>reader.next() - range it</title>
			<link>http://www.daniweb.com/forums/thread246339.html</link>
			<pubDate>Mon, 14 Dec 2009 17:55:53 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">reader = csv.reader(open('new_mondy_csc_data_revise.csv'), delimiter=',', quotechar='&quot;')<br />
header = tuple(reader.next())<br />
print &quot;%-14s|%-10s|%-5s|%-5s|%-11s|%-11s|%-11s|%-11s|%-11s|%3s&quot; % header # read header line from csv<br />
print &quot;-&quot; * 45</pre><br />
There are a total of 10 fields in the header across a csv file<br />
I want to print the first three instead, how can I do that?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>checker</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246339.html</guid>
		</item>
		<item>
			<title>Pick file from filesystem</title>
			<link>http://www.daniweb.com/forums/thread246329.html</link>
			<pubDate>Mon, 14 Dec 2009 17:26:20 GMT</pubDate>
			<description>Hi folks, 
 
I dont need any code snippet, but at least i need somebody to lead me to a solution.  
 
I got an app form that will have personal info from employees, and i need to let them pick a photo from filesystem to attach to this form. 
 
what i will do with the photo i already have the...</description>
			<content:encoded><![CDATA[<div>Hi folks,<br />
<br />
I dont need any code snippet, but at least i need somebody to lead me to a solution. <br />
<br />
I got an app form that will have personal info from employees, and i need to let them pick a photo from filesystem to attach to this form.<br />
<br />
what i will do with the photo i already have the theory, but dont know how to open a filesystem window, let the person pick a photo, and than.. do something with this photo.<br />
<br />
any tips? thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>fferrandini</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246329.html</guid>
		</item>
		<item>
			<title><![CDATA[What is wrong? A "random-" problem. Python. Please help!]]></title>
			<link>http://www.daniweb.com/forums/thread246314.html</link>
			<pubDate>Mon, 14 Dec 2009 15:54:25 GMT</pubDate>
			<description><![CDATA[I wonder how the random.normalvariate function works. When I do the method below, I end up with negative numbers. I don't want that. How do I prevent that? 
 
And also, i want 10 numbers, but it always turn out 9 and a "none". What is none? How can i remove it? 
 
CODE: 
i  <div class="codeblock">...]]></description>
			<content:encoded><![CDATA[<div>I wonder how the random.normalvariate function works. When I do the method below, I end up with negative numbers. I don't want that. How do I prevent that?<br />
<br />
And also, i want 10 numbers, but it always turn out 9 and a &quot;none&quot;. What is none? How can i remove it?<br />
<br />
CODE:<br />
i <pre style="margin:20px; line-height:13px">mport random<br />
&nbsp; &nbsp; &nbsp; &nbsp; resultat = [random.normalvariate(self.my, self.sigma) for i in range(0,9)] <br />
&nbsp; &nbsp; &nbsp; &nbsp; print resultat</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Skrutten</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246314.html</guid>
		</item>
		<item>
			<title>What is wrong? Please help!  Python game</title>
			<link>http://www.daniweb.com/forums/thread246301.html</link>
			<pubDate>Mon, 14 Dec 2009 15:00:22 GMT</pubDate>
			<description><![CDATA[I'm trying to use my methods, but i always get " <bound method Deltagare.tavla of <__main__.Deltagare instance at 0xfba58>>"  
 
what does it mean? is something wrong with my class?]]></description>
			<content:encoded><![CDATA[<div>I'm trying to use my methods, but i always get &quot; &lt;bound method Deltagare.tavla of &lt;__main__.Deltagare instance at 0xfba58&gt;&gt;&quot; <br />
<br />
what does it mean? is something wrong with my class?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Skrutten</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246301.html</guid>
		</item>
		<item>
			<title>Range and Lists</title>
			<link>http://www.daniweb.com/forums/thread246257.html</link>
			<pubDate>Mon, 14 Dec 2009 12:39:06 GMT</pubDate>
			<description>hello, long time lurker first time poster! 
 
currently writing a program that generates 100 random integer values in the range of 1 - 50, then displays how many of those numbers are in the range 1-10, 11-20 etc etc.  
 
i generated the numbers with no problem, but im not too sure how to tackle the...</description>
			<content:encoded><![CDATA[<div>hello, long time lurker first time poster!<br />
<br />
currently writing a program that generates 100 random integer values in the range of 1 - 50, then displays how many of those numbers are in the range 1-10, 11-20 etc etc. <br />
<br />
i generated the numbers with no problem, but im not too sure how to tackle the next part of the program.<br />
<br />
any suggestions on  how my program should be structured would be greatly appreciated!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>Graxxis</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246257.html</guid>
		</item>
		<item>
			<title>tkinter - button HELP~!</title>
			<link>http://www.daniweb.com/forums/thread246218.html</link>
			<pubDate>Mon, 14 Dec 2009 09:19:40 GMT</pubDate>
			<description><![CDATA[self.button1 =  Button(root, text = '1', \ 
                               command = self.buttonAction) 
        self.button1.grid(row = 1, column = 0) 
         
self.button2 =  Button(root, text = '2', \ 
                              command = self.buttonAction) 
 
 def buttonAction(self): 
    ...]]></description>
			<content:encoded><![CDATA[<div>self.button1 =  Button(root, text = '1', \<br />
                               command = self.buttonAction)<br />
        self.button1.grid(row = 1, column = 0)<br />
        <br />
self.button2 =  Button(root, text = '2', \<br />
                              command = self.buttonAction)<br />
<br />
 def buttonAction(self):<br />
        if self.button1 <span style="color:Red">is clicked/pressed... </span>:<br />
            value = 1<br />
<br />
how do i express the word in red in python code?!!??<br />
thanks :D</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>wildplace</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246218.html</guid>
		</item>
		<item>
			<title>help!!!</title>
			<link>http://www.daniweb.com/forums/thread246209.html</link>
			<pubDate>Mon, 14 Dec 2009 08:32:55 GMT</pubDate>
			<description>can you help me with this things? i really suck doing it in python...</description>
			<content:encoded><![CDATA[<div>can you help me with this things? i really suck doing it in python...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>faded jeans</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246209.html</guid>
		</item>
		<item>
			<title>store image in blob type of mysql</title>
			<link>http://www.daniweb.com/forums/thread246207.html</link>
			<pubDate>Mon, 14 Dec 2009 08:20:17 GMT</pubDate>
			<description>Hi all, 
 
i am new to python 
how to store image into database blob using python 
please help me for this its urgent</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
i am new to python<br />
how to store image into database blob using python<br />
please help me for this its urgent</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>rajeshwari_ib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246207.html</guid>
		</item>
		<item>
			<title>file content copying</title>
			<link>http://www.daniweb.com/forums/thread246197.html</link>
			<pubDate>Mon, 14 Dec 2009 07:04:44 GMT</pubDate>
			<description>Hi friends 
 
I am new to python. 
I have doc file and jpg file. 
I want to append jpg file content to doc file. 
How to achieve this with python please help me.</description>
			<content:encoded><![CDATA[<div>Hi friends<br />
<br />
I am new to python.<br />
I have doc file and jpg file.<br />
I want to append jpg file content to doc file.<br />
How to achieve this with python please help me.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>rajeshwari_ib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246197.html</guid>
		</item>
		<item>
			<title>word frequency percentage</title>
			<link>http://www.daniweb.com/forums/thread246105.html</link>
			<pubDate>Sun, 13 Dec 2009 21:25:42 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">class Database(Student):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; g = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; choice = ['Basketball','Football','Other','Baseball','Handball','Soccer','Volleyball','I do not like sport']<br />
&nbsp; &nbsp; &nbsp; &nbsp; data = student.sport<br />
&nbsp; &nbsp; &nbsp; &nbsp; k = len(student.fname)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print k<br />
&nbsp; &nbsp; &nbsp; &nbsp; freq = {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in data:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freq[i] = freq.get(i, 0) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in choice:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if i not in freq:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freq[i] = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; for i in freq:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print i, freq[i]</pre><br />
I want to calculate each frequency in percentage. I tried to use freq[i] / k but all returned 0 0 0 0 0 0  <br />
<br />
How do I calculate each frequency?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>checker</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246105.html</guid>
		</item>
		<item>
			<title>Finding longest row of same elements in a list</title>
			<link>http://www.daniweb.com/forums/thread246051.html</link>
			<pubDate>Sun, 13 Dec 2009 15:59:23 GMT</pubDate>
			<description><![CDATA[How could one find the length of longest row of same elements in a list. For example if i have a list 
 
list = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1] 
 
and i need to find the the length of longest row of 0's. In this case it would be 7, cause there are 7 zeros...]]></description>
			<content:encoded><![CDATA[<div>How could one find the length of longest row of same elements in a list. For example if i have a list<br />
<br />
list = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]<br />
<br />
and i need to find the the length of longest row of 0's. In this case it would be 7, cause there are 7 zeros starting with list[6] up to list[12]</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ahspats</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread246051.html</guid>
		</item>
		<item>
			<title>Python Xlib Help</title>
			<link>http://www.daniweb.com/forums/thread245978.html</link>
			<pubDate>Sun, 13 Dec 2009 05:56:16 GMT</pubDate>
			<description><![CDATA[Okay, well I've been looking for at least an hour now for some straight-forward python-xlib documentation, and I have been unable to find any. Luckily...I have quite the easy problem. 
 
If somebody would be able to help me create a simple script that would say "Hello" every time the left mouse...]]></description>
			<content:encoded><![CDATA[<div>Okay, well I've been looking for at least an hour now for some straight-forward python-xlib documentation, and I have been unable to find any. Luckily...I have quite the easy problem.<br />
<br />
If somebody would be able to help me create a simple script that would say &quot;Hello&quot; every time the left mouse button is clicked, I have the rest of what I would like to do figured out<br />
<br />
This is what I have so far, to no avail:<br />
 <pre style="margin:20px; line-height:13px">#!/usr/bin/python<br />
<br />
import Xlib<br />
import Xlib.display<br />
<br />
def main():<br />
&nbsp; &nbsp; display = Xlib.display.Display()<br />
&nbsp; &nbsp; root = display.screen().root<br />
&nbsp; &nbsp; while True:<br />
&nbsp; &nbsp; &nbsp; &nbsp; event = root.display.next_event()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if event:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Hello&quot;<br />
<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; main()</pre>Thank you so much in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>SoulMazer</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245978.html</guid>
		</item>
		<item>
			<title><![CDATA[Selling just doesn't work!]]></title>
			<link>http://www.daniweb.com/forums/thread245933.html</link>
			<pubDate>Sat, 12 Dec 2009 23:02:46 GMT</pubDate>
			<description><![CDATA[Okay, I am writing a dopewars clone/wannabe in python. I have it pretty much the way I want it, except that selling items does not work. Buying them does fine, it is just selling them. 
 
Here is the code: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px">...]]></description>
			<content:encoded><![CDATA[<div>Okay, I am writing a dopewars clone/wannabe in python. I have it pretty much the way I want it, except that selling items does not work. Buying them does fine, it is just selling them.<br />
<br />
Here is the code:<br />
 <pre style="margin:20px; line-height:13px">#!/usr/bin/env python<br />
#<br />
#&nbsp; &nbsp; &nbsp;  pimp.py<br />
#&nbsp; &nbsp; &nbsp;  <br />
#&nbsp; &nbsp; &nbsp;  @authors: KarimRuan, <br />
#&nbsp; &nbsp; &nbsp;  Copyright 2009 <br />
#&nbsp; &nbsp; &nbsp;  <br />
#&nbsp; &nbsp; &nbsp;  This program is free software; you can redistribute it and/or modify<br />
#&nbsp; &nbsp; &nbsp;  it under the terms of the GNU General Public License as published by<br />
#&nbsp; &nbsp; &nbsp;  the Free Software Foundation; either version 2 of the License, or<br />
#&nbsp; &nbsp; &nbsp;  (at your option) any later version.<br />
#&nbsp; &nbsp; &nbsp;  <br />
#&nbsp; &nbsp; &nbsp;  This program is distributed in the hope that it will be useful,<br />
#&nbsp; &nbsp; &nbsp;  but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
#&nbsp; &nbsp; &nbsp;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br />
#&nbsp; &nbsp; &nbsp;  GNU General Public License for more details.<br />
#&nbsp; &nbsp; &nbsp;  <br />
#&nbsp; &nbsp; &nbsp;  You should have received a copy of the GNU General Public License<br />
#&nbsp; &nbsp; &nbsp;  along with this program; if not, write to the Free Software<br />
#&nbsp; &nbsp; &nbsp;  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,<br />
#&nbsp; &nbsp; &nbsp;  MA 02110-1301, USA.<br />
import sys, os<br />
import random<br />
<br />
global cash<br />
cash = 500<br />
global dealers<br />
dealers = 2<br />
global hp<br />
hp = 25<br />
global gang<br />
gang = 1<br />
global guns<br />
guns = 0<br />
<br />
global thugHP<br />
thugHP = 20<br />
<br />
<br />
def la_prompt():<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;COMING SOON&quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return<br />
<br />
def la():<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers, hp, gang<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;CASH: &quot;, cash,&nbsp; &quot;dealers: &quot;, dealers, &quot;HP: &quot;, hp, &quot;GANG MEMBERS: &quot;, gang<br />
&nbsp; &nbsp; &nbsp; &nbsp; print<br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'you are in Los Angelos.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print <br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'Rictor sells GUNS. Use &quot;trade guns&quot;. Ace sells DEALERS. use &quot;buy DEALERS&quot;.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'You should tell your dealers &quot;dealers work&quot;.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;You can also go : cleveland, bronxe, NY&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; i = random.randrange(1, 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if i == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;2 thugs want to join your gang!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gang = gang + 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fight()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You find $500'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 500<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cop_fight()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt() <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'Two dealers want to join your crew.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers + 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Error.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; la_prompt()<br />
<br />
<br />
<br />
<br />
def foo_sell():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Sell how many DEALERS?<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; a. 1 dealer for $50<br />
&nbsp; &nbsp; &nbsp; &nbsp; b. 2 dealers for $100<br />
&nbsp; &nbsp; &nbsp; &nbsp; c. 3 dealers for $150<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; or:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; d. exit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'a':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if dealers &gt; 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You sell 1 dealer&nbsp; for $50.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers - 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 50<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You do not have enough dealers to sell.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You have ', dealers, ' dealers to sell.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'b':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if dealers &gt; 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You sell 2 dealers for $100.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers - 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 100<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You do not have enough to sell 2 dealers.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You have &quot;, dealers, &quot; dealers to sell.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'c':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if dealers &gt; 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You sell 3 dealers for $150.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers - 3<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 150<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You do not have enough to sell 3 dealers.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You have ', dealers, ' dealers to sell.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'd':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
def foo_buy():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a. buy 1 guns for $100<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b. buy 2 dealers for $200<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c. buy 3 dealers for $300<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d. exit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'a':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 100:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 100<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'b':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 200:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers + 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 200<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'c':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 300:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers + 3<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 300<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'd':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
def foo_prompt():<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'buy dealers':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'sell dealers':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'exit':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not Recognized.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
def foo_trade():<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR CASH: &quot;, cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR dealers: &quot;, dealers<br />
&nbsp; &nbsp; &nbsp; &nbsp; print<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; YO YO YO, I gots some mad hustlin' dealers for sale. Jus use<br />
&nbsp; &nbsp; &nbsp; &nbsp; 'buy dealers'. I can also take some of them dealers off ya hands.<br />
&nbsp; &nbsp; &nbsp; &nbsp; Jus use 'sell dealers'. Use 'exit' to leave my shop.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; foo_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
################################################<br />
#&nbsp; BOB TRADING<br />
################################################<br />
def bob_sell():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, guns<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Sell how many GUNS?<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; a. 5 guns for $35<br />
&nbsp; &nbsp; &nbsp; &nbsp; b. 10 guns for $75<br />
&nbsp; &nbsp; &nbsp; &nbsp; c. 20 guns for $175<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; or:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; d. exit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'a':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if guns &gt; 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You sell 5 guns for $35.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns - 5<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 35<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You do not have enough guns to sell.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You have ', guns, 'to sell.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'b':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if guns &gt; 10:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You sell 10 guns for $75.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns - 10<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 75<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You do not have enough to sell 10 guns.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You have &quot;, guns, &quot; to sell.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'c':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if guns &gt; 20:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You sell 20 guns for $175.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns - 20<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 175<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You do not have enough to sell 20 guns.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You have ', guns, ' to sell.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'd':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
def bob_buy():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, guns<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a. buy 5 guns for $50<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b. buy 10 guns for $100<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c. buy 20 guns for $200<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d. exit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'a':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 50:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns + 5<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 50<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'b':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 100:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns + 10<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 100<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'c':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cash &lt; 200:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not enough cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guns = guns + 20<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash - 200<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'd':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
def bob_prompt():<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'buy guns':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_buy()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'sell guns':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_sell()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'exit':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Not Recognized.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
def bob_trade():<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, guns<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR CASH: &quot;, cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR GUNS: &quot;, guns<br />
&nbsp; &nbsp; &nbsp; &nbsp; print<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; HI: my name is Bob. Do you want to 'sell guns' or 'buy guns'?<br />
&nbsp; &nbsp; &nbsp; &nbsp; type 'exit' to exit shop.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bob_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
def work_dealers():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; cearn = random.randrange(50, 99)<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;you earned &quot;, cearn, &quot;cash.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cash = cash + cearn<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_dealers<br />
<br />
'''<br />
def work_dealers():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; income = random.randint(self, 1, 9)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cash = cash + income<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_dealers()<br />
'''<br />
def clev_income():<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_dealers()<br />
<br />
def clev_prompt():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers, hp, gang, thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'dealers work':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_income()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'trade guns':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bob_trade()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'buy dealers':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo_trade()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'go la':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; la()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'go bronxe':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bronxe()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'go ny':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ny()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'look':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'exit':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.exit(0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'Not Recognized.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
def cop_fight():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global hp, thugHP, cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; charhp = hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; thughp = thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;YOU ARE IN A FIGHT!&quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +++++++++++++++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; COP&nbsp; &nbsp;  +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +++++++++++++++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (hp &gt; 0) and (thugHP &gt; 0):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # player attacks<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chardmg = random.randrange(2) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You attack the COP!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You deal ', chardmg, 'damage'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thugHP -= chardmg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR HP: &quot;, hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;COP HP: &quot;, thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw_input()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  # thug attacks<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thugdmg = random.randrange(1) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'The COP attacks you!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'The COP deals ', thugdmg, 'damage to you!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charhp -= thugdmg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Your HP: &quot;, hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'COP HP: ', thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw_input()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if charhp &lt; 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;The COP killed you.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;GAME OVER&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gameover()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You killed the COP!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cearn = random.randrange(10, 25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOU EARNED &quot;, cearn, &quot;CASH!\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + cearn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return <br />
<br />
def fight():<br />
&nbsp; &nbsp; &nbsp; &nbsp; global hp, thugHP, cash<br />
&nbsp; &nbsp; &nbsp; &nbsp; charhp = hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; thughp = thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;YOU ARE IN A FIGHT!&quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +++++++++++++++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; THUG&nbsp; &nbsp;  +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +++++++++++++++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (hp &gt; 0) and (thugHP &gt; 0):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; # player attacks<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chardmg = random.randrange(2) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You attack the thug!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You deal ', chardmg, 'damage'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thugHP -= chardmg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOUR HP: &quot;, hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;THUG HP: &quot;, thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw_input()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  # thug attacks<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thugdmg = random.randrange(1) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'The thug attacks you!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'The thug deals ', thugdmg, 'damage to you!'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charhp -= thugdmg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Your HP: &quot;, hp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'Thug HP: ', thugHP<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw_input()<br />
&nbsp; &nbsp; &nbsp; &nbsp; if charhp &lt; 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;The thug killed you.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;GAME OVER&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gameover()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;You killed the thug!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cearn = random.randrange(10, 25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;YOU EARNED &quot;, cearn, &quot;CASH!\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + cearn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
def cleveland():<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; global cash, dealers, hp, gang<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;CASH: &quot;, cash,&nbsp; &quot;dealers: &quot;, dealers, &quot;HP: &quot;, hp, &quot;GANG MEMBERS: &quot;, gang<br />
&nbsp; &nbsp; &nbsp; &nbsp; print<br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'you are in cleveland.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print <br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'Bob sells GUNS. Use &quot;trade guns&quot;. Foo sells DEALERS. use &quot;buy dealers&quot;.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print 'You should tell your dealers &quot;dealers work&quot;.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;You can also go : la, bronxe, NY&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; i = random.randrange(1, 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if i == 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;2 thugs want to join your gang!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gang = gang + 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fight()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'You find $50'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash = cash + 50<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt() <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cop_fight()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt() <br />
&nbsp; &nbsp; &nbsp; &nbsp; elif i == 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print 'Two dealers want to join your crew.'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dealers = dealers + 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;Error.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; clev_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
def game():<br />
&nbsp; &nbsp; &nbsp; &nbsp; cleveland()<br />
&nbsp; &nbsp; &nbsp; &nbsp; la()<br />
&nbsp; &nbsp; &nbsp; &nbsp; # bronxe()&nbsp; TODO<br />
&nbsp; &nbsp; &nbsp; &nbsp; # ny()&nbsp; &nbsp; &nbsp; TODO<br />
<br />
def menu_prompt():<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = raw_input(&quot;&gt; &quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if x == 'a':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; game()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'b':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadgame()<br />
&nbsp; &nbsp; &nbsp; &nbsp; elif x == 'c':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; credits()<br />
&nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;THAT IS NOT A VALID OPTION.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menu_prompt()<br />
<br />
def clear():<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
<br />
<br />
def menu():<br />
&nbsp; &nbsp; &nbsp; &nbsp; clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ++ ++&nbsp; ++&nbsp; ++ +&nbsp; &nbsp; +&nbsp;  ++ ++ ++++++ +&nbsp; &nbsp; + +&nbsp; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; + + + +&nbsp; + ++ + +&nbsp; +&nbsp;  + + + +&nbsp; &nbsp; &nbsp; + +&nbsp; + +&nbsp; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; +&nbsp;  + ++++ ++ +&nbsp; + +&nbsp;  +&nbsp;  + +++&nbsp; &nbsp; +&nbsp; + + +&nbsp; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; +&nbsp;  + +&nbsp; + ++ +&nbsp;  ++&nbsp;  +&nbsp;  + ++++++ +&nbsp;  ++ ++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; A: PLAY NEW GAME<br />
&nbsp; &nbsp; &nbsp; &nbsp; B: LOAD GAME (COMING SOON)<br />
&nbsp; &nbsp; &nbsp; &nbsp; C: CREDITS (COMING SOON)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_prompt()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
def main():<br />
&nbsp; &nbsp; &nbsp; &nbsp; print &quot;&quot;&quot;\<br />
&nbsp; &nbsp; &nbsp; &nbsp; ++++ + ++ ++ ++++&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +&nbsp; &nbsp;  +&nbsp; +&nbsp; &nbsp; +++++&nbsp; +++++<br />
&nbsp; &nbsp; &nbsp; &nbsp; ++++ + + + + ++++&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + + +&nbsp; +++&nbsp;  +++++&nbsp; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; +&nbsp; &nbsp; + +&nbsp;  + +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + +&nbsp; +&nbsp;  +&nbsp; +&nbsp; +&nbsp;  +++++<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; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BY: KARIMRUAN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  +++++&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; raw_input()<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
main()</pre><br />
<br />
Any help would be greatly appreciated! I also attached the .py incase it is easier to test it without having to delete line numbers.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>mruane</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245933.html</guid>
		</item>
		<item>
			<title>sorting problem</title>
			<link>http://www.daniweb.com/forums/thread245931.html</link>
			<pubDate>Sat, 12 Dec 2009 22:55:29 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 csv<br />
<br />
class Reader(object):<br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.names = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.idigit = []<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.fileReader_list=[]<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.fileReader = csv.reader(open(&quot;survey_result.csv&quot;, &quot;rb&quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.fileReader_list.extend(self.fileReader)<br />
&nbsp; &nbsp; &nbsp; &nbsp; for column in self.fileReader_list:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.names.append(column[1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.idigit.append(column[2])<br />
&nbsp; &nbsp; &nbsp; &nbsp; del self.names[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; del self.idigit[0]<br />
<br />
X = Reader()<br />
for i, names in enumerate(X.names):<br />
&nbsp; &nbsp; print names, X.idigit[i]</pre>    <br />
Ch, Sbb 6748<br />
Oudfd, Sufdfdfy 8473<br />
Sdfdfu, Radfdf 5667<br />
Adfn, Mudfmmdfd 4290<br />
Wodfdf, Yeddfdfon 8066<br />
Chdfdng, Widfdfn 3325<br />
Badfd, Sadfdf 4742<br />
<br />
<br />
I want to sort them out. I tried <br />
k = names, X.idigit[i] then print k, however, this turns everything into a list, which I do not want to do.<br />
Is there any alternative suggestion to do it?<br />
<br />
I do this because I need to use textwrap later to formulate these data into a wrap table</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>jwxie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245931.html</guid>
		</item>
		<item>
			<title>how do i make the scroll bars on the side and bottom of a window?</title>
			<link>http://www.daniweb.com/forums/thread245924.html</link>
			<pubDate>Sat, 12 Dec 2009 22:15:52 GMT</pubDate>
			<description><![CDATA[i just started learning GUI, and i made my first graphic interface using the tkinter module, but as information is piled up and goes beyond the window's dimensions, i need those scroll bars to up and down]]></description>
			<content:encoded><![CDATA[<div>i just started learning GUI, and i made my first graphic interface using the tkinter module, but as information is piled up and goes beyond the window's dimensions, i need those scroll bars to up and down</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>i are smart</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245924.html</guid>
		</item>
		<item>
			<title>telnet java client  to connect to python game server</title>
			<link>http://www.daniweb.com/forums/thread245919.html</link>
			<pubDate>Sat, 12 Dec 2009 21:49:08 GMT</pubDate>
			<description><![CDATA[hello i have a python chat server (multi client) and i wanted to connect a java client to it but i have been searching alot about java-python connection and i got solutions like using APIs as YAML or SOAP but i just can't figure out which one or if there's a thiird simpler way,, 
appreciationg any...]]></description>
			<content:encoded><![CDATA[<div>hello i have a python chat server (multi client) and i wanted to connect a java client to it but i have been searching alot about java-python connection and i got solutions like using APIs as YAML or SOAP but i just can't figure out which one or if there's a thiird simpler way,,<br />
appreciationg any help :~)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>lidyaMikhail</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245919.html</guid>
		</item>
		<item>
			<title>Help formatting in numpy.loadtxt</title>
			<link>http://www.daniweb.com/forums/thread245873.html</link>
			<pubDate>Sat, 12 Dec 2009 17:30:29 GMT</pubDate>
			<description>I need to read in a large amount of data from a csv file into arrays.  I am using Numpy as I need to later manipulate and plot the results.  I have decided to use numpy.loadtxt as this appears to be the most efficient method to read in the data.  I can read the data into one big string array but I...</description>
			<content:encoded><![CDATA[<div>I need to read in a large amount of data from a csv file into arrays.  I am using Numpy as I need to later manipulate and plot the results.  I have decided to use numpy.loadtxt as this appears to be the most efficient method to read in the data.  I can read the data into one big string array but I am struggling to convert the data as I read it in.  <br />
Here is the code I am using...<br />
<br />
 <pre style="margin:20px; line-height:13px"># -*- coding: utf-8 -*-<br />
&quot;&quot;&quot;<br />
Created on Sat Nov 21 21:41:05 2009<br />
<br />
@author: Roger Iles<br />
&quot;&quot;&quot;<br />
import numpy as np<br />
<br />
test=np.loadtxt('data_dev_test.csv',delimiter=',', unpack=True,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dtype={'names':('localtime','localdate','elapsedtime','dose','units'),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  'formats': ('s8','s7','s10','.3f','s2')})<br />
<br />
<br />
print test</pre><br />
And the data has the format...<br />
<br />
<span style="font-weight:bold">11:16:29, 24NOV00, 0000:00:00,1.087,nG<br />
11:17:34, 24NOV00, 0000:01:04,1.087,nG</span><br />
<br />
On running the code I get the following error...<br />
<br />
<span style="font-weight:bold">Traceback (most recent call last):<br />
  File &quot;C:\Python26\Lib\site-packages\xy\tepc.py&quot;, line 11, in &lt;module&gt;<br />
    'formats': ('s8','s7','s10','.4f','s2')})<br />
  File &quot;C:\Python26\lib\site-packages\numpy\lib\io.py&quot;, line 443, in loadtxt<br />
    dtype = np.dtype(dtype)<br />
TypeError: data type not understood</span><br />
<br />
I'd really appreciate any assistance here as I am farily new to Python and do not know where to go next.<br />
<br />
Many thanks in advance,<br />
<br />
RogerI</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>RogerI</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245873.html</guid>
		</item>
		<item>
			<title>Hex encryption help</title>
			<link>http://www.daniweb.com/forums/thread245871.html</link>
			<pubDate>Sat, 12 Dec 2009 17:07:27 GMT</pubDate>
			<description><![CDATA[Okay, this is what I am trying to do. I am attempting to create my own encrypter. I have the base encryption running, used just to encrypt a string you put in. I am going to add functionality to open a text file's contents and encrypt them, outputing them into another text file. I will be working...]]></description>
			<content:encoded><![CDATA[<div>Okay, this is what I am trying to do. I am attempting to create my own encrypter. I have the base encryption running, used just to encrypt a string you put in. I am going to add functionality to open a text file's contents and encrypt them, outputing them into another text file. I will be working on that later, so I might post up my questions if I can't figure it out. Anyways, this is what I need help with:<br />
1) How do I open a file's binary code, and convert it to hex?<br />
2) After opening it in hex, it shoud become manipulatable, such as, I can make it into a list, then change each odd charecter, correct?<br />
3) After messing with the hex, how do I convert it back into binary, then save it?<br />
Thank you very much in advance!<br />
~ Hondros</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>hondros</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245871.html</guid>
		</item>
		<item>
			<title>Python tkinter resize problem</title>
			<link>http://www.daniweb.com/forums/thread245830.html</link>
			<pubDate>Sat, 12 Dec 2009 13:14:08 GMT</pubDate>
			<description><![CDATA[Hi! 
I'm trying to combine some frames in a GUI as a toolbar and content area. Currently I'm on windows and using python 3, and I want preferrably my app to work on *nix and mac as well. 
 
The problem is that in the following app, when I resize it the toolbar area is increasing/decreasing, and the...]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
I'm trying to combine some frames in a GUI as a toolbar and content area. Currently I'm on windows and using python 3, and I want preferrably my app to work on *nix and mac as well.<br />
<br />
The problem is that in the following app, when I resize it the toolbar area is increasing/decreasing, and the content area is staying the same. I would like the opposite to happen. In other words, the area with the 'up' button shouldn't be resized, but the area with the 'down' button should.<br />
<br />
My reasoning is that since the lower area, b, is using a sticky in all directions, and the upper button is sticking north, so the lower area should be resized.<br />
<br />
Thanks for your help!<br />
 <pre style="margin:20px; line-height:13px">from tkinter import *<br />
<br />
class app( Frame ):<br />
&nbsp; &nbsp; def __init__( self, master=None ):<br />
&nbsp; &nbsp; &nbsp; &nbsp; Frame.__init__( self, master )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.grid( sticky='nswe' )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.top = root.winfo_toplevel()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.top.rowconfigure( 0, weight=1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.top.columnconfigure( 0, weight=1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.rowconfigure( 0, weight=1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.columnconfigure( 0, weight=1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; a = Button( self, text=&quot;up&quot; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; a.grid( row=0, column=0, sticky='n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.b = Canvas( self, bg='black' )<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.b.grid( row=1, column=0, sticky='nswe' )<br />
&nbsp; &nbsp; &nbsp; &nbsp; c = Button( self.b, text=&quot;down&quot; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; c.grid( sticky='nswe')<br />
&nbsp; &nbsp; &nbsp; &nbsp; d = self.b.create_window( 10, 10, window=c, anchor=NW )<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; root = Tk()<br />
&nbsp; &nbsp; appl = app( master=root )<br />
&nbsp; &nbsp; appl.mainloop()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>ribot</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245830.html</guid>
		</item>
		<item>
			<title>Help plz with range in list!</title>
			<link>http://www.daniweb.com/forums/thread245798.html</link>
			<pubDate>Sat, 12 Dec 2009 11:28:42 GMT</pubDate>
			<description><![CDATA[So my listname is men =[] 
 
How can i print just the 10 first elements of the list? It contains 15... 
And it's a matrix... 
 
I thought about making a while-loop while i > 9: but it didn't work. 
 
Can anybody help me please? :)  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>So my listname is men =[]<br />
<br />
How can i print just the 10 first elements of the list? It contains 15...<br />
And it's a matrix...<br />
<br />
I thought about making a while-loop while i &gt; 9: but it didn't work.<br />
<br />
Can anybody help me please? :) <pre style="margin:20px; line-height:13px">for gender in men:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print gender[0] + &quot; &quot; + gender[1] + &quot;\t&quot;&quot;\t&quot;&quot; &quot; + gender[2] + &quot;\t&quot; + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gender[3] + &quot;\t&quot; , gender[10]</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>goisagi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245798.html</guid>
		</item>
		<item>
			<title><![CDATA[How to 'refresh' in wxPython?]]></title>
			<link>http://www.daniweb.com/forums/thread245766.html</link>
			<pubDate>Sat, 12 Dec 2009 07:33:18 GMT</pubDate>
			<description><![CDATA[Hey All, 
 
I have 'Py-mailer' here.... here's how it is so far: 
 
 
import smtplib 
import wx 
 
window=wx.App()]]></description>
			<content:encoded><![CDATA[<div>Hey All,<br />
<br />
I have 'Py-mailer' here.... here's how it is so far:<br />
<br />
 <pre style="margin:20px; line-height:13px">import smtplib<br />
import wx<br />
<br />
window=wx.App()<br />
<br />
class pymailer(wx.Frame):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; def __init__(self):<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.Frame.__init__(self,None,-1,&quot;Py-mailer&quot;,size=(900,700))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.panel=wx.Panel(self,-1)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; menubar=wx.MenuBar()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; filem=wx.Menu()<br />
&nbsp; &nbsp; &nbsp; &nbsp; filem.Append(201,&quot;Quit&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Bind(wx.EVT_MENU,self.Quit,id=201)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; viewm=wx.Menu()<br />
&nbsp; &nbsp; &nbsp; &nbsp; viewm.Append(202,&quot;About&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Bind(wx.EVT_MENU,self.About,id=202)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; menubar.Append(filem,&quot;File&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; menubar.Append(viewm,&quot;Help&quot;)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.SetMenuBar(menubar)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel, -1, &quot;Login ID:&quot;, pos=(10,10))<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel, -1, &quot;Password:&quot;, pos=(10,40))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.username=wx.TextCtrl(self.panel,101,&quot;Login ID&quot;,pos=(100,10))&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.password=wx.TextCtrl(self.panel,102,&quot;Password&quot;,style=(wx.TE_PASSWORD),pos=(100,40))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel, -1, &quot;@gmail.com&quot;, pos=(220,10))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; login=wx.Button(self.panel,103,label=&quot;Login&quot;,pos=(115,70))<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Bind(wx.EVT_BUTTON,self.Login,id=103)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel,-1,&quot;To:&quot;,pos=(10,120))<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel,-1,&quot;Subject:&quot;,pos=(10,150))<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel,-1,&quot;Message:&quot;, pos=(10,180))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.to_info=wx.TextCtrl(self.panel,104,pos=(80,120),size=(300,20))&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.sub_info=wx.TextCtrl(self.panel,105,pos=(80,150),size=(300,20))&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.msg_info=wx.TextCtrl(self.panel,106,pos=(80,180),size=(800,400))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; send=wx.Button(self.panel,107,&quot;Send&quot;,pos=(400,600))<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Bind(wx.EVT_BUTTON,self.Send,id=107)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Centre()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Show()<br />
<br />
&nbsp; &nbsp; def Quit(self,event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.Close()<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; def About(self,event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; about=wx.AboutDialogInfo()<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; about.SetName(&quot;Py-Mailer&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; about.SetCopyright(&quot;(c) 2009 Sravan and Daniel&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; about.SetWebSite(&quot;http://www.team-vaska.co.cc&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; about.AddDeveloper(&quot;Sravan&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; about.AddDeveloper(&quot;Daniel Pacheco&quot;)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.AboutBox(about)<br />
<br />
&nbsp; &nbsp; def Login(self,event):<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.user=self.username.GetValue()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.passw=self.password.GetValue()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.loginmsg=wx.StaticText(self.panel,-1,&quot;...&quot;,pos=(10,200))<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(self.user==&quot;&quot; and self.passw==&quot;&quot;):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wx.MessageBox(&quot;Error 002: You did not enter your username and/or password&quot;,&quot;Enter Login Details&quot;)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; try:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.s.login(self.user,self.passw)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.loginmsg.SetLabel(&quot;Logged in...&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; except:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.loginmsg.SetLabel(&quot;Failed to login, please try again...&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; def Send(self,event):<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.to=self.to_info.GetValue()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.subject=self.sub_info.GetValue()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.message=self.msg_info.GetValue()<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.msg=&quot;To: &quot;+self.to+&quot;\nSubject: &quot;+self.subject+&quot;\n&quot;+self.message<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.s.sendmail(self.user,self.to,self.msg)<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.s.quit()&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wx.StaticText(self.panel,-1,&quot;Your message has been sent!&quot;,pos=(175,500))&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
pymailer()<br />
window.MainLoop()</pre><br />
Now what I want to do is: when the user clicks the &quot;Send&quot; button, the panel should refresh, and only a StaticText should be displayed in the centre saying &quot;Sending...&quot;. After that I should say (after the message is sent) &quot;You message has been successfully sent to _____&quot;.<br />
<br />
How do I make the panel destroy all it's contents?<br />
<br />
Thanks,<br />
Sravan</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>sravan953</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245766.html</guid>
		</item>
		<item>
			<title>need help Ntlm python</title>
			<link>http://www.daniweb.com/forums/thread245745.html</link>
			<pubDate>Sat, 12 Dec 2009 05:40:15 GMT</pubDate>
			<description><![CDATA[i try to connect python to internet but can't 
 Error 407 Proxy authentication required  
 
Is there someone who can help 
 
thank 
 
 -]]></description>
			<content:encoded><![CDATA[<div>i try to connect python to internet but can't<br />
 Error 407 Proxy authentication required <br />
<br />
Is there someone who can help<br />
<br />
thank<br />
<br />
 -</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>aditri</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245745.html</guid>
		</item>
		<item>
			<title>Equal probability problem</title>
			<link>http://www.daniweb.com/forums/thread245707.html</link>
			<pubDate>Sat, 12 Dec 2009 00:33:12 GMT</pubDate>
			<description>Ive written a program to do with drawing a line from a centre point and it is meant to snake randomly from the centre. 
 
However, it seems to be incredibly biased as to where it decides to go. 
 
the 4 directions are as simple as up down left and right, but it seems to only really head upwards....</description>
			<content:encoded><![CDATA[<div>Ive written a program to do with drawing a line from a centre point and it is meant to snake randomly from the centre.<br />
<br />
However, it seems to be incredibly biased as to where it decides to go.<br />
<br />
the 4 directions are as simple as up down left and right, but it seems to only really head upwards. Yet i can see that some of the numbers do infact tell it to snake downwards, however it seems to make no real difference.<br />
<br />
Any suggestions? (I do know there is some redundant code in there, but ill preen that later on.)<br />
<br />
Running python 2.6<br />
<br />
 <pre style="margin:20px; line-height:13px">#<br />
#<br />
#<br />
from graphics import *<br />
def main():<br />
&nbsp; &nbsp; numWalks, numSteps, = getInputs()<br />
&nbsp; &nbsp; north,south,east,west = takeWalks(numWalks, numSteps)<br />
&nbsp;  <br />
<br />
def getInputs():<br />
&nbsp; <br />
&nbsp; &nbsp; numWalks = input(&quot;How many random walks to take? &quot;)<br />
&nbsp; &nbsp; numSteps = input(&quot;How many steps for each walk? &quot;)<br />
&nbsp; &nbsp; return numWalks, numSteps<br />
<br />
<br />
def takeWalks(numWalks, numSteps):<br />
&nbsp; &nbsp; totalSteps = 0<br />
&nbsp; &nbsp; north=0<br />
&nbsp; &nbsp; south=0<br />
&nbsp; &nbsp; east=0<br />
&nbsp; &nbsp; west=0<br />
&nbsp; &nbsp; from math import sqrt<br />
&nbsp; &nbsp; from random import randint<br />
&nbsp; &nbsp; from graphics import *<br />
&nbsp; &nbsp; centre= Point(numWalks*numSteps,numWalks*numSteps)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; centrex,centrey=(numWalks*numSteps),(numWalks*numSteps)<br />
&nbsp; &nbsp; x,y=centrex,centrey<br />
&nbsp; &nbsp; win=GraphWin(&quot;&quot;,(numWalks*2)*numSteps,(numWalks*2)*numSteps)<br />
&nbsp; &nbsp; circle = Circle(centre, numWalks*numSteps)<br />
&nbsp; &nbsp; circle.setWidth(2)<br />
&nbsp; &nbsp; circle.draw(win)&nbsp;  <br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; for walk in range(numWalks):&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; direction = (randint(1,5)+randint(1,5)+randint(1,5)+randint(1,5))/4&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for step in range(numSteps):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if direction == 1:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startx,starty=x,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,y+x,y+1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line= Line(Point(startx,starty), Point(x,y))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line.draw(win)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif direction == 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startx,starty=x,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,y=x,y-1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line= Line(Point(startx,starty), Point(x,y))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line.draw(win)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif direction == 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startx,starty=x,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,y=x+1,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line= Line(Point(startx,starty), Point(x,y))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line.draw(win)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startx,starty=x,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,y=x-1,y<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line= Line(Point(startx,starty), Point(x,y))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line.draw(win)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; print direction<br />
&nbsp; &nbsp; &nbsp; &nbsp; #y1=(north-south)<br />
&nbsp; &nbsp; &nbsp; &nbsp; #x1=(east - west)<br />
&nbsp; &nbsp; &nbsp; &nbsp; #distance = sqrt(x1**2 + y1**2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; return north,south,east,west<br />
<br />
def printExpectedDistance(distance):<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; print &quot;The expected number of steps away from the &quot;<br />
&nbsp; &nbsp; print &quot;start point is&quot;, int(distance)<br />
<br />
main()</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum114.html">Python</category>
			<dc:creator>takarii</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread245707.html</guid>
		</item>
	</channel>
</rss>
