Re: [Tutor] simon says

2012-09-10 Thread William R. Wing (Bill Wing)
On Sep 10, 2012, at 1:15 PM, Matthew Ngaha  wrote:

> hi guy my book has set me an assignment of a simon says game but i
> don't really understand what it's asking me to do. here's the text:
> 
> write a version of the simon says game where a player has to repeat an
> ever-growing, random sequence of colours and sounds using the
> keyboard.
> 
> Anyone understand the task?
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Sounds as though what is wanted in a Pythonic version of an early electronic 
game "Simon" that was marketed back in the late 70's.  It was roughly Frisbee 
shaped although slightly larger.  The top was divided into four quadrant-shaped 
paddles each of a different color.  The game consisted of Simon generating 
longer and longer sequences of random color-sound flashes (each element in the 
sequence consisted of a momentary sound accompanied by the appropriate quadrant 
lighting up).  After Simon had generated a sequence, the player had to 
duplicate it by pressing the paddles.  A successful recreation of a sequence 
was rewarded by Simon generating a longer one, until the player finally screwed 
up.  At that point Simon made an electronic rude noise and the device was 
handed on to the next player if there were multiple players.  The player who 
succeeded in matching the longest sequence was the winner of that round.

I'll bet ebay still has them for sale, and Google would get you a description 
that would be better than mine.

-Bill
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread eryksun
On Mon, Sep 10, 2012 at 12:34 PM, Greg Nielsen
 wrote:
> I will admit that the whole Blender project is cool, but Jerry has a point.
> All I wanted to know was how to get Pygame and TkInter to work together, and
> I got a solid answer about 12 hours ago. (Check out Eryksun's code, it's
> beyond cool, past awsome, and close to sexy.) As such, I am considering this
> post closed. Thank you all for your help.

The credit goes to the answer on Stack Overflow. I just modified it a bit.

Another option would be to use a pygame GUI toolkit, especially if you
want full screen mode. The pygame wiki discusses two that I suppose
are the most popular:

http://www.pygame.org/wiki/gui
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in Vertica

2012-09-10 Thread Dave Angel
On 09/10/2012 04:49 PM, C.L. Shetline wrote:
>
>
> Python 2.4.3 with Vertica Database on Linux.
>
> We are migrating from an Informix database to Vertica. We have C code and a 
> lot of
> SQL Stored procedures in our Informix db that are not viable in Vertica. We 
> are trying
> to convert them to Python.
>
> My first questions is:
>
> I am using pyodbc to connect to the Vertica database. When I do a select on 
> count and
> print the result it displays as (for example) 4L (which is the row count plus 
> the
> data type). If I try to use the variable in a conditional it does not work. I 
> have no idea how
> to have data value simply be 4 !

Have you  tried printing  type(number_of_rows) ?

> cursor.execute("SELECT COUNT(*) from cv_gls_wkly_misc")
> result = cursor.fetchone()
> number_of_rows = result[0]
> print `number_of_rows

Please copy/paste the code and other messages.  That last line has a
syntax error.

>
> The data display is the (select count(*)) and a selected row.
And who printed that line out?

> 4L

If you're claiming that's coming from the above print statement (after
fixing the syntax error), then the variable number_of_rows is NOT a long
or an int.  Perhaps it's a string.  Without knowing that, we can't tell
you the best way to fix it.

Perhaps you're not printing it at all, but just entering 
number_of_rows  in the interactive interpreter.  In that case, the
variable might be a long object of value 4.   IF that's the case, then
you can convert it back to an int by   something like number_of_rows =
int(number_of_rows)

> [(5185L, 93L, Decimal("42.50"), Decimal("50.36"), Decimal("3406.35"), 
> Decimal("0"), Decimal("78.00"), Decimal("0"), Decimal("66.00"), Decimal("0"), 
> Decimal("12.73"), Decimal("0"), Decimal("0"), Decimal("311.00"))]

And what's that supposed to represent?  And displayed by what means?



 



-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in Vertica

2012-09-10 Thread Emile van Sebille

On 9/10/2012 1:49 PM C.L. Shetline said...

Python 2.4.3 with Vertica Database on Linux.

We are migrating from an Informix database to Vertica. We have C code
and a lot of
SQL Stored procedures in our Informix db that are not viable in Vertica.
We are trying
to convert them to Python.

My first questions is:

I am using pyodbc to connect to the Vertica database. When I do a select
on count and
print the result it displays as (for example) 4L (which is the row count
plus the
data type). If I try to use the variable in a conditional


Please show us this conditional and how you build it...



it does not work.



... and include the traceback so that we see both your input and the 
error that's output.


Emile




I have no idea how to have data value simply be 4 !

cursor.execute("SELECT COUNT(*) from cv_gls_wkly_misc")
result = cursor.fetchone()
number_of_rows = result[0]
print `number_of_rows


