[Tutor] Tip: Firefox quicksearch for module docs

2006-10-10 Thread John Fouhy
For all you firefox users out there, create a bookmark in your "Quick
searches" bookmark folder with the keyword 'python' and the location
'http://www.python.org/doc/current/lib/module-%s.html'.

Then, you can just type (for example): "python random" into the search
bar, and go straight to
http://www.python.org/doc/current/lib/module-random.html.  Nifty :-)

(more quick searches here:
http://wormus.com/leakytap/Internet/CustomKeywordspython )

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help me with this Tkinter code

2006-10-10 Thread John Fouhy
On 11/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> shouldn't you mainloop your root?

By convention, you should, but you don't have to.  mainloop is
mainloop; calling it on root just makes it easy to find.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multithreading random()

2006-10-10 Thread John Fouhy
On 10/10/06, Dick Moores <[EMAIL PROTECTED]> wrote:
> I can get what appears to be a random number precise(?) to 17 digits.
> How many base-10 digits would a "53-bit
> precision float" have, if converted to base 10?
>
>  >>> 2 ** 52
> 4503599627370496L
>  >>> 2**53
> 9007199254740992L
>  >>>
>
>  >>> len(str(2**53))-1
> 15
>
> So is the answer to my question something like len(str(2**53)) -1?
> (minus 1 because of the L in the long integer)

The string representation of longs doesn't include the 'L':

>>> str(999L)
'999'
>>> repr(999L)
'999L'

I think the answer is "approximately, yes".  But you have to be a bit
careful with talking about floating point numbers in terms of
decimals.  eg:

>>> 1.1
1.1001

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multithreading random()

2006-10-10 Thread John Fouhy
On 10/10/06, Dick Moores <[EMAIL PROTECTED]> wrote:
> Didn't know about Google's code search,
> <http://www.google.com/codesearch>. What was your search string?

Search string was just "jumpahead lang:python".  Had to scroll past a
bunch of results for python/random.py before I found those, though.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multithreading random()

2006-10-09 Thread John Fouhy
On 10/10/06, Dick Moores <[EMAIL PROTECTED]> wrote:
> Please refer to
> <http://www.python.org/doc/current/lib/module-random.html>, from which I 
> quote:
>
> "The functions supplied by this module are actually bound methods of
> a hidden instance of the random.Random class. You can instantiate
> your own instances of Random to get generators that don't share
> state. This is especially useful for multi-threaded programs,
> creating a different instance of Random for each thread, and using
> the jumpahead() method to make it likely that the generated sequences
> seen by each thread don't overlap."
>
> Could someone point me to an example script where this was done? I'd
> very much like to learn how to do that.

Using google's code search, I found this:

def _create_random_generators(self, num, delta, firstseed=None):
"""Return list of 'num' distinct generators.
Each generator has its own unique segment of delta elements
from Random.random()'s full period.
Seed the first generator with optional arg firstseed (default
is None, to seed from current time).
"""
g = Random(firstseed)
result = [g]
for i in range(num - 1):
laststate = g.getstate()
g = Random()
g.setstate(laststate)
g.jumpahead(delta)
result.append(g)
return result

Although, from looking at the docs you quoted, this may not be correct
for python2.3+.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multithreading random()

2006-10-09 Thread John Fouhy
On 10/10/06, Dick Moores <[EMAIL PROTECTED]> wrote:
> And another question. That page also says, "Almost all module
> functions depend on the basic function random(), which generates a
> random float uniformly in the semi-open range [0.0, 1.0). Python uses
> the Mersenne Twister as the core generator. It produces 53-bit
> precision floats and has a period of 2**19937-1." What is a 53-bit
> precision float? Would that be something like a float accurate to 8
> or 9 figures (dividing 53 by 8). Or what?

Hi Dick,

Have a look here: http://en.wikipedia.org/wiki/Double_precision
and here: http://en.wikipedia.org/wiki/IEEE_floating-point_standard

Basically, floating point numbers are of the form "x times 2**y",
where x is a binary number between 1 and 10 (that's binary 10, decimal
2).  53 bits means 53 binary digits of precision (including the
initial 1).

Does that help?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Menus / Mac

2006-10-09 Thread John Fouhy
On 09 Oct 2006 15:43:01 -0400, Joel Levine <[EMAIL PROTECTED]> wrote:
> I'm guessing it is a Mac problem.  I've tried it on 3 different Macs, with 
> slightly different dates and configurations of Python and its libraries.  
> Same story each time.

It works for me :-) (MBPro, Tiger)

Remember that macs have a universal menu bar.  If you click on the
window it created, the menubar at the top should change appropriately.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Integer division Help requested

2006-10-03 Thread Joseph John
HI All    I am trying out python I  understoon when  7/3  gives "2"But I cannot understand ,   when i give 7/-3  gives resuls "-3"I feel  7/3  should give -2 
since  integer  divison returns floor    Advice requested   Thanks   Joseph John
      
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] save configuration of one application.

2006-10-03 Thread John Fouhy
On 04/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> you can make a config.ini file and use that one module that parses ini
> files.
> I can't remember what it's called.
> configparser I think, but I wouldn't bet my life on it :)

Yes, ConfigParser.

The docs for ConfigParser are a bit confusing in places (IMO), but
there are people here who can help if you get stuck.

> Or you could just write the settings out to a file.

Using ConfigParser means your configuratino files will be
human-readable and human-editable.  If you don't care about that, you
could stick them in a dictionary and use pickle to write it to a file.
 Or use the shelve module.

> If you choose to go the latter route, keep in mind that  modules are
> compiled to .pyc files upon importation,
> so you'll have to remove those anytime you modify config.py or the old
> code will be used instead.

The python interpreter should check the timestamps on foo.py vs
foo.pyc, and recompile if it thinks things have changed.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] My number-guessing program

2006-10-02 Thread John Fouhy
On 03/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Note that the random.randint function includes both endpoints (I.E. the
> numbers are 1-10 including 10)
> but the range() function doesn't include the last endpoint.

Which is why (in my not-so-humble opinion :-) ) we should tell people
to use random.randrange instead of random.randint!

(random.randrange takes up to 3 arguments with exactly the same
meanings as range())

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] One of my 'baby step' programs

2006-10-02 Thread John Fouhy
On 03/10/06, Alan Gilfoy <[EMAIL PROTECTED]> wrote:
>
> >>>> for i in range(10):
> > ...  break
> > ... else:
> > ...  print 'foo'
> > ...
> >>>> for i in range(10):
> > ...  pass
> > ... else:
> > ...  print 'foo'
> > ...
> > foo
> >>>>
>
> pardon the newb question, but what do these code lines do?

They demonstrate when the else: clause in a for statement gets executed.

Spaces sometimes get lost in email, so I'll write them again, with
underscores instead of spaces:

for i in range(10):
break
else:
print 'foo'

In this case, the for loop will exit because of the break statement,
and so the else: clause will not execute.

for i in range(10):
pass
else:
print 'foo'

In this case, the loop body is just 'pass', which is python's
do-nothing statement.  So the loop will exit normally, and the else:
clause will execute (resulting in the string 'foo' being printed).

Does this help?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] One of my 'baby step' programs

2006-10-01 Thread John Fouhy
On 02/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> I had no idea you could have an 'else' tied to a 'while' loop.
> Interesting

It allows you to distinguish between exiting the loop via a break and
exiting the loop normally.

eg:

>>> for i in range(10):
...  break
... else:
...  print 'foo'
...
>>> for i in range(10):
...  pass
... else:
...  print 'foo'
...
foo
>>>

There was a discussion of for..else linked in Dr Dobb's Python URL
recently: 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/bc1d8038e65c449/

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread John Fouhy
On 02/10/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> or maybe random sample:
> In [22]: random.sample(('heads', 'tails'), 1)[0]
> Out[22]: 'tails'

I think random.choice would be a better option here:

>>> random.choice(['heads', 'tails'])
'tails'
>>> [random.choice(['heads', 'tails']) for i in range(10)]
['tails', 'tails', 'heads', 'tails', 'tails', 'tails', 'heads',
'heads', 'heads', 'heads']

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is my Python install hosed?

2006-10-01 Thread John Fouhy
On 02/10/06, Will Shattuck <[EMAIL PROTECTED]> wrote:
> I'm going through the tutorial "Learning to Program" at
> http://www.freenetpages.co.uk/hp/alan.gauld/.  I reached the section
> talking about sys.exit().  I typed it in as indicated, but I received
> errors rather than it actually exiting the Python Shell windows
> generated when starting IDLE.  Here is the text:
>
> ==
> >>> import sys
> >>> sys.exit()
>
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> sys.exit()
> SystemExit
> ==

Nah, I get that too.  I think it's an IDLE thing.

>From the command line:

Python 2.4.3 (#1, Mar 30 2006, 11:02:16)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> raise SystemExit
Morpork:~ repton$

>From IDLE:

IDLE 1.1.3
>>> raise SystemExit

Traceback (most recent call last):
  File "", line 1, in -toplevel-
raise SystemExit
SystemExit
>>>

IDLE will just be catching the exception, I guess.  You can do it yourself:

>>> try:
...  sys.exit()
... except SystemExit:
...  print 'Not exiting!'
...
Not exiting!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] opening files

2006-09-25 Thread John Purser
On Mon, 2006-09-25 at 12:55 -0600, max . wrote:
> hello i cant understand how to open text files with python
> i have tried tutorials and evrything i just cant get pleas help
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Hello Max,

my_file = open('c:\\path\to\file\file.txt', 'r')
my_file.readlines()
my_file.close()

Really, it's so simple it's hard to come up with directions.  Just do
it.

John Purser

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] looping problem

2006-09-23 Thread John Fouhy
On 24/09/06, Python <[EMAIL PROTECTED]> wrote:
> slices may be the best way to go
> listA = biglist[0::3]   # start from index 0 taking every third element
> listB = biglist[2::3]   # start from index 2 taking every third element

I'm not certain they would be.. If you do that, you will:

1. Create a really big list.
2. Go through the list, taking every third element.
3. Go through the list again, taking every third+2 element.

If the list is really big, step 1. might take some time and/or space,
and you would like to avoid it.

If we have:

f2= open('myfile','r')
listA = []
listB = []

then we can iterate through f2 as follows:

for i, line in enumerate(f2):
if i % 3 == 0 then
listA.append(line)
elif i % 3 == 2 then
listB.append(line)

