Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Alan Gauld

"bhaaluu" <[EMAIL PROTECTED]> wrote 

In addition to Kents comments about dictionaruy 
access I think there may be another problem in 
your logic.

> The first loop is supposed to populate G with
> a random range of 4 integers 10 to 109
> in random keys 1-19 that have a zero (except keY 6 and  keY 11)
> So keY 6 and keY 11 should both have a zero in G after the
> four integers have been sown.
> 
>if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0:
>tablE.values()[5][6] = 0
>tablE.values()[10][6] = 0
>cnt -= 1
>keY = random.choice(a)

This detects any of the exception cases so a simple else 
clause should be sufficient for the others. However if you 
really want an explicit check...

>if keY != 6 or keY != 11 or table.values()[keY-1][6] == 0:

This test should use 'and' rather than 'or' since you want 
all of the conditions to be true, not just one of them.
But since the failing condituions should all have been 
caught above simply using else here would do what 
I think you want.

>b = range(10,110) # 10 to 109
>integer = random.choice(b)
>tablE.values()[keY-1][6] = integer
>cnt += 1


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

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


Re: [Tutor] how to make python program as executable

2008-01-30 Thread Alan Gauld
"brindly sujith" <[EMAIL PROTECTED]> wrote

> i am developing a  GUI application in python(tkinter)
>
> i want to know how to make the python program as a application ie i 
> want to
> make it executable

If you are on Windows it should be executable already,
just double click on the main file in Windows Explorer
and it should run. If not the file associations need setting.

If you are on a Unix based system you will need to use
chmod +x to  make the file executable. You will also
need the shebang line set:

#! /bin/env python

or whatever is appropriate on your system.

HTH,

Alan G. 


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


[Tutor] how to enable overrideredirect

2008-01-30 Thread brindly sujith
from Tkinter import *
import tkMessageBox
import tkFileDialog,os
def quit():
if tkMessageBox.askokcancel("Quit","DO u really want to quit"):
root.destroy()

def fiopen():
file1 = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a 
file')
os.system("openoffice %s"%file1.name)

root=Tk()
label=Label(root,text="Welcome to PC-FREE PROJECTOR")
label.pack()
button=Button(root,text="select",command=fiopen)
button.pack()
button1=Button(root,text="Exit",command=quit)
button1.pack()
root.overrideredirect(True)
root.geometry('%dx%d+%d+%d' % (root.winfo_screenwidth(),
   root.winfo_screenheight(),
   0, 0))
root.lift()
root.mainloop()


the above program is my application

please execute this program...

while executing this program

initially a window will openafter that the buttons 'select'
and 'exit' is not working...

i checked out by disabling root.overrideredirect(True) line in
the program...then its working

what is the problem here...i want this program to work perfectly

plz do reply me

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


Re: [Tutor] how to make python program as executable

2008-01-30 Thread Luke Paireepinart
Alan Gauld wrote:
> "brindly sujith" <[EMAIL PROTECTED]> wrote
>
>   
>> i am developing a  GUI application in python(tkinter)
>>
>> i want to know how to make the python program as a application ie i 
>> want to
>> make it executable
>> 
>
> If you are on Windows it should be executable already,
> just double click on the main file in Windows Explorer
> and it should run. If not the file associations need setting.
>
> If you are on a Unix based system you will need to use
> chmod +x to  make the file executable. You will also
> need the shebang line set:
>
> #! /bin/env python
>
> or whatever is appropriate on your system.
>   
I think he meant " i want to make the application [into an] executable" 
I.E. he wants an .exe file on Windows.
In this case, you can use py2exe, and there's another alternative I 
can't remember.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
This is probably a totally naïve and silly idea, 
but I thought I'd run it by the Tutors anyway.

Years ago I learned a bit of Visual Basic (VB6, 
IIRC) at a community college. Months ago I 
downloaded the free Visual Basic 2005 Express 
(), 
but didn't do much with it.

But I was wondering if it was possible to write 
Python code in Iron Python and use it somehow in 
Visual Basic 2005 Express. VB seemed a very easy 
way to create a GUI, but of course I prefer Python for the code.

So, possible/impossible/impractical/foolish/Pythonically_traitorous?

Thanks,

Dick Moores

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


Re: [Tutor] how to make python program as executable

2008-01-30 Thread Thorsten Kampe
* Luke Paireepinart (Wed, 30 Jan 2008 03:59:59 -0600)
> I think he meant " i want to make the application [into an]
> executable" I.E. he wants an .exe file on Windows.
> In this case, you can use py2exe, and there's another alternative I
> can't remember.

The better alternative is "Pyinstaller"...

Thorsten

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


Re: [Tutor] how to enable overrideredirect

2008-01-30 Thread Kent Johnson
brindly sujith wrote:

> while executing this program 
> 
> initially a window will openafter that the buttons 'select'
> and 'exit' is not working...

It works for me as written on Mac OSX with Python 2.5.1. What platform 
are you running on? How are you running the program? If you are running 
it from IDLE, try running from a command line.

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


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Kent Johnson
Dick Moores wrote:

> But I was wondering if it was possible to write 
> Python code in Iron Python and use it somehow in 
> Visual Basic 2005 Express. VB seemed a very easy 
> way to create a GUI, but of course I prefer Python for the code.
> 
> So, possible/impossible/impractical/foolish/Pythonically_traitorous?

This shows how to use IronPython code from C#, does that help?
http://www.ironpython.info/index.php/Contents#Embedding

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 29, 2008 9:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Try
>  if keY == 6 or keY == 11 or tablE[keY-1][6] != 0:
>  tablE[5][6] = 0
>  tablE[10][6] = 0
>
> etc.
>
> Kent
>
> PS what's with the strange capitalization of variable names?

It's a test snippet. I use unusual names in my tests.

