[Tutor] difflib - restoring from a unified diff?

2006-10-01 Thread Liam Clarke
Hi all,

I'm writing a wiki at the moment, and I want to store unified diffs to 
allow easy reverting between versions of a document. It appears that 
difflib.restore() can only generate original text from diffs returned 
from ndiff() or compare() which store the full text of both versions.

As this offers no efficiency in storage space over storing the actual 
text, it doesn't much serve my purpose - does anyone know of a 3rd party 
module that, given a text and a unified diff, can return the altered 
text? I can probably write one myself if I sweat a bit, but I'd much 
rather use any pre-existing modules.

Regards,

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


Re: [Tutor] Puzzled by print lst.sort()

2006-10-01 Thread Dick Moores
At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>Maybe following is helpful:
>
> >>> a=[3,2,1]
> >>> b=a[:]
> >>> b.sort()
> >>> c=sorted(a)
> >>> print a,b,c
> >>> [3, 2, 1] [1, 2, 3] [1, 2, 3]
> >>>
>
>Shantanoo

Sorry to be dense, but I don't see what showing what happens to a 
copy of list a adds to the explanation:
 >>> a = [3,2,1]
 >>> b = a[:]
 >>> b.sort()
 >>> b
[1, 2, 3]
 >>>

given that:

 >>> a = [3,2,1]
 >>> a.sort()
 >>> a
[1, 2, 3]
 >>>

I suppose I've misunderstood how you were trying to assist me.

Thanks,

Dick




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


Re: [Tutor] Puzzled by print lst.sort()

2006-10-01 Thread Liam Clarke
Dick Moores wrote:
> At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>   
>> Maybe following is helpful:
>>
>> 
> a=[3,2,1]
> b=a[:]
> b.sort()
> c=sorted(a)
> print a,b,c
> [3, 2, 1] [1, 2, 3] [1, 2, 3]
>
>   
>> Shantanoo
>> 
>
> Sorry to be dense, but I don't see what showing what happens to a 
> copy of list a adds to the explanation:
>  >>> a = [3,2,1]
>  >>> b = a[:]
>  >>> b.sort()
>  >>> b
> [1, 2, 3]
>  >>>
>
> given that:
>
>  >>> a = [3,2,1]
>  >>> a.sort()
>  >>> a
> [1, 2, 3]
>  >>>
>
> I suppose I've misunderstood how you were trying to assist me.
>
> Thanks,
>
> Dick
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   
I think what Shantanoo was getting at was the reference thing, i.e.,

 >>> a = [3,2,1]
 >>> b = a[:]
 >>> b.sort()
 >>> a
[3, 2, 1]
 >>> b
[1, 2, 3]
 >>>

As opposed to

 >>> a = [3,2,1]
 >>> b = a
 >>> b.sort()
 >>> a
[1, 2, 3]
 >>> b
[1, 2, 3]
 >>>

You may not always have access to Python 2.4.

Regards,

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


[Tutor] error message

2006-10-01 Thread mike viceano
hello i wrote a litle program ware you pick a number and the computer
guesses it and i recently decided to make it so it dosint reguess
numbers but now i get a error message

here is the program

def number(number):
   from random import randrange
   guess=randrange(number*2)
   print guess
   guessed.append(guess)
   guesses=1
   guessed=[]
   while guess !=number:
   guess=randrage(number*2)
   if guess not in guessed:
   guessed.append(guess) #here is ware the problem is
   guesses=guesses+1
   print"i got the number",number,"number","in",guesses,"guesses"

and here is the error

Traceback (most recent call last):
File "", line 1, in -toplevel-
   guess.number(10)
File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/guess.py",
line 5, in number
   guessed.append(guess)
UnboundLocalError: local variable 'guessed' referenced before assignment

any help is great

_
Express yourself - download free Windows Live Messenger themes! 
http://clk.atdmt.com/MSN/go/msnnkwme002001msn/direct/01/?href=http://imagine-msn.com/themes/vibe/default.aspx?locale=en-us&source=hmtagline

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


Re: [Tutor] difflib - restoring from a unified diff?