This may be faster..
(although I should like to see evidence before committing to that
statement :-) )

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] tuples versus lists

2006-09-14 Thread John Fouhy
Generally, you should use a tuple when you have different things that
you want to clump together to make one data structure.  Whereas you
should use a list when you have multiple things that are the same,
that you want to iterate over.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] arrays

2006-09-14 Thread John Fouhy
On 15/09/06, federico ramirez <[EMAIL PROTECTED]> wrote:
> an array to order the keys and then display it in order but..python orders
> the array like this
>
> ['_1', '_10', '_11', '_12', '_13', '_2', '_3', '_4', '_5', '_6', '_7', '_8',
> '_9']
>
> and i want
>
> ['_1', '_2', '_3', '_4', '_5', '_6', '_7', '_8', '_9','_10', '_11', '_12',
> '_13']

Hi,

First, just a terminology note -- in python, these are called lists, not arrays.

> arr = []
> for key in db.keys():
> arr += [key]
> arr.sort()
> arr.reverse()

db.keys() returns a _new_ list, so there is no need to do this step;
you could just write:
arr = db.keys()

Now, since your keys are strings, python is sorting them
lexicographically, which is why (for instance) '_10' comes before
'_2'.  You need to tell python to change its sort order.

You can do this in a couple of ways.  If you have python2.4 or
greater, you can use the key= keyword argument to sort, like this:

def keyToInt(s):
"""Convert '_10' to 10, '_2' to 2, etc. """
return int(s[1:])
arr.sort(key=keyToInt)

If you have an earlier version of python, you can define your own
comparison function:

def myCmp(x, y):
return cmp(keyToInt(x), keyToInt(y))
arr.sort(myCmp)

You can also use the decorate-sort-undecorate idiom, which may be
faster than a custom comparison function if the list is very large.

decorated = [(keyToInt(s), s) for s in arr]
decorated.sort()
arr = [x[1] for x in decorated]

> for i in range(len(db)):
> print db[arr[i]],''

In python, you can iterate over lists directly.  ie, since arr is your
list of keys:

for key in arr:
print db[key], ''

HTH!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-09-14 Thread John Fouhy
On 15/09/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> This is the first time I have posted to this list so I hope I am asking
> appropriate question in acceptable way. Want I want to do is take a file and
> cut it into pieces so each piece is a new unique file; the new files would be
> one line (newline) from the file I want to cut up. The file  I want to cut up
> has 3900 lines. This is as far as I have got.

So, you want to create 3900 different files, then?

What do you want to call these files?

You can iterate through each line of a file like this:

input = open('/Users/timothy/Desktop/t' , 'r')
for line in input:
# ...

So, in the body of the for loop, all you would need to do is decide
what to call the new file, open the file, write line to it, and then
close it.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
On 14/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
> The deitel book has a note on page 229:
>Failure to specify an object reference (usually called self) as the
> first parameter in a method definition causes fatal logic errors when
> the method is invoked at runt-ime.
>
> Now I've got methods all over the place among several scripts that don't
> use self, and each other works fine as I'd expect.

It depends whether you're writing class methods or not.

I could do this, for example:

def increment(x):
return x+1

and that would be fine, with no self parameter.  It's just a
standalone function.

OTOH, I might decide I want to write my own integer wrapper.

class MyInt(object):
def __init__(self, i):
self.value = i

I would create an instance of MyInt like so:

i = MyInt(3)

The parameter 3 gets passed to __init__ as 'i'.  If I left out 'self',
python would complain that __init__ only takes one argument and I've
given it two.

I could define a MyInt method like this:

def increment(self):
self.value = self.value + 1

thus:
>>> i.increment()
>>> i.increment()
>>> print i.value
5

How would you write increment() without a self parameter?  You need
some way of referring to the "value" attribute of the instance.  If
you just write "value = value + 1", python will think you are talking
about a local variable, and complain because it can't find one with
that name.  If you write:

def increment():
self.value = self.value + 1

then you're referring to this variable called "self", but where is it
coming from?  There's no global variable "self", it's not one of the
parameters to the method, and you're not defining it in the method.

Does that help at all?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what happens when...

2006-09-13 Thread John Fouhy
On 14/09/06, josip <[EMAIL PROTECTED]> wrote:
>
> Hi all!
> Can You explain me what happens when in this function I remove board arg:
> def human_move(board, human)?
> What is doing that argument?

Have you tried removing the argument and running the code?  What error
message do you get?  What do you think it means?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
On 14/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
> Can anyone explain what I've been reading? I'm trying to understand why
> many documents show:
>def myMethod(vars):
> or
>class myClass(var):
> and others show:
>def myMetheod(self, vars)
> or
>class myClass(self, vars)

Um.  Can you give an example of something saying "class myClass(self,
vars)" ?  The "arguments" to a class are other classes that you want
to inherit from, and are different from function arguments!

As to your other question, though ---

Suppose I have a class:

class MyClass(object):
# etc

And suppose I create an instance of that class:

mc = MyClass()

And then I call a method on that instance:

mc.someFunc(3, 'foo')

Although I have given the function someFunc two arguments, it will
actually be passed _three_ arguments.  The first argument will be mc
itself.  So, in the definition of MyClass, you would have:

def someFunc(self, x, s):
# etc

"self" is the name traditionally given to the first parameter, which
receives the class instance.  If you wanted to make things explicit,
you could instead do:

MyClass.someFunc(mc, 3, 'foo')

I think this is exactly equivalent to mc.someFunc(3, 'foo').  (someone confirm?)

On the other hand, if you're writing a utility function that's not
part of a class, you won't give it a "self" parameter.

Hope this helps :-)

> Also, what is with the double underscores? (__init__ for example) is
> this required? or a Pythonic naming convention? When and how to use?

Various special methods have the form "__xxx__".  For example, the
builtin function str converts things into strings.  str is associated
with the special method __str__.  If you write:

s = str(o)

this is equivalent to:

s = o.__str__()

and you can define / override the __str__ function in your own classes
to control how they are converted to strings.

Also, there is a convention that variable names starting with a single
underscore are private (since there's no "true" concept of
private/public in python).  Variable names starting with two
underscores are "more private", and python mangles the name a bit.

eg, try the following:

class Foo(object):
def __init__(self):
self.x = 1
self._y = 2
self.__z = 3

f = Foo()
print f.x
print f._y
print f.__z

> I'm 'trying' to write clear pythonic code since in all reality it gives
> a nice polish to the code when compared to writing c style.

I don't think you'll find many here who disagree with that :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Traversing Excel Columns

2006-09-12 Thread John Fouhy
On 12/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
> I'm not sure what internal blanks means.. but I'll take a stab and say
> "no", there are going to be NO blanks once I start reading the column
> unless there are no more values to read... null or "" would be fine for
> a stopping point.

Well, basically, I'm thinking you could say something like:

for i in itertools.count(1):
if xlSht.Cells(1, i).Value in (None, ''):
maxCol = i
break

This should start at (1,1) (the top-left cell), and move right, until
it hits a blank cell, at which point it aborts.

You could do the same thing, but changing row instead of column, to
find the maximum column.

So, by "internal blanks", I meant blank cells with non-blank cells to
the right, or below.

Also, if the first row is not necessarily the longest, you would need
a bit more trickery.

> also, what is makepy.py? I'm still working through a couple books on
> python, so I haven't got all the tricks yet :]

makepy.py is a utility that comes with pythonwin. Basically it builds
python libraries corresponding to COM objects.  If you do this
(one-time only), your code should run faster.  Also, you will get
meaningful help(), and you can look at the code it produces to get a
quick list of all the available methods, and what arguments they
expect.

You can run it from the command line, or you can run it from the menu
of the pythonwin IDE.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Traversing Excel Columns

2006-09-11 Thread John Fouhy
On 12/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
> I don't suppose that anyone has a fix for me eh? I've tried about all I
> can think of and I'd like to be able to give this program a trial
> tomorrow when I get back to work.. sure would save me some time :]

Will there be internal blanks?  You could just scan for Cells(row,
col).Value in (None, '').

Otherwise, run makepy.py (if you haven't already) on Excel, and then
look through the code it generates.  It will show you all the methods
you can call, and what arguments they expect.  Something may leap out
at you.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Dates

2006-09-10 Thread John CORRY
Bob and Alan,

Thanks for the help.  I have gone with the following code and it works!

a = "date(%i,%i,%i)" % (2006,01,31)
b = "date(%i,%i,%i)" % (2006,12,31)
sql = 'SELECT * FROM times where rt_weekst >= %s and rt_weekst <= %s and
rt_type = "%s" ' % (a,b,"R",)
db = mx.ODBC.Windows.DriverConnect('DSN=tnt')
c = db.cursor() 
c.execute(sql)

As you rightly pointed out, I needed to get my sql string formatted and
working before putting it anywhere near the c.execute command.

Many thanks,

John.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Dates

2006-09-10 Thread John CORRY
Alan,

Thanks for the help.  I have converted the dates to strings but I get
the same error.  Please see the updated code below, is this what you
meant by converting the dates to strings?

import mx.ODBC
import mx.ODBC.Windows
import mx.DateTime
import datetime
a = datetime.date(2006,01,31)
b = datetime.date(2006,12,31)
c = str(a)
d = str(b)
print a,b,c,d

db = mx.ODBC.Windows.DriverConnect('DSN=tnt')
c = db.cursor()
c.execute('SELECT * FROM times where rt_weekst >= ? and rt_weekst <= ?
and rt_type == ?', (c,d,"R",))
for row in c.fetchall():
print row
row = str(row)

c.close()


The output is below:

2006-01-31 2006-12-31 2006-01-31 2006-12-31
Traceback (most recent call last):
  File "C:\test\timemanager.py", line 18, in ?
c.execute('SELECT * FROM times where rt_weekst >= ? and rt_weekst <=
?  and rt_type == ?', (c,d,"R",))
DataError: ('22005', 301, '[Microsoft][ODBC Visual FoxPro
Driver]Operator/operand type mismatch.', 4579)

Is there another way I can approach this problem?  Say if I use
something like:

c.execute('SELECT * FROM times where rt_weekst >= date(?) and rt_weekst
<= date(?)  and rt_type == ?', (c,d,"R",))

I get the following error:

2006-01-31 2006-12-31 2006-01-31 2006-12-31
Traceback (most recent call last):
  File "C:\test\timemanager.py", line 18, in ?
c.execute('SELECT * FROM times where rt_weekst >= date(?) and
rt_weekst <= date(?)  and rt_type == ?', (c,d,"R",))
ProgrammingError: ('37000', 229, '[Microsoft][ODBC Visual FoxPro
Driver]Too few arguments.', 4579)

Thanks for any suggestions.

John.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Dates

2006-09-09 Thread John CORRY
Hi All,

I am using the code below to select items from a visual foxpro database
where the dates are between the 31/01/2006 and 31/12/2006.  The good
news is that the code below works.

However, I want to make the from and to dates variable.  I want to
change the range depending on user input.  I can't get this to work. I
have tried the code below marked "Tried" but I get the error:

Traceback (most recent call last):
  File "C:\test\timemanager.py", line 16, in ?
c.execute('SELECT * FROM times where rt_weekst >= ? and rt_weekst <=
?  and rt_type == ?', (a,b,"R",))
DataError: ('22005', 301, '[Microsoft][ODBC Visual FoxPro
Driver]Operator/operand type mismatch.', 4579)

Code that works is below:


import mx.ODBC
import mx.ODBC.Windows
import mx.DateTime



db = mx.ODBC.Windows.DriverConnect('DSN=tnt')
c = db.cursor()
c.execute('SELECT * FROM times where rt_weekst >= date(2006,01,31) and
rt_weekst <= date(2006,12,31)  and rt_type == ?', ("R",))
for row in c.fetchall():
print row
row = str(row)
   
c.close()


Tried but get errors:

import mx.ODBC
import mx.ODBC.Windows
import mx.DateTime

import datetime
a = datetime.date(2006,01,31)
b = datetime.date(2006,12,31)
db = mx.ODBC.Windows.DriverConnect('DSN=tnt')
c = db.cursor()
c.execute('SELECT * FROM times where rt_weekst >= ? and rt_weekst <= ?
and rt_type == ?', (a,b,"R",))
for row in c.fetchall():
print row
row = str(row)

c.close()   

Is there a way to format the date so that the Select statement works?

Thanks,

John.



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A simple list question...

2006-09-07 Thread John Fouhy
On 08/09/06, Richard Querin <[EMAIL PROTECTED]> wrote:
> I've got a list of strings. There are some duplicates. I want a list
> of only the unique entries in that list. So I do the following:
>
> mylist = ['project1' , 'project2', 'project3', 'project4', 'project1']
>
> d = {}
>
> for item in mylist:
>d[item] = None
>
> cleanedlist = d.keys()
>
> But d.keys() seems to add '\n' to each entry in cleanedlist.

Um.  I'm not in a position to test your code right now, but I can't
think of any reason why it would do that..

> 1. How can I easily strip out the newline characters from the elements
> of cleanedlist?

You could do [s.strip() for s in cleanedlist] -- the .strip() string
method will strip whitespace from both ends of the string.

> 2. Is there a better way to achieve my objective (ie. a list method
> for generating the cleaned list?)

cleanedlist = list(set(mylist))

If you don't have python 2.4+, you will need to import the sets module.

Also, depending on what you are doing with cleanedlist, you could just
leave it as a set.  Or even construct mylist as a set.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] File open error

2006-09-04 Thread John Fouhy
On 05/09/06, Magnus Wirström <[EMAIL PROTECTED]> wrote:
> When i'm executing it i get this error (runtime)
>
> Traceback (most recent call last):
>  File "C:\python\boa\backup\backupwin.py", line 135, in OnStartaButton
>config = open("backup.conf", "r")
> TypeError: an integer is required

Looks like you're redefining 'open' somewhere.  Look through your
code; do you have anything like:

def open(...):

or

    open =

or

from ... import open

or

from ... import *

?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pretty_printing

2006-09-03 Thread John Fouhy
On 04/09/06, Lowell H. Tackett <[EMAIL PROTECTED]> wrote:
> I would like to---so far without luck--to print out my Python scripts with
> syntax highlighting (using Mandrake Linux as my OS/host.)  Using enscript has
> not gotten me anywhere; nor has a package I found on the *net called
> 'pretty-print', or some such similar to that.

Well, you could open your code in vim or emacs and click "print"? :-)

> It occured to me that it ought to be very simple to gain access to those
> syntax discrimnators, write a code script that creates a 'dye' for each
> syntax type, and pipe a print request thru such a file.

Well, on this windows system, the vim python syntax file is in
Vim\vim70\syntax\python.vim.

It looks like you could make a reasonable stab at parsing it without
knowing what everything means, especially if you're willing to accept
the odd error.

I'm not sure how you want to go about colourizing things, though.  If
you have a postscript printer, you could generate your own postscript,
maybe..

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hi All

2006-09-02 Thread John Purser
On Sat, 2 Sep 2006 13:39:05 +0200
tomd <[EMAIL PROTECTED]> wrote:

> > i have just started working on Python ...
> > please let me know the books to refer to start
> > learning
> 
> I recommend Beginning Python from Magnus Lie Hetland, apart from being
> comprehensive and targetted at beginners, it will take you through the
> develoopment of 10 various projects, including game, file sharing
> application, or discussion forum.
> 
> -- 
> Tom, http://www.vscripts.net/
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

What he said!

John Purser

-- 
Be careful!  Is it classified?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] GUI Programing

2006-08-31 Thread John Fouhy
On 01/09/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote:
> I'm going to try some GUI programming does anyone know where the start like
> using tk or wx or what ever i want it to it will run on Windows UNIX and Mac
> systems can you tell me whats best to use and give me a link to a good
> tutorial?

Tkinter is (IMO) easier to learn.  In particular, check out "Thinking
in Tkinter" (google for it); it's an excellent way to learn Tkinter.

Tkinter is also very basic.  wx has many more widgets and controls
available.  wx also looks a lot better.  But the documentation for wx
isn't very good.  wxpython has been evolving -- it started out as a
direct python port of some C++ libraries, and
has been becoming more pythonic as time goes by.  So if you go looking
for example code, you could find something written in the modern,
pythonic style, or you could get something written in the traditional,
C++ style.  Until you learn to recognise the latter and transform it
to the former, you may find learning from the web difficult.

Both Tkinter and wxpython should work across all platforms.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can you tell me whats wrong with this code?

2006-08-30 Thread John Fouhy
On 31/08/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote:
> first of all i have random.randint imported as rand like this:
>
> from random import randint as rand
>
> it is giving me an error at the line
>
> space = rand(1,82)
>
> the error its giving me is
>
> Traceback (most recent call last):
>   File "sudoku.py", line 1050, in ?
> space = rand(1,82)
> TypeError: 'int' object is not callable

It's telling you that "rand" is an int.  Since it didn't start off
like that, I suspect you have assigned to rand somewhere.

Have a look through your code; are there any lines starting with:

rand =

?

Also, in my opinion, it's a bad idea to rename standard library
functions like that.  If another python programmer looked at your
code, they would probably be familiar with randint and understand what
it does, but they won't know exactly what "rand" does without looking
through the rest of your code.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How would I make a program that password protects on an inactivity timer?

2006-08-28 Thread John Fouhy
On 29/08/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> If this is not possible, is there any way to end/restart the explorer.exe
> program? If not, is there any other way you would reccomend securing the
> computer? (not a program thats downloaded, we have to prove that everything
> we download is for educational purposes @_@)

Hmm, one thing that might work, as a way of manually locking your
screen: write a Tkinter app that pops up a password dialog and exits
when you type in the correct password.  Then set the global grab for
the Entry widget.

I haven't actually used global grab before (it's pretty bad manners!),
but I think it will restrict all input to itself, and refuse attempts
to let anything else have focus. Not certain, though.  But it may be
worth a try.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] making independent program?

2006-08-28 Thread John Fouhy
On 29/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> Thats probably because the most common methods for
> producing an exe file are "non-trivial" to use, especially for
> newbies.
>
> Look up py2exe on Google...

py2exe is not too hard for simple tasks (unless something goes wrong),
especially if you can find someone to throw a sample setup.py at you.
There are people on this list who can help..

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A list of ints to a strings

2006-08-25 Thread John Fouhy
On 26/08/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote:
> I need to convert a list of intgers to a string so for example
>
>  I have this
>  x = [1, 2, 3, 4, 5, 6]
>
>  I want this
>
>  x = "1 2 3 4 5 6"

Actually, I disagree with David's solution somewhat --- I think that
the pythonic way to do this is as follows:

Firstly, you can use a list comprehension to convert each integer into
a separate string.  If you don't know about list comprehensions, you
can read about them in any python tutorial.

>>> x = [1, 2, 3, 4, 5]
>>> y = [str(i) for i in x]
>>> y
['1', '2', '3', '4', '5']

Then you can use the .join() method of strings to join them into a
single line.  In this case, the separator is a space, ' ':

>>> z = ' '.join(y)
>>> z
'1 2 3 4 5'

If you want to put one number on each row, you can use the newline
character '\n' as a separator instead:

>>> '\n'.join(y)
'1\n2\n3\n4\n5'
>>> print '\n'.join(y)
1
2
3
4
5

HTH!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Displaying in columnar / tabular form

2006-08-24 Thread John Fouhy
On 25/08/06, Vincent Gulinao <[EMAIL PROTECTED]> wrote:
> Anyone knows a neat way of displaying output in columnar/tabular form?
>
> Say you have a list with both dictionary and string members; you want to
> print the data, dictionary being one element per line, and the string on the
> next "column" aligned on the first element of the dictionary, or something
> like that.

If you want to DIY, have a look at string formatting (ie: the % operator).

I don't quite understand your example, so here's an (untested) example
of my own -- printing a list of strings in a table of 3 columns:

input = [ ... ] # list of strings
WIDTH = 3  # columns in the table
# split input up into tuples, ie: first 3, then next 3, then next 3, etc.
rows = [input[WIDTH*i:WIDTH*i+WIDTH] for i in range(len(input)//WIDTH + 1)]
# get max width of each column
widths = [max([row[i] for row in rows]) for i in range(WIDTH)]

for row in rows:
for i, s in enumerate(row):
print '%*s' % (widths[i], s),
print

The idea is to figure out what goes on each row of the table, then
calculate the maximum width of each column.  Then
'%*s' % (w, s)
will be the string s, padded to width w.

(I always forget whether it gets padded on the left or on the right,
but you can always reverse it by adding a -: '%-*s'  )

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Query to the tutor mailing list

2006-08-24 Thread John Fouhy
On 25/08/06, Joe Gamman <[EMAIL PROTECTED]> wrote:
> Anyway, would appreciate any comments on the idea.

It seems like the sort of thing you find in textbooks or "learn to
program" books -- most books of this nature have suitable exercises at
the end of each chapter, or spread throughout each chapter.  Also,
creating good problems seems to me like it would be a difficult thing
to do, without plagiarising existing works.

Have you tried looking at programming books, or online tutorials (eg,
Alan Gauld's?  Or I think "How to think like a computer scientist"
uses python.)?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread John Fouhy
On 24/08/06, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> Sorry, but it only showed a text-box with the message "Invalid syntax!",
> then highlighted the %.

Ok, so that would be on this line, I guess?

print "Guess ", %d1.0, "."(k)

Well, that's where the syntax error is, sure enough.  Your editor told
you; you didn't need to ask us.

In order to fix this bug, you need to figure out what you want to
achieve with this line of code, and then look at the documentation or
tutorials to figure out how to write the code correctly.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread John Fouhy
On 24/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> PATH is an environment variable and therefore changing it only
> affects the current process environment. You need to change it
> at source which used to be in AUTOEXEC.BAT but I don't think
> that is the preferred place in Win2K/XP.

To change the path in modern Microsoft Windows:

Right-click on "My Computer" (on the desktop or in Explorer), and
select "Properties".  Click on the "Advanced" tab.  Click the
"Environment variables" button.  Find "Path" in the System variables
list control.  Click "Edit" and make the changes you want...

Remember the days when information like this was actually _documented_? :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread John Fouhy
What does the python interpreter tell you when you run the code?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] banners

2006-08-23 Thread John Fouhy
On 23/08/06, Juhász János <[EMAIL PROTECTED]> wrote:
> I just played about this exercise and it has to be about spelling and not
> about hardcoding, as It is more interestig to join banner characters into
> the same line.

I had a brief think about that as well.  I think if I tried to code
it, my approach would be something like:

class Letter(object):
def __init__(self, letter):
# convert letter into rows of characters, somehow.
# end up with something like:
self.rows = ['#', '  #  ', '  #  ', '# #  ', ' ##  ']

def getWidth(self):
return max(len(s) for s in self.rows)

def getRow(self, i):
return self.rows[i]

Then to print a string:

s = 'John Fouhy'
letters = [Letter(c) for c in s]

for i in range(HEIGHT):
for letter in letters:
print '%*s' % (letter.getWidth(), letter.getRow(i)),
print

Undecided how to map from a character 'c' to a Letter, but Bob's idea
looks good.  If you drew each letter using the appropriate character
then you could automatically derive your dictionary keys, and still
replace the character by '*' if you wanted.  Letter height HEIGHT is a
constant.

And obviously, you would need to do a bit more work to handle word wrapping.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] custom container subclassing list-- slices are lists!?

2006-08-21 Thread John Fouhy
On 22/08/06, Marcus Goldfish <[EMAIL PROTECTED]> wrote:
> Second, I think I found a partial answer in the Feb 22, 2005 tutor thread
> http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2502290.
>  To preserve type, I need to override some special functions.  In the case
> of slicing, I need to override with something like this:
>
> def __getslice__(self, i, j):
>return MyFoo(list.__getslice__(self, i, j))

__getslice__ is apparantly deprecated these days; you should override
__getitem__ instead.
(see the links I posted in my last message)

> This seems straightforward, but raises other questions: what other functions
> should I override, e.g., __add__, __radd__?  Is there a preferred pythonic
> way to creating a custom list container?

Hmm, if you were talking about dicts, I would have said "Use
UserDict.DictMixin".  But there doesn't seem to be a
UserList.ListMixin.  There's a community one here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440656  that
might work for you, but I haven't used it myself.

> Finally, should I slice-copy my input list, inlist, to prevent side effects,
> or is this handled by list?

Should be handled by the list.  For instance if x is a list, then
list(x) is a copy of x (y=list(x) is equivalent to y=x[:]).  But you
should be able to test this easily enough..

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] custom container subclassing list-- slices are lists!?

2006-08-21 Thread John Fouhy
On 22/08/06, Marcus Goldfish <[EMAIL PROTECTED]> wrote:
> >>> class MyFoo(list):
>def __init__(self, inlist):
>   self = inlist[:]

Um, I'm fairly sure this line is not doing what you think it is doing!

self is just a local variable.  When __init__ is called, self is bound
to the MyFoo instance.  But when you do 'self = inlist[:]', you just
rebind it to a copy of inlist.  You aren't changing self..

> >>> me = MyFoo(range(10))
> >>> type(me)
> 
>
> >>> type(me[0:3])
> 

Have you tried implementing __getitem__ and __setitem__ for slice objects?
(see http://docs.python.org/ref/sequence-methods.html and
http://docs.python.org/ref/sequence-types.html#l2h-231)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a better main() : Critique request

2006-08-20 Thread John Fouhy
On 21/08/06, Tony Cappellini <[EMAIL PROTECTED]> wrote:
> 1. check the number of arguments as well as checking that each argument was
> valid.
> 4. If the argument validation failed, a Usage() function would be called to
> show all possible arguments
> 5. Provide a "help" option  to display all the possible arguments.

Hi,

I haven't read your whole post, I'm afraid, but I did see that you
were using getopt.

If you use optparse instead, it will take care of all this for you.

Basically, you create a parser, and tell it what arguments you are
expecting, including:
 - short name
 - long name
 - help text
 - argument type (int / string / float / bool)
 - default value

If you give your script the -h or --help option, optparse will
generate usage text (which you can customise).  Likewise, if you give
it an unknown argument, or an argument of the wrong type.

I've only just started playing with it myself, but it looks pretty nifty :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-08-17 Thread John Fouhy
On 18/08/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote:
> Mr. Kuhlman it says python is not configured for tk.
>
> but on another note does anyone know how to make a 2d array?

Are you in charge of your machine, or does someone else administer it?

I don't know SUSE very well, but I expect that you can fix this by
installing a package called something like "python-tkinter".

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-08-17 Thread John Fouhy
On 18/08/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote:
> thank you but IDLE doesnt seem to work on Suse 9.2 do you know a way to fix
> it?

Why not -- what goes wrong?  Is there an error message?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading

2006-08-15 Thread John Fouhy
On 16/08/06, Jeff Peery <[EMAIL PROTECTED]> wrote:
> hello, how do I stop a thread? do I need to kill it or can I simply call a
> stop function... kinda like the start function? I read a bit on google and
> it sounded like using a kill isn't recommended for some reason... so how is
> this thing stopped? thanks!

The only good way for a thread to stop is for its run() method to exit.

It kinda depends what your thread is doing, and what technique you are
using to keep it alive, but one possibility is to do something like:

class Worker(threading.Thread):
def run(self):
self.running = True
while(self.running):
# do stuff

def stop(self):
self.running = False

In this case, the you call .stop() on your Worker object, and the
thread will exit when it next gets to the top of the while loop.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Global variables

2006-08-14 Thread John Fouhy
On 15/08/06, Kermit Rose <[EMAIL PROTECTED]> wrote:
> My routine strongfac calculates a value for fac in the subroutine, and the
> calling routine picks up a different vaalue.
>
> An illustration.
>
> In strong fac:
>
> fac = [1,2,3]
> print fac
> return fac
>
> in fermat:
>
> fac = strongfac(z)
> print fac
>
> prints [0,0,0]
>
> And most of the time it does not misbehave like this.

Can you post actual code to illustrate the problem?  Don't post your
entire module; just show us the functions involved, the input that
causes the problem, and what output you expect to get.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to remove html ags

2006-08-14 Thread John Fouhy
On 15/08/06, anil maran <[EMAIL PROTECTED]> wrote:
> hi luke
> i tried to do this for 2 weeks using the regexps
> i couldnt find it
> and hence i was asking you guys
> thanks
> anil

What have you tried?  What problems were you having?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [pygtk] key_press_event

2006-08-13 Thread John CORRY
Sandro,

That's exactly what I need.  

Thanks,

John.

> def callback3(self,data,widget):
> 
> input = data.get_text()
> print input
> data.set_text("test")


If you don't return True, default callback will be called that insert
the 'a'.

I have something like this:

def digits_check_input_cb(self, widget, event):
"""prevents the possibility of inputting wrong chars"""
## fixme: missing comma, and cut&paste
key = gtk.gdk.keyval_name (event.keyval)

 
ONLYDIGITS="([0-9.,]|BackSpace|Left|Right|F1|period|Tab|Up|Down)"
if not re.match (ONLYDIGITS, key):
return True

Not sure whether this is the best way thought...

sandro
*;-)

-- 
Sandro Dentella  *:-)
http://www.tksql.orgTkSQL Home page - My GPL work


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] key_press_event

2006-08-13 Thread John CORRY
Hi,

I'm using Python 2.4, pygtk and Glade2.

I have a few text entries.  I am trying to put validation on the text
entry boxes.  I am trying to catch the key_press_event, check the key
that has been pressed and either allow it or put back the old text.  The
code is below with the output after it.

class Test:
def __init__(self):
self.wTree = gtk.glade.XML ("test.glade", "window1")
dic={"on_window1_delete_event" : self.quit10, }
self.wTree.signal_autoconnect(dic)

cancel = self.wTree.get_widget("button2")
cancel.connect("clicked", self.quit, )
text1 = self.wTree.get_widget("entry1")
text2 = self.wTree.get_widget("entry2")
text2.connect("key_press_event",self.callback3)
login = self.wTree.get_widget("button1")
login.connect("clicked", self.callback2, text1,text2)
def callback3(self,data,widget):

input = data.get_text()
print input
data.set_text("test")
   

def callback2(self,data,text1,text2):
print 'hello'
def quit10(self,obj,data):
gtk.main_quit()
sys.exit(1)
def quit(self,obj):
gtk.main_quit()
sys.exit(1)
if __name__ == '__main__':
Test()
try:
gtk.threads_init()
except:
print "No threading was enabled when you compiled pyGTK!"
import sys
sys.exit(1)
gtk.threads_enter()
gtk.main()
gtk.threads_leave()


The box starts of with 123 in it.  If I hit the 'a' key on the key board
I get the following result.

123 is printed and 'atest' appears in the text entry box.

Is there a way to catch the key_press (in this case the 'a') and check
to see if it is a number.  If it is not a number, ignore it.  If it is a
number accept it.  

Why does the 'a' appear in 'atest'.  It is like the code works first,
sets the text to 'test' and then the key press works and inserts the
'a'.  Do I need to disconnect the key press signal?

Thanks,

John. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] self (again)

2006-08-13 Thread John Aherne
I have been following the thread on self because for the past month I 
have been driven potty trying to be sure that I understand the 
ramifications of how self works.

I have tried to create some code that tries to prove how self, 
variables, assignment and namespace gel together. I can't convince 
myself that I have it right.

I think it works as follows. I just need to know what is right.

Class variables are 'global' for the class and all instances of the class.

Using self makes the assignment 'local' to the instance. This is used to 
create variables that will retain the assigned value for the duration of 
the instance. This variable is 'global' for the instance. It can be 
accessed by all the functions in the class/instance without being passed 
as a parameter from function to function.

Self is used if you want to create a class where you store data for a 
'long' period of time. Not like local variables that only have duration 
for the execution of the function.

Within the def functions inside the class, assignments inside the 
function are local.

If the def function inside a class takes a set of parameters that are 
passed in from outside e.g.
class one:
 def func1(parm1,parm2,parm3):

These parameters are passed by reference. So they refer to values held 
elsewhere.
If I use the names inside the function what problem will I give myself. 
Are they local, global.
e.g. if parm1=='somevalue': How long can I trust the value in the passed 
parameter - parm1

What namespace are they in.

I run all this under modpython on windows, where one python interpreter 
runs all the instances so I have multiple copies of the code running in 
the same interpreter. What is likely to happen to these values being 
passed by reference if several people log in at once and run the code.

Hope I have explained myself so people can understand what I mean.

Looking forward to the light of understanding.

Regards

John Aherne




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Rock, Paper, Scissors

2006-08-10 Thread John Fouhy
Hi Chris,

On 11/08/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
>def plays(self):
>self.choice = raw_input("Pick (R)ock, (P)aper, or
> (S)cissors! ")
>if self.choice == 'r':
>self.choice = 'rocks'
>elif self.choice == 'p':
>self.choice = 'paper'
>elif self.choice == 's':
>self.choice = 'scissors'
>else:
>print "Invalid response"

A couple of comments here ---

Firstly, to me, 'self.choice' is the thing you want to save, which is
distinct from the user's input.  So, I would call the result of
raw_input something else.  eg:

fromUser = raw_input("Pick (R)ock, (P)aper, or
(S)cissors! ")
if fromUser == 'r':
self.choice = 'rocks'
# etc

Secondly, if the user enters 'R' (as you request), your program will
say "Invalid response", because 'R' != 'r'.  You can get around this
by saying:

if fromUser.lower() == 'r':

Thirdly, a dictionary would make this much simpler.  Something like:

translate = { 'r':'rock', 's':'scissors', 'p':'paper' }
try:
self.choice = translate[fromUser.lower()]
except KeyError:
print 'Invalid response.'
# what else are you going to do?  what does self.choice become?

> def compare_objects(human, computer):
>print "Human picked ", human.choice
>print "Computer picked", computer.choice
>if human.choice == computer.choice:
>print "Draw!"
>elif human.choice == 'rocks' and computer.choice ==
> 'paper':
>print "Computer wins!"
>computer.points = computer.points + 1
[...]

You can use a similar dictionary-based approach here.  You could use a
dictionary to make a data structure that expresses what beats what,
and then reduce your code to:

if human.choice == computer.choice:
print 'Draw!'
elif # human beats computer
print 'Human wins!'
else:
print 'Computer wins!'

HTH :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wx.Notebook query in wxpython

2006-08-10 Thread John Fouhy
On 11/08/06, Amresh Kulkarni <[EMAIL PROTECTED]> wrote:
> I am developing a GUI which has a notebook with multiple tabs. The tabs are
> formed by adding pages to the notebook.
> I have a check menu to select/deselect the tabs(pages) i want. On checking
> on an item it will must show the respective tab and unchecking should hide
> it.
[...]

Hi Amresh,

I suggest you try asking on the wxPython list,
[EMAIL PROTECTED]  (you will probably have to
subscribe first).

The people on that list are both very knowledgable and very helpful :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] searching for a string in a dictionary

2006-08-09 Thread John Fouhy
On 09/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> But type is still not accessible as an attribute.
> It looked to me like he wanted a list of dictionaries
> in which case it wouyld be:
>
> if teststring in [s['type'] for s in all_types]

Err, that is what I meant :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] searching for a string in a dictionary

2006-08-09 Thread John Fouhy
On 09/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > all_types:
> >  > datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}>
> >  > datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}>
> > .
> >  > datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}>
> > there is such a list
> >
> > how do i search for a particular string say teststring in this list
>
> This isn't a list in any sense that Python will recognise.
> Can you show us the actual data structures please?

I think what he wants is:

if 'teststring' in [s.type for s in all_types]

...

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Exercise in writing a python function.

2006-08-08 Thread John Fouhy
On 09/08/06, Kermit Rose <[EMAIL PROTECTED]> wrote:
> Hello John.
>
> Thanks for replying.
>
> In my previous version,  I used z as the critical value,.
>
> Since I created zlim,  a function of z, to be passed in as a parameter, I no
> longer need z
>
> in the parameter list.
>
> In another part of the program, z is multiplied by
>
> product of mpylist[ k][0] ** mult[k] for k  in range(len(mpylist)).
>
>
> I'm feeling something akin to writer's block when I sit down and attempt to
> start the code.
>
> I know that if I can just get started then the rest of the code will begin
> to flow in my thoughts.
>
> I did not really expect anyone to help me, but if you wish to  indicate the
> first few lines of
>
> either python or psuedo code
> for this routine, it probably will help me get started.
>
>
> Kermit   <  [EMAIL PROTECTED]  >

Hi Kermit,

Your basic data structure is a list (actually, several related lists),
which you work your way through.  So I would start off with a for
loop:

for k in range(len(mult)):

Then, in the body of the loop, your basic logic is:

Add 1 to mult[k].
If mult[k] is not too big, exit.
Otherwise, ...

Hmm, actually, I'm not sure I do understand.  Does mpylist ever
change?  How is mult related to zlim?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Exercise in writing a python function.

2006-08-08 Thread John Fouhy
On 09/08/06, Kermit Rose <[EMAIL PROTECTED]> wrote:
> def incr(mult,z,zlim,mpylist):
> # mult is a vector of exponents for the multipliers in mpylist.
> # z is a positive odd  integer.
> # zlim is the upper bound  critical value for the sum of  ( mpylist[k][0] *
> mpylist[k][1] )
> # where kth multiplier is mpylist [k][0]
> # and kth  multiplier index is mpylist [k][1]
>
> # function incr returns the next value of vector mult.
> # mult may be thought as a number written in a variable base.
> # mult[0] is the least significant and matches multiplier mpylist[0][0]
> # adding one to mult would mean adding 1 to mult[0]
> # unless doing so would make sum of multiplier * index exceed zlim.
> # in that case mult[0] is set to zero, and 1 is added to mult[1]
> # unless doing so would make sum of multilier * index exceed zlim
> # in that case, mult[0] and mult[1] is set to zero,
> # and 1 is added to mult[2]
> # unless . . .
>
>
> # mult[0] is set to -1 to indicate that the largest possible value of mult
> has been exceeded.
> # mpylist[0][0] = 2 and all other multipliers  in mpylist are odd.
> # mult[0], the index on multiplier 2, must not equal 1.  It may equal zero,
> or any integer > 1,
> # provided the zlim constraint is met.

Hi Kermit,

Is there anything particular that you're stuck on?

I think I understand your function, although I'm not sure what role z
plays.  Are you looking for help on how to translate the description
you've given into logic suitable for programming?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] try & except

2006-08-08 Thread John Fouhy
On 09/08/06, Magnus Wirström <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm playing around with try: and except: i have a code like this
>try:
>bibl=os.listdir("c:\\klientdata\\")
>except:
>wx.MessageBox("Kunde inte läsa käll
> biblioteket.","Säkerhetskopiering",wx.OK|wx.ICON_ERROR)
>
> (yeah ... it's swedish :) )
>
> So far i get how to use it but i would like to be able to execute the
> try block again after it jumped to the exception. How can i make it
> retry to read the directory?

What logic are you looking for?  Is it ---

  "Try to read directory.  If it doesn't work, try again.  If it still
doesn't work, abort."

or ---

   "Try to read directory.  If it doesn't work, keep trying until it does."

In the former case, you could just put another try block in your except block:

   try:
   bibl=os.listdir("c:\\klientdata\\")
   except:
   wx.MessageBox("Kunde inte läsa käll
biblioteket.","Säkerhetskopiering",wx.OK|wx.ICON_ERROR)
   try:
   bibl=os.listdir("c:\\klientdata\\")
   except:
   wx.MessageBox("Kunde inte läsa käll
biblioteket.","Säkerhetskopiering",wx.OK|wx.ICON_ERROR)

In the latter case, you probably want some kind of loop:

success = False
while not success:
   try:
   bibl=os.listdir("c:\\klientdata\\")
   success = True
   except:
   wx.MessageBox("Kunde inte läsa käll
biblioteket.","Säkerhetskopiering",wx.OK|wx.ICON_ERROR)

Of course, it would be nice to give the users another way out of the loop :-)

HTH!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Rock, Paper, Scissors

2006-08-07 Thread John Fouhy
On 08/08/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> This looks like a fun project to work on.  From
> reading the description, I feel this would be pretty
> straight forward game to program.  However, I have no
> idea how the computer would decide if it wanted a
> rock, paper, or a pair of scissors.  Any hints?

Well, the easiest way to do it would be to make it random --- have a
look at the random module in the standard library.

For example, random.randrange(3) will give you a random integer in [0,
1, 2], which you could map to rock/paper/scissors.

[the random module also has a function randint, which is similar to
randrange.  I prefer randrange, because the arguments match the
arguments to range(), whereas randint is a bit different]

Or random.choice(['rock', 'paper', 'scissors']) will give you a string.

Of course, if you want to be more clever, I understand that RSP
programs that always pick what the human picked in the previous round
tend to do better than random (unless the human notices, at which
point they start doing very badly :-) ).

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] creating a method name on the fly

2006-08-07 Thread John Fouhy
On 08/08/06, wesley chun <[EMAIL PROTECTED]> wrote:
> import Tkinter
>
> root = Tkinter.Tk()
> MyButton = partial(Tkinter.Button, root, fg='white', bg='blue')
> b1 = MyButton(text='Button 1')
> b2 = MyButton(text='Button 2')
> qb = MyButton(text='QUIT', bg='red', command=root.quit)
>
> "MyButton" contains all the common stuff for all buttons while the
> others can take the defaults or override them! it sure looks cleaner
> than having lots of duplicated code:
>
> b1 = Tkinter.Button(root, fg='white', bg='blue', text='Button 1')
> b2 = Tkinter.Button(root, fg='white', bg='blue', text='Button 2')
> qb = Tkinter.Button(root, fg='white', text='QUIT', bg='red', 
> command=root.quit)

I sometimes do this:

buttonOpts = { 'fg':'white', 'bg':'blue' }
packOpts = { I forget :-) }
buttons = [('Button 1', None), ('Button 2', None), ('Button 3', root.quit)]

for label, callback in buttons:
b = Tkinter.Button(label, command=callback, **buttonOpts)
b.pack(**packOpts)

But, yeah, partial application will be cool :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] creating a method name on the fly