-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 29, 2008 9:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
> > if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0:
> > tablE.values()[5][6] = 0
> > tablE.values()[10][6] = 0
>
> This is not the right way to access the values of a dict. tablE.values()
> is a list of the values in tablE, but it is not in the order you expect;
> it is easiest to think that it is in a random or indeterminate order.
>
> Try
>  if keY == 6 or keY == 11 or tablE[keY-1][6] != 0:
>  tablE[5][6] = 0
>  tablE[10][6] = 0
>
> etc.
>
> Kent
>

Now that you mention it, I do seem to remember that the order of
a list is indeterminate.

What kind of Python array structure would you use if you need to
access each element in the exact order it appears in the table?
The only element that gets changed is the last one, all the others
stay exactly the same. So far, this structure seems to be working
okay in the big program. Maybe 2-3% of the time is an integer put
in keys 6 or 11.

-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
At 04:02 AM 1/30/2008, Kent Johnson wrote:
>Dick Moores wrote:
>
>>But I was wondering if it was possible to write Python code in Iron 
>>Python and use it somehow in Visual Basic 2005 Express. VB seemed a 
>>very easy way to create a GUI, but of course I prefer Python for the code.
>>So, possible/impossible/impractical/foolish/Pythonically_traitorous?
>
>This shows how to use IronPython code from C#, does that help?
>http://www.ironpython.info/index.php/Contents#Embedding

Thanks, Kent, but I can't tell if it does or not..

Dick

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


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
At 05:26 AM 1/30/2008, Kent Johnson wrote:
>Dick Moores wrote:
>
But I was wondering if it was possible to write Python code in 
Iron Python and use it somehow in Visual Basic 2005 Express.
>
>You might have better luck asking on an IronPython list. I don't 
>know if we have any IronPython gurus here.

Thanks, Kent. I will.

Dick


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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 8:24 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
> > Now that you mention it, I do seem to remember that the order of
> > a list is indeterminate.
>
> No; the order of a dict is indeterminate, and consequently the order of
> lists derived from dicts with keys(), values(), etc. is indeterminate.

The order of the dictionary is indeterminate. But the key is always
attached to the value, and in my case, the value is a list, so

print tablE.keys() #prints all the keys [in an ordered list, 1-19]

print tablE.keys()[5] #prints the key, 6

print tablE.values() #prints a list of [all [the lists]]

print tablE.values()[5] #prints only the [list for key 6]

print tablE.values()[5][2] #prints the third element: 1

So what you're saying here is that while it might work okay on
my system, that this may not work the same way on another
system?

>
> The order of a list is determined by how you create it.

Yes, this is how it works in my list test, and this is what my Python
books say. (Although I may have forgotten that on a conscious level,
I am now reminded of it.) 8^D

> >
> > What kind of Python array structure would you use if you need to
> > access each element in the exact order it appears in the table?
>
> A list of lists may be the correct structure for your program. You could
> define tablE as
>
> tablE= [[ 0, 2, 0, 0, 0, 0, 0],# 1
>  [ 1, 3, 3, 0, 0, 0, 0],# 2
>  [ 2, 0, 5, 2, 0, 0, 0],# 3
> ...
>
> [ 9, 0, 0,16, 0, 0, 0]]   # 19
>
> Kent
>

I'll give it a go, and see if I can make that work.
However, except for not getting 100% in my number
distribution routine, the dictionary seems to be working okay
(on my system).

Here's a simple example of the dictionary in action.
"for" loops have replaced all the "if" selections... this was the first example.
I've left the "if"'s in so the table.values() can be easily seen.

#!/usr/bin/python
# 2007-01-19
# 2007-01-20
"""
Map
+--+--+
|  |  |
| 5   |
|  1   |  |
|  +--  --+N
|  |  ||
+--  --+  4   | W--+--E
|  |  ||
|  +--  --+S
|  2   |  |
| 3   |
|  |  |
+--+--+
"""
#rm#  N S E W
travelTable = {1:[0,2,5,0],
   2:[1,0,3,0],
   3:[4,0,0,2],
   4:[5,3,0,0],
   5:[0,4,0,1]}

def main():
roomNum = 1
print \
"""
Instructions:
Move through the rooms by pressing [N] for North, [S]
for South, [E] for East, [W] for West, and [Q] to Quit.
These movement keys are not case sensitive (ie. [n] is
the same as [N]).
"""
name = raw_input("What is your name? ")
exploring=True
while exploring:
print name + ", your strength is",
print str(strength) +"."
#
print name,"you are in room",roomNum
#
if travelTable.values()[roomNum-1][0] != 0:
print "A door leads North."
if travelTable.values()[roomNum-1][1] != 0:
print "A door leads South."
if travelTable.values()[roomNum-1][2] != 0:
print "A door leads East."
if travelTable.values()[roomNum-1][3] != 0:
print "A door leads West."
#
move = raw_input("Which way do you want to go? ")
if move.upper() == "Q":
exploring=False
#
if move.upper()=="N" and travelTable.values()[roomNum-1][0] == 0:
print
print "You cannot move that way."
if move.upper()=="S" and travelTable.values()[roomNum-1][1] == 0:
print
print "You can't walk through walls."
if move.upper()=="E" and travelTable.values()[roomNum-1][2] == 0:
print
print "Try another direction."
if move.upper()=="W" and travelTable.values()[roomNum-1][3] == 0:
print
print "There is no door to the West."
#
if move.upper() =="N" and travelTable.values()[roomNum-1][0] != 0:
roomNum = travelTable.values()[roomNum-1][0]
if move.upper() =="S" and travelTable.values()[roomNum-1][1] != 0:
roomNum = travelTable.values()[roomNum-1][1]
if move.upper() =="E" and travelTable.values()[roomNum-1][2] != 0:
roomNum = travelTable.values()[roomNum-1][2]
if move.upper() =="W" and travelTable.values()[roomNum-1][3] != 0:
roomNum = travelTable.values()[roomNum-1][3]
#
print
main()

-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegia

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote:
> On Jan 30, 2008 8:24 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
>> bhaaluu wrote:
>>> Now that you mention it, I do seem to remember that the order of
>>> a list is indeterminate.
>> No; the order of a dict is indeterminate, and consequently the order of
>> lists derived from dicts with keys(), values(), etc. is indeterminate.
> 
> The order of the dictionary is indeterminate. But the key is always
> attached to the value, and in my case, the value is a list, so
> 
> print tablE.keys() #prints all the keys [in an ordered list, 1-19]

This is implementation dependent. You should not depend on the order of 
elements in tablE.keys()

> print tablE.keys()[5] #prints the key, 6

This is implementation dependent.

> print tablE.values() #prints a list of [all [the lists]]

Yes. The order of the list (of lists) is implementation dependent.

> print tablE.values()[5] #prints only the [list for key 6]

This is implementation dependent and pointless. You are not using the 
dict at all except as a way to store a list of lists. Either use 
tablE[6], which will always return the list associated with the key 6, 
or just keep your lists in a list directly.

> So what you're saying here is that while it might work okay on
> my system, that this may not work the same way on another
> system?

Yes. The order of keys() and values() is implementation dependent. It 
may change with different versions of Python and different 
implementations. It can also change as you add more elements to the dict.

(For example, one problem the Jython folks have had getting Django to 
run on Jython is that the Django unit tests make assumptions about the 
order of dict values. These assumptions are not true in Jython and the 
unit tests fail.)

> if travelTable.values()[roomNum-1][0] != 0:

Again, the use of travelTable.values() is pointless, inefficient (it 
creates a new list every time you call it) and indeterminate. Really, 
you shouldn't be doing this. I can't think of any reason to code this way.

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


Re: [Tutor] how to make python program as executable

2008-01-30 Thread Michael Langford
On the command line type "which python"

Then at the top of your script put:

#!/usr/bin/python

or whatever path the which command outputted.

Then run chmod on the program:

chmod ugo+x script.py

then the following will work:
./script.py

If you actually want to build an executable that doesn't depend on the
presence of python, then this tutorial will help you:
http://wiki.python.org/moin/Freeze


  --Michael

On Jan 30, 2008 9:11 AM, brindly sujith <[EMAIL PROTECTED]> wrote:
> i am using linux...
>
> plz tell me how to do it
>
>
>



-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote:
> Now that you mention it, I do seem to remember that the order of
> a list is indeterminate.

No; the order of a dict is indeterminate, and consequently the order of 
lists derived from dicts with keys(), values(), etc. is indeterminate.

The order of a list is determined by how you create it.
> 
> What kind of Python array structure would you use if you need to
> access each element in the exact order it appears in the table?

A list of lists may be the correct structure for your program. You could 
define tablE as

tablE= [[ 0, 2, 0, 0, 0, 0, 0],# 1
 [ 1, 3, 3, 0, 0, 0, 0],# 2
 [ 2, 0, 5, 2, 0, 0, 0],# 3
...
[ 9, 0, 0,16, 0, 0, 0]]   # 19

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


Re: [Tutor] how to make python program as executable

2008-01-30 Thread Michael Langford
What platform? The mechanism is different for each major OS.



On Jan 30, 2008 2:25 AM, brindly sujith <[EMAIL PROTECTED]> wrote:
> hi
>
> i am developing a  GUI application in python(tkinter)
>
> i want to know how to make the python program as a application ie i want to
> make it executable
>
> please guide me
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Kent Johnson
Dick Moores wrote:

>>> But I was wondering if it was possible to write Python code in Iron 
>>> Python and use it somehow in Visual Basic 2005 Express.

You might have better luck asking on an IronPython list. I don't know if 
we have any IronPython gurus here.

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 9:22 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> This is implementation dependent.
>[snip]
>
> > if travelTable.values()[roomNum-1][0] != 0:
>
> Again, the use of travelTable.values() is pointless, inefficient (it
> creates a new list every time you call it) and indeterminate. Really,
> you shouldn't be doing this. I can't think of any reason to code this way.
>
> Kent

This is good to know!
The reason I coded it that way is because I'm learning.
I seem to always be learning... that's why I'm subscribed
to THIS list. 8^D

Back to the drawing board!
Thank you very much for your help!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 3:35 AM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> In addition to Kents comments about dictionaruy
> access I think there may be another problem in
> your logic.
>
>
> "bhaaluu" <[EMAIL PROTECTED]> wrote
>
> > The first loop is supposed to populate G with
> > a random range of 4 integers 10 to 109
> > in random keys 1-19 that have a zero (except keY 6 and  keY 11)
> > So keY 6 and keY 11 should both have a zero in G after the
> > four integers have been sown.
> >
> >if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0:
> >tablE.values()[5][6] = 0
> >tablE.values()[10][6] = 0
> >cnt -= 1
> >keY = random.choice(a)
>
> This detects any of the exception cases so a simple else
> clause should be sufficient for the others. However if you
> really want an explicit check...
>
> >if keY != 6 or keY != 11 or table.values()[keY-1][6] == 0:
>
> This test should use 'and' rather than 'or' since you want
> all of the conditions to be true, not just one of them.
> But since the failing condituions should all have been
> caught above simply using else here would do what
> I think you want.
>
>
> >b = range(10,110) # 10 to 109
> >integer = random.choice(b)
> >tablE.values()[keY-1][6] = integer
> >cnt += 1
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld

Thank you Alan and Kent.
Your suggestions caused me to completely start
from scratch. It also looks like the "nested sequence"
will be easier to use in the long run (and I'm into this
for the long run!). 8^D

This is working properly now on my
GNU/Linux system running Python 2.4.3:

#!/usr/bin/python
# 2008-01-30

import random

# setup environment
# N S E W U D T
travelTable=[[0,2,0,0,0,0,0],# ROOM 1
 [1,3,3,0,0,0,0],# ROOM 2
 [2,0,5,2,0,0,0],# ROOM 3
 [0,5,0,0,0,0,0],# ROOM 4
 [4,0,0,3,5,13,0],   # ROOM 5
 [0,0,1,0,0,0,0],# ROOM 6
 [0,8,0,0,0,0,0],# ROOM 7
 [7,0,0,0,0,0,0],# ROOM 8
 [0,9,0,0,0,8,0],# ROOM 9
 [8,0,11,0,0,0,0],   # ROOM 10
 [0,0,10,0,0,0,0],   # ROOM 11
 [0,0,0,13,0,0,0],   # ROOM 12
 [0,0,12,0,5,0,0],   # ROOM 13
 [0,15,17,0,0,0,0],  # ROOM 14
 [14,0,0,0,0,5,0],   # ROOM 15
 [17,0,19,0,0,0,0],  # ROOM 16
 [18,16,0,14,0,0,0], # ROOM 17
 [0,17,0,0,0,0,0],   # ROOM 18
 [9,0,0,16,0,0,0]]   # ROOM 19

# distribute positive numbers 10 to 109
# place in last element of 4 random lists
# nothing is placed in list 6 or 11
cnt=0
while cnt <= 3:
a = range(1,20)
room = random.choice(a)
if room != 6 and room != 11 and travelTable[room-1][6] == 0:
b = range(10,110)
treasure = random.choice(b)
travelTable[room-1][6] = treasure
else:
cnt -= 1
cnt += 1

# distribute negtive numbers -4 to -1
# place in last element of 4 random lists
# nothing is placed in list 6 or 11
cnt=4
while cnt > 0:
a = range(1,20)
room = random.choice(a)
if room != 6 and room != 11 and travelTable[room-1][6] == 0:
travelTable[room-1][6] = -cnt
else:
cnt += 1
cnt -= 1

# put positive numbers in the last element
# of two specific lists overwriting any
# number that exists
a = range(1,99)
travelTable[3][6]= 100 + random.choice(a)
travelTable[15][6]= 100 + random.choice(a)

print " 1:", travelTable[0][6]
print " 2:", travelTable[1][6]
print " 3:", travelTable[2][6]
print " 4:", travelTable[3][6]
print " 5:", travelTable[4][6]
print " 6:", travelTable[5][6]
print " 7:", travelTable[6][6]
print " 8:", travelTable[7][6]
print " 9:", travelTable[8][6]
print "10:", travelTable[9][6]
print "11:", travelTable[10][6]
print "12:", travelTable[11][6]
print "13:", travelTable[12][6]
print "14:", travelTable[13][6]
print "15:", travelTable[14][6]
print "16:", travelTable[15][6]
print "17:", travelTable[16][6]
print "18:", travelTable[17][6]
print "19:", travelTable[18][6]
# end of program

-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote:

> # distribute positive numbers 10 to 109
> # place in last element of 4 random lists
> # nothing is placed in list 6 or 11
> cnt=0
> while cnt <= 3:
> a = range(1,20)
> room = random.choice(a)

room = random.randint(1, 19) is simpler.

> if room != 6 and room != 11 and travelTable[room-1][6] == 0:
> b = range(10,110)
> treasure = random.choice(b)

Use randint() here too.

> travelTable[room-1][6] = treasure
> else:
> cnt -= 1
> cnt += 1

This use of cnt is a bit strange. Why not increment only in the 
successful 'if' and get rid of the 'else' entirely?

Rather than repeating the loop until you get three distinct, valid 
random numbers, you could do something like this:

# Change 7 rooms, not room 6 or 11
changeableRooms = range(1, 20)
changeableRooms.remove(6)
changeableRooms.remove(11)

roomsToChange = random.sample(changeableRooms, 7)

# First three get something good
for room in roomsToChange[:3]:
   travelTable[room-1][6] = random.randint(10, 119)

# Last four get something bad
for i, room in enumerate(roomsToChange[3:]):
   travelTable[room-1][6] = -i-1

> print " 1:", travelTable[0][6]
etc - use a loop and string formatting:

for i, room in enumerate(travelTable):
   print ' %s: %s' % (i+1, room[6])

Finally, you might consider putting a dummy entry at travelTable[0], or 
number the rooms from 0, so you don't have to adjust the indices all the 
time.

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bob gailer
bhaaluu wrote:
> # N S E W U D T
> travelTable=[[0,2,0,0,0,0,0],# ROOM 1
>  [1,3,3,0,0,0,0],# ROOM 2
It is good to finally see that you are building an adventure game.

Consider creating a instance of a Room class for each room and saving 
them in a collection such as a list.

This will give you much more flexibility as your game grows.

Inevitably I wound up doing a bunch of things more "Pythonically" so 
there may be stuff here you don't relate to yet. But is is all worth 
studying and will save you hours of headache later.

- code -
import random
class Room:
  roomNo = 0
  def __init__(self, destinations, updatable=True):
Room.roomNo += 1
self.roomNo = Room.roomNo
self.destinations = destinations
# store treasure apaart from destinations
self.treasure = 0 # add intial treasure
self.updatable = updatable # may have the treasure updated
  def updateTreasure(self, treasure):
self.treasure = treasure
  def __repr__(self):
return " %s:%s" % (self.roomNo, self.treasure)

rooms = [
  Room([0,2,0,0,0,0]),  # ROOM 1
  Room([1,3,3,0,0,0]),  # ROOM 2
  Room([2,0,5,2,0,0]),  # ROOM 3
  Room([0,5,0,0,0,0]),  # ROOM 4
  Room([4,0,0,3,5,13]), # ROOM 5
  Room([0,0,1,0,0,0], False), # ROOM 6 flagged as not updatable
  Room([0,8,0,0,0,0]), # ROOM 7
  Room([7,0,0,0,0,0]), # ROOM 8
  Room([0,9,0,0,0,8]), # ROOM 9
  # etc for the rest of the rooms -
]
  # note I omitted the initial treasure value since it is always 0
  # I modified the last for statement to account for only 9 rooms

# use random.sample to create random subsets of values and rooms
# - eliminates all the loops and tests
# note this ensures no duplicate treasures (do you want that?)

# create list of 8 random treasure values
values = random.sample(range(10,110),4) + random.sample(range(-4, 0),4)

# create list of 8 randomly selected updatable rooms
roomsToUpdate= random.sample([room for room in rooms if room.updatable], 8)

# update the rooms' Treasures
for room, value in zip(roomsToUpdate, values):
  room.updateTreasure(value)

a = range(1,99)
for room in (3,5):
  rooms[room].updateTreasure(100 + random.choice(a))

for room in rooms: print room 
- end code -

Things I did not do, but suggest:
- store the room destinations in a text file rather than hard-coding 
them in the program. It is almost always a good idea to separate logic 
from data.

 -create a Treasure class, storing instances directly in roo,s rather 
than indexes, and storing treasure definitions in the text file.

-store room instances in the destinations rather than indexes.

At this point you no longer need indexes!

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

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 12:46 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
>
> > # distribute positive numbers 10 to 109
> > # place in last element of 4 random lists
> > # nothing is placed in list 6 or 11
> > cnt=0
> > while cnt <= 3:
> > a = range(1,20)
> > room = random.choice(a)
>
> room = random.randint(1, 19) is simpler.
>
> > if room != 6 and room != 11 and travelTable[room-1][6] == 0:
> > b = range(10,110)
> > treasure = random.choice(b)
>
> Use randint() here too.
>
> > travelTable[room-1][6] = treasure
> > else:
> > cnt -= 1
> > cnt += 1
>
> This use of cnt is a bit strange. Why not increment only in the
> successful 'if' and get rid of the 'else' entirely?
>
> Rather than repeating the loop until you get three distinct, valid
> random numbers, you could do something like this:
>
> # Change 7 rooms, not room 6 or 11
> changeableRooms = range(1, 20)
> changeableRooms.remove(6)
> changeableRooms.remove(11)
>
> roomsToChange = random.sample(changeableRooms, 7)
>
> # First three get something good
> for room in roomsToChange[:3]:
>travelTable[room-1][6] = random.randint(10, 119)
>
> # Last four get something bad
> for i, room in enumerate(roomsToChange[3:]):
>travelTable[room-1][6] = -i-1
>
> > print " 1:", travelTable[0][6]
> etc - use a loop and string formatting:
>
> for i, room in enumerate(travelTable):
>print ' %s: %s' % (i+1, room[6])
>
> Finally, you might consider putting a dummy entry at travelTable[0], or
> number the rooms from 0, so you don't have to adjust the indices all the
> time.
>
> Kent
>

Thank you Kent! All of these look like very useful suggestions.

What I'm trying to do is implement an old Text Adventure Game
that was written c.1983. I'm trying to keep the flavor of the game
as close as possible to the original.

I'm not old enough, in computer years, to remember the "Glory Days"
of Text Adventure Games on computers like the Apple ][, Atari,
Commodore 64, IBM PC, VIC 20, and so forth. As a result, I don't
know anything about Text Adventure Games. So this is a real
learning experience for me in more ways than just learning Python.

The book I'm using as a reference is at:
http://www.atariarchives.org/adventure/
Creating Adventure Games On Your Computer.
The author was Tim Hartnell.
http://en.wikipedia.org/wiki/Tim_Hartnell

Most of the problems so far stem from the old line-numbered BASIC's
GOTO [line-number] statements. There are other problems as well,
but _that one crops up regularly.

Nevertheless, it has been fun, so far. I'm a Hobbyist programmer, so
even if I don't succeed at making a Retro-game, I'm having fun trying.

At least I'm getting a good idea of what an old-timey Text Adventure
Game is all about. The only thing I can think of of, is that it must have
been quite a challenge to get one of those old computers to do anything
at all so if someone could get a TAG working, it must have been
quite a thrill! 8^D

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Alan Gauld

"Dick Moores" <[EMAIL PROTECTED]> wrote

> But I was wondering if it was possible to write 
> Python code in Iron Python and use it somehow in 
> Visual Basic 2005 Express. VB seemed a very easy 
> way to create a GUI, but of course I prefer Python for the code.


It should be possible but I've no idea how. I suspect you 
might need to write the Python code in a class but I'm not 
even sure about that. My experiece of .NET is both very
limited and entirely in C#

But the whole idea of the intermediate code thing is 
that you can intermix languages.

Alan G

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 2:24 PM, bob gailer <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
> > # N S E W U D T
> > travelTable=[[0,2,0,0,0,0,0],# ROOM 1
> >  [1,3,3,0,0,0,0],# ROOM 2
> It is good to finally see that you are building an adventure game.
>
> Consider creating a instance of a Room class for each room and saving
> them in a collection such as a list.
>
> This will give you much more flexibility as your game grows.

WooHoo! YES! This is what I started out wanting to do, as an exercise
in learning Python Object Oriented Programming (POOP). I thought
a Text Adventure Game would be a perfect learning tool because
it seems to have objects that model the real world (or a fantasy world).
There is the Explorer, a world (The Castle), Rooms to explore, objects
in the rooms, like Treasure to be picked-up, and Monsters to fight.

However, not having any experience with Text Adventure Games has
been a real bummer for me as far as designing POOP classes. So I
fell back on procedural programming in order to learn more about
TAGs, so I'd have a better idea about how to design the class in POOP.

>
> Inevitably I wound up doing a bunch of things more "Pythonically" so
> there may be stuff here you don't relate to yet. But is is all worth
> studying and will save you hours of headache later.
>

I really appreciate source code. I probably learn faster by modifying
and running source code than anything else, unless it is a step-by-step
tutorial that also has source code that can be modified and run! 8^D

> - code -
> import random
> class Room:
>   roomNo = 0
>   def __init__(self, destinations, updatable=True):
> Room.roomNo += 1
> self.roomNo = Room.roomNo
> self.destinations = destinations
> # store treasure apaart from destinations
> self.treasure = 0 # add intial treasure
> self.updatable = updatable # may have the treasure updated
>   def updateTreasure(self, treasure):
> self.treasure = treasure
>   def __repr__(self):
> return " %s:%s" % (self.roomNo, self.treasure)
>
> rooms = [
>   Room([0,2,0,0,0,0]),  # ROOM 1
>   Room([1,3,3,0,0,0]),  # ROOM 2
>   Room([2,0,5,2,0,0]),  # ROOM 3
>   Room([0,5,0,0,0,0]),  # ROOM 4
>   Room([4,0,0,3,5,13]), # ROOM 5
>   Room([0,0,1,0,0,0], False), # ROOM 6 flagged as not updatable
>   Room([0,8,0,0,0,0]), # ROOM 7
>   Room([7,0,0,0,0,0]), # ROOM 8
>   Room([0,9,0,0,0,8]), # ROOM 9
>   # etc for the rest of the rooms -
> ]
>   # note I omitted the initial treasure value since it is always 0
>   # I modified the last for statement to account for only 9 rooms
>
> # use random.sample to create random subsets of values and rooms
> # - eliminates all the loops and tests
> # note this ensures no duplicate treasures (do you want that?)
>
> # create list of 8 random treasure values
> values = random.sample(range(10,110),4) + random.sample(range(-4, 0),4)
>
> # create list of 8 randomly selected updatable rooms
> roomsToUpdate= random.sample([room for room in rooms if room.updatable], 8)
>
> # update the rooms' Treasures
> for room, value in zip(roomsToUpdate, values):
>   room.updateTreasure(value)
>
> a = range(1,99)
> for room in (3,5):
>   rooms[room].updateTreasure(100 + random.choice(a))
>
> for room in rooms: print room
> - end code -

I'll copy/paste this into an editor, and see if I can make it do anything.
Thank you!

>
> Things I did not do, but suggest:
> - store the room destinations in a text file rather than hard-coding
> them in the program. It is almost always a good idea to separate logic
> from data.

Right now, my procedural Python program has a main.py, data.py and
action.py. After Kent told me about using a nested sequence structure
instead of a dictionary, all I had to do was edit data.py and change
the table from a dictionary to a list of lists, then edit the other two
files and do a simple search and destroy to get rid of the " .values() ".
It really didn't take as long as I thought it would to change over.

>
>  -create a Treasure class, storing instances directly in roo,s rather
> than indexes, and storing treasure definitions in the text file.
>
> -store room instances in the destinations rather than indexes.
>
> At this point you no longer need indexes!
>
> --
> Bob Gailer
> 919-636-4239 Chapel Hill, NC

Thanks again for the POOP!
Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
At 11:46 AM 1/30/2008, Alan Gauld wrote:

>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> > But I was wondering if it was possible to write
> > Python code in Iron Python and use it somehow in
> > Visual Basic 2005 Express. VB seemed a very easy
> > way to create a GUI, but of course I prefer Python for the code.
>
>
>It should be possible but I've no idea how. I suspect you
>might need to write the Python code in a class but I'm not
>even sure about that. My experiece of .NET is both very
>limited and entirely in C#
>
>But the whole idea of the intermediate code thing is
>that you can intermix languages.

Alan, could you explain what you mean by "the intermediate code thing"?

Thanks,

Dick

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
I got Bob's code running!
Here it is for all nineteen rooms:

#!/usr/bin/python
# 2008-01-30
# bob gailer [Tutor]
import random
class Room:
 roomNo = 0
 def __init__(self, destinations, updatable=True):
   Room.roomNo += 1
   self.roomNo = Room.roomNo
   self.destinations = destinations
   # store treasure apaart from destinations
   self.treasure = 0 # add intial treasure
   self.updatable = updatable # may have the treasure updated
 def updateTreasure(self, treasure):
   self.treasure = treasure
 def __repr__(self):
   return " %s:%s" % (self.roomNo, self.treasure)

# Table of Rooms
rooms = [
  Room([0,2,0,0,0,0,0]),# 1 Hallway
  Room([1,3,3,0,0,0,0]),# 2 Audience Chamber
  Room([2,0,5,2,0,0,0]),# 3 Great Hall
  Room([0,5,0,0,0,0,0]),# 4 Private Meeting Room
  Room([4,0,0,3,15,13,0]),  # 5 Inner Hallway
  Room([0,0,1,0,0,0,0],False),  # 6 Entrance (Not Updatable)
  Room([0,8,0,0,0,0,0]),# 7 Kitchen
  Room([7,10,0,0,0,0,0]),   # 8 Store Room
  Room([8,8,8,8,8,8,0]),# 9 Lift
  Room([8,0,11,0,0,0,0]),   #10 Rear Vestibule
  Room([0,0,10,0,0,0,0],False), #11 Exit (Not Updatable)
  Room([0,0,0,13,0,0,0]),   #12 Dungeon
  Room([0,0,12,0,5,0,0]),   #13 Guardroom
  Room([0,15,17,0,0,0,0]),  #14 Master Bedroom
  Room([14,0,0,0,0,5,0]),   #15 Upper Hall
  Room([17,0,19,0,0,0,0]),  #16 Treasury
  Room([18,16,0,14,0,0,0]), #17 Chambermaid's Bedroom
  Room([0,17,0,0,0,0,0]),   #18 Dressing Chamber
  Room([9,0,0,16,0,0,0])]   #19 Small Room

# note I omitted the initial treasure value since it is always 0
# use random.sample to create random subsets of values and rooms
# - eliminates all the loops and tests
# note this ensures no duplicate treasures (do you want that?)

# create list of 8 random treasure values
values = random.sample(range(10,110),4) + random.sample(range(-4, 0),4)
print " values:",values

# create list of 8 randomly selected updatable rooms
roomsToUpdate = random.sample([room for room in rooms if room.updatable], 8)
print "8 rooms:",roomsToUpdate

# update the rooms' Treasures
for room, value in zip(roomsToUpdate, values):
 room.updateTreasure(value)

a = range(1,99)
for room in (3,15):
 rooms[room].updateTreasure(100 + random.choice(a))

for room in rooms:
print room
# end code 


On Jan 30, 2008 2:24 PM, bob gailer <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
> > # N S E W U D T
> > travelTable=[[0,2,0,0,0,0,0],# ROOM 1
> >  [1,3,3,0,0,0,0],# ROOM 2
> It is good to finally see that you are building an adventure game.
>
> Consider creating a instance of a Room class for each room and saving
> them in a collection such as a list.
>
> This will give you much more flexibility as your game grows.
>
> Inevitably I wound up doing a bunch of things more "Pythonically" so
> there may be stuff here you don't relate to yet. But is is all worth
> studying and will save you hours of headache later.
>
>[code snipped - see at top]
>
> Things I did not do, but suggest:
> - store the room destinations in a text file rather than hard-coding
> them in the program. It is almost always a good idea to separate logic
> from data.
>
>  -create a Treasure class, storing instances directly in roo,s rather
> than indexes, and storing treasure definitions in the text file.
>
> -store room instances in the destinations rather than indexes.
>
> At this point you no longer need indexes!
>
> --
> Bob Gailer
> 919-636-4239 Chapel Hill, NC
>
>

Thanks!
Happy Programing!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Luke Paireepinart

>
> Alan, could you explain what you mean by "the intermediate code thing"?
He's referring to CLR.  The .NET framework compiles all of its programs 
into a Common Language Runtime, so at the lower level,
there's no(t much?) difference between the different languages, and thus 
they can interface with each other.
I'm sure the Wikipedia article on CLR would be a lot more informative 
than I can be.
HTH,
-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 10:13 PM, Tiger12506 <[EMAIL PROTECTED]> wrote:
> If you're looking for examples - I like the zork games...
>
> http://www.csd.uwo.ca/Infocom/download.html
>

I've already looked at the Infocom site and didn't find
anything that helped me understand Text Adventure
Games like  Hartnell's book does. BASIC is easy to
read, and with the book's explanations, I'm learning
how to program a TAG in Python. My goal is to code
the game in POOP when I understand enough game
elements to design classes for the various objects in
the game, like rooms, treasure, monsters, and so
forth. Bob Gailer recently sent a POOP example
that does a setup of the environment. His Room class
gave me an idea of how it is done. POOP has been
somewhat difficult for me to grasp. At first, it was all
the new vocabulary. Then connecting the vocabulary
to concepts. Most tutorials revolve around the mechanics
of POOP, but don't really get into how to think about
POOP from a design point of view. I'm pretty sure that
once I "get it", I'll wonder why it took me so long... at
least that's how it's been in the past when I've tried to
learn a new concept. So I study it until I hit a block, then
go do something else for awhile. Then I study it some
more. Hartnell's book doesn't get into POOP because
it was written in c.1983 line-numbered BASIC. However,
he has a much better grasp of c.1983 TAGs than I do.
I fixed enough typos in two of the games in the book
to get them running in a GWBASIC interpreter on an
old 286 DOS computer. I can play the game on the 286,
read the code, and read the book. Then I try to do
something similar in Python.

The Infocom games are cool, but they don't give me
the feedback like Hartnell's book and code does.

BTW, there's also "RenPy" which is an Open Source
Interactive Fiction / Visual Novel engine written in Python.
That's pretty cool, but they aren't at all like the TAGs
in Hartnell's book.

There's also a really nice Adventure game tutorial
over at Brian Wisti's site:
http://coolnamehere.com/geekery/python/ifiction/index.html

References:
http://www.csd.uwo.ca/Infocom/
http://www.atariarchives.org/adventure/
http://en.wikipedia.org/wiki/Tim_Hartnell
http://www.renpy.org/wiki/renpy/Home_Page

Believe me, I've looked at a LOT of stuff trying to get a
handle on Adventure Games. 8^D

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Alan Gauld

"Dick Moores" <[EMAIL PROTECTED]> wrote

>>But the whole idea of the intermediate code thing is
>>that you can intermix languages.
>
> Alan, could you explain what you mean by "the intermediate code 
> thing"?

.NET works like Java in that it doesn't compile into machine
language object code directly but uses a framework called
the Common Language Runtime(CLR)  and an underlying
foundation known as the Common Language Infrastructure (CLI)
which in turn includes the Common Type System (CTS) and the
Common Intermediate Language (CIL)  which all of the .NET family
of languages must support.

The CLR includes things like a common exception handling
framework, comon object model and of course the common
types (so an int looks the same in VB or C#) and intermediate
language that is interpreted by the .NET environment. Exactly like a
Java JIT compiler converts Java bytecode into machine code
prior to execution.compiled Java bytecode. This is all hidden
inside an exe file by providing a standard exe style header
which Windows can use to determine the type of exe and
for CLR files launch the .NET environment.

For more detail see the MS .NET web pages and other .NET sites.

I also recommend the O'Reilly ".NET Framework Essentials"
book for an overview of how it all fits together.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld







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


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
At 02:32 PM 1/30/2008, Luke Paireepinart wrote:


>>Alan, could you explain what you mean by "the intermediate code thing"?
>He's referring to CLR.  The .NET framework compiles all of its 
>programs into a Common Language Runtime, so at the lower level,
>there's no(t much?) difference between the different languages, and 
>thus they can interface with each other.
>I'm sure the Wikipedia article on CLR would be a lot more 
>informative than I can be.

Looks like a good article, Luke. 


I just remembered that a friend dropping by this evening is a 
Microsoft programmer/manager. I think he's mentioned IPython to me 
before. Maybe he can help with what I'm trying to do. No answer from 
the IPython Users List yet..

Dick


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


Re: [Tutor] Iron Python and Visual Basic 2005 Express

2008-01-30 Thread Dick Moores
At 03:03 PM 1/30/2008, Alan Gauld wrote:

>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> >>But the whole idea of the intermediate code thing is
> >>that you can intermix languages.
> >
> > Alan, could you explain what you mean by "the intermediate code
> > thing"?
>
>.NET works like Java in that it doesn't compile into machine
>language object code directly but uses a framework called
>the Common Language Runtime(CLR)  and an underlying
>foundation known as the Common Language Infrastructure (CLI)
>which in turn includes the Common Type System (CTS) and the
>Common Intermediate Language (CIL)  which all of the .NET family
>of languages must support.
>
>The CLR includes things like a common exception handling
>framework, comon object model and of course the common
>types (so an int looks the same in VB or C#) and intermediate
>language that is interpreted by the .NET environment. Exactly like a
>Java JIT compiler converts Java bytecode into machine code
>prior to execution.compiled Java bytecode. This is all hidden
>inside an exe file by providing a standard exe style header
>which Windows can use to determine the type of exe and
>for CLR files launch the .NET environment.
>
>For more detail see the MS .NET web pages and other .NET sites.
>
>I also recommend the O'Reilly ".NET Framework Essentials"
>book for an overview of how it all fits together.

Thanks very much, Alan. I think I'm in over my head here.

I'm somewhat surprised that what I asked about doing in my initial 
post doesn't seem to have been done yet..

Dick


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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote:
> References:
> http://www.csd.uwo.ca/Infocom/
> http://www.atariarchives.org/adventure/
> http://en.wikipedia.org/wiki/Tim_Hartnell
> http://www.renpy.org/wiki/renpy/Home_Page
> 
> Believe me, I've looked at a LOT of stuff trying to get a
> handle on Adventure Games. 8^D

I'm surprised you don't have any references to Colossal Cave:
http://en.wikipedia.org/wiki/Colossal_Cave_Adventure

This article talks about the data files used to define the cave - a good 
example of data-driven programming:
http://www.digitalhumanities.org/dhq/vol/001/2/09.html

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


Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 11:25 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
> > References:
> > http://www.csd.uwo.ca/Infocom/
> > http://www.atariarchives.org/adventure/
> > http://en.wikipedia.org/wiki/Tim_Hartnell
> > http://www.renpy.org/wiki/renpy/Home_Page
> >
> > Believe me, I've looked at a LOT of stuff trying to get a
> > handle on Adventure Games. 8^D
>
> I'm surprised you don't have any references to Colossal Cave:
> http://en.wikipedia.org/wiki/Colossal_Cave_Adventure

I've heard of Colossal Cave, but no, I haven't looked at
it (yet?). Most of my searches have tried to be related
to programming an Adventure Game, with less of an
interest in just playing an adventure game. However,
I have tried a couple of the older Infocom games (with
limited success, I might add).

>
> This article talks about the data files used to define the cave - a good
> example of data-driven programming:
> http://www.digitalhumanities.org/dhq/vol/001/2/09.html

THIS IS SWEET!  This article is really well written.
Actually, Hartnell's book also has a brief history of
adventure games, and Crowther and Woods, among
others are mentioned. Hartnell talks about the
pre-computer gamers who recreated historical battles,
who later went on  and developed Dungeon & Dragons
type games and RPGs (another genre of gaming that
I know nothing about). Later, those games were
computerized.  I'm not sure how many people still
play these games? The local used-book store has
several shelves packed with RPG books.

>
> Kent
>

Thanks for these links, Kent!
I never may have found them otherwise.
Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] appending to a list

2008-01-30 Thread David Bear
I want to return a tuple from a function. I want to append the second
element of that tupple to a list. For example

mylist = []
def somefunc():
   return(3.14, 'some string')

somenum, mylist.append(??) somefunc()

obviously, the syntax doesn't work. This should be easy, but I've never seen
example code. any pointers?


-- 
--
David Bear
College of Public Programs at Arizona State University

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


Re: [Tutor] appending to a list

2008-01-30 Thread Bill Campbell
On Wed, Jan 30, 2008, David Bear wrote:
>I want to return a tuple from a function. I want to append the second
>element of that tupple to a list. For example
>
>mylist = []
>def somefunc():
>   return(3.14, 'some string')
>
>somenum, mylist.append(??) somefunc()
>
>obviously, the syntax doesn't work. This should be easy, but I've never seen
>example code. any pointers?

mylist.append(somefunc()[1])

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:(206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

If ye love wealth greater than liberty, the tranquillity of servitude
greater than the animating contest for freedom, go home from us in peace.
We seek not your consul, nor your arms.  Crouch down and lick the hand that
feeds you.  May your chains set lightly upon you;  and may posterity forget
ye were our countrymen. -- Samuel Adams (American Patriot)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how to use freeze for making executable python file in linux

2008-01-30 Thread brindly sujith
can i use freeze to make my python program in to executable in linux

if yes...plz tell me how to use freeze

whether i need to install something or its default in python
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor