<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel about="http://blog.gmane.org/gmane.comp.python.tutor">
    <title>gmane.comp.python.tutor</title>
    <link>http://blog.gmane.org/gmane.comp.python.tutor</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48053"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48045"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48043"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48042"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48036"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48032"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48031"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48027"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48026"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48021"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48020"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48019"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48012"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48008"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48007"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48004"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48001"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/48000"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/47990"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.tutor/47988"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48053">
    <title>Best way to define comparison</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48053</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Tiago Katcipis</dc:creator>
    <dc:date>2008-05-17T18:18:38</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48045">
    <title>datetime syntax error for May 8th and 9th 2008??</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48045</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Che M</dc:creator>
    <dc:date>2008-05-17T04:09:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48043">
    <title>Dictionaries or Numpy?</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48043</link>
    <description>Hi, I'm writing an AI for a board game called Blokus, and I believe
that the quality of the program is going to greatly depend on the
efficiency of the algorithm I use to generate legal moves and rate
them.

I know sort of how I'm going to do this legal move generation, and I
know it is going to require lots of accesses to an array of some kind
which will represent the game board.

I'm fairly new to Python, and I am not sure whether it would be faster
for me to use a Dictionary data type to represent the board
(advantages: indices can be strings or tuples, and the dictionary can
store different types of data as well, so programming would be easier)
or the Numpy array type (don't know much about this, but I have heard
Numpy is faster).

So is Numpy faster for simple array accesses? That would be valuable
and I'd deal with having an integer-indexed integer array if I had to.

Code might look something like this:

for playable_corner in all_playable_corners:
    for piece in all_available_pieces:
        for ea</description>
    <dc:creator>Adam Clarridge</dc:creator>
    <dc:date>2008-05-16T22:59:50</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48042">
    <title>quickly pulling marbles out of urns</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48042</link>
    <description>I'm looking for a faster way to do the following problem:

I have an urn with many different colors of marbles in it.  I pull one
out and note the color.  I do not replace it.

For the programming of this, I actually know how many are yellow,
green, etc.  So the way the code works right now is:

import math
...

randindex = math.randint(1,number_of_marbles)
for color in colors:
   if randindex&lt;=marble_count[color]: #we've found what color it will be
       break
   else:                                          #try next color
       randindex -= marble_count[color]
marble_count[color] -= 1
number_of_marbles -= 1
return color

Unfortunately, I have hundreds of thousands of colors, so it spends a
while on this loop.  And I have to keep choosing marbles many times at
different points of the code.

Is there a quicker way to do this?

Thanks,
Joel
_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>Joel Miller</dc:creator>
    <dc:date>2008-05-16T21:43:19</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48036">
    <title>Getting started with Python</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48036</link>
    <description>
I can't.




is all very well if the interpreter knows where file.py is.


I want to do this :



Is this not possible ?

</description>
    <dc:creator>ppaarrkk</dc:creator>
    <dc:date>2008-05-16T12:16:10</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48032">
    <title>Guido van Robot help</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48032</link>
    <description>Hi,

Would anyone be able to offer assistance re: using
Guido van Robot to perform pattern recognition (as in
it "sees" a particular pattern (like a 3x5 grid
depiction of the letter "A") and responds
accordingly)? In my example, Guido recognizes a
specific letter by placing down an appropriate amount
of beepers. A = 1 beeper, B = 2, etc.

I'm able to create separate definitions to recognize
specific letters, but my difficulty arises when I try
to make a program so robust that it should be able to
recognize any letter of the alphabet no matter what
order they would be in.

Thanks,

Jill


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/
_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>Gillian</dc:creator>
    <dc:date>2008-05-15T17:50:51</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48031">
    <title>Open a directory in the default file manager</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48031</link>
    <description>Hello,
is there any function/module that allows me to open a directory in the 
default file manager of a operating system?

Here I a piece of code how to open a URL in the default webbrowser:

http://www.python.org/doc/lib/module-webbrowser.html

import webbrowser
myurl = 'http://www.python.org'
webbrowser.open_new_tab(myurl)


I just wanna do the same with a directory.

The function should open Explorer on Windows, Nautilus on Gnome, Thunar 
onn XFCE4, ...

Thanks for your help in advance.

Regards,
Timmie

_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>Tim Michelsen</dc:creator>
    <dc:date>2008-05-15T18:10:05</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48027">
    <title>(no subject)</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48027</link>
    <description>hi ,i am working to replace three lines in a httpd.conf file using
regular expression.i am able to change only one among them but while
replacing other i am not geeting good idea to replace all the three
lines just in a single script ,,my script is like

 #!usr/bin/python

import sys
import os
import re
import  string

def replace_file(file,search,replace):
cregex=re.compile(search)
for current_line in file:
if cregex.search(current_line):
current_line=re.sub(search,replace,current_line)
print current_line
else:
print current_line


def main():
file =open("/root/Desktop/httpd.conf").readlines()
replace_file(file,'User apache ' , 'User myuser ')
#replace_file(file,'Group apache','Group myuser')
#replace_file(file,DirectoryIndex\ index.html\ index.html.var,DirectoryIndex\ index.html\ index.html.var\ login.html)



if __name__ == '__main__':
        main()


I am running this command to save the output in a temp file then replacing with original httpd.conf.

can I do this in a single </description>
    <dc:creator>root</dc:creator>
    <dc:date>2008-05-15T15:22:22</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48026">
    <title>Freeze utility</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48026</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Diego Trazzi</dc:creator>
    <dc:date>2008-05-15T12:10:40</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48021">
    <title>Random module error</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48021</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Guess?!?</dc:creator>
    <dc:date>2008-05-15T07:00:04</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48020">
    <title>Iterate through dictionary values and remove item</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48020</link>
    <description>Hello all,

I have dictionary like the following:

d={(1,23A):[a,b,c,d],  (1,24A):[b,c,d], (2,23A):[a,b], (2,24A):[a,b,c,d]}

I would like to iterate through the dictionary such that if it finds
the value 'a' in the values of the key that it would remove the value
'b' from the values list. In addition if it finds 'a' in the values
list I would like it to take the first item from the key tuple k[0]
and and then look through the dictionary for that k[0] value and then
remove 'b' from its value list even if 'a' is not present in that
list. So at the end I would like my dictionary to end with:

d={(1,23A):[a,c,d],  (1,24A):[c,d], (2,23A):[a], (2,24A):[a,c,d]}

Initally I did the following:

for k,v in d.items():
u=k[0]
b=k[1]
if 'a' in v:
for k,v in d.items():
if k[0] == u:
for values in v:
if values == 'b':
v.remove(values)

However this will be a very big dictionary and it ended up running for
a very long time - in fact I had to kill the process.

Can anyone suggest an alternate method to do this?

Thanks in a</description>
    <dc:creator>GTXY20</dc:creator>
    <dc:date>2008-05-15T06:40:24</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48019">
    <title>looking for ways to get diff between two txt files</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48019</link>
    <description>Hi,

I would really appreciate if someone help to find a way to calculate
delta (diff) between two similar text files. I have looked at difflib
and found related script at this site
http://www.java2s.com/Code/Python/Utility/Printfilediffsincontextunifiedorndiffformats.htm

Is there a simple way to just get delta between two files? e.g. I have
below two files and the delta between these two files is in
diff_output.txt

file1.txt
hello world

file2.txt
hello world
hello python

diff_output.txt
hello python

</description>
    <dc:creator>Kamal</dc:creator>
    <dc:date>2008-05-15T05:58:14</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48012">
    <title>basic lists and loops question</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48012</link>
    <description>Something basic about lists and loops that I'm not getting here. I've got 
a long list of dictionaries that looks like this:

lst = [{'placename': u'Stow, Lincolnshire', 'long-name': u'Stow, 
Lincolnshire.', 'end': datetime.date(1216, 9, 28), 'start': 
datetime.date(1216, 9, 26)},
{'placename': u'Lincoln, Lincolnshire', 'long-name': u'Lincoln, 
Lincolnshire.', 'end': datetime.date(1216, 9, 30), 'start': 
datetime.date(1216, 9, 28)},
{'placename': u'Lincoln, Lincolnshire', 'long-name': u'Lincoln, 
Lincolnshire.', 'end': datetime.date(1216, 10, 2), 'start': 
datetime.date(1216, 10, 1)},
{'placename': u'Grimsby, Lincolnshire', 'long-name': u'Grimsby, 
Lincolnshire.', 'end': datetime.date(1216, 10, 4), 'start': 
datetime.date(1216, 10, 3)},
{'placename': u'Louth, Lincolnshire', 'long-name': u'Louth, 
Lincolnshire.', 'end': datetime.date(1216, 10, 4), 'start': 
datetime.date(1216, 10, 4)}
]

