<?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://permalink.gmane.org/gmane.comp.python.tutor/48057"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48056"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48055"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48054"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48053"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48052"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48051"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48050"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48049"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48048"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48047"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48046"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48045"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48044"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48043"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48042"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48041"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48040"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48039"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/48038"/>
      </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://permalink.gmane.org/gmane.comp.python.tutor/48057">
    <title>Re: Best way to define comparison</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48057</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-18T02:29:58</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48056">
    <title>Re: Best way to define comparison</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48056</link>
    <description>
It uses __eq__() if it is defined, otherwise __cmp__()
http://docs.python.org/ref/customization.html

Kent

PS Please use Reply All to reply to the list
_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor

</description>
    <dc:creator>Kent Johnson</dc:creator>
    <dc:date>2008-05-17T23:36:47</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48055">
    <title>Re: Best way to define comparison</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48055</link>
    <description>
Use __cmp__() if it meets your needs - you just have to define one
method and you get all comparisons. The other special methods - "rich
comparisons" - were introduced in Python 2.1 to allow additional
flexibility when __cmp__() is not adequate.
http://www.amk.ca/python/2.1/index.html#SECTION000500000000000000000

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

</description>
    <dc:creator>Kent Johnson</dc:creator>
    <dc:date>2008-05-17T22:40:22</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48054">
    <title>Re: Best way to define comparison</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48054</link>
    <description>
AFAIK either approach is OK. No advantages. (Other than writing one 
method vs 2).

</description>
    <dc:creator>bob gailer</dc:creator>
    <dc:date>2008-05-17T19:30:46</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48053">
    <title>Best way to define comparison</title>
    <link>http://permalink.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://permalink.gmane.org/gmane.comp.python.tutor/48052">
    <title>Re: Dictionaries or Numpy?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48052</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Adam Clarridge</dc:creator>
    <dc:date>2008-05-17T16:12:10</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48051">
    <title>Re: Iterate through dictionary values and remove item</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48051</link>
    <description>
Lads...

 &gt;&gt;&gt; d={
...     1: {23A:[a,b,c,d],  24A:[b,c,d]},
...     2: {23A:[a,b], 24A:[a,b,c,d]}
...   }
   File "&lt;input&gt;", line 2
     1: {23A:[a,b,c,d],  24A:[b,c,d]},
           ^
SyntaxError: invalid syntax
 &gt;&gt;&gt;

Let's get a proper syntax for our data before attempting to process it.


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

</description>
    <dc:creator>Ricardo Araoz</dc:creator>
    <dc:date>2008-05-16T13:01:36</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48050">
    <title>Re: datetime syntax error for May 8th and 9th 2008??</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48050</link>
    <description>

che,

john is correct.  any leading zero (0) of an integer number will be
translated as base 8 or octal, which counts by 8's:

00, 01, 02, 03, 04, 05, 06, 07, 10 (decimal/base 10: 8*1+0=8),
11 (decimal: 8*1+1=9), 12 (decimal: 8*1+2=10), 13 (decimal 8+3=11),
14, 15, 16, 17 (decimal: 15), 20 (decimal: 8*2+0=16), 21 (decimal:
8*2+1=17), etc...

the problem with "08" is that because you're counting by 8s, a value
of "08" is invalid because the digits "8" and "9" are not part of the
octal "alphabet" or character set. that is why "07" works but not
"08".

as an FYI, because of this confusion, starting with Python 3.0, octal
numbers will require a lowercase "o" (in the same manner as
hexadecimal/base 16 numbers require an "x") after leading 0, i.e.,
0o7, 0o16, etc.  (Oo8 is still an invalid octal number.)

hope this helps!
</description>
    <dc:creator>wesley chun</dc:creator>
    <dc:date>2008-05-17T06:38:42</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48049">
    <title>Re: quickly pulling marbles out of urns</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48049</link>
    <description>
Kent's suggest seems simplest: represent the marbles as a list of
integers, where marbles[i] is the integer corresponding to marble i's
colour.

If that doesn't work (too many marbles?), maybe some kind of binary
tree approach?  e.g. a MarbleColour class which stores
 - the colour
 - the number of marbles with this colour
 - the number of marbles in the left subtree
 - the number of marbles in the right subtree

where either subtree could be None (and thus have 0 marbles).

Set the binary tree up initially so it's balanced by marble weight (if
the marble colours are all approximately the same size at the start,
you could approximate this by just filling in colours from the top in
any order).  Then you can randomly generate a colour by generating a
random int in (0,1) and comparing with the proportions in the node.
Then you just have to update the weights for the colour you choose and
all nodes above it.

Should be log_2(n) to pick one colour and n.log_2(n) to pick colours
until you run out.

</description>
    <dc:creator>John Fouhy</dc:creator>
    <dc:date>2008-05-17T04:51:14</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48048">
    <title>Re: datetime syntax error for May 8th and 9th 2008??</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48048</link>
    <description>
It's simpler than that... Try this:

  File "&lt;stdin&gt;", line 1
    x = 08
         ^
SyntaxError: invalid token
8

Basically, python interprets integer literals starting with 0 as octal
numbers.  It's an old convention from C (or earlier?).  It doesn't
affect strings, so int('010') == 10 (unless you use eval).

HTH!

</description>
    <dc:creator>John Fouhy</dc:creator>
    <dc:date>2008-05-17T04:29:50</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48047">
    <title>Re: quickly pulling marbles out of urns</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48047</link>
    <description>
You probably know, this is called sampling without replacement. If you
can put all the 'marbles' in a list, here is a promising approach:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/dff9425afdb744e5/6b9a84329c0815d4?lnk=raot

This is probably worth looking at too though I can't understand it at this hour:
http://safari.oreilly.com/0596007973/pythoncook2-CHP-18-SECT-4

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

</description>
    <dc:creator>Kent Johnson</dc:creator>
    <dc:date>2008-05-17T04:15:23</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48046">
    <title>Re: datetime syntax error for May 8th and 9th 2008??</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48046</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:18:39</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48045">
    <title>datetime syntax error for May 8th and 9th 2008??</title>
    <link>http://permalink.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://permalink.gmane.org/gmane.comp.python.tutor/48044">
    <title>Re: Dictionaries or Numpy?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48044</link>
    <description>
Hi Adam,

I believe a general rule of programming is: don't optimize until you
know you need to.  I would advise using dictionaries for simplicity.
If the program turns out slower than you would like, you can use
profiling tools to figure out where in the code it is spending most of
its time.  If this turns out to involve dictionary lookups, you could
then look at changing to Numpy (hint: you could use the timeit module
to benchmark dictionary access against Numpy arrays).  If your program
design is good, the change should be too hard.

http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize

</description>
    <dc:creator>John Fouhy</dc:creator>
    <dc:date>2008-05-17T00:08:15</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48043">
    <title>Dictionaries or Numpy?</title>
    <link>http://permalink.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 each_square in piece:
            # if square is not in a legal position, don't add to list
of legal moves

So that if statement would be accessing the board array many many
times. I guess my question is: Is there any way to test Dictionary
access time vs. Numpy array access time?

Thanks,

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

</description>
    <dc:creator>Adam Clarridge</dc:creator>
    <dc:date>2008-05-16T22:59:50</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48042">
    <title>quickly pulling marbles out of urns</title>
    <link>http://permalink.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://permalink.gmane.org/gmane.comp.python.tutor/48041">
    <title>Re: Getting started with Python</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48041</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>jay</dc:creator>
    <dc:date>2008-05-16T16:02:44</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48040">
    <title>Re: Open a directory in the default file manager</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48040</link>
    <description> &gt; Hello,
 &gt; is there any function/module that allows me to open a directory in the
 &gt; default file manager of a operating system?

On Windows you can use os.startfile().
On "pure" Unices there's no such thing as filetype associations
However, if you use a desktop environment, you can spawn xdg-open (from 
xdg-utils) from Python. This will autodetect gnome, kde and xfce and use 
their tools (gnome-open, kfmclient, exo-open).
I think on OS X/Darwin there's a similar utility called `open'.

You can use sys.platform to determine which system you're running on.

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

</description>
    <dc:creator>Thomas Pani</dc:creator>
    <dc:date>2008-05-16T15:55:58</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48039">
    <title>Re: Getting started with Python</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48039</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Hansen, Mike</dc:creator>
    <dc:date>2008-05-16T15:57:45</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48038">
    <title>Re: Getting started with Python</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48038</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>jay</dc:creator>
    <dc:date>2008-05-16T15:44:04</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/48037">
    <title>Re: Getting started with Python</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/48037</link>
    <description>_______________________________________________
Tutor maillist  -  Tutor&lt; at &gt;python.org
http://mail.python.org/mailman/listinfo/tutor
</description>
    <dc:creator>Moishy Gluck</dc:creator>
    <dc:date>2008-05-16T15:20:47</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>