2006-10-01 Thread Kent Johnson
Liam Clarke wrote:
> Hi all,
> 
> I'm writing a wiki at the moment, and I want to store unified diffs to 
> allow easy reverting between versions of a document. It appears that 
> difflib.restore() can only generate original text from diffs returned 
> from ndiff() or compare() which store the full text of both versions.
> 
> As this offers no efficiency in storage space over storing the actual 
> text, it doesn't much serve my purpose - does anyone know of a 3rd party 
> module that, given a text and a unified diff, can return the altered 
> text? I can probably write one myself if I sweat a bit, but I'd much 
> rather use any pre-existing modules.

I don't see a python module for this but you could use os.system() to 
invoke patch.

Kent

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


Re: [Tutor] error message

2006-10-01 Thread Kent Johnson
mike viceano wrote:
> hello i wrote a litle program ware you pick a number and the computer
> guesses it and i recently decided to make it so it dosint reguess
> numbers but now i get a error message
> 
> here is the program
> 
> def number(number):
>from random import randrange
>guess=randrange(number*2)
>print guess
>guessed.append(guess)
>guesses=1
>guessed=[]
>while guess !=number:
>guess=randrage(number*2)
>if guess not in guessed:
>guessed.append(guess) #here is ware the problem is
>guesses=guesses+1
>print"i got the number",number,"number","in",guesses,"guesses"
> 
> and here is the error
> 
> Traceback (most recent call last):
> File "", line 1, in -toplevel-
>guess.number(10)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/guess.py",
> line 5, in number
>guessed.append(guess)
> UnboundLocalError: local variable 'guessed' referenced before assignment

It pays to read the traceback carefully, this one is giving you a lot of 
good clues.

First, the error is at line 5. This is the *first* line with 
"guessed.append(guess)", not the one you have commented.

Second, the error message is that 'guessed' is referenced before 
assignment. Where is 'guessed' assigned? Two lines later, on line 7 with 
"guessed=[]"

Do you know how to fix it now?

Kent

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


[Tutor] Python code to split and reassemble files

2006-10-01 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi guys,

Awhile back, I believe I saw a cookbook recipe for splitting and
reassembling text/binary files.

Does anyone know where this or something similar can be found?

I am working on a file transfer mechanism via MQSeries and breaking
large files to smaller chunks would improve efficiency.

- --
Thank you,
Andrew Robert
Senior MQ Engineer
Information Technologies
MFS Investment Management
Phone:   617-954-5882

E-mail:  [EMAIL PROTECTED]
Linux User Number: #201204
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)
Comment: GnuPT 2.7.2

iD4DBQFFH+RCDvn/4H0LjDwRAtQQAKCeKSCHnsKa5tXye6/bJHm551hyrgCVEp2K
aScfnRPpxVgjJPyM/zqo3Q==
=6LHh
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python code to split and reassemble files

2006-10-01 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Never mind.. :)


found it at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800

However, if someone has something better, I would be very interested.



Andrew Robert wrote:
> Hi guys,
> 
> Awhile back, I believe I saw a cookbook recipe for splitting and
> reassembling text/binary files.
> 
> Does anyone know where this or something similar can be found?
> 
> I am working on a file transfer mechanism via MQSeries and breaking
> large files to smaller chunks would improve efficiency.
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)
Comment: GnuPT 2.7.2

iD8DBQFFH+i/Dvn/4H0LjDwRAr6dAJ48jTQzjWNPEfB3RLkOk9Z93QOalQCcDubg
Fv7y2wpg/kEgt+f6vZwfkdA=
=4c84
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python code to split and reassemble files

2006-10-01 Thread Kent Johnson
Andrew Robert wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Hi guys,
> 
> Awhile back, I believe I saw a cookbook recipe for splitting and
> reassembling text/binary files.
> 
> Does anyone know where this or something similar can be found?

Searching the cookbook for 'split file' finds this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800

Kent

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


[Tutor] Help

2006-10-01 Thread Kefka Palazzo

			OK, first of all, I just started learning python a few hours ago so deal with me here.



I'm picking up quite fast on Python since I took a C++ class a year ago
when i was 13. However, before I go deep into learning it, I want to
know if Python will work for the purpouses I need.


I am trying to learn a programming language good for programming
entire games (core functions too) similar to both the Final Fantasy and
Metroid series. From the book I'm learning from (Python Programming for
the Absolute Beginner, by Michael Dawsom) it seems like within a week
or two I'll have a basic grasp on most of the functions, but I want to
know if it will be worth it for what I need it for or if I would be
better off learning something different (and harder >.<)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2006-10-01 Thread Glenn T Norton
Kefka Palazzo wrote:

> OK, first of all, I just started learning python a few hours ago so 
> deal with me here.
>
> I'm picking up quite fast on Python since I took a C++ class a year 
> ago when i was 13. However, before I go deep into learning it, I want 
> to know if Python will work for the purpouses I need.
>
> I am trying to learn a programming language good for programming 
> entire games (core functions too) similar to both the Final Fantasy 
> and Metroid series. From the book I'm learning from (Python 
> Programming for the Absolute Beginner, by Michael Dawsom) it seems 
> like within a week or two I'll have a basic grasp on most of the 
> functions, but I want to know if it will be worth it for what I need 
> it for or if I would be better off learning something different (and 
> harder >.<)
>
>
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>
I'm not a game writer, but there a good quote on the home page from 
Firaxis Games
http://www.python.org/about/quotes/  ( bottom of page )

Good Luck,
Glenn

-- 
"What's an Ear? ... A Jar and with a War of course!  " 
Why Programmers are Lonely - Reason #14

Glenn Norton
Application Developer
Nebraska.gov
1-402-471-2777
[EMAIL PROTECTED]

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


Re: [Tutor] Help

2006-10-01 Thread wesley chun
> I am trying to learn a programming language good for programming entire
> games (core functions too)

check out the PyGame engine:
http://pygame.org

download the games written on top of PyGame that appear to match the
functionality you're looking for.  if you learn Python at the same
time, tweaking those games and changing their functionality will help
you learn it even faster.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2006-10-01 Thread Kent Johnson
wesley chun wrote:
>> I am trying to learn a programming language good for programming entire
>> games (core functions too)
> 
> check out the PyGame engine:
> http://pygame.org
> 
> download the games written on top of PyGame that appear to match the
> functionality you're looking for.  if you learn Python at the same
> time, tweaking those games and changing their functionality will help
> you learn it even faster.

You should also look at the PyGame Challenge web site:
http://www.pyweek.org/

I'm not a game writer either but I have a few thoughts...my impression 
is that Python and PyGame are a good foundation for hobbyist games. The 
PyGame and PyWeek games are good examples. I doubt that you could write 
a commercial quality game like Final Fantasy using just these tools 
though. Commercial games have highly optimized game engines. Some of 
them use Python as scripting engines for high-level game play; I doubt 
that any commercial games use Python for their core game engine.

On the other hand, you are a long way from being able to write Final 
Fantasy. You need to start small and develop your skills. Python and 
PyGame should be well suited for this.

You might want to read this:
http://tinyurl.com/hc6xc

which says in part, "Starcraft, Everquest and Quake were all made by 
teams of professionals who had budgets usually million dollar plus. More 
importantly though, all of these games were made by people with a lot of 
experience at making games. They did not just decide to make games and 
turned out mega-hit games, they started out small and worked their way 
up. This is the point that anyone who is interested in getting into game 
development needs to understand and repeat, repeat, repeat until it 
becomes such a part of your mindset that you couldn’t possibly 
understand life without this self evident, universal truth."

and here are more links:
http://en.wikipedia.org/wiki/Game_programming
http://www-cs-students.stanford.edu/~amitp/gameprog.html

I found these all by Googling "game programming language"; there are 
many more interesting links there.

Good luck,
Kent

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


[Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread Will Shattuck
Hi all,

I thought that it would be a great idea to learn Python while porting
the BASIC code from this book.  So I printed all the pages, have them
"bound" by a big binder clip, and read through the first bit.

In Chapter 2 there is a type of "Choose Your Own Adventure" type
section.  Since I didn't have two quarters, but I did have my laptop,
I put together a quick "pycoin.py" program to "flip" the coins.  Since
I am an extreme beginner I thought I would submit it for review.  Here
you go:

=
import random

coin1 = 0
coin2 = 0

coin1 = random.randint(1, 10)
coin2 = random.randint(1, 10)

if coin1 <= 5:
print "Coin1 is Heads"
else:
print "Coin1 is Tails"

if coin2 <= 5:
print "Coin2 is Heads"
else:
print "Coin2 is Tails"
=


-- 
Will Shattuck  ( willshattuck.at.gmail.com )
Home Page:  http://www.thewholeclan.com/will

When you get to your wit's end, you'll find God lives there.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Is my Python install hosed?

2006-10-01 Thread Will Shattuck
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
==

I seem to have issues running some programs from the web, but not
others. I do make sure that the prereqs are met.

Thanks for any help,
Will

-- 
Will Shattuck  ( willshattuck.at.gmail.com )
Home Page:  http://www.thewholeclan.com/will

When you get to your wit's end, you'll find God lives there.
___
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] Is my Python install hosed?

2006-10-01 Thread Will Shattuck
On 10/1/06, John Fouhy <[EMAIL PROTECTED]> wrote:
> 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:
> >
[...]
> 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
>

Thanks, didn't know about the Python command prompt.  Worked there.  Thanks :)

Will
___
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 Dick Moores
At 04:38 PM 10/1/2006, Will Shattuck wrote:
>Hi all,
>
>I thought that it would be a great idea to learn Python while porting
>the BASIC code from this book.  So I printed all the pages, have them
>"bound" by a big binder clip, and read through the first bit.
>
>In Chapter 2 there is a type of "Choose Your Own Adventure" type
>section.  Since I didn't have two quarters, but I did have my laptop,
>I put together a quick "pycoin.py" program to "flip" the coins.  Since
>I am an extreme beginner I thought I would submit it for review.  Here
>you go:
>
>=
>import random
>
>coin1 = 0
>coin2 = 0
>
>coin1 = random.randint(1, 10)
>coin2 = random.randint(1, 10)
>
>if coin1 <= 5:
> print "Coin1 is Heads"
>else:
> print "Coin1 is Tails"
>
>if coin2 <= 5:
> print "Coin2 is Heads"
>else:
> print "Coin2 is Tails"
>=

Works fine, but instead of
coin1 = random.randint(1, 10)
coin2 = random.randint(1, 10)

you could simplify by using
coin1 = random.randrange(2)
coin2 = random.randrange(2)

and adjusting the rest of your code accordingly.

Dick Moores



___
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 Kent Johnson
Dick Moores wrote:
> Works fine, but instead of
> coin1 = random.randint(1, 10)
> coin2 = random.randint(1, 10)
> 
> you could simplify by using
> coin1 = random.randrange(2)
> coin2 = random.randrange(2)

or maybe random sample:
In [22]: random.sample(('heads', 'tails'), 1)[0]
Out[22]: 'tails'

Kent

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


[Tutor] Changing Mobile and Landline Number no more a problem

2006-10-01 Thread MyNewNo


 
Changing Mobile and Landline Number no more a problem !
Whenever we change our telephone numbers (both Mobile and Landline) and Service Providers (all providers such as BSNL, Reliance, Tata Indicom, Airtel/Hutch, Aircel, etc.), we miss out a number of valuable contacts and as a result we even incur losses. 
Now changing Landline and Mobile numbers and Service Providers are no longer a problem.
1. New No. Information through  I N T E R N E T :
Now you can “announce” your New Contact Details using MyNewNo.com at a negligible fee (Only Rs.100/- per number/year). 
1.Change of Landline and Mobile numbers
2.Change of email addresses
3.Change of Postal addresses 
Now you can change your Mobile and Landline numbers and Service Providers as many times as you want and still hold onto all your contacts, who just need to access our site to get your new contact info.
2. New No. Information through I V R S (Over Phone) :

IVRS (Interactive Voice Response System) available  at an additional cost.
IVRS is an automatic telephone based facility that will give New Mobile and Landline numbers over the telephone directly. 
People who have no access to the Internet can get easily the New telephone numbers through phone directly. 
For additional information, please contact MyNewNo.com on 094440 89331 or please visit www.MyNewNo.com or write to [EMAIL PROTECTED]
Best Regards 
www.MyNewNo.com
Contact : [EMAIL PROTECTED] or Mobile 094440 89331
 
NB: If you do not want to receive similar messages, please send us a “remove” message. Best Regards.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] database web app, what tool?

2006-10-01 Thread Paulino
Hi!

Im a very biginner in programming and I started with python, witch I 
found much easier tahn i thought.

I want to build an intranet page in my organization that shows some data 
from our financial aplication's database.

For the starting point I would like it to show invoices lists per 
supplier and link each line to a pdf image of the selected invoice that 
is stored in a determined folder.

The aim is only to make querys and show the results. No updates, nor 
insert's

The database is MS SQL 2005



Right now I connect to the database via pymssql, and i can retrieve data 
and send it to a wx.Grid or to a reportlab pdf file, with platypus 
tables (a couple of months ago i would say i'd never be able to do it... 
and now i want to do more...)

Now I want to send it to the browser so the administration can see it 
every time they need.


What tool is more suitable?

There are so many options!

Zope-Plone have it's own web server, so less config is required. But i 
can't find any recipe or tutorial usefull for this task...

there is also django, turbogears, webware, apache and mod-python.


Thank you


Paulino


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


Re: [Tutor] Changing Mobile and Landline Number no more a problem

2006-10-01 Thread Kent Johnson
Sorry, a slip of the mouse let that through.

Kent

___
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


[Tutor] One of my 'baby step' programs

2006-10-01 Thread Alan Gilfoy
-code block-

number = 3
running = True

while running:
   guess = int(raw_input("Please enter a number : ")) #lets user guess a number

   if guess == number:
   print "Yay, you got the right number, good for you. But you 
don't get any prizes. Do I look like a walking ATM to you?"
   running = False #this causes the guess-again loop to start.
   elif guess < number:
   print "No, my number is higher than that"
   else:
   print "No, my number is lower than that."

else:
   print "The number-guessing loop is over."

print "Done."

-end code block-

Darnit, it's very simple, but I still like the fac tthat is does 
something to user input.

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


[Tutor] senior project

2006-10-01 Thread Alan Gilfoy
I am a senior at the School Without Walls in Rochester, NY. As such, I 
get to do a senior project. I decided to work on computer programming, 
since that is sometihng that I certianly think can hold my interest 
throughout the school year.

(despite my compute rinteresat, I've never done anything much more 
advanced than HTML, for some reason)

One of my community advisers suggested I start with Python. (he also 
suggested this mailing list)

So far, I've liked the 
http://swaroopch.info/text/Byte_of_Python:Main_Page tutorial, for 
basics.





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


Re: [Tutor] Help

2006-10-01 Thread Marc Poulin
--- Kefka Palazzo <[EMAIL PROTECTED]> wrote:

> I am trying to learn a programming language good for
> programming entire
> games (core functions too) similar to both the Final
> Fantasy and Metroid
> series. From the book I'm learning from (Python
> Programming for the Absolute
> Beginner, by Michael Dawsom) it seems like within a
> week or two I'll have a
> basic grasp on most of the functions, but I want to
> know if it will be worth
> it for what I need it for or if I would be better
> off learning something
> different (and harder >.<)

>From the http://panda3d.org website:

Panda3D is a 3D engine: a library of subroutines for
3D rendering and game development. The library is C++
with a set of Python bindings. Game development with
Panda3D usually consists of writing a Python program
that controls the the Panda3D library.

Panda3D was developed by Disney for their massively
multiplayer online game, Toontown. It was released as
free software in 2002. Panda3D is now developed
jointly by Disney and Carnegie Mellon University's
Entertainment Technology Center


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
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 Will Shattuck
On 10/1/06, John Fouhy <[EMAIL PROTECTED]> wrote:
> 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']
>

Thanks all.  My main intent is to keep it simple.  I may expand some
of these code samples into my own sort or tutorial on python.  Some
say that if you can teach something to others then you know that you
know the subject.

I'll research these out and pick what fits for me.  Thanks all :)

Will

-- 
Will Shattuck  ( willshattuck.at.gmail.com )
Home Page:  http://www.thewholeclan.com/will

When you get to your wit's end, you'll find God lives there.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] database web app, what tool?

2006-10-01 Thread Liam Clarke
Paulino wrote:

Hi Paulino,

Tough question that. What is your existing web server? That'd be a good 
starting point. Zope/Plone are great, but they have a steep learning 
curve that doesn't seem essential to what you're doing. Django is 
simpler, but once again, doesn't immediately fit to what you're trying 
to do, but it could do.

I'd say just a straight mod_python would be simplest, to be honest, but 
it really depends on what you're doing.

Regards,

Liam Clarke
> Hi!
>
> Im a very biginner in programming and I started with python, witch I 
> found much easier tahn i thought.
>
> I want to build an intranet page in my organization that shows some data 
> from our financial aplication's database.
>
> For the starting point I would like it to show invoices lists per 
> supplier and link each line to a pdf image of the selected invoice that 
> is stored in a determined folder.
>
> The aim is only to make querys and show the results. No updates, nor 
> insert's
>
> The database is MS SQL 2005
>
>
>
> Right now I connect to the database via pymssql, and i can retrieve data 
> and send it to a wx.Grid or to a reportlab pdf file, with platypus 
> tables (a couple of months ago i would say i'd never be able to do it... 
> and now i want to do more...)
>
> Now I want to send it to the browser so the administration can see it 
> every time they need.
>
>
> What tool is more suitable?
>
> There are so many options!
>
> Zope-Plone have it's own web server, so less config is required. But i 
> can't find any recipe or tutorial usefull for this task...
>
> there is also django, turbogears, webware, apache and mod-python.
>
>
> Thank you
>
>
> Paulino
>
>
> ___
> 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] senior project

2006-10-01 Thread wesley chun
> One of my community advisers suggested I start with Python. (he also
> suggested this mailing list)


take a look at "how to think like a computer scientist" by downey,
elkner, etc.  it was originally written for C++ and Java but Jeff
Elkner, a high school programming AP instructor, ported it to Python.

there are dead tree and online versions available.

http://www.ibiblio.org/obp/thinkCSpy/

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] timeit at the command line

2006-10-01 Thread Dick Moores
C:\>python -m timeit  -s"x=0" "while x<100:" "  x+=1"
1000 loops, best of 3: 0.123 usec per loop

C:\>python -m timeit -s"for x in range(100):" "x+=1"
Traceback (most recent call last):
   File "E:\Python25\lib\runpy.py", line 95, in run_module
 filename, loader, alter_sys)
   File "E:\Python25\lib\runpy.py", line 52, in _run_module_code
 mod_name, mod_fname, mod_loader)
   File "E:\Python25\lib\runpy.py", line 32, in _run_code
 exec code in run_globals
   File "E:\Python25\lib\timeit.py", line 285, in 
 sys.exit(main())
   File "E:\Python25\lib\timeit.py", line 249, in main
 t = Timer(stmt, setup, timer)
   File "E:\Python25\lib\timeit.py", line 116, in __init__
 code = compile(src, dummy_src_name, "exec")
   File "", line 4
 _t0 = _timer()
   ^
IndentationError: expected an indented block


Is there a better way to indicate the indentation of "  x+=1"  (2 
spaces in this case) ? For me, this usually works in a while loop, 
but so far, never in a for loop.

 says:
"A multi-line statement may be given by specifying each line as a 
separate statement argument; indented lines are possible by enclosing 
an argument in quotes and using leading spaces. Multiple -s options 
are treated similarly."

Thanks,

Dick Moores


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


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

2006-10-01 Thread Luke Paireepinart
Alan Gilfoy wrote:
> -code block-
>
> number = 3
> running = True
>
> while running:
>guess = int(raw_input("Please enter a number : ")) #lets user guess a 
> number
>
>if guess == number:
>print "Yay, you got the right number, good for you. But you 
> don't get any prizes. Do I look like a walking ATM to you?"
>running = False #this causes the guess-again loop to start.
>elif guess < number:
>print "No, my number is higher than that"
>else:
>print "No, my number is lower than that."
>
> else:
>print "The number-guessing loop is over."
>   
I had no idea you could have an 'else' tied to a 'while' loop.
Interesting
> print "Done."
>
> -end code block-
>
> Darnit, it's very simple, but I still like the fac tthat is does 
> something to user input.
>   
you should look into the 'random' module.
You can generate a random integer with the random.randint() function.
Then us programmers who peek at your code can't cheat and choose 3 every 
time :)
Good luck on your project!
Any idea what it'll be yet?
-Luke
___
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] One of my 'baby step' programs

2006-10-01 Thread Dick Moores


At 09:49 PM 10/1/2006, Luke Paireepinart wrote:
I had no idea you could have an
'else' tied to a 'while' loop.
Interesting
I looked this up in Python in a Nutshell. From p. 69:
The else Clause on Loop Statements
while and for statements may optionally have a
trailing else clause. The statement or block under that else
executes when the loop terminates naturally (at the end of
the for iterator, or when the while loop condition becomes
false), but not when the loop terminates prematurely (via
break, return, or an exception). When a loop contains
one or more break statements, you often need to check whether
the loop terminates naturally of prematurely. You can use an else
clause on the loop for this purpose:
for x in some_container:
    if is_ok(x):
break  # item x is
satisfactory, terminate loop
else:
    print "Warning: no satisfactory item was found in
container"
    x = None
Dick Moores



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