[Tutor] Tutor Digest, Vol 70, Issue 5
aivars
aivars868 at gmail.com
Wed Dec 2 20:15:16 CET 2009
Mark,
I have the first edition of your book. What is the difference between
two editions?
2009/12/2 <tutor-request at python.org>:
> Send Tutor mailing list submissions to
> tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> tutor-request at python.org
>
> You can reach the person managing the list at
> tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
> 1. Fwd: Moving from Python 2 to Python 3: A 4 page "cheat sheet"
> (Kent Johnson)
> 2. Re: Moving from Python 2 to Python 3: A 4 page "cheatsheet"
> (Alan Gauld)
> 3. pygame help with livewires (Skylar Struble)
> 4. Re: Moving from Python 2 to Python 3: A 4 page "cheatsheet"
> (Kent Johnson)
> 5. Re: Moving from Python 2 to Python 3: A 4 page "cheatsheet"
> (Joerg Woelke)
> 6. Re: Moving from Python 2 to Python 3: A 4 page "cheatsheet"
> (Wayne Werner)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 2 Dec 2009 07:29:10 -0500
> From: Kent Johnson <kent37 at tds.net>
> To: "*tutor python" <tutor at python.org>
> Subject: [Tutor] Fwd: Moving from Python 2 to Python 3: A 4 page
> "cheat sheet"
> Message-ID:
> <1c2a2c590912020429k247b4fe1gca44c5b9839c239e at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Forwarded from python-announce. A helpful summary of the differences
> between Python 2 and 3 (though some of the differences were introduced
> well before Python 3).
>
> Kent
>
> ---------- Forwarded message ----------
> From:?Mark Summerfield <list at qtrac.plus.com>
> To:?comp-lang-python-announce at moderators.isc.org
> Date:?Tue, 1 Dec 2009 06:05:09 -0800 (PST)
> Subject:?Moving from Python 2 to Python 3: A 4 page "cheat sheet"
> I've produced a 4 page document that provides a very concise summary
> of Python 2<->3 differences plus the most commonly used new Python 3
> features. It is aimed at existing Python 2 programmers who want to
> start writing Python 3 programs and want to use Python 3 idioms rather
> than those from Python 2 where the idioms differ.
>
> It uses Python 3.1 syntax since that looks like being the standard for
> a few years in view of the language moratorium.
>
> The document is U.S. Letter size but will also print fine on A4
> printers.
>
> It is available as a free PDF download (no registration or anything)
> from InformIT's website. Here's the direct link:
> http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf
>
> And of course, if you want more on Python 3, there's always the
> documentation---or my book:-)
> "Programming in Python 3 (Second Edition)" ISBN-10: 0321680561.
> --
> Mark Summerfield, www.qtrac.eu
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 2 Dec 2009 13:56:05 -0000
> From: "Alan Gauld" <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Moving from Python 2 to Python 3: A 4 page
> "cheatsheet"
> Message-ID: <hf5rls$bq4$1 at ger.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=original
>
>
> "Kent Johnson" <kent37 at tds.net> wrote
>
>> Forwarded from python-announce. A helpful summary of the differences
>> between Python 2 and 3 (though some of the differences were introduced
>> well before Python 3).
>
>> It is available as a free PDF download (no registration or anything)
>> from InformIT's website. Here's the direct link:
>> http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf
>
>
> It didn't work for me I always got forwarded to the Book "home page" on
> InformIT
>
> Alan G
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 2 Dec 2009 09:38:53 -0500
> From: Skylar Struble <skylarstruble at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] pygame help with livewires
> Message-ID:
> <664a3e4c0912020638i69a8aabfofb4ea44b59169ab6 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> ok so its working and drops a normal cow and randomly a green cow but
> i want it to be able to tell when you collide with the green cow cause
> its gonna be a powerup.
>
> heres the code for my program.
>
> # Pizza Panic
> # Player must catch falling pizzas before they hit the ground
>
> from livewires import games, color
> import random
> hscorefile = open("hscores.txt", 'r')
> score = 0
> level = 1
> pizzascore = 2
> stl = 15
> lstl = 15
> pizza_speed = 1
> cook_speed = 4
> pizza_drop = 0.5
> level_up_drop = 1
> highscore = int(hscorefile.read(100000000))
> hscorefile.close()
> games.init(screen_width = 640, screen_height = 480, fps = 50)
>
> class Pan(games.Sprite):
> """
> A pan controlled by player to catch falling pizzas.
> """
> global score
> image = games.load_image("pan.bmp")
>
> def __init__(self):
> """ Initialize Pan object and create Text object for score. """
> global level
> global hs
> global score
> super(Pan, self).__init__(image = Pan.image, x =
> games.mouse.x, bottom = games.screen.height)
>
> self.score = games.Text(value = 0, size = 25, color = color.black,
> top = 5, right = games.screen.width - 10)
> games.screen.add(self.score)
> self.leveltxt = games.Text(value = "level:", size = 25, color
> = color.black,
> top = 5, right = games.screen.width - 580)
> games.screen.add(self.leveltxt)
> self.level = games.Text(value = level, size = 25, color = color.black,
> top = 5, right = games.screen.width - 566)
> games.screen.add(self.level)
> self.hs = games.Text(value = "Highscore:" + str(highscore),
> size = 25, color = color.black,
> top = 5, right = games.screen.width - 320)
> games.screen.add(self.hs)
>
> def update(self):
> """ Move to mouse x position. """
> self.x = games.mouse.x
>
> if self.left < 0:
> self.left = 0
>
> if self.right > games.screen.width:
> self.right = games.screen.width
>
> self.check_catch()
>
> def check_catch(self):
> """ Check if catch pizzas. """
> global pizza_drop
> global level
> global score
> global score_to_level
> global cook_speed
> global pizza_speed
> global stl
> global lstl
> global pizzascore
> stl = (lstl *2.5)
> for pizza in self.overlapping_sprites:
> self.score.value = self.score.value + pizzascore
> score = self.score.value
> if self.score.value >= stl:
> lstl = stl
> pizza_drop += 0.2
> self.level.value += 1
> pizza_speed += .25
> pizzascore = pizzascore * 2
> cook_speed += 5
> level = level + 1
> lvlup_message = games.Message(value = "Level " + str(level),
> size = 90,
> color = color.red,
> x = games.screen.width/2,
> y = games.screen.height/2,
> lifetime = 2 * games.screen.fps)
> games.screen.add(lvlup_message)
> self.score.right = games.screen.width - 10
> pizza.handle_caught()
> class Pizza(games.Sprite):
> """
> A pizza which falls to the ground.
> """
> global pizza_speed
> speed = 1.5
> image = games.load_image("pizza.bmp")
>
> def __init__(self, x, y = 90):
> """ Initialize a Pizza object. """
> super(Pizza, self).__init__(image = Pizza.image,
> x = x, y = y,
> dy = pizza_speed)
>
> def update(self):
> """ Check if bottom edge has reached screen bottom. """
> if self.bottom > games.screen.height:
> self.end_game()
> self.destroy()
>
> def handle_caught(self):
> """ Destroy self if caught. """
> self.destroy()
>
> def end_game(self):
> global highscore
> global score
> global name
> """ End the game. """
> if score > highscore:
> hsfile = open("hscores.txt", "w")
> hsfile.write(str(score))
> hsfile.close()
> hs_message = games.Message(value ="New highscore of " + str(score),
> size = 45,
> color = color.red,
> x = games.screen.width/2,
> y = games.screen.height/2,
> lifetime = 1 * games.screen.fps,
> after_death = games.screen.quit)
> games.screen.add(hs_message)
> else:
> end_message = games.Message(value = "game over",
> size = 45,
> color = color.red,
> x = games.screen.width/2,
> y = games.screen.height/2,
> lifetime = 0 * games.screen.fps,
> after_death = games.screen.quit)
> games.screen.add(end_message)
>
>
> class power_pizza1(games.Sprite):
> """
> A pizza which falls to the ground.
> """
> global pizza_speed
> speed = 1.5
> image = games.load_image("power_pizza1.bmp")
>
> def __init__(self, x, y = 90):
> """ Initialize a Pizza object. """
> super(power_pizza1, self).__init__(image = power_pizza1.image,
> x = x, y = y, dy = pizza_speed)
>
>
> def update(self):
> """ Check if bottom edge has reached screen bottom. """
> if self.bottom > games.screen.height:
> self.destroy()
>
> def handle_caught(self):
> """ Destroy self if caught. """
> self.destroy()
> class Chef(games.Sprite):
> """
> A chef which moves left and right, dropping pizzas.
> """
> global cook_speed
> image = games.load_image("chef.bmp")
>
> def __init__(self, y = 55, speed = 1000, odds_change = 55):
> """ Initialize the Chef object. """
> super(Chef, self).__init__(image = Chef.image,
> x = games.screen.width / 2,
> y = y,
> dx = cook_speed)
>
> self.odds_change = odds_change
> self.time_til_drop = 0
>
>
> def update(self):
> """ Determine if direction needs to be reversed. """
> if self.left < 0 or self.right > games.screen.width:
> self.dx = -self.dx
> elif random.randrange(self.odds_change) == 0:
> self.dx = -self.dx
>
> self.check_drop()
>
>
> def check_drop(self):
> rpp = 5
> """ Decrease countdown or drop pizza and reset countdown. """
> global pizza_drop
> if self.time_til_drop > 0:
> self.time_til_drop -= pizza_drop
> else:
> new_pizza = Pizza(x = random.randrange(40, 600))
> rpp = random.randrange(1, 5)
> if rpp == 3:
> power_pizza = power_pizza1 (x = random.randrange(40, 600))
> games.screen.add(power_pizza)
> else:
> games.screen.add(new_pizza)
>
> # set buffer to approx 30% of pizza height, regardless of
> pizza speed
> self.time_til_drop = int(new_pizza.height * 1.3 / Pizza.speed) + 1
>
>
> def main():
> """ Play the game. """
> wall_image = games.load_image("wall.jpg", transparent = False)
> games.screen.background = wall_image
>
> the_chef = Chef()
> games.screen.add(the_chef)
>
> the_pan = Pan()
> games.screen.add(the_pan)
>
> games.mouse.is_visible = False
>
> games.screen.event_grab = True
> games.screen.mainloop()
>
> # start it up!
> main()
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 2 Dec 2009 10:13:25 -0500
> From: Kent Johnson <kent37 at tds.net>
> To: Alan Gauld <alan.gauld at btinternet.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] Moving from Python 2 to Python 3: A 4 page
> "cheatsheet"
> Message-ID:
> <1c2a2c590912020713l72b85952ka4d5b8f3d1e2ad7e at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Wed, Dec 2, 2009 at 8:56 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>
>> "Kent Johnson" <kent37 at tds.net> wrote
>>
>>> Forwarded from python-announce. A helpful summary of the differences
>>> between Python 2 and 3 (though some of the differences were introduced
>>> well before Python 3).
>>
>>> It is available as a free PDF download (no registration or anything)
>>> from InformIT's website. Here's the direct link:
>>>
>>> http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf
>>
>>
>> It didn't work for me I always got forwarded to the Book "home page" on
>> InformIT
>
> Strange. Worked for me yesterday and again just now.
>
> Kent
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 2 Dec 2009 15:13:20 +0100
> From: Joerg Woelke <joewoe at fsmail.de>
> To: tutor at python.org
> Subject: Re: [Tutor] Moving from Python 2 to Python 3: A 4 page
> "cheatsheet"
> Message-ID: <20091202141320.GC9158 at localhost>
> Content-Type: text/plain; charset=us-ascii
>
> * Alan Gauld <alan.gauld at btinternet.com> [091202 15:07]:
>> >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf
>>
>>
>> It didn't work for me I always got forwarded to the Book "home page"
>> on InformIT
> Worked for me with wget(1).
>
> --
> You are capable of planning your future.
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 2 Dec 2009 09:26:08 -0600
> From: Wayne Werner <waynejwerner at gmail.com>
> To: Joerg Woelke <joewoe at fsmail.de>
> Cc: tutor at python.org
> Subject: Re: [Tutor] Moving from Python 2 to Python 3: A 4 page
> "cheatsheet"
> Message-ID:
> <333efb450912020726x22cffc60q6b911387dc13a2ae at mail.gmail.com>
> Content-Type: text/plain; charset="windows-1252"
>
> On Wed, Dec 2, 2009 at 8:13 AM, Joerg Woelke <joewoe at fsmail.de> wrote:
>
>> Alan Gauld <alan.gauld at btinternet.com> [091202 15:07]:
>> > >
>> http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf
>> >
>> >
>> > It didn't work for me I always got forwarded to the Book "home page"
>> > on InformIT
>> Worked for me with wget(1).
>>
>
>
> And for me with Google Chrome on Ubuntu...
> -Wayne
> --
> To be considered stupid and to be told so is more painful than being called
> gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
> every vice, has found its defenders, its rhetoric, its ennoblement and
> exaltation, but stupidity hasn?t. - Primo Levi
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/tutor/attachments/20091202/f33c0b0b/attachment.htm>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 70, Issue 5
> ************************************
>
--
Regards,
Aivars Enkuzens
More information about the Tutor
mailing list