2006-08-07 Thread John Fouhy
On 08/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> Why not just add the buttons to a list as you create them then
> iterate over the list? Or better still use a dictionary with the name
> as key.

You can do nice things with tuples.

A simple example would be:

# (label, callback)
buttons = [('OK', self.OnOk), ('Cancel', self.OnCancel)]

for label, callback in buttons:
b = Button(self, label=label, ...)
# place b in your GUI
b.Bind(..., self.OnCancel)

Obviously, the exact syntax and stuffw ill depend on the GUI toolkit
you are using.

Also you can put more information in your data structure if you want
(eg, information on placing the button, styles for the button, etc).
And, if you need to save the Button objects themselves, you could add
them to a dict in the body of the loop:

self.buttons = {}
for label, callback in buttons:
# ...
self.buttons[label] = b

It means that all the information about your GUI is brought together
in one place where it's easy to see, and all the mechanical work is
pushed off to one side :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to use

2006-08-05 Thread John Fouhy
On 05/08/06, anil maran <[EMAIL PROTECTED]> wrote:
> list comprehensions to return a dictionary

Well, hyou can use the dict function.  eg:

dict((x, x**x) for x in range(10))

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (*args, **kwargs)

2006-08-05 Thread John Fouhy
On 05/08/06, Matt Williams <[EMAIL PROTECTED]> wrote:
> I guess the next question is _how_ do you use it intelligently? I'm
> interested because I'm trying to put stuff into a db using sqlobject.

One common place to use it is when you are dealing with inheritance.

For example, suppose I'm writing a Tkinter program, and I want to make
my own GUI component.  I might write:

class MyCustomFrame(Tkinter.Frame):
def __init__(self, parent, foo, bar, baz=None, **kw):
Tkinter.Frame.__init__(self, parent, **kw)
# do something with foo, bar, baz; etc.

The reason for doing this is that Tkinter objects support all kinds of
keyword arguments, and this lets me support them in my custom code
without having to explicitely list them all.

Of course, I could also set/override some of the Tkinter keyword
arguments.  eg, I could make a frame with a pink background like this:

class PinkFrame(Tkinter.Frame):
def __init__(self, parent, **kw):
kw['background'] = 'pink' # line 2
Tkinter.Frame.__init__(self, parent, **kw)

(note that I can't skip line 2, and replace line 3 with
"Tkinter.Frame.__init__(self, parent, background='pink', **kw)"
because if kw already contains a value for background, python will get
confused and throw an exception..)

> class MyClass:
>
>  def __init__(self,**kw)
>  self.property1 = self.kw['property1']
> self.property2 = self.kw['property2']
> etc
>
> Does anyone know of an example of this ?

I'm not sure there's much value in using **kw if you know exactly what
keyword arguments you're expecting.  Although you can be a bit fancy,
eg:

def __init__(self, **kw):
for key in **kw:
setattr(self, key, kw[key])

But you run the risk of writing obscure code that's hard to follow..

If you were implementing the range() function, you would use *args.
Perhaps something like this:

def range(*args):
if len(args) == 1:
return _range(0, args[0], 1)
elif len(args) == 2:
return _range(args[0], args[1], 1)
else:
return _range(args[0], args[1], args[2])# could replace
this with: return _range(*args)

def _range(start, stop, step):
# etc

HTH!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2006-07-31 Thread John Fouhy
On 01/08/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> Traceback (most recent call last):
>  File "", line 1, in ?
>  File "linkedPriorityQueue.py", line 27
>else node.cargo <= self.head.cargo:
>^
> SyntaxError: invalid syntax
>
> I am not sure what this means.  Everything is spelled
> correctly.

An 'else' clause doesn't take a condition.  The general shape of an if
statement is:

if [condition]:
do something
elif [another condition]:
do something else
else:
do other things

The 'else' clause is the catchall for anything that doesn't match one
of the preceding conditions, so it doesn't have its own condition.

What I often like to do is to use a comment to indicate what is true
in the 'else' branch.  eg:

   else:  # node.cargo <= self.head.cargo
   self.last.next = node
   self.last = node

HTH!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The In Operator

2006-07-26 Thread John Fouhy
On 27/07/06, Steve Haley <[EMAIL PROTECTED]> wrote:
> The error message is the same when I run the author's code but the error
> statement itself seems to indicate that there IS an in operator.  I guess I
> really have a three questions.  Is the in operator in version 2.1 of Python?
>  If it is, what is the syntax?  (I tried to find it in the help etc. and
> couldn't.)

There is an 'in' operator in py2.1; as the error message explains, it
expects a sequence on the right hand side.

Sequences are:
 - lists
 - strings
 - tuples

You could change the code to:

 if "Dancing Baloney" in geek.keys():

and it would work; the .keys() method of a dictionary returns a list
containing the dictionary's keys (in arbitrary order).

You could also change the code to:

if geek.has_key("Dancing Baloney"):

This will be more efficient, and this is equivalent to using "in" in
recent versionf of python.
(ie: "key in dict" is equivalent to "dict.has_key(key)")

(are you new to programming in general, or just python in particular?)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] confused by linked queue

2006-07-24 Thread John Fouhy
On 25/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
>>>> from linked_queue import *
> >>> queue = Queue()
> >>> queue.isEmpty()
> True
> >>> queue.insert("cargo")
> >>> print queue.head
> cargo
> >>> print queue.length
> 1
> >>> queue.insert("more_cargo")
> >>> print queue.length
> 2
> >>> print queue.head
> cargo
>
> Where is my second node?  How can I access it?

Try 'print queue.head.next' :-)

A queue is, well, a queue.  Visualise a queue of people.  Initially,
the queue is empty: there's no one standing there.  Then someone comes
and stands at the head of the queue; now the queue has one person in
it (queue.length is 1).

Then, another person comes along.  That person starts at the head of
the queue, and walks down the queue until they find the end.  Then
they join the end.

This is what is happening in this bit of code --- here, you walk down
the queue until you get to the end (ie: a node with no "next" node):

   # find the last node in the list
   last = self.head
   while last.next:
   last = last.next

And here, you add the new node on to the end:

   # append the new node
   last.next = node

It appears there is a bug in the code; these two lines should NOT be
part of the while loop (ie: the indendation is incorrect).

The result looks something like this:

(best viewed with a fixed-width font)

head --> /\/\
 | next --+--> | next --+--> None
 ||||
 | cargo-\|| cargo-\|
 \---+/\---+/
 | |
\|/   \|/
  "cargo""more cargo"

Hope this helps; if not, ask more questions :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What's the invalid syntax?

2006-07-24 Thread John Fouhy
On 25/07/06, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
> What's the invalid syntax?

I don't know, what did python tell you when you tried to run the code?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is there a method like this already?

2006-07-24 Thread John Fouhy
On 25/07/06, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
> Is there a method in Python like this already:
>
> [code]
> #This program calculates how many days it has been from one day to the
> other.

Have a look at the datetime module: if date1 and date2 are both
datetime.date instances, then (date1-date2) is a datetime.timedelta,
and (date1-date2).days is the number of days in the timedelta.

Reading the documentation helps!

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] loops to assign variables

2006-07-22 Thread John CORRY








Hi,

 

I am refactoring my code.  I am trying to reduce the amount of lines
by using more loops.  I tend to use
copy and paste a lot instead of writing a loop to do the work.

 

For example, I have 30 textentry
boxes numbered from entry20 to entry50. 
I have used the following code to assign the entryboxes
to a local name.

 

text20 = self.wTree.get_widget("entry20")

text21 = self.wTree.get_widget("entry21")

 

I have had a go at writing a loop for the above 30 textentry boxes. 
It is below, but it does not work. 


 

for x in
range(20,51):

   
ent = "entry%s" % (str(x))

   
   

   
text_x = self.wTree.get_widget(ent)

 

Is it possible to do what I want it to do?  Am I on the right lines?  Any help or advice would be greatly
appreciated.

 

Thanks,

 

John.






___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Good teamwork!

2006-07-21 Thread John CORRY








George/Kent,

 

Thanks guys for the pointers.

 

Kent – The
gtk-entry-set-alignment() works a treat.

 

George – I like the look of the sample code
you posted.  At the moment it doesn’t
give me exactly what I need but I am still playing with it.  There may be another question on this
later!

 

I have downloaded the ValidatedEntry
extension and had a quick look at it. It looks like it will sort out my
validation problems.

 

A good team effort!

 

Thanks,

 

John. 

 

   






___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] : finding out if the horizontal scrollbar on a Tix.CheckList is being used or not

2006-07-21 Thread John Fouhy
On 21/07/06, Orri Ganel <[EMAIL PROTECTED]> wrote:
> I'm working on the GUI for my extended iTunes search, which allows
> searches far beyond the native iTunes capability.  Once the search has
> been completed, a window contining a Tix.CheckList with the resulting
> tracks is displayed.  If anyone has any idea how to figure out whether
> or not the horizontal scrollbar is visible (ie if the length of the
> track name extends beyond the width of the CheckList) programmatically,
> I'd be extremely grateful :-).

I don't know how to check the scrollbar, but one thing you could try
playing with: tkFont.Font instances support a .measure method.  So, if
f is a tkFont.Font, then f.measure('hello world!') will return how
many pixels wide that string would be on the screen.  You could maybe
compare this with the width of the widget itself?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using python to create and save a Ms Word file

2006-07-20 Thread John Fouhy
On 21/07/06, andrew clarke <[EMAIL PROTECTED]> wrote:
> A quick Google later, and it seems you need to add the following methods
> to the CWordAutomate class:
>
>def Save(self, sFilename):
>self.m_obDoc.SaveAs(sFilename)
>
>def Quit(self):
>self.m_obWord.Quit()

Check out the Visual Basic documentation that comes with Word (I think
it's an optional component when you install).  That will descibe (in a
VBA context) the functions you can call after Dispatching something.

Also, pythonwin comes with a utility called makepy.py.  If you run
this, it will crank through your available COM objects and generate a
whole bunch of python code to tell python about what functions are
available.  Once you've done this, you can (I think) use help() and
dir() to find out what functions are available, and what arguments
they expect.  You can also read through the generated code itself;
it's more helpful than you might expect :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Help me make it look pretty!

2006-07-20 Thread John CORRY








Good evening all.

 

I am writing a program using python 2.4, glade 2 and pygtk.  It takes
input from the user using textentry boxes.  The input should be a number.  When the user keys the data in, it
automatically left justifies.  The
function below, takes the input for four boxes and right justifies it by using
an ugly, string format.  The boxes
are 45 characters big, so I use the len function to
fit them into the box.  The code is
below.

 

I am looking for a way to set the text entry up, so that
there is a decimal point in the box regardless of what the user does and I am
also looking for a way to keep the numbers right justified.

 

Any suggestions or comments as always are greatly
appreciated.

 

Regards,

 

John.

 

 

def
callback36(self,data,text37,text38,text39,text40,text41,text42,label):

    a =
text37.get_text()

    

    b =
text38.get_text()

    c =
text39.get_text()

    d =
text40.get_text()

    a= float(a)

    b= float(b)

    c=
float(c)

    d= float(d)

    

    try:

   


   
e = float(a + b + c + d)

   
g = e/a

   
e = "%0.2f" % e

   


   
g = "%0.2f" % g

   
g = str(g)

   
label.hide()

    e = "
%s" % e

   
a = "
%s" % a

   
b = "
%s" % b

   
c = "
%s" % c

   
d = "
%s" % d

   
g = "%s%%" % g

   
text42.set_text(str(g))


   
if len(e)>45:

   
x = len(e) - 45

   
x = x + 4

   
y = e[x:]

   
text41.set_text(str(y))  


   
return 

   
else:

   
text41.set_text(str(e))


   
return

   

    except:

   
label.show()

   
return






___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] removing a card

2006-07-19 Thread John Fouhy
On 20/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
>def __cmp__(self):
[...]
> I am confused by this error because I modified __cmp__
> in the Card class to take two arguments.  Am I missing
> something here?

You haven't defined it that way in the code you posted..

I presume you meant to type:

def __cmp__(self, other)

?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Comparing times

2006-07-18 Thread John Fouhy
On 18/07/06, Steve Nelson <[EMAIL PROTECTED]> wrote:
> What I want to do is establish if the time of the process is *later*
> than the system date.  For example, we might have a process with a
> time of 11:15:00, when the system time is 10:00:00.  In practice this
> means that the process is from 11am yesterday.
>
> Other than splitting the string up more and saying is 11 bigger than
> 10, how can I go about this?

Have a look at time.strptime.  Eg, if s is '11:15:00' then
time.strptime(s, '%H:%M:%S') will be a tuple of 9 integers which you
should be able to compare directly with other time tuples.

# untested
def cmptime(s1, s2):
"""Compare two times as strings in %H:%M:%S format."""
return cmp(time.strptime(s1, '%H:%M:%S'), time.strptime(s2, '%H:%M:%S'))

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
On 14/07/06, Steve Nelson <[EMAIL PROTECTED]> wrote:
> How does one query a match object in this way?  I am learning by
> fiddling interactively.

If you're fiddling interactively, try the dir() command --

ie:

>>> m = re.match(...)
>>> dir(m)

It will tell you what attributes the match object has.

Or you can read the documentation --- a combination of both approaches
usually works quite well :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
On 14/07/06, Steve Nelson <[EMAIL PROTECTED]> wrote:
> What I don't understand is how in the end the RE *does* actually match
> - which may indicate a serious misunderstanding on my part.
>
> >>> re.match("a[bcd]*b", "abcbd")
> <_sre.SRE_Match object at 0x186b7b10>
>
> I don't see how abcbd matches! It ends with a d and the RE states it
> should end with a b!
>
> What am I missing?

It doesn't have to match the _whole_ string.

[bcd]* will match, amongst other things, the empty string (ie: 0
repetitions of either a b, a c, or a d).  So "a[bcd]*b" will match
"ab", which is in the string abcbd.

It will also match "abcb", which is the longest match, and thus
probably the one it found.

If you look at the match object returned, you should se that the match
starts at position 0 and is four characters long.

Now, if you asked for "a[bcd]*b$", that would be a different matter!

HTH :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with strings and lists.

2006-07-13 Thread John Fouhy
On 14/07/06, Alan Collins <[EMAIL PROTECTED]> wrote:
> You now want columns 1, 5, and 7 printed and aligned (much like a
> spreadsheet). For example:
>
> Monday547757699 100%
> Wednesday 77449 100%

Let me attempt to be the first to say:

String substitutions!!!

The docs are here: http://docs.python.org/lib/typesseq-strings.html

At their simplest, you can do things like:

s = '%s || %s || %s' % (columns[0], columns[4], columns[6])

This will print:

Monday || 547757699 || 100%

Next, you can specify padding as well:

s = '%12s || %12s || %5s' % (columns[0], columns[4], columns[6])

and the first string will be padded with spaces to 12 characters, the
second to 12, and the last to 5.  You can change which side it pads on
by specifying negative field widths --- eg, %-12s instead of %12s.
(one will produce "  Monday", the other "Monday  ".  I forget
which.)

Next, you can tell python to read the field width from a variable:

s = '%*s || %*s || %*s' % (12, columns[0], 12, columns[4], 5, columns[6])
(ie: width first)

So all you need to do is find the maximum field width (have a look at
list comprehensions and the max() function), then use string
formatting operators to lay everything out :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] email anonymizing

2006-07-13 Thread John Fouhy
On 14/07/06, anil maran <[EMAIL PROTECTED]> wrote:
> i want to know how to generate
> [EMAIL PROTECTED] =>  [EMAIL PROTECTED]
> and then how do i do the translation
> [EMAIL PROTECTED] => [EMAIL PROTECTED]

Hi Anil,

Do you have any programming experience in other languages?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] abs beginner first project

2006-07-12 Thread John Fouhy
On 12/07/06, josip <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I have finished learning python book and python for absolute beginners book.
> Now I want to start my first project.
>
> Can someone sugest me project for first time (and some pointers,please)?

Do you listen to music on your computer?  You could write a program to
catalogue your MP3 files.  For example, you could type something like:

  python findMP3s.py -artist Beatles

and it would return all the mp3s you have by the Beatles.  There's a
few modules around that will help you read id3 tags (unless you're
using an intel mac :-/ ) and the rest should be fun stuff with data
structures.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread John Fouhy
On 12/07/06, Marcus Goldfish <[EMAIL PROTECTED]> wrote:
> # 1st, find the 'stale' items in our dictionary to delete
> # lstKeepers is a list of current pictures
> # Note: if I try to iterate over the keys of the dict and
> # remove-as-I-go, I get an exception (dict size changed
> # during iteration)

Try this:

for key in myDict.keys():
  if key not in lstKeepers:
del myDict[key]

The difference here is that myDict.keys() creates a list containing
the keys of myDict at the start of the loop, and then iterates over
the list.

If lstKeepers is big, it might be more efficient to make it into a set first ---

keepSet = set(lstKeepers)
for key in myDict.keys():
  if key not in keepSet:
del myDict[key]

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] no loops

2006-07-11 Thread John Fouhy
On 12/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> Now the exercise is:
> As an exercise, rewrite this function so that it
> doesn't contain any loops.
>
> I have been staring at this function and drawing a
> blank.  Something tells me that I need to use
> iteration, but I am not sure how I could implement it.

Hi Chris,

You are using iteration.  That's what loops are :-)

Perhaps you meant to say "recursion", which is where a function calls
itself.  You could solve this recursively, but I think Gregor's
comment is closer to what they want you to do.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need Help

2006-07-11 Thread John or Margaret Montgomery
On Tue, 11 Jul 2006 06:41:23 -0500
Luke Paireepinart <[EMAIL PROTECTED]> wrote:

> Hi.
> Shappell, John J CW2 wrote:
> >
> > Here is the assignment
> >
> [snip assignment]
> Please don't ask about homework in the future.  Did your professor tell 
> you to submit queries to this list?  If so, could you ask him not to? 
> it's against the policies of the tutor mailing list to give homework 
> help.  However, I can give you a few hints about python in general.  The 
> rules may be different but my impression was that there was no homework 
> to be submitted here.  If I'm wrong please correct me.
> >

Perhaps I am wrong, Luke but my impression was that this request was fine. He 
openly stated it was homework and he did considerable work on it before getting 
stuck. Also he specifically did not ask for a solution but wished to be nudged 
in the right direction.

I am sorry that I do not have the knowledge to help but perhaps your tip did 
the trick.

Perhaps Danny or Kent would clarify this situation.

John Montgomery
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Need Help

2006-07-11 Thread Shappell, John J CW2
Title: [Tutor] Need Help





Here is the assignment


You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the office for incidental purchases). The requirements for the program are to allow users to input the amount of cash deposited, the amount of cash withdrawn and to get a report of the balance at any given time. You will need to also add the date of each deposit and the date of each withdrawal and provide a date with the balance returned upon a given query. The program should be able to provide a printed report and support a command line query.

You are to use the object oriented properties of Python to accomplish this task. 


This is where I am at so far.  I don't understand how to get the Account class into the program. Can you help a little,  Just looking for an idea or some guidance

#!/usr/bin/python
# Filename: petty cash.py


print "Welcome to the petty cash account"
print "Did you deposit or withdrawl money today"
print


# print out menu
print "please select a number"
print "1 for deposit"
print "2 for withdrawl"


# Get user's choice:
number = input (">")
#
if number == 1:
    deposit = input ("how much?")
    print "I deposited:", deposit
    
elif number == 2:
    withdrawl = input ("How Much?")
    print "I withdrew:", withdrawl
    
print "what is today's date?"
# Get date from user
date = input (">")


This is where I get stuck. The program will allow me to input the deposit or withdrawl ammount and the date but does nothing ownce it gets here

class Account:
 def __init__(self, initial):
 self.balance = initial
 def deposit(self, amt):
 self.balance = self.balance + amt
 def withdraw(self,amt):
 self.balance = self.balance - amt
 def getbalance(self):
 return self.balance 


V/R


CW2 John Shappell
HHB 2-44 ADA BN
Work 270-798-6823
FAX 775-618-2455
[EMAIL PROTECTED]
[EMAIL PROTECTED]






___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I copy files recursively?

2006-07-10 Thread John Fouhy
On 11/07/06, Richard Querin <[EMAIL PROTECTED]> wrote:
> I know this is probably a dumb question:
>
> I've got mp3 files that are downloaded (by ipodder) into individual
> subfolders. I'd like to write a quick script to move (not copy) all the mp3
> files in those folders into a single destination folder. I was thinking I
> could do it easily from the linux command line (cp -r copies the subfolders
> out as well) but I can't figure out how to do it. Is there an easy way to
> achieve this using Python? I am assuming this would be something Python was
> designed to make easy..

You could do it from the command line with something like:

$ for f in `find ./ -name *.mp3`; do mv $f /foo/bar/$f; done

(actually, that won't work; you'll need to find a way to convert
"/x/y/z.mp3" to "z.mp3".  I don't have a linux commandline handy to
test.. basename, maybe? You could do it with awk --

$ for f in `find ./ -name *.mp3`; do mv $f /foo/bar/`echo $f | awk -F
'/' '{print $NF}'`; done

but that's pretty hairy and may not work :-/
)

In python, you can use os.rename to move and os.walk to walk your
directory structure.  Something like:

source = '/ipodder'
dest = '/foo/bar'
for root, dirs, files in os.walk(source):
for f in files:
os.rename(os.path.join(root, f), os.path.join(dest, f))

(although I would do a test run first, if I were you, since I often
get os.walk wrong :-) )

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Splitting

2006-07-09 Thread John Fouhy
On 10/07/06, Abhinav Gaurav <[EMAIL PROTECTED]> wrote:
> John Fouhy <[EMAIL PROTECTED]> wrote:
> > What version of python are you running?
> 1.5.2 is the version.

Right.  Well, you're slightly over 7 years out of date :-)  Do you
have the ability to upgrade?  You or your system administrator can
download the latest release from http://python.org/ -- python 2.4.3 is
the latest stable release.  You will probably find that much of what
you read on the web is incorrect for python 1.5.2.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Splitting

2006-07-09 Thread John Fouhy
On 10/07/06, Abhinav Gaurav <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Thanks for your help! I am wondering if it works fine then why it failing on
> my comp. And what is the remedy for it?

What version of python are you running?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Wiget

2006-06-29 Thread John Fouhy
On 30/06/06, ryan luna <[EMAIL PROTECTED]> wrote:
> def number_anwser(self):
> guess = self.guess_ent.get()
> guess = int(guess)
> response = ""
> tries = 1
>
> if (guess < the_number):
> response += "Higher"
> tries += 1
> elif (guess > the_number):
> response += "Lower"
> tries += 1
> else:
> tries = str(tries)
> response += "Correct! that was my number, \n"
> response += "You guessed it in just "
> response += tries
> response += " tries!"
>
> self.response_txt.delete(0.0, END)
> self.response_txt.insert(0.0, response)

This is the function that gets called whenever your button is clicked.
 So, every time you click the button, "tries" gets set to 1.

I assume you have a class derived from Frame -- can you think how to
store your "tries" value in your Frame object?

(do you know the difference between local variables and object attributes?)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to check a files size

2006-06-28 Thread John Fouhy
On 29/06/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> See shutil.copyfile()

Why isn't this function in the os module with the other file commands?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Writing an "Alt-Enter"

2006-06-19 Thread John Fouhy
On 20/06/06, URBAN LANDREMAN <[EMAIL PROTECTED]> wrote:
> I'm trying to write a .csv file which I can subsequently load into Excel.
> The part that's tripping me up is I want to include an "Alt-Enter" between
> two of the fields so that when Excel reads the file, it will enter the two
> fields into the same cell, but on separate lines.

Hi,

You could try printing a carriage return: '\r'.

But, also --- have you looked into the csv module?  It's designed for
writing (and reading) csv files, and it knows about Excel.  It might
be that you can feed it strings with newlines in them and it will
produce the output you want.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beginner question(s)

2006-06-18 Thread John Fouhy
> Also, does anyone know of a PDA that would run python?

Some of the new Nokias run python: http://www.forum.nokia.com/python

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] lambda and creating GUIs

2006-06-16 Thread John Fouhy
On 17/06/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> I understand this:
> >
> > def f(w): gtk.main_quit()
> > button.connect("clicked", f)
> >
> Now my question is what is "w"?  What is being passed
> to the function?

I don't know GTK, but I would guess some kind of event class.  Other
GUIs I've used (Tkinter, wxPython) pass event objects to callbacks,
which contain information like
 - which mouse button was clicked
 - the exact mouse coordinates (relative to the corner of the screen
or the corner of the widget)
 - which key was pressed
etc.

You may know some of the information, some of it may not apply, you
may not care about the rest of it, but you usually get it anyway :-)

In this case, the program doesn't care about any of the extra
information, so it accepts the event, but it does nothing with it.

Try this:

def show(e):
print e
print 'Class:', e.__class__
print 'Members:'
for attr in dir(e):
print '%s: %s' % (attr, getattr(e, attr))

button.connect("clicked", show)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Delete directories recursively

2006-06-16 Thread John Corry



Amresh,
 
I had this problem a few months back.  I 
approached it backwards.  Maybe not the right way to do it.  I removed 
all the files and directories and then had my exception handle the file if 
it was read only.  The exception  handler changes the file from 
read-only to not read only and then calls the function again.  

 
Is there a better way to do it?  Would appreciate 
feedback on the code below.
 
import shutil
import 
os
 
def 
zaps(self):  
    
try:    
shutil.rmtree('f:/m2m')   
except OSError, 
inst:    
print 
OSError    
os.chmod(inst.filename, 
0666)    
self.zaps()
 
Regards,
 
John.

  -Original Message-From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of Amresh 
  KulkarniSent: 16 June 2006 16:27To: 
  tutor@python.orgSubject: [Tutor] Delete directories 
  recursivelyHi,I need to delete a directory and 
  its sub directories. However all dir's, sub dir;s and files have read only 
  access. How do i do this efficeintly using the os.walk command. I cannot 
  run this command on the dir as it gives me an error due to the read only 
  attribute. Is there any other way to do this? -- 
  ~~AMRESH~~ 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] lambda and creating GUIs

2006-06-15 Thread John Fouhy
(resending to include Tutor -- sorry for the dupe, Christopher)

On 16/06/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> I have been reading though the PyGTK tutorial.
> Can anyone explain how lambda is being used in this
> statement:
>
> button.connect("clicked", lambda w: gtk.main_quit())


Do you understand what lambda does in general?

Does it help if I rewrite the code like this:

def onQuit(w):
   gtk.main_quit()
button.connect("clicked", onQuit)

?

Provided you get your indentation correct ("def onQuit" and
"button.connect" should be at the same level), and provided you aren't
using the name "onQuit" somewhere else in that method, this code
should be a dropin replacement for the line you quote.

--

John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Offtopic observation

2006-06-07 Thread John Fouhy
On 08/06/06, doug shawhan <[EMAIL PROTECTED]> wrote:
> This marks the third time this week I have been typing in a question for the
> group, and have made the answer apparent just by trying to explain my
> question clearly.

I'm usually a step back from that --- the answer becomes apparent
approximately five seconds _after_ I send off my question..

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Combo Box in Tkinter

2006-06-06 Thread John Fouhy
Check out Python MegaWidgets (pmw.sourceforge.net).

On 07/06/06, Keo Sophon <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there any Combo Box in Tkinter? I looked for it but only found list box.
> Might it be list box having any option to make itself as a combo box?
>
> Thanks,
> Phon
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] FileDialogBox in Tkinter

2006-06-05 Thread John Fouhy
On 06/06/06, Keo Sophon <[EMAIL PROTECTED]> wrote:
> What to do in order to get FileDialogBox in Tkinter for using? Where to find a
> complete reference of Tkinter?

Fredrik Lundh's guide (which Bernard linked) is a good Tkinter
reference.  For the FileDialogBox, you will need another import
statement --- 'import Tkinter' or 'from Tkinter import *' won't bring
it in.

New Mexico Tech has a good reference too:
http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html  It's a bit
old, but a lot of it is still accurate, and it goes into more detail
than the pythonware one.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Not Really Questions

2006-06-04 Thread John Connors
G'day,

While the list is kind of slow I thought I'd post a few thoughts on a couple 
of things in Python that bug me. They're not really questions but maybe 
someone can help me understand.

The first one is lists... I can't for the life of me understand why a list 
starts at zero. In everything else in life other than programming the 1st 
item in a list is always 1.

The next thing I don't understand is why the last number in a range is not 
used...

For a in range(1,6):
print a,

1 2 3 4 5

Once again it defies the logic of everything else we are taught in life.

The 3rd whinge is object oriented programming. I think I understand the 
principle behind OOP but in practise, to me, it just makes programs jumbled, 
unreadable and bloated. Just about every summary I have read on Python says 
it is designed to have a simple syntax and is easy to learn. As a beginner I 
can look at Python code and have a very good idea of what is happening and 
why unless it's written in OOP style in which case I have no idea.

John

_
Read, write and reply to Hotmail on your mobile. Find out more. 
http://mobilecentral.ninemsn.com.au/mcmobileHotmail/home.aspx

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


<    2   3   4   5   6   7   8   9   10   11   >