I have a function that searches through them to find pairs of dictionaries 
that satisfy certain criteria. When the nested </description>
    <dc:creator>Jon Crump</dc:creator>
    <dc:date>2008-05-14T19:02:20</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48008">
    <title>James D Mcclatchey is out of the office.</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48008</link>
    <description>
I will be out of the office starting  05/14/2008 and will not return until
05/19/2008.

I will respond to your message when I return.


***IMPORTANT NOTICE: This communication, including any attachment, contains information that may be confidential or privileged, and is intended solely for the entity or individual to whom it is addressed.  If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message is strictly prohibited.  Nothing in this email, including any attachment, is intended to be a legally binding signature.***

_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>James D Mcclatchey</dc:creator>
    <dc:date>2008-05-14T11:09:41</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48007">
    <title>Help with class.self variables</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48007</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Mark</dc:creator>
    <dc:date>2008-05-14T07:45:33</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48004">
    <title>destroying a window once a movie has stoped playing</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48004</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Nick.Treloar&lt; at &gt;education.nsw.gov.au</dc:creator>
    <dc:date>2008-05-14T01:07:58</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48001">
    <title>Sorting Dictionary Keys</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48001</link>
    <description>
Jim,

OK, use the example below for sorting dictionary keys and placing them in a
list. Note that an error will happen if the format on the print statement
does not correspond to the type of sort.


#THIS SORTS A DICTIONARY BY USING SET THEORY AND DIC ITEMS!
import random
dic = {}
print "Randomizing!"
for i in range(20):
    dic[ random.randrange(100)] = random.randrange(100, 1000)
print "Dic:"
j=0
list=[]
for k,i in dic.items():
    print "K=%d I=%d" % (k,i)
    list.append("K=%d I=%d" % (k,i))
    j+=1

j=0
print "Sorted Dic By Set:"
print "Num: Old,  Sorted"
for k in sorted(set(dic)):
    print "(%d) %s | K=%d I=%d" % (j+1, list[j], k,dic[k])
    j+=1

j=0
print "Sorted Dic By Items:"
print "Num: Old,  Sorted"
for k,i in sorted(dic.items()):
    print "(%d) %s | K=%d I=%d" % (j+1, list[j], k,i)
    j+=1


--- On Tue, 5/13/08, James Hartley &lt;jjhartley&lt; at &gt;gmail.com&gt; wrote:

  From: James Hartley &lt;jjhartley&lt; at &gt;gmail.com&gt;
  Subject: [Tutor] sorting dictionary keys?
  To: tutor&lt; at &gt;python.org
  Date: Tuesday, May 13, 2</description>
    <dc:creator>FT</dc:creator>
    <dc:date>2008-05-14T00:10:57</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/48000">
    <title>(no subject)</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/48000</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Nick.Treloar&lt; at &gt;education.nsw.gov.au</dc:creator>
    <dc:date>2008-05-14T00:34:48</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/47990">
    <title>sorting dictionary keys?</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/47990</link>
    <description>I suspect this is a brain-dead question...

Given the following code, output is as expected:

$ cat test.py
d = { 'a' : 1, 'd' : 2, 'b' : 3, 'c' : 0 }

for i in d.keys():
    print "%s\t%s" % (i, d[i])
$ python test.py
a       1
c       0
b       3
d       2
$

But if the keys are sorted, I get an error:
$ cat test1.py
d = { 'a' : 1, 'd' : 2, 'b' : 3, 'c' : 0 }

for i in d.keys().sort():
    print "%s\t%s" % (i, d[i])
$ python test1.py
Traceback (most recent call last):
  File "test.py", line 3, in &lt;module&gt;
    for i in d.keys().sort():
TypeError: 'NoneType' object is not iterable
$

What is the correct manner to iterate through sorted dictionary keys?

Thanks.

Jim
_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>James Hartley</dc:creator>
    <dc:date>2008-05-13T11:06:28</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/47988">
    <title>a replace function using re module</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/47988</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Dick Moores</dc:creator>
    <dc:date>2008-05-13T06:22:00</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.tutor/47987">
    <title>How to make a python binding for a c library?</title>
    <link>http://comments.gmane.org/gmane.comp.python.tutor/47987</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>tuyun</dc:creator>
    <dc:date>2008-05-13T01:37:32</dc:date>
  </item>
  <textinput about="http://search.gmane.org/?group=$group=gmane.comp.python.tutor">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.python.tutor</link>
  </textinput>
</rdf:RDF>