The data display is the (select count(*)) and a selected row.
4L
[(5185L, 93L, Decimal("42.50"), Decimal("50.36"), Decimal("3406.35"),
Decimal("0"), Decimal("78.00"), Decimal("0"), Decimal("66.00"),
Decimal("0"), Decimal("12.73"), Decimal("0"), Decimal("0"),
Decimal("311.00"))]

Regards,
CVez


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python in Vertica

2012-09-10 Thread C.L. Shetline



Python 2.4.3 with Vertica Database on Linux.

We are migrating from an Informix database to Vertica. We have C code and a lot 
of
SQL Stored procedures in our Informix db that are not viable in Vertica. We are 
trying
to convert them to Python.

My first questions is:

I am using pyodbc to connect to the Vertica database. When I do a select on 
count and
print the result it displays as (for example) 4L (which is the row count plus 
the
data type). If I try to use the variable in a conditional it does not work. I 
have no idea how
to have data value simply be 4 !

cursor.execute("SELECT COUNT(*) from cv_gls_wkly_misc")
result = cursor.fetchone()
number_of_rows = result[0]
print `number_of_rows


The data display is the (select count(*)) and a selected row.
4L
[(5185L, 93L, Decimal("42.50"), Decimal("50.36"), Decimal("3406.35"), 
Decimal("0"), Decimal("78.00"), Decimal("0"), Decimal("66.00"), Decimal("0"), 
Decimal("12.73"), Decimal("0"), Decimal("0"), Decimal("311.00"))]

Regards,
CVez

  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread Matthew Ngaha
> This seems less about "simon says" the social game, and more about
> "simon", the 1980s electronic toy.
>
> That toy had four colored buttons that would light up in a sequence,
> playing a tone for each color.  The player would then have to press
> the buttons in the same sequence.  The game would then replay the
> sequence and add an additional step.  Player would have to enter the
> longer sequence in.  Continue until player loses (and game made an
> angry buzz).
>
> It was quite addictive.

this sounds like a lot of fun! time to think about how i will go about
this:) Thanks for making it clear.

Also @ Emile, thanks for the link.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread Emile van Sebille

On 9/10/2012 12:40 PM Brett Ritter said...

On Mon, Sep 10, 2012 at 12:24 PM, Matthew Ngaha  wrote:

thanks for your input. i understand Simon Says. I'm just struggling to
see the connection with the assignment. a sequence of colours and
sounds using the keyboard. I 'm trying to understand how this relates
to the game


This seems less about "simon says" the social game, and more about
"simon", the 1980s electronic toy.

That toy had four colored buttons that would light up in a sequence,
playing a tone for each color.  The player would then have to press
the buttons in the same sequence.  The game would then replay the
sequence and add an additional step.  Player would have to enter the
longer sequence in.  Continue until player loses (and game made an
angry buzz).

It was quite addictive.




Good call -- that sounds like what they're at.

See http://en.wikipedia.org/wiki/Simon_%28game%29

Emile


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread Brett Ritter
On Mon, Sep 10, 2012 at 12:24 PM, Matthew Ngaha  wrote:
> thanks for your input. i understand Simon Says. I'm just struggling to
> see the connection with the assignment. a sequence of colours and
> sounds using the keyboard. I 'm trying to understand how this relates
> to the game

This seems less about "simon says" the social game, and more about
"simon", the 1980s electronic toy.

That toy had four colored buttons that would light up in a sequence,
playing a tone for each color.  The player would then have to press
the buttons in the same sequence.  The game would then replay the
sequence and add an additional step.  Player would have to enter the
longer sequence in.  Continue until player loses (and game made an
angry buzz).

It was quite addictive.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Hey. trying to set a data base.

2012-09-10 Thread Keitaro Kaoru
my imports are
import json
import time
from tools import Arguments



@Arguments(mincount = 0, maxcount = 2)
def rank(mgr, room, user, msg, params):
if mgr.isRoomLocked(room) and not user.name == "mr": return
if len(params) < 2:
if len(params) == 0: name = user.name
else: name = params[0]
tg = ch.User(name)
tgrank = mgr.getRank(tg)
data = shared_db.get("level:" + tg.name)
data == json.loads(data)
if data[1] == "level":
mgr.sendObject(room, Html("%s's
rank is %s (%i), set %s ago by %s.", tg.name.title(),
mgr.getRankName(tgrank).title(), tgrank, tdelta(data[3]),
data[2].title()))
else:
if mgr.getRank(user) < 2: return
name, level = params
try:
level = int(level)
except ValueError:
try:
level = mgr.rankNames[level.lower()]
except KeyError:
return Error("Invalid rank name.")
srcrank = mgr.getRank(user)
tg = ch.User(name)
tgrank = mgr.getRank(tg)
if user == tg: return Error("You're not allowed to set your own
rank, silly goose. :3")
if srcrank == level: return Error("You're not allowed to set 
people
to a higher or equal rank than you.")
if tgrank == srcrank: return Error("Did you really think that 
would
work :|. wow people are dummer than i thought.")
mgr.setRank(tg, level)
shared_db.set("level:" + tg.name, json.dumps([room.name, 
"level",
user.name, time.time()]))
return Html("%s's rank set to %s (%i).",
tg.name.title(), mgr.getRankName(level).title(), level)


thats my db.. trying to set ranks for people.and make a db so i can
see how long ago i did it. and by who did it.

 Kawaii:  [mrvjj] [error] /usr/lib/python3.2/json/decoder.py: 345:
TypeError(expected string or buffer)

i get that error...

-- 
~~Austin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread Matthew Ngaha
>> hi guy my book has set me an assignment of a simon says game but i
>> don't really understand what it's asking me to do. here's the text:

It's the last chapter of Python Prgogramming for the absolute
beginner. they have covered all the basics. Even simple tkinter apps
and Pygame games. If i understand what the task was asking me to do,
im confident , even though i might struggle, that in the end i could
do it. But i simply don't understand what this task is asking for. It
doesn't sound similar to Simon Says
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread Matthew Ngaha
> You should read up on the Simon Says rules and such. It's an
> established, old game. Once you get that, then work on replicating it
> through software.
>

thanks for your input. i understand Simon Says. I'm just struggling to
see the connection with the assignment. a sequence of colours and
sounds using the keyboard. I 'm trying to understand how this relates
to the game
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] simon says

2012-09-10 Thread bob gailer

On 9/10/2012 1:15 PM, Matthew Ngaha wrote:

hi guy my book has set me an assignment of a simon says game but i
don't really understand what it's asking me to do. here's the text:

write a version of the simon says game where a player has to repeat an
ever-growing, random sequence of colours and sounds using the
keyboard.

Anyone understand the task?


the best I could to is make guesses. that does not help us. what is 
"your book"? what have you learned so far that might give you a clue as 
to what is asked for?


are you familiar with the "simon says game"? if not see 
http://en.wikipedia.org/wiki/Simon_says


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] simon says

2012-09-10 Thread Matthew Ngaha
hi guy my book has set me an assignment of a simon says game but i
don't really understand what it's asking me to do. here's the text:

write a version of the simon says game where a player has to repeat an
ever-growing, random sequence of colours and sounds using the
keyboard.

Anyone understand the task?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Greg Nielsen
I will admit that the whole Blender project is cool, but Jerry has a point.
All I wanted to know was how to get Pygame and TkInter to work together,
and I got a solid answer about 12 hours ago. (Check out Eryksun's code,
it's beyond cool, past awsome, and close to sexy.) As such, I am
considering this post closed. Thank you all for your help.

Greg
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Walter Prins
Hi Jerry,

On 10 September 2012 16:00, Jerry Hill  wrote:
> On Mon, Sep 10, 2012 at 1:18 AM, Dwight Hutto  wrote:
>> Please beieve me when I say use Blender, and it's Python API. It's a 3-D
>> app, and you can code python with it.
>>
>> The game engine will make it muche easier for you to do 'new age' gaming.
>
> I don't understand how this relates to the question in the original
> post.  Blender is used to create 3D assets for a game.  It's not a
> game engine of its own though, is it?

Actually it is (a game engine), and a pretty decent one at that by the
looks of things, with decent Python bindings, so certainly worth
mentioning to the OP.

Some links:
http://www.blender.org/education-help/tutorials/game-engine/
http://www.tutorialsforblender3d.com/
http://bgame.anicator.com/games/game.php?id=61
http://blenderartists.org/forum/showthread.php?256650-Quality-Blender-Games-LINKS


Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Jerry Hill
On Mon, Sep 10, 2012 at 1:18 AM, Dwight Hutto  wrote:
> Please beieve me when I say use Blender, and it's Python API. It's a 3-D
> app, and you can code python with it.
>
> The game engine will make it muche easier for you to do 'new age' gaming.

I don't understand how this relates to the question in the original
post.  Blender is used to create 3D assets for a game.  It's not a
game engine of its own though, is it?  I thought the original question
was about how to write the game engine, particularly how to have both
Tk widgets and a PyGame Screen both display, so that he can take
advantage of pre-built Tk widgets like buttons and list boxes, and use
PyGame to render his in-game playing field.

I agree that blender looks like a great way to create 3D assets for a
game, but since the OP was talking about sprites, I don't think
Blender is going to be of any help to him.

Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help - My First Program Fails

2012-09-10 Thread Steven D'Aprano

On 10/09/12 19:40, tayo rotimi wrote:

Hi Steven.


Thank you for your answer below. The program now runs,
using print("Game Over").

I use Python 3..; but the book - python for absolute
beginner - that I have is an old (2003) edition. I don't
know how this combination may affect my learning, going
forward. Could you please suggest how I can something
current.


You could buy a more current book that covers Python 3 :)

E.g. http://www.apress.com/9781430216322

(This is not a recommendation, just the first one I
stumbled across.)

But honestly, there aren't that many differences between
Python 2 and 3. print is the main one. There are a few
others, but they are mostly advanced functionality.

In my opinion, with a little bit of care and attention to
detail, if you are prepared to check the notes in the Fine
Manual and if necessarily ask for help here, you can learn
Python 3 from a Python 2 book. It won't be *as* convenient,
of course, but it will be doable.


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Greg Nielsen
Ok kids, settle down.

Quick question to Dwight; why Blender? Im not going for "new age" like
that. (Personally when you spend that much time making a game look nice,
the core mechinics suffer.) However, it does look rather shiny and
powerful. All I really need though are some GUI components to add to my
game. I could write them myself, but if someone else already did the work,
why bother. Have any other recomendations or related info on Blender?

Greg
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help - My First Program Fails

2012-09-10 Thread tayo rotimi
Hi Steven. 


Thank you for your answer below. The program now runs, using print("Game 
Over"). 

I use Python 3..; but the book - python for absolute beginner - that I have is 
an old (2003) edition. I don't know how this combination may affect my 
learning, going forward. Could you please suggest how I can something current. 


Regards.

Tayo.


My answer to your question appears below:



On Sun, Sep 09, 2012 at 03:56:22PM -0700, tayo rotimi wrote:
> My first exercise: print "Game Over" does not run! Where have I missed it? 
> The error message is as follows:
> 
> ?File "", line 1
> ?? print "Game Over"
> ??? ??? ??? ??? ??? ^
> ?SyntaxError: invalid syntax 


Are you using Python 3 instead of Python 2?

One of the changes between the 2.x versions and the 3.x versions is that 
print is no longer a statement, but is now a function. That means you 
have to write it using round brackets (parentheses for Americans):

# version 2.x
print "Game Over"

# version 3.x
print("Game Over")


For simple printing, there's not much advantage either way, but for more 
advanced printing, the function form is much better.



-- 
Steven___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Dwight Hutto
> Note to self, avoid http://www.hitwebdevelopment.com like the plague as
> the CEO has poor communication skills :)
>
> Mark Lawrence.
>
> Point out the poor communication skills then ...Mark. Don't just use
> useless propaganda.
>
-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Dwight Hutto
;)

-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Dwight Hutto
On Mon, Sep 10, 2012 at 3:08 AM, Mark Lawrence wrote:

> On 10/09/2012 06:18, Dwight Hutto wrote:
>
>> Please believe me when I say use Blender, and it's Python API. It's a 3-D
>> app, and you can code python with it.
>>
>> The game engine will make it muche easier for you to do 'new age' gaming.
>>
>>
And I quote:

Hello Tutor,

 Quick question. Working on a new game and want to build in a GUI.

My response::
Please believe me when I say use Blender, and it's Python API. It's a 3-D
app, and you can code python with it.



>
>> When replying can you please quote the context, without that the above is
> meaningless.
>
> Note to self, avoid 
> http://www.hitwebdevelopment.**comlike the 
> plague as the CEO has poor communication skills :)
>
>


> Note to yourself:
>

Never respond with a meaningless critique, unless you can back it up.  I
believe I gave the OP advice he needed to utilize python, and have an GDK
with is worth learning, just as easily as pygame, with much more features.

 P..S. The plague(virus) had great communication skills, which is why it
was a plague. Do a wiki search on google.
-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygame and TkInter

2012-09-10 Thread Mark Lawrence

On 10/09/2012 06:18, Dwight Hutto wrote:

Please beieve me when I say use Blender, and it's Python API. It's a 3-D
app, and you can code python with it.

The game engine will make it muche easier for you to do 'new age' gaming.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



When replying can you please quote the context, without that the above 
is meaningless.


Note to self, avoid http://www.hitwebdevelopment.com like the plague as 
the CEO has poor communication skills :)


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor