How to build python with shared libraries.

2013-07-16 Thread guxiaobo1982
Hi,

I am not so familiar with Python, I just want to use the multicorn external 
data wrapper and plpythonu2 language with PostgreSQL, my question is which 
option to specify when build Python 3.3 with shared libraries from source.


Regards,


Xiaobo Gu-- 
http://mail.python.org/mailman/listinfo/python-list


grimace: a fluent regular expression generator in Python

2013-07-16 Thread Ben Last
Hi all

I'd be interested in comments on a fluent regular expression generator I've
been playing with (inspired by the frustrations of a friend of mine who's
learning).

The general use case is to be able to construct RE strings such as:

r'^\(\d{3,3}\)-{1,1}\d{3,3}\-{1,1}\d{4,4}$' (intended to match North
American phone number)

as:

from grimace import RE
north_american_number_re = (RE().start

.literal('(').followed_by.exactly(3).digits.then.literal(')')

.then.one.literal("-").then.exactly(3).digits

.then.one.dash.followed_by.exactly(4).digits.then.end
.as_string())

The intent is to provide clarity: since the strings would normally be
generated and compiled when a module is first imported, there's minimal
overhead.

It's on github at https://github.com/benlast/grimace and the first blog
post that explains it is here: http://benlast.livejournal.com/30871.html (I've
added to it since then).

Tests are the best explanation, and they're in the __init__ at the end so
that they're self-executing if the init is executed.

I'm thinking about other features to implement, and more use cases would be
welcome.

Cheers
ben
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bluetooth Sockets

2013-07-16 Thread Simfake Fake
Just bumping this, but has anybody have any personal experience with
bluetooth in python 3? Perhaps my issue is that the windows version doesn't
include it?


On Sat, Jul 13, 2013 at 6:23 PM, Simfake Fake wrote:

> Hi. I'm trying to connect to a bluetooth serial adaptor using python 3.x.
> However, in python 3.3.2 win x32, I get "AttributeError: module has no
> attribute AF_..." when trying to use socket.AF_BLUETOOTH, despite the docs
> http://docs.python.org/3.3/library/socket.html . The code I have is very
> similar to that found
> http://kevindoran1.blogspot.com.au/2013/04/bluetooth-programming-with-python-3.html
> I need to use python 3.x, as this is eventually going to run within
> Blender. It's going to run within blender so I can use blender to visualize
> and solve inverse-kinematic stuff for a robot arm.
>
> Regards
> Jak_o_Shadows
>
-- 
http://mail.python.org/mailman/listinfo/python-list


help on python regular expression named group

2013-07-16 Thread Mohan L
Dear All,

Here is my script :

#!/usr/bin/python
import re

# A string.
logs = "date=2012-11-28 time=21:14:59"

# Match with named groups.
m =
re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))",
logs)

# print
print m.groupdict()

Output:


{'date': '2012-11-28', 'datetime': '*date=2012-11-28 time=21:14:59*',
'time': '21:14:59'}


Required output :
==

{'date': '2012-11-28', 'datetime': '*2012-11-28 21:14:59*', 'time':
'21:14:59'}

need help to correct the below regex

(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))"

so that It will have : 'datetime': '2012-11-28 21:14:59' instead of
'datetime': 'date=2012-11-28 time=21:14:59'

any help would be greatly appreciated

Thanks
Mohan L
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bluetooth Sockets

2013-07-16 Thread Chris Angelico
On Tue, Jul 16, 2013 at 3:52 PM, Simfake Fake  wrote:
> Just bumping this, but has anybody have any personal experience with
> bluetooth in python 3? Perhaps my issue is that the windows version doesn't
> include it?

I haven't worked with Bluetooth in Python, but my reading of the
socket module docs is that AF_BLUETOOTH doesn't imply strong support
anyway. I'd recommend looking for a dedicated bluetooth module; there
seem to be some around.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a little more explicative error message?

2013-07-16 Thread Terry Reedy

On 7/16/2013 1:44 AM, Vito De Tullio wrote:

Hi

I was writing a decorator and lost half an hour for a stupid bug in my code,
but honestly the error the python interpreter returned to me doesn't
helped...

$ python3
Python 3.3.0 (default, Feb 24 2013, 09:34:27)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.

from functools import wraps
def dec(fun):

...  @wraps
...  def ret(*args, **kwargs):
...   return fun(*args, **kwargs)


At this point, when dec(fun) is called, the interpreter *successfully* 
executes ret = wraps(ret), which works, but is wrong, because wraps 
should be called with the wrapped function fun as its argument, not the 
wrapper function ret. The interpreter should instead execute

ret = partial(update_wrapper, wrapped = fun, ...)(ret)
which will update ret to look like fun.


...  return ret
...

@dec

... def fun(): pass


At this point, the interpreter *successfully* executes fun = dec(fun) = 
(wraps(ret))(fun), which causes ret = wraps(ret) before returning ret. 
Notice that when dec returns, the wraps code is over and done with. 
Instead the interpreter should execute

fun = (partial(update_wrapper, wrapped = fun, ...)(ret))(fun)


...

fun()

Traceback (most recent call last):
   File "", line 1, in 
TypeError: update_wrapper() missing 1 required positional argument:
'wrapper'


Because fun has not been properly wrapped because you left out a call.


Soo... at a first glance, no tricks... can you tell where is the error? :D


Not exactly, but it must have something to do with wraps, so the first 
thing I would do is to look at the wraps doc if I had not before. It 
only takes a couple of minutes.


>>> from functools import wraps
>>> help(wraps)
Help on function wraps in module functools:

wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', 
'__doc__', '__annotations__'), updated=('__dict__',))

Decorator factory to apply update_wrapper() to a wrapper function

Returns a decorator that invokes update_wrapper() with the decorated
   function as the wrapper argument and the arguments to wraps() as
   the remaining arguments. ...

This is pretty clear that wraps is not a decorator but a function that 
returns  decorator, which means that is must be called with an argument 
in the @del statement.


To really understand what is intended to happen so I could write the 
commentary above, I looked at the code to see

def wraps(wrapped, ...):
''
return partial(update_wrapper, wrapped=wrapped,
   assigned=assigned, updated=updated)


As I said, the error is totally mine, I just forgot to pass the function as
parameter to wraps. But... what is "update_wrapper()"? and "wrapper"? There
is no useful traceback or something... just... this.

Ok, the documentation clearly says:

 This is a convenience function to simplify applying partial() to
 update_wrapper().

So, again, shame on me... I just read carefully the doc *after* 20 minutes
trying everything else...  still... I think should be useful if wraps()
intercept this error saying something more explicit about the missing fun
parameter...


How is a function that has already been called and has returned without 
apparent error supposed to catch a later error caused by its return not 
being correct, due to its input not being correct?


Your request is like asking a function f(x) to catch ZeroDivisionError 
if it return a 0 and that 0 is later used as a divisor after f returns, 
as in 1/f(x).


When you call wraps with a callable, there is no way for it to know that 
the callable in intended to the be the wrapper instead of the wrappee, 
unless it were clairvoyant ;-).


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: grimace: a fluent regular expression generator in Python

2013-07-16 Thread Joshua Landau
On 15 July 2013 23:21, Ben Last  wrote:
> Hi all
>
> I'd be interested in comments on a fluent regular expression generator I've
> been playing with (inspired by the frustrations of a friend of mine who's
> learning).
>
> The general use case is to be able to construct RE strings such as:
>
> r'^\(\d{3,3}\)-{1,1}\d{3,3}\-{1,1}\d{4,4}$' (intended to match North
> American phone number)
>
> as:
>
> from grimace import RE
> north_american_number_re = (
>RE().start
>.literal('(').followed_by.exactly(3).digits.then.literal(')')
>.then.one.literal("-").then.exactly(3).digits
>.then.one.dash.followed_by.exactly(4).digits.then.end
>.as_string()
> )

This looks really busy. How about something more like:

from grimace import RE, start, digits, dash, end
RE(start, "(", digits[3], ")-", digits[3], dash, digits[4], end).as_string()

?

and then you can do cool stuff like (Regex completely untested, I
hardly use the things):

RE((start | tab), (digits[:], inverse(dash)[4])[:2]) →
r"(^|\t)(\d*[^\-]{4,4}){0,2}"


> The intent is to provide clarity: since the strings would normally be
> generated and compiled when a module is first imported, there's minimal
> overhead.
>
> It's on github at https://github.com/benlast/grimace and the first blog post
> that explains it is here: http://benlast.livejournal.com/30871.html (I've
> added to it since then).
>
> Tests are the best explanation, and they're in the __init__ at the end so
> that they're self-executing if the init is executed.
>
> I'm thinking about other features to implement, and more use cases would be
> welcome.
>
> Cheers
> ben
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on python regular expression named group

2013-07-16 Thread Joshua Landau
On 16 July 2013 07:55, Mohan L  wrote:
>
> Dear All,
>
> Here is my script :
>
> #!/usr/bin/python
> import re
>
> # A string.
> logs = "date=2012-11-28 time=21:14:59"
>
> # Match with named groups.
> m =
> re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))",
> logs)
>
> # print
> print m.groupdict()
>
> Output:
> 
>
> {'date': '2012-11-28', 'datetime': 'date=2012-11-28 time=21:14:59', 'time':
> '21:14:59'}
>
>
> Required output :
> ==
>
> {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time':
> '21:14:59'}
>
> need help to correct the below regex
>
> (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))"
>
> so that It will have : 'datetime': '2012-11-28 21:14:59' instead of
> 'datetime': 'date=2012-11-28 time=21:14:59'
>
> any help would be greatly appreciated

Why do you need to do this in a single Regex? Can't you just "
".join(..) the date and time?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding other people's code

2013-07-16 Thread Jean-Michel Pichavant
- Original Message -
> Thanks for all the suggestions, I'm afraid I didn't get a chance to
> view them over the weekend but I will get started with them this
> morning. I'm currently using sublime 2 for my text editor and tried
> to create a UML diagram using Pylint to try and get a map overview
> of what's going on. Unfortunately it seemed to map the classes into
> groups such as StringIO, ThreadPool, GrabOut etc.. rather than into
> the modules they belong go and how they fit together. Maybe this is
> just my inexperience showing through or I'm using the program wrong.
> If anyone has any 'mapping' programs they use to help them visualise
> program flow that would be a great bonus.
> 
> To be fair to who programmed it, most functions are commented and I
> can't complain about the messiness of the code, It's actually very
> tidy. (I suppose Python forcing it's formatting is another reason
> it's an easily readable language!) Luckily not blanked import * were
> used otherwise I really would be up the creek without a paddle.
> Thanks!

Do not hesitate to ask this list about specific part of the code, looks like 
you've already put some efforts understanding it so people will happily try to 
help you.
Just make sure you can actually expose the code to the public.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bluetooth Sockets

2013-07-16 Thread Christian Heimes
Am 13.07.2013 10:53, schrieb Simfake Fake:
> Hi. I'm trying to connect to a bluetooth serial adaptor using python
> 3.x. However, in python 3.3.2 win x32, I get "AttributeError: module has
> no attribute AF_..." when trying to use socket.AF_BLUETOOTH, despite the
> docs http://docs.python.org/3.3/library/socket.html . The code I have is
> very similar to that
> found 
> http://kevindoran1.blogspot.com.au/2013/04/bluetooth-programming-with-python-3.html
> I need to use python 3.x, as this is eventually going to run within
> Blender.. It's going to run within blender so I can use blender to
> visualize and solve inverse-kinematic stuff for a robot arm.

AF_BLUETOOTH is only available on Linux and some BSD variants. Windows
has different bluetooth stacks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RE Module Performance

2013-07-16 Thread Devyn Collier Johnson


Am 07/12/2013 07:16 PM, schrieb MRAB:

On 12/07/2013 23:16, Tim Delaney wrote:

On 13 July 2013 03:58, Devyn Collier Johnson mailto:[email protected]>> wrote:


Thanks for the thorough response. I learned a lot. You should write
articles on Python.
I plan to spend some time optimizing the re.py module for Unix
systems. I would love to amp up my programs that use that module.


If you are finding that regular expressions are taking too much time,
have a look at the https://pypi.python.org/pypi/re2/ and
https://pypi.python.org/pypi/regex/2013-06-26 modules to see if they
already give you enough of a speedup.


FYI, you're better off going to http://pypi.python.org/pypi/regex
because that will take you to the latest version.

Thank you everyone for the suggestions. I have not tried them yet.

Devyn Collier Johnson
--
http://mail.python.org/mailman/listinfo/python-list


Floating point minimum and maximum exponent values

2013-07-16 Thread Marco

Hi all, why the maximum and minimum exp values are 1024 and -1021?:

>>> sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, 
max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, 
min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, 
radix=2, rounds=1)


The values (in double precision) 0 and 2047 are reserved for zero, 
infinity and NaN (in combination with the fraction), so I was expecting 
-1022 and 1023...



--
Marco Buttu
--
http://mail.python.org/mailman/listinfo/python-list


Re: Floating point minimum and maximum exponent values

2013-07-16 Thread Chris Angelico
On Tue, Jul 16, 2013 at 9:43 PM, Marco  wrote:
> Hi all, why the maximum and minimum exp values are 1024 and -1021?:
>
 sys.float_info
> sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
> min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15,
> mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
>
> The values (in double precision) 0 and 2047 are reserved for zero, infinity
> and NaN (in combination with the fraction), so I was expecting -1022 and
> 1023...

Piece of extreme oddity, this.

>>> help(sys.float_info)
... lots of other info ...
 |  max_exp
 |  DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
 |
 |  min_exp
 |  DBL_MIN_EXP -- minimum int e such that radix**(e-1) is a
normalized float
...

So it's technically correct. Followup question: Why is it off by one?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eGenix EuroPython 2013 Talks & Videos

2013-07-16 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING
eGenix EuroPython 2013 Talks & Videos


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/EuroPython-2013-Presentations.html


We have just published the talks slides and videos of our EuroPython
2013 presentations.

The EuroPython Conference is the one of the premier conferences for
Python users and developers. This year it was held from July 1-7 in
Florence, Italy.



EGENIX TALKS AT EUROPYTHON

At this year's EuroPython, Marc-André Lemburg, CEO of eGenix, gave the
following two talks at the conference, providing some insights into
our experience with running Python projects. The presentations are
available for viewing and download from our Presentations and Talks
section.

http://www.egenix.com/library/presentations/

Designing Large-Scale Applications in Python


Concepts for designing large and scalable Python applications that
work in practice.

Python is often referred to as a scripting language. While Python is
an ideal platform for scripting, integration or plugin tasks, it does
in fact cover all the concepts needed for truly large-scale object
oriented application development. However, complex applications bring
new challenges.

The talk will draw on the speaker’s experience with large-scale
application design using Python as central implementation language and
provide a cookbook approach to many of the problems you face when
designing and organizing complex application frameworks.

The approach has been proven in many real-life projects, ranging from
web application servers in varying fields of application to complete
finance trading systems. Python has always proven to be a truly good
choice with an outstanding time-to-market advantage over other
implementation languages such as Java or C++. It allows small software
development companies to successfully compete against multi-million
dollar ventures.

Talk video and slides:
http://www.egenix.com/library/presentations/EuroPython2013-Designing-Large-Scale-Applications-in-Python/

and

Efficient Python development with small teams
-

As we all know, Python is a very efficient implementation language -
so efficient, that you sometimes face new challenges in projects. Very
often, you can completely skip the prototype phase and go directly to
the main development phase. Customers love this, of course, but this
approach tends to come with its own unique set of requirements and
problems.

Team size, communication, application design, work distribution,
milestone and customer expectation management are important factors
for the success of such a project.

The talk will discuss a few strategies that have worked in many larger
projects and also touch upon some things that did not work out well.

Talk video and slides:
http://www.egenix.com/library/presentations/EuroPython2013-Efficient-Python-development-with-small-teams/



INFORMATION

About Python (http://www.python.org/):

Python is an object-oriented Open Source programming language
which runs on all modern platforms. By integrating ease-of-use,
clarity in coding, enterprise application connectivity and rapid
application design, Python establishes an ideal programming
platform for today's IT challenges.

About eGenix (http://www.egenix.com/):

eGenix is a software project, consulting and product company
focusing on expert project services and professional quality
products for companies, Python users and developers.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 16 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2013-07-16: Python Meeting Duesseldorf ... today

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Floating point minimum and maximum exponent values

2013-07-16 Thread Christian Heimes
Am 16.07.2013 14:04, schrieb Chris Angelico:
> Piece of extreme oddity, this.
> 
 help(sys.float_info)
>  lots of other info ...
>  |  max_exp
>  |  DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
>  |
>  |  min_exp
>  |  DBL_MIN_EXP -- minimum int e such that radix**(e-1) is a
> normalized float
> 
> 
> So it's technically correct. Followup question: Why is it off by one?

Because float.h defines DBL_MAX_EXP like that.

Why? I can't tell, too.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on python regular expression named group

2013-07-16 Thread Mohan L
On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau  wrote:

> On 16 July 2013 07:55, Mohan L  wrote:
> >
> > Dear All,
> >
> > Here is my script :
> >
> > #!/usr/bin/python
> > import re
> >
> > # A string.
> > logs = "date=2012-11-28 time=21:14:59"
> >
> > # Match with named groups.
> > m =
> >
> re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))",
> > logs)
> >
> > # print
> > print m.groupdict()
> >
> > Output:
> > 
> >
> > {'date': '2012-11-28', 'datetime': 'date=2012-11-28 time=21:14:59',
> 'time':
> > '21:14:59'}
> >
> >
> > Required output :
> > ==
> >
> > {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time':
> > '21:14:59'}
> >
> > need help to correct the below regex
> >
> > (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))"
> >
> > so that It will have : 'datetime': '2012-11-28 21:14:59' instead of
> > 'datetime': 'date=2012-11-28 time=21:14:59'
> >
> > any help would be greatly appreciated
>
> Why do you need to do this in a single Regex? Can't you just "
> ".join(..) the date and time?
>

I using another third party python script. It takes the regex from
configuration file. I can't write any code. I have to do all this in single
regex.



Thanks
Mohan L
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: grimace: a fluent regular expression generator in Python

2013-07-16 Thread Anders J. Munch

Ben Last wrote:

north_american_number_re = (RE().start

.literal('(').followed_by.exactly(3).digits.then.literal(')')
 
.then.one.literal("-").then.exactly(3).digits

.then.one.dash.followed_by.exactly(4).digits.then.end
 .as_string())


Very cool.  It's a bit verbose for my taste, and I'm not sure how well it will 
cope with nested structure.


Here's my take on what readable regexps could look like:

north_american_number_re = RE.compile(r"""
^
"(" digit{3} ")"  # And why shouldn't a regexp
"-" digit{3}  # include en embedded comment?
"-" digit{4}
$
""")

The problem with Perl-style regexp notation isn't so much that it's terse - it's 
that the syntax is irregular (sic) and doesn't follow modern principles for 
lexical structure in computer languages.  You can get a long way just by 
ignoring whitespace, putting literals in quotes and allowing embedded comments.


Setting the re.VERBOSE flag achieves two out of three, so you can write:

north_american_number_re = RE.compile(r"""
^
( \d{3} )   # Definite improvement, though I really miss putting
- \d{3} # literals in quotes.
- \d{4}
$
""")

It's too bad re.VERBOSE isn't the default.

regards, Anders

--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this a bug?

2013-07-16 Thread Jack Bates

On 15/07/13 09:13 AM, Joshua Landau wrote:

On 15 July 2013 16:50, Jack Bates  wrote:

Hello,

Is the following code supposed to be an UnboundLocalError?
Currently it assigns the value 'bar' to the attribute baz.foo

foo = 'bar'
class baz:
   foo = foo


If so, then no. Assignments inside class bodies are special-cased in
Python. This is because all assignments refer to properties of "self"
on the LHS but external things too on the RHS. This is why you can do
"def x(): ..." instead of "def self.x(): ..." or some other weird
thing. There's also some extra special stuff that goes on.

In order to make this an UnboundLocalError, lots of dramatic and
unhelpful changes would have to take place, hence the current
behaviour. The current behaviour is useful, too.


Ah, thank you Chris Angelico for explaining how this is like what 
happens with default arguments to a function and Joshua Landau for 
pointing out how assignments inside class bodies refer to properties of 
"self" on the LHS. It makes sense now. Only I'm struggling to find where 
the behavior is defined in the language reference. Can someone please 
help point me to where in the language reference this is discussed? I've 
been hunting through the section on naming and binding:



http://docs.python.org/3/reference/executionmodel.html#naming-and-binding
--
http://mail.python.org/mailman/listinfo/python-list


Re: help on python regular expression named group

2013-07-16 Thread MRAB

On 16/07/2013 11:18, Mohan L wrote:




On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau mailto:[email protected]>> wrote:

On 16 July 2013 07:55, Mohan L mailto:[email protected]>> wrote:
 >
 > Dear All,
 >
 > Here is my script :
 >
 > #!/usr/bin/python
 > import re
 >
 > # A string.
 > logs = "date=2012-11-28 time=21:14:59"
 >
 > # Match with named groups.
 > m =
 >
re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))",
 > logs)
 >
 > # print
 > print m.groupdict()
 >
 > Output:
 > 
 >
 > {'date': '2012-11-28', 'datetime': 'date=2012-11-28
time=21:14:59', 'time':
 > '21:14:59'}
 >
 >
 > Required output :
 > ==
 >
 > {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time':
 > '21:14:59'}
 >
 > need help to correct the below regex
 >
 > (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))"
 >
 > so that It will have : 'datetime': '2012-11-28 21:14:59' instead of
 > 'datetime': 'date=2012-11-28 time=21:14:59'
 >
 > any help would be greatly appreciated

Why do you need to do this in a single Regex? Can't you just "
".join(..) the date and time?


I using another third party python script. It takes the regex from
configuration file. I can't write any code. I have to do all this in
single regex.


A capture group captures a single substring.

What you're asking is for it to with capture 2 substrings (the date and
the time) and then join them together, or capture 1 substring and then
remove part of it.

I don't know of _any_ regex implementation that lets you do that.

--
http://mail.python.org/mailman/listinfo/python-list


Re: help on python regular expression named group

2013-07-16 Thread Joshua Landau
On 16 July 2013 16:38, MRAB  wrote:
> On 16/07/2013 11:18, Mohan L wrote:
>>
>> I using another third party python script. It takes the regex from
>> configuration file. I can't write any code. I have to do all this in
>> single regex.
>>
> A capture group captures a single substring.
>
> What you're asking is for it to with capture 2 substrings (the date and
> the time) and then join them together, or capture 1 substring and then
> remove part of it.
>
> I don't know of _any_ regex implementation that lets you do that.

If MRAB is correct, there is one straw-clutching method. If in the
configuration you pass a regex *object* rather than a regex string,
you could duck-type as a regex object. This might sound far-fetched
but it's happened once to me.

Otherwise, good luck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Floating point minimum and maximum exponent values

2013-07-16 Thread Serhiy Storchaka

16.07.13 15:04, Chris Angelico написав(ла):

Piece of extreme oddity, this.


help(sys.float_info)

... lots of other info ...
  |  max_exp
  |  DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
  |
  |  min_exp
  |  DBL_MIN_EXP -- minimum int e such that radix**(e-1) is a
normalized float
...

So it's technically correct. Followup question: Why is it off by one?


sys.float_info.max == sys.float_info.radix**sys.float_info.max_exp - 
sys.float_info.radix**(sys.float_info.max_exp-sys.float_info.mant_dig)



--
http://mail.python.org/mailman/listinfo/python-list


Help with pygame

2013-07-16 Thread Daniel Kersgaard
I'm having a little trouble, tried Googling it, but to no avail. Currently, I'm 
working on making a snake game, however I'm stuck on a simple border. The only 
thing I need help with is when you run the program, the bottom right corner of 
the border is missing. I'm not sure why. And I know I'm no where near finished, 
I've simply got a wall, and a randomly placed piece of food. A classmate 
mentioned increasing the BLOCK_SIZE variable in the width for loop, but that 
simply moved the top and bottom walls over one pixel. I'm stuck, and any help 
would be greatly appreciated! And I'm not sure if there is a better or easier 
way of providing my code, so I just pasted it below.

import pygame as pg
import random as rnd
import sys

#define colors using rgb
RED= (255,0,0)
RED_DARK   = (150,0,0)
GREEN  = (0,255,0)
GREEN_DARK = (0,150,0)
BLUE   = (0,0,255)
BLUE_DARK  = (0,0,150)
WHITE  = (255,255,255)
BLACK  = (0,0,0)

#block size
BLOCK_SIZE = 30


#play area and game speed
WIDTH = 25
HEIGHT = 25
SPEED = 8
SPEED_TICK =2
SPEED_NIC = 5
SHORT = 12
LONG = 1


UP = 0
DOWN = 1
LEFT = 2
RIGHT = 3


class food:

#class constructor
def __init__(self, surface, min_xcord, max_xcord, min_ycord, max_ycord):
self.surface = surface
self.min_xcord = min_xcord
self.max_xcord = max_xcord
self.min_ycord = min_ycord
self.max_ycord = max_ycord

self.apple = pg.Surface((BLOCK_SIZE, BLOCK_SIZE))
self.apple.set_alpha(255)
self.apple.fill(RED)
#get food position
def getPosition(self):
return (rnd.randint(self.min_xcord, self.max_xcord), 
rnd.randint(self.min_ycord, self.max_ycord))

#draw the food on the play area
def draw(self):
position = self.getPosition()

self.surface.blit(self.apple, (position[0] * BLOCK_SIZE, position[1] * 
BLOCK_SIZE))

def drawWalls(surface):

# create wall block
wallblock = pg.Surface((BLOCK_SIZE, BLOCK_SIZE))
wallblock.set_alpha(255)
wallblock.fill(BLUE)

#left and right walls
for y in range(HEIGHT):
surface.blit(wallblock, (0, y * BLOCK_SIZE))
surface.blit(wallblock, (WIDTH * BLOCK_SIZE, y * BLOCK_SIZE))

for x in range(WIDTH):
surface.blit(wallblock, (x * BLOCK_SIZE, 0))
surface.blit(wallblock, (x * BLOCK_SIZE, HEIGHT * BLOCK_SIZE))

pg.display.flip()

def main():

#initalize pygame
pg.init()

#initalize the main screen, screen is 'pygame.Surface'
screen = pg.display.set_mode(((WIDTH + 1) * BLOCK_SIZE, (HEIGHT + 1) * 
BLOCK_SIZE))
screen.fill(BLACK)

drawWalls(screen)

myfood = food(screen, 1, 24, 1, 24)
myfood.draw()

pg.display.flip()
  

main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this a bug?

2013-07-16 Thread Ian Kelly
On Tue, Jul 16, 2013 at 9:25 AM, Jack Bates  wrote:
> Ah, thank you Chris Angelico for explaining how this is like what happens
> with default arguments to a function and Joshua Landau for pointing out how
> assignments inside class bodies refer to properties of "self" on the LHS. It
> makes sense now. Only I'm struggling to find where the behavior is defined
> in the language reference. Can someone please help point me to where in the
> language reference this is discussed? I've been hunting through the section
> on naming and binding:
>
> http://docs.python.org/3/reference/executionmodel.html#naming-and-binding

The documentation appears to be wrong.  It says:

"""
If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block. This can lead to errors when a name is used within a
block before it is bound. This rule is subtle. Python lacks
declarations and allows name binding operations to occur anywhere
within a code block. The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.
"""

But this only applies to function blocks, not the general case.  In
general, I believe it is more accurate to say that a variable is local
to the block if its name is found in the locals() dict.  That normally
won't be true until the variable has been bound.  Any references prior
to that will look for a global variable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with pygame

2013-07-16 Thread Chris Angelico
On Wed, Jul 17, 2013 at 3:29 AM, Daniel Kersgaard
 wrote:
> def drawWalls(surface):
>
> #left and right walls
> for y in range(HEIGHT):
> surface.blit(wallblock, (0, y * BLOCK_SIZE))
> surface.blit(wallblock, (WIDTH * BLOCK_SIZE, y * BLOCK_SIZE))
>
> for x in range(WIDTH):
> surface.blit(wallblock, (x * BLOCK_SIZE, 0))
> surface.blit(wallblock, (x * BLOCK_SIZE, HEIGHT * BLOCK_SIZE))

Hm. I'm not entirely sure as I don't have pygame to test your code on,
but this strikes me as odd: you're blitting the x loop once for every
iteration of the y loop. Shouldn't the two loops be at the same
indentation?

I think you perhaps want to offset one of the lines. Currently, you're
running x from 0 up, and y from 0 up, so you're drawing the (0,0) cell
twice. If you add 1 to one of them, you should be able to draw all
four walls correctly. Alternatively, leave this as it is, and just add
one more draw at (WIDTH, HEIGHT) to fill in the last square.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with pygame

2013-07-16 Thread Daniel Kersgaard
I didn't even think about that! I added one more draw and it worked like a 
charm, thanks so much! I'm not sure why I couldn't think of that!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding other people's code

2013-07-16 Thread David M Chess
> Literally any idea will help, pen and paper, printing off all the code 
and doing some sort of highlighting session - anything! 
> I keep reading bits of code and thinking "well where the hell has that 
been defined and what does it mean" to find it was inherited from 3 
modules up the chain. 
> I really need to get a handle on how exactly all this slots together! 
Any techniques,tricks or methodologies that people find useful would be 
much appreciated.

I'd highly recommend Eclipse with PyDev, unless you have some strong 
reason not to.  That's what I use, and it saves pretty much all of those 
"what's this thing?" problems, as well as lots of others...

DC
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with pygame

2013-07-16 Thread Dave Angel

On 07/16/2013 01:29 PM, Daniel Kersgaard wrote:

I'm having a little trouble, tried Googling it, but to no avail. Currently, I'm 
working on making a snake game, however I'm stuck on a simple border. The only 
thing I need help with is when you run the program, the bottom right corner of 
the border is missing. I'm not sure why. And I know I'm no where near finished, 
I've simply got a wall, and a randomly placed piece of food. A classmate 
mentioned increasing the BLOCK_SIZE variable in the width for loop, but that 
simply moved the top and bottom walls over one pixel. I'm stuck, and any help 
would be greatly appreciated! And I'm not sure if there is a better or easier 
way of providing my code, so I just pasted it below.

import pygame as pg
import random as rnd
import sys

#define colors using rgb
RED= (255,0,0)
RED_DARK   = (150,0,0)
GREEN  = (0,255,0)
GREEN_DARK = (0,150,0)
BLUE   = (0,0,255)
BLUE_DARK  = (0,0,150)
WHITE  = (255,255,255)
BLACK  = (0,0,0)

#block size
BLOCK_SIZE = 30


#play area and game speed
WIDTH = 25
HEIGHT = 25
SPEED = 8
SPEED_TICK =2
SPEED_NIC = 5
SHORT = 12
LONG = 1


UP = 0
DOWN = 1
LEFT = 2
RIGHT = 3


class food:

 #class constructor
 def __init__(self, surface, min_xcord, max_xcord, min_ycord, max_ycord):
 self.surface = surface
 self.min_xcord = min_xcord
 self.max_xcord = max_xcord
 self.min_ycord = min_ycord
 self.max_ycord = max_ycord

 self.apple = pg.Surface((BLOCK_SIZE, BLOCK_SIZE))
 self.apple.set_alpha(255)
 self.apple.fill(RED)
 #get food position
 def getPosition(self):
 return (rnd.randint(self.min_xcord, self.max_xcord), 
rnd.randint(self.min_ycord, self.max_ycord))

 #draw the food on the play area
 def draw(self):
 position = self.getPosition()

 self.surface.blit(self.apple, (position[0] * BLOCK_SIZE, position[1] * 
BLOCK_SIZE))

def drawWalls(surface):

 # create wall block
 wallblock = pg.Surface((BLOCK_SIZE, BLOCK_SIZE))
 wallblock.set_alpha(255)
 wallblock.fill(BLUE)

 #left and right walls
 for y in range(HEIGHT):
 surface.blit(wallblock, (0, y * BLOCK_SIZE))
 surface.blit(wallblock, (WIDTH * BLOCK_SIZE, y * BLOCK_SIZE))

 for x in range(WIDTH):
 surface.blit(wallblock, (x * BLOCK_SIZE, 0))
 surface.blit(wallblock, (x * BLOCK_SIZE, HEIGHT * BLOCK_SIZE))



Two things wrong here.  One is that your lines are zero based and 
therefore they don't fill the far end, and other is that you draw the 
horizontal lines many times.


#left and right walls
for y in range(HEIGHT):
surface.blit(wallblock, (0, y * BLOCK_SIZE))
surface.blit(wallblock, (WIDTH * BLOCK_SIZE, (y+1) * BLOCK_SIZE))

#top and bottom walls
wallblock.fill(GREEN) #REMOVE ME
for x in range(WIDTH):
surface.blit(wallblock, ((x+1) * BLOCK_SIZE, 0))
surface.blit(wallblock, (x * BLOCK_SIZE, HEIGHT * BLOCK_SIZE))

What I did here was to (temporarily) color the top and bottom walls 
GREEN instead of BLUE, and you can better see what happens.  I also 
fixed two of the walls to start at 1 instead of zero.  And unindented 
the latter code so it only displays once.


Once you see what it's doing, you probably want to remove the line that 
I labelled  "REMOVE ME"




 pg.display.flip()

def main():

 #initalize pygame
 pg.init()

 #initalize the main screen, screen is 'pygame.Surface'
 screen = pg.display.set_mode(((WIDTH + 1) * BLOCK_SIZE, (HEIGHT + 1) * 
BLOCK_SIZE))
 screen.fill(BLACK)

 drawWalls(screen)

 myfood = food(screen, 1, 24, 1, 24)
 myfood.draw()

 pg.display.flip()


main()




--
DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: GeoIP2 for retrieving city and region ?

2013-07-16 Thread Νικόλας

Στις 14/7/2013 1:57 πμ, ο/η Michael Torrie έγραψε:

On 07/13/2013 12:23 PM, Νικόλας wrote:

Do you know a way of implementing anyone of these methods to a script?


Yes.  Modern browsers all support a location API in the browser for
javascript.  See this:

http://diveintohtml5.info/geolocation.html



Lest say i embed inside my index.html the Javascript Geo Code.

Is there a way to pass Javascript's outcome to my Python cgi script somehow?

Can Javascript and Python Cgi somehow exchnage data?
--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list


Re: GeoIP2 for retrieving city and region ?

2013-07-16 Thread Joel Goldstick
On Tue, Jul 16, 2013 at 3:43 PM, Νικόλας  wrote:

> Στις 14/7/2013 1:57 πμ, ο/η Michael Torrie έγραψε:
>
>> On 07/13/2013 12:23 PM, Νικόλας wrote:
>>
>>> Do you know a way of implementing anyone of these methods to a script?
>>>
>>
>> Yes.  Modern browsers all support a location API in the browser for
>> javascript.  See this:
>>
>> http://diveintohtml5.info/**geolocation.html
>>
>>
> Lest say i embed inside my index.html the Javascript Geo Code.
>
> Is there a way to pass Javascript's outcome to my Python cgi script
> somehow?
>
> Can Javascript and Python Cgi somehow exchnage data?
>
> --
> What is now proved was at first only imagined!
> --
> http://mail.python.org/**mailman/listinfo/python-list
>

Learn about ajax


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Homework help requested (not what you think!)

2013-07-16 Thread John Ladasky
Hi folks,

No, I'm not asking for YOU to help ME with a Python homework assignment!

Previously, I mentioned that I was starting to teach my son Python.  

https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ

He just took a course at his high school called Web Technology and Design.  
They had the students use tools like Dream Weaver, but they also hand-coded 
some HTML and JavaScript.  He has a little experience.  I am building on it.

Well, a few other parents caught wind of what I was doing with my son, and they 
asked me whether I could tutor their kids, too.  I accepted the jobs (for pay, 
actually).  

The kids all claim to be interested.  They all want to write the next great 3D 
video game.  Thus, I'm a little surprised that the kids don't actually try to 
sit down and code without me prompting them.  I think that they're disappointed 
when I show them how much they have to understand just to write a program that 
plays Tic Tac Toe.

Where programming is concerned, I'm an autodidact.  I started programming when 
I was twelve, with little more guidance than the Applesoft Basic manual and the 
occasional issue of Byte Magazine.  I hacked away.  Over the years, I have 
acquired a working knowledge of BASIC, 6502 assembly language, Pascal, C, and 
finally Python (my favorite).  If I knew how to impart a love of 
experimentation to my students, I would do that.

One kid looks like he's ready to forge ahead.  In the mean time, one parent has 
recognized his son's lack of independence, and has asked me to assign 
programming homework.  I hope it doesn't kill the kid's enthusiasm, but I'm 
willing to try it.

So, what I am seeking are suggestions for programming assignments that I can 
give to brand-new students of Python.  Please keep in mind that none of them 
are even up to the task of a simple algorithm like Bubble Sort -- at least, not 
yet.

Many thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this a bug?

2013-07-16 Thread Terry Reedy

On 7/16/2013 2:04 PM, Ian Kelly wrote:


The documentation appears to be wrong.  It says:

"""
If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block. This can lead to errors when a name is used within a
block before it is bound. This rule is subtle. Python lacks
declarations and allows name binding operations to occur anywhere
within a code block. The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.
"""

I agree that there is a problem.
http://bugs.python.org/issue18478


But this only applies to function blocks, not the general case.  In
general, I believe it is more accurate to say that a variable is local
to the block if its name is found in the locals() dict.


That is not true for functions, where names are classified as local 
*before* being added to the locals dict. (Actually, names are usually 
not added to the locals dict until locals() is called to update it).


It would be better to say that names are local if found in the local 
namespace, and consider that names are added to a function local 
namespace (which is *not* the local() dict) when classified (before 
being bound), but otherwise only when bound.



  That normally

won't be true until the variable has been bound.  Any references prior
to that will look for a global variable.


At module scope, globals() == locals(). But feel free to suggest a 
different fix for the issue than I did.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread David Hutto
You have to utilize a set curriculum to teach. Look at several books like
Dive Into Python, and such, then work with the student on an individualized
project for each one. For 3D you go with pygame and trig, or go with
Blender's python API
 or matplotlib. Just at first show the basic types of data, that is what
I'd suggest, like mutable immutable, lists tuples, and dictionaries to get
the hang of data containment that will probably move on to database
management, and loopiing/iterating through data, or updating a GUI.
Further teaching is moving on to what the student is trying to accomplish.

HTH


On Tue, Jul 16, 2013 at 6:43 PM, John Ladasky wrote:

> Hi folks,
>
> No, I'm not asking for YOU to help ME with a Python homework assignment!
>
> Previously, I mentioned that I was starting to teach my son Python.
>
> https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ
>
> He just took a course at his high school called Web Technology and Design.
>  They had the students use tools like Dream Weaver, but they also
> hand-coded some HTML and JavaScript.  He has a little experience.  I am
> building on it.
>
> Well, a few other parents caught wind of what I was doing with my son, and
> they asked me whether I could tutor their kids, too.  I accepted the jobs
> (for pay, actually).
>
> The kids all claim to be interested.  They all want to write the next
> great 3D video game.  Thus, I'm a little surprised that the kids don't
> actually try to sit down and code without me prompting them.  I think that
> they're disappointed when I show them how much they have to understand just
> to write a program that plays Tic Tac Toe.
>
> Where programming is concerned, I'm an autodidact.  I started programming
> when I was twelve, with little more guidance than the Applesoft Basic
> manual and the occasional issue of Byte Magazine.  I hacked away.  Over the
> years, I have acquired a working knowledge of BASIC, 6502 assembly
> language, Pascal, C, and finally Python (my favorite).  If I knew how to
> impart a love of experimentation to my students, I would do that.
>
> One kid looks like he's ready to forge ahead.  In the mean time, one
> parent has recognized his son's lack of independence, and has asked me to
> assign programming homework.  I hope it doesn't kill the kid's enthusiasm,
> but I'm willing to try it.
>
> So, what I am seeking are suggestions for programming assignments that I
> can give to brand-new students of Python.  Please keep in mind that none of
> them are even up to the task of a simple algorithm like Bubble Sort -- at
> least, not yet.
>
> Many thanks!
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding other people's code

2013-07-16 Thread David Hutto
Any program, to me, is just like speaking english. The class, or function
name might not fully mesh with what your cognitive structure assumes it to
be.read through the imports first, and see the classes and functions come
alive with experience comes intuition of what it does, and the instances
that can be utilized with it. The term RTFM, and google always comes to
mind as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GeoIP2 for retrieving city and region ?

2013-07-16 Thread alex23

On 16/07/2013 12:48 PM, Michael Torrie wrote:

I've posted a link to detailed information on this no less than three
times, yet Nikos has not read any of it, sadly.


Just a quick reminder for everyone:

"Ferrous Cranus is utterly impervious to reason, persuasion and new 
ideas, and when engaged in battle he will not yield an inch in his 
position regardless of its hopelessness. Though his thrusts are 
decisively repulsed, his arguments crushed in every detail and his 
defenses demolished beyond repair he will remount the same attack again 
and again with only the slightest variation in tactics."


http://www.politicsforum.org/images/flame_warriors/flame_62.php

--
http://mail.python.org/mailman/listinfo/python-list


Re: Help with pygame

2013-07-16 Thread Terry Reedy

On 7/16/2013 1:29 PM, Daniel Kersgaard wrote:

I'm having a little trouble, tried Googling it, but to no avail.

> Currently, I'm working on making a snake game, however
> I'm stuck on a simple border.

To give a variation of the other answers, it would be easier if you drew 
the four sides more symmetrically, in something like the following order:


top (including both top corners)
bottom (including both bottom corners)
left (omitting both left corners)
right (omitting both right corners)

Including the corners with the sides instead of the top and bottom would 
be okay. So would be including one (different) corner with each line. 
Just pick a scheme that does each one once. Using the above, if 0, 0 and 
X, Y are upper left and bottom right corners,

and we use inclusive ranges:

top: 0, 0 to X, 0  # includes corners
bot: 0, Y to X, Y  # includes corners
lef: 0, 1 to 0, Y-1   # excludes corners
rit: X, 1 to X-1, Y-1 # excludes corners

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread Chris Angelico
On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
 wrote:
> I think that they're disappointed when I show them how much they have to 
> understand just to write a program that plays Tic Tac Toe.


The disillusionment of every novice programmer, I think. It starts out
as "I want to learn programming and make a game". Real programming is
more like "I can automate mundane tasks", which doesn't sound half as
exciting. But this is why I'm dubious of programming courses that
actually try to hold onto the "let's make a game" concept, because the
students are likely to get a bit of a let-down on realizing that it
really doesn't work that easily ("this is a two-week course, at the
end of it I should have written the next 
for all my friends").

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread Joel Goldstick
On Tue, Jul 16, 2013 at 8:40 PM, Chris Angelico  wrote:

> On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
>  wrote:
> > I think that they're disappointed when I show them how much they have to
> understand just to write a program that plays Tic Tac Toe.
>
>
> The disillusionment of every novice programmer, I think. It starts out
> as "I want to learn programming and make a game". Real programming is
> more like "I can automate mundane tasks", which doesn't sound half as
> exciting. But this is why I'm dubious of programming courses that
> actually try to hold onto the "let's make a game" concept, because the
> students are likely to get a bit of a let-down on realizing that it
> really doesn't work that easily ("this is a two-week course, at the
> end of it I should have written the next 
> for all my friends").
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>

There is a book : http://inventwithpython.com/  *Invent Your Own Computer
Games with Python*
which claims to teach people to program games in python.  I haven't read
it, but it seems to be for beginning programmers.  Take a look.. Maybe it
would work for your kids.  It says its for kids younger than high school,
but it claims to be for all ages.  It does cover the turf your gang seems
most interested in.  Other positives -- its free online.  so no
investment.  And it introduces the concept of open source which is really a
key to a large segment of the whole software world, so that gives another
teaching moment

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GeoIP2 for retrieving city and region ?

2013-07-16 Thread Chris Angelico
On Wed, Jul 17, 2013 at 10:51 AM, Dennis Lee Bieber
 wrote:
> On Tue, 16 Jul 2013 22:43:35 +0300, ???  declaimed
> the following:
>
>>
>>Lest say i embed inside my index.html the Javascript Geo Code.
>>
>>Is there a way to pass Javascript's outcome to my Python cgi script somehow?
>>
>>Can Javascript and Python Cgi somehow exchnage data?
>
> Using plain CGI is going to be painful -- since /everything/ is 
> handled
> a whole new page request. You would have to handle session cookies, etc.
>
> Your "index.html" would attempt to run the JavaScript (note that some
> users may have JavaScript turned off -- how will you handle that), if it
> gets information it would have to do a "GET index2.html?lat=xxx?long=yyy"
> or something similar, which will result in a new page load on the user --
> hopefully with a cookie set so you know NOT to run the geolocation code on
> subsequent pages.
>
> AJAX is a process to allow JavaScript on the browser to interact with 
> a
> server (using XML data structures), and likely use DOM operations in the
> browser (and the last time I did something on this nature, I had to have
> different code for Internet Explorer vs Firefox, and don't know of
> Chrome/Opera share one of the others calls) to make changes on the web page
> without doing a full submit/render operation

AJAX changes the client end, but not the server (well, you might
change the server's output format to make it easier, but it's not
essential). So you *can* still use the CGI that you're familiar with.

For reference, Firefox/Chrome/Opera/Safari are all pretty much
identical for this sort of work; and the recent IEs (9, I think, and
10) are following them too. There are trivial differences, but for the
basics, it's possible to support IE8+, Chrome, Firefox back as far as
the Iceweasel from Debian Squeeze (I think that's Ff 3.5), and so on,
all from the same code. No per-browser checks required.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


tkinter redraw rates

2013-07-16 Thread fronagzen
Hm. So I've written a GUI in tkinter. I've found two performance issues, I was 
hoping someone could point me in the right direction.

Firstly, I'm using an image as a border, namely:

from tkinter import *
from tkinter import ttk

root_frame = Tk()
root_frame.configure(background = 'black')

img1 = PhotoImage("frameBorder", data="""
   R0lGODlhQABAAMIHABkfLTMrMzMrZjNVZjNVmUFchywAQABD9A
   i63P4wykmrvTjrzbu/hlGMZGmeaBp2QmgIQSzPdG3fbShk+u3/wFkONAgaj7aBoWIo
   Ip9P5aQFrSJfkpd1C2xluWDfEhIKm2mrh/bM9qrZ8MDYYYiz54263Yxn6PdgfQt/gF
   uCCoSFVYcAiYpPjI6PR5GTVpWWUJiZV2SckJ6flKGiQZulP6eoN6qrNa2uM7CxMbO0
   trG4rrqrvKi+pcCiwp/EnMaZyJbKk8yPzorQhdKA1HuRMLQ0bnSSuYyN2mhZ2eLcD1
   TicjtZ3sPgfu7J8A0EBOWfQxg5a4/87BtcCBxIsKDBgh8SKlzIsKHDhxAVJgAAOw==""")

style = ttk.Style()
style.element_create("RoundedFrame", "image", "frameBorder",
  border=30, sticky="nsew")
style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])

input_frame = ttk.Frame(root_frame,
style = "RoundedFrame",
padding = 15,
width = 640,
height = 180
)
input_frame.pack(padx=10, pady=10)

This works, yes, but is annoyingly laggy on an older computer when I try to 
move the window around. I figure it's because the program has to keep redrawing 
the image border when dragged around, and is exacerbated by the fact that I 
have two of the imageborder frames in my application. How can I remedy this? 
I've tried using a hard-drawn image on a Canvas instead of the image border, 
but it's suboptimal because that prevents resizing the window.


The other performance issue I've found is that when the logic is running, the 
app doesn't redraw. Ordinarily this would be acceptable, but as part of my 
program, it loads data from a website, and during the load, the window 
completely freezes up and doesn't respond until the download is done; as I 
understand it, tkinter doesn't redraw until it is forced to by .update() or 
control is given back to the mainloop. How can I force a more frequent redraw 
rate?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread David Hutto
I've had a similar problem with a tkinter/3D app. right now I'm looking
toward Blender, and the Python API, but there is also wxpython, and the
usual python's library gtk.

There is also matplotlib with the ion window. but, I, personally, am going
to go with Blender, and Python API, with maybe a few other imports, and if
ctypes...includes if I remember C correctly without reference at this time
the usages of returned data type values
for you to utilize.


But for the plainer answer I'd go with wxpython if you decide not to use a
different library, and for a GDK, Blend


On Tue, Jul 16, 2013 at 8:57 PM,  wrote:

> Hm. So I've written a GUI in tkinter. I've found two performance issues, I
> was hoping someone could point me in the right direction.
>
> Firstly, I'm using an image as a border, namely:
>
> from tkinter import *
> from tkinter import ttk
>
> root_frame = Tk()
> root_frame.configure(background = 'black')
>
> img1 = PhotoImage("frameBorder", data="""
>R0lGODlhQABAAMIHABkfLTMrMzMrZjNVZjNVmUFchywAQABD9A
>i63P4wykmrvTjrzbu/hlGMZGmeaBp2QmgIQSzPdG3fbShk+u3/wFkONAgaj7aBoWIo
>Ip9P5aQFrSJfkpd1C2xluWDfEhIKm2mrh/bM9qrZ8MDYYYiz54263Yxn6PdgfQt/gF
>uCCoSFVYcAiYpPjI6PR5GTVpWWUJiZV2SckJ6flKGiQZulP6eoN6qrNa2uM7CxMbO0
>trG4rrqrvKi+pcCiwp/EnMaZyJbKk8yPzorQhdKA1HuRMLQ0bnSSuYyN2mhZ2eLcD1
>
>  TicjtZ3sPgfu7J8A0EBOWfQxg5a4/87BtcCBxIsKDBgh8SKlzIsKHDhxAVJgAAOw==""")
>
> style = ttk.Style()
> style.element_create("RoundedFrame", "image", "frameBorder",
>   border=30, sticky="nsew")
> style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])
>
> input_frame = ttk.Frame(root_frame,
> style = "RoundedFrame",
> padding = 15,
> width = 640,
> height = 180
> )
> input_frame.pack(padx=10, pady=10)
>
> This works, yes, but is annoyingly laggy on an older computer when I try
> to move the window around. I figure it's because the program has to keep
> redrawing the image border when dragged around, and is exacerbated by the
> fact that I have two of the imageborder frames in my application. How can I
> remedy this? I've tried using a hard-drawn image on a Canvas instead of the
> image border, but it's suboptimal because that prevents resizing the window.
>
>
> The other performance issue I've found is that when the logic is running,
> the app doesn't redraw. Ordinarily this would be acceptable, but as part of
> my program, it loads data from a website, and during the load, the window
> completely freezes up and doesn't respond until the download is done; as I
> understand it, tkinter doesn't redraw until it is forced to by .update() or
> control is given back to the mainloop. How can I force a more frequent
> redraw rate?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread Chris Angelico
On Wed, Jul 17, 2013 at 10:53 AM, Joel Goldstick
 wrote:
> There is a book : http://inventwithpython.com/  Invent Your Own Computer
> Games with Python
> which claims to teach people to program games in python.  I haven't read it,
> but it seems to be for beginning programmers.  Take a look.. Maybe it would
> work for your kids.

Not my siblings specifically, but I've seen this happen elsewhere quite a bit.

Thing is, they still won't be making the next Call of Duty Black Ops,
or Alice: Madness Returns, or even the next Angry Birds. It's like
looking at the roads and how car manufacturers produce things that run
from here to Sydney, and then learning how to build a go-kart with
wooden wheels - strong disappointment in the scale of achievement.
Which is a pity, because that go-kart can be a lot of fun; the novice
programmer has to get past that disappointment and discover the other
fun aspects of coding, like the ability to improve your own
environment. (At work, one of my most useful oddments of code is a log
tailing system that runs on each of N remote servers and effectively
runs "tail -F foo.log" for each of M log files, tags the lines with
the hostname and log file name, and sends it to a single display on my
computer. Makes my job easier to the extent that I probably paid off
the time investment within a week, but it's hardly glamorous stuff.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread David Hutto
On Tue, Jul 16, 2013 at 9:32 PM, David Hutto  wrote:

> I've had a similar problem with a tkinter/3D app. right now I'm looking
> toward Blender, and the Python API, but there is also wxpython, and the
> usual python's library gtk.
>
> There is also matplotlib with the ion window. but, I, personally, am going
> to go with Blender, and Python API, with maybe a few other imports, and if
> ctypes...includes if I remember C correctly without reference at this time
> the usages of returned data type values
> for you to utilize.
>
>
> But for the plainer answer I'd go with wxpython if you decide not to use a
> different library, and for a GDK, Blend
>
>
> On Tue, Jul 16, 2013 at 8:57 PM,  wrote:
>
>> Hm. So I've written a GUI in tkinter. I've found two performance issues,
>> I was hoping someone could point me in the right direction.
>>
>> Firstly, I'm using an image as a border, namely:
>>
>> from tkinter import *
>> from tkinter import ttk
>>
>> root_frame = Tk()
>> root_frame.configure(background = 'black')
>>
>> img1 = PhotoImage("frameBorder", data="""
>>R0lGODlhQABAAMIHABkfLTMrMzMrZjNVZjNVmUFchywAQABD9A
>>i63P4wykmrvTjrzbu/hlGMZGmeaBp2QmgIQSzPdG3fbShk+u3/wFkONAgaj7aBoWIo
>>Ip9P5aQFrSJfkpd1C2xluWDfEhIKm2mrh/bM9qrZ8MDYYYiz54263Yxn6PdgfQt/gF
>>uCCoSFVYcAiYpPjI6PR5GTVpWWUJiZV2SckJ6flKGiQZulP6eoN6qrNa2uM7CxMbO0
>>trG4rrqrvKi+pcCiwp/EnMaZyJbKk8yPzorQhdKA1HuRMLQ0bnSSuYyN2mhZ2eLcD1
>>
>>  TicjtZ3sPgfu7J8A0EBOWfQxg5a4/87BtcCBxIsKDBgh8SKlzIsKHDhxAVJgAAOw==""")
>>
>> style = ttk.Style()
>> style.element_create("RoundedFrame", "image", "frameBorder",
>>   border=30, sticky="nsew")
>> style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])
>>
>> input_frame = ttk.Frame(root_frame,
>> style = "RoundedFrame",
>> padding = 15,
>> width = 640,
>> height = 180
>> )
>> input_frame.pack(padx=10, pady=10)
>>
>> This works, yes, but is annoyingly laggy on an older computer when I try
>> to move the window around. I figure it's because the program has to keep
>> redrawing the image border when dragged around, and is exacerbated by the
>> fact that I have two of the imageborder frames in my application. How can I
>> remedy this? I've tried using a hard-drawn image on a Canvas instead of the
>> image border, but it's suboptimal because that prevents resizing the window.
>>
>>
>> The other performance issue I've found is that when the logic is running,
>> the app doesn't redraw. Ordinarily this would be acceptable, but as part of
>> my program, it loads data from a website, and during the load, the window
>> completely freezes up and doesn't respond until the download is done; as I
>> understand it, tkinter doesn't redraw until it is forced to by .update() or
>> control is given back to the mainloop. How can I force a more frequent
>> redraw rate?
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> I've had a similar problem with a tkinter/3D app. right now I'm looking
> toward Blender, and the Python API, but there is also wxpython, and the
> usual python's library gtk.
>
> There is also matplotlib with the ion window. but, I, personally, am going
> to go with Blender, and Python API, with maybe a few other imports, and if
> ctypes...includes if I remember C correctly without reference at this time
> the usages of returned data type values
> for you to utilize.
>
>
> But for the plainer answer I'd go with wxpython if you decide not to use a
> different library, and for a GDK, Blender.
>



-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread Dave Angel

On 07/16/2013 08:57 PM, [email protected] wrote:

Hm. So I've written a GUI in tkinter. I've found two performance issues, I was 
hoping someone could point me in the right direction.

Firstly, I'm using an image as a border, namely:





This works, yes, but is annoyingly laggy on an older computer when I try to 
move the window around. I figure it's because the program has to keep redrawing 
the image border when dragged around, and is exacerbated by the fact that I 
have two of the imageborder frames in my application. How can I remedy this? 
I've tried using a hard-drawn image on a Canvas instead of the image border, 
but it's suboptimal because that prevents resizing the window.



This part I can't help with, as I'm not that familiar with tkinter in 
particular.  If I had to guess an approach, I'd tell you to create an 
object that represents the scaled border image, and then when it moves, 
you just reblit it.  And if/when the scale changes, you then recreate 
the object at the new scale.  Most of the time you won't be scaling.


But what that means in tkinter calls, I don't know and don't have time 
tonight to figure out.




The other performance issue I've found is that when the logic is running, the 
app doesn't redraw. Ordinarily this would be acceptable, but as part of my 
program, it loads data from a website, and during the load, the window 
completely freezes up and doesn't respond until the download is done; as I 
understand it, tkinter doesn't redraw until it is forced to by .update() or 
control is given back to the mainloop. How can I force a more frequent redraw 
rate?



Tkinter, like every other GUI I know of, is event driven.  You're not 
intended to do "logic is running" kinds of events.  Break up larger 
problems into little tasks, and daisy chain them, returning to the event 
loop after each little piece.


A second approach that works with some GUI's is to fire up the event 
loop at periodic intervals in your long function;  get it to do a few 
other events and then return to you.  This isn't recommended usually 
because it can get very messy.  And it may not even be possible in tkinter.


Third approach is to start another thread to do the "logic is running." 
 Make sure that thread never calls any GUI stuff, but just updates 
values that can be seen by the main thread and its GUI stuff.  When 
you're done, post a message to the GUI to tell it to redraw whichever 
parts are now changed.



--
DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread fronagzen
On Wednesday, July 17, 2013 9:40:15 AM UTC+8, Dave Angel wrote:
> On 07/16/2013 08:57 PM, [email protected] wrote:
> 
> > Hm. So I've written a GUI in tkinter. I've found two performance issues, I 
> > was hoping someone could point me in the right direction.
> 
> >
> 
> > Firstly, I'm using an image as a border, namely:
> 
> 
> 
>  
> 
> >
> 
> > This works, yes, but is annoyingly laggy on an older computer when I try to 
> > move the window around. I figure it's because the program has to keep 
> > redrawing the image border when dragged around, and is exacerbated by the 
> > fact that I have two of the imageborder frames in my application. How can I 
> > remedy this? I've tried using a hard-drawn image on a Canvas instead of the 
> > image border, but it's suboptimal because that prevents resizing the window.
> 
> >
> 
> 
> 
> This part I can't help with, as I'm not that familiar with tkinter in 
> 
> particular.  If I had to guess an approach, I'd tell you to create an 
> 
> object that represents the scaled border image, and then when it moves, 
> 
> you just reblit it.  And if/when the scale changes, you then recreate 
> 
> the object at the new scale.  Most of the time you won't be scaling.
> 
> 
> 
> But what that means in tkinter calls, I don't know and don't have time 
> 
> tonight to figure out.
> 
> 
> 
> >
> 
> > The other performance issue I've found is that when the logic is running, 
> > the app doesn't redraw. Ordinarily this would be acceptable, but as part of 
> > my program, it loads data from a website, and during the load, the window 
> > completely freezes up and doesn't respond until the download is done; as I 
> > understand it, tkinter doesn't redraw until it is forced to by .update() or 
> > control is given back to the mainloop. How can I force a more frequent 
> > redraw rate?
> 
> >
> 
> 
> 
> Tkinter, like every other GUI I know of, is event driven.  You're not 
> 
> intended to do "logic is running" kinds of events.  Break up larger 
> 
> problems into little tasks, and daisy chain them, returning to the event 
> 
> loop after each little piece.
> 
> 
> 
> A second approach that works with some GUI's is to fire up the event 
> 
> loop at periodic intervals in your long function;  get it to do a few 
> 
> other events and then return to you.  This isn't recommended usually 
> 
> because it can get very messy.  And it may not even be possible in tkinter.
> 
> 
> 
> Third approach is to start another thread to do the "logic is running." 
> 
>   Make sure that thread never calls any GUI stuff, but just updates 
> 
> values that can be seen by the main thread and its GUI stuff.  When 
> 
> you're done, post a message to the GUI to tell it to redraw whichever 
> 
> parts are now changed.
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

Thanks for the responses.

Yeah, I understand that tkinter isn't really designed for 'logic is running' 
style issues, but I do need to load that data, and sometimes, that can take a 
while. I am in fact experimenting with threading another process to update the 
window, yes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread Dave Angel

On 07/16/2013 09:51 PM, [email protected] wrote:

If you are going to use googlegroups, then at least bypass its worst 
bugs, like double-spacing everything it quotes.

 http://wiki.python.org/moin/GoogleGroupsPython



Yeah, I understand that tkinter isn't really designed for 'logic is running' 
style issues, but I do need to load that data, and sometimes, that can take a 
while. I am in fact experimenting

>  with threading another process to update the window, yes.
- ----




Those three words/phrases strike a real discord.

Multithreading is not the same as multiprocessing.  And you probably 
don't ever want to update a window with a different thread than the one 
that created it.  Not that it can't be done, at least in some languages, 
but that it's real rat-hole of problems.


The extra thread or process (with different problems to each) should be 
doing the "logic is running" but NOT the gui.




--
DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-16 Thread fronagzen
Noted on the quoting thing.

Regarding the threading, well, first, I'm not so much a programmer as someone 
who knows a bit of how to program.

And it seems that the only way to update a tkinter window is to use the 
.update() method, which is what I was experimenting with. Start up a new thread 
that just loops the .update() with a 1ms sleep until the download is done. It 
seems to work, actually.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on python regular expression named group

2013-07-16 Thread wxjmfauth
Le mardi 16 juillet 2013 08:55:58 UTC+2, Mohan L a écrit :
> Dear All,
> 
> 
> 
> Here is my script :
> 
> 
> 
> #!/usr/bin/python
> 
> 
> import re
> 
> 
> 
> 
> # A string.
> logs = "date=2012-11-28 time=21:14:59"
> 
> 
> 
> # Match with named groups.
> m = 
> re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))", 
> logs)
> 
> 
> 
> # print
> 
> 
> print m.groupdict()
> 
> 
> Output: 
> 
> 
> 
> 
> {'date': '2012-11-28', 'datetime': 'date=2012-11-28 time=21:14:59', 'time': 
> '21:14:59'}
> 
> 
> 
> 
> 
> Required output :
> 
> ==
> 
> 
> {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time': '21:14:59'}
> 
> 
> 
> need help to correct the below regex 
> 
> 
> 
> 
> 
> (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))"
> 
> 
> 
> 
> so that It will have : 'datetime': '2012-11-28 21:14:59' instead of 
> 'datetime': 'date=2012-11-28 time=21:14:59'
> 
> 
> 
> 
> any help would be greatly appreciated
> 
> 
> 
> Thanks
> Mohan L

--

Not sure, I'm correct. I took you precise string to
refresh my memory.

>>> import re
>>> tmp = 'date=\d{4}-\d{2}-\d{2}'
>>> DatePattern = '(?P' + tmp + ')'
>>> tmp = 'time=\d{2}:\d{2}:\d{2}'
>>> TimePattern = '(?P' + tmp + ')'
>>> pattern = DatePattern + ' ' + TimePattern
>>> pattern
'(?Pdate=\\d{4}-\\d{2}-\\d{2}) 
(?Ptime=\\d{2}:\\d{2}:\\d{2})'
>>> CompiledPattern = re.compile(pattern)
>>> s = 'date=2012-11-28 time=21:14:59'
>>> mo = CompiledPattern.search(s)
>>> print(mo)
<_sre.SRE_Match object at 0x02CD4188>
>>> print(mo.groups())
('date=2012-11-28', 'time=21:14:59')
>>> print(mo.groupdict())
{'DATEPATTERN': 'date=2012-11-28', 'TIMEPATTERN': 'time=21:14:59'}
>>> print(mo.group(1), mo.group('DATEPATTERN'))
date=2012-11-28 date=2012-11-28
>>> print(mo.group(2), mo.group('TIMEPATTERN'))
time=21:14:59 time=21:14:59
>>>


jmf

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread alex23

On 17/07/2013 8:43 AM, John Ladasky wrote:

The kids all claim to be interested.  They all want to write the next great 3D 
video game.  Thus, I'm a little surprised that the kids don't actually try to 
sit down and code without me prompting them.  I think that they're disappointed 
when I show them how much they have to understand just to write a program that 
plays Tic Tac Toe.


One possible approach would be to pick existing games developed in 
PyGame and assist them to modify or extend them. This can be a lot less 
overwhelming than starting a game from scratch, and exposes them to the 
basic concepts such as the main event loop, separating out logic from 
display etc. Code reading is as valuable a skill as code writing.


Another possibility is using a more extensive framework like Unity, 
which provides a lot of the toolchain to simplify the development 
process. While Unity doesn't support Python by default, it does provide 
Boo, which is Python-inspired. It's also built on top of the Mono 
framework, and I believe people have had some success with using .NET's 
IronPython with it.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-16 Thread Steven D'Aprano
On Tue, 16 Jul 2013 15:43:45 -0700, John Ladasky wrote:

> The kids all claim to be interested.  They all want to write the next
> great 3D video game.  Thus, I'm a little surprised that the kids don't
> actually try to sit down and code without me prompting them.  I think
> that they're disappointed when I show them how much they have to
> understand just to write a program that plays Tic Tac Toe.

I morn the death of Hypercard :(

http://www.loper-os.org/?p=568

Using Hypercard was like using Lego. You could literally copy and paste 
buttons from one app to another -- not code, the actual GUI button -- to 
copy their functionality.


You could try Pythoncard:

http://pythoncard.sourceforge.net/


> So, what I am seeking are suggestions for programming assignments that I
> can give to brand-new students of Python.  Please keep in mind that none
> of them are even up to the task of a simple algorithm like Bubble Sort
> -- at least, not yet.

Alas, I don't think there is *any* system for GUI programming that comes 
even close to what is needed to keep the majority of new students 
interested. But you might have some success with text-based games. Here 
are two suggestions:

- guess the number


- twenty questions ("is it bigger than a breadbox?")




You might also like to investigate Inform-7.

http://inform7.com/


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list