Re: [Tutor] seeing the results of a python program in windows7

2012-03-15 Thread Brian van den Broek
On 15 Mar 2012 04:14, bob gailer bgai...@gmail.com wrote:

 On 3/14/2012 12:12 PM, Tamar Osher wrote:

 I can run a python program in Notepad++, but what happens is that the
black box flashes and disappears immediately, so that I never see the
results.


  How can I style it so that the results of the program stay on the
computer screen, for me to see?

 Do this:

 try:
   # your program goes here
 finally:
   raw_input(Press any key)
 # if you are running Python 3 replace raw_input with input

 Adding the try-finally construct ensures that any exception in your code
will be visible.


Alternatively, invoke python to run your program at the prompt with the
interactive switch:

  python -i myscript.py

Best,

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


[Tutor] minecraft and python

2012-03-15 Thread Hadi ismail

Hello, im new to python i've decided to learn python so i can make plugins in 
games like css and minecraft i have a question about
minecraft, there is a plugin that loads plugins made in python. 
http://forums.bukkit.org/threads/dev-pythonloader-v0-3-1-load-plugins-written-in-python-1597.30389/page-2
This sounds really nice because i dont have to learn java but i dont know how 
to start
how would make a program that works in minecraft for example this program

Roll the dice 
numbers 1-10 if the player picks the right number he gets a reward
you can only do it once in a while
the rewards could be items or something

i know how to do this in python but i dont know how to do it in way that it 
works in minecraft seems like its impossible for me and there are no tutorials 
on it 
because the python loader plugin doesnt tell you how to do this stuff and i 
couldnt find anything online about it please help thank you
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] minecraft and python

2012-03-15 Thread Alan Gauld

On 15/03/12 07:53, Hadi ismail wrote:


i know how to do this in python but i dont know how to do it in way that
it works in minecraft seems like its impossible for me and there are no
tutorials on it


There are probably tutorials on how to do it in Java and you will need 
to translate how Java does it to Python. Also you may be able to find 
plugins written in Python by other people and you can study their code 
to see how they did similar things.


Unfortunately you will be very lucky if you find anyone on this list to 
answer your questions. You would really need to ask on a minecraft forum 
or mailing list. Even if you did find someone it's not really relevant 
to this list since it is about learning to program in

python, not learning to interface with product xyz...

good luck,

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


[Tutor] null inputs

2012-03-15 Thread ADRIAN KELLY

Hi guys, 
how do i prevent a user from leaving a blank when inputting?
 
e.g. 
age=int(input(what age are you? )).. i want to stop the user 
pressing enter
 
if age==?

 
  
Adrian Kelly 
1 Bramble Close
Baylough
Athlone
County Westmeath

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


[Tutor] FW: null inputs

2012-03-15 Thread ADRIAN KELLY



Adrian Kelly 
1 Bramble Close
Baylough
Athlone
County Westmeath

0879495663

 



From: kellyadr...@hotmail.com
To: tutor@python.org
Subject: null inputs
Date: Thu, 15 Mar 2012 14:19:16 +




Hi guys, 
how do i prevent a user from leaving a blank when inputting?
 
e.g. 
age=int(input(what age are you? )).. i want to stop the user 
pressing enter
 
if age==?

 
  
age=raw_input(what age are you? )
if age==:
age=int(age)
print please enter your age
else:
print your age is ,age
 *
i have tried this but still no luck, if anyone can help i would apprecitate it
  

Adrian Kelly 
1 Bramble Close
Baylough
Athlone
County Westmeath

0879495663

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


Re: [Tutor] FW: null inputs

2012-03-15 Thread James Reynolds
On Thu, Mar 15, 2012 at 10:32 AM, ADRIAN KELLY kellyadr...@hotmail.comwrote:



 Adrian Kelly
 1 Bramble Close
 Baylough
 Athlone
 County Westmeath

 0879495663


  --
 From: kellyadr...@hotmail.com
 To: tutor@python.org
 Subject: null inputs
 Date: Thu, 15 Mar 2012 14:19:16 +

 Hi guys,
 how do i prevent a user from leaving a blank when inputting?

 e.g.
 age=int(input(what age are you? )).. i want to stop the
 user pressing enter

 if age==?


   
 age=raw_input(what age are you? )
 if age==:
 age=int(age)
 print please enter your age
 else:
 print your age is ,age
  *
 i have tried this but still no luck, if anyone can help i would
 apprecitate it



 Adrian Kelly
 1 Bramble Close
 Baylough
 Athlone
 County Westmeath

 0879495663


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



You can't prevent users from entering whatever they feel like it, but you
can prevent your program from processing that input and force them to try
again.

The typical way this is done is through a while loop:

age = ''

while age != ''
age=raw_input(what age are you? )

this will continue to loop until you give it something other than ''.

Of course, you can build on this, you know, something like:

checker = False

while checker:
age=raw_input(what age are you? )
try:
age = int(age)
checker = True
except TypeError:
  print you didn't enter an integer for an age!
  print try again!!!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] FW: null inputs

2012-03-15 Thread Hugo Arts
On Thu, Mar 15, 2012 at 3:56 PM, James Reynolds eire1...@gmail.com wrote:


 You can't prevent users from entering whatever they feel like it, but you
 can prevent your program from processing that input and force them to try
 again.

 The typical way this is done is through a while loop:

 age = ''

 while age != ''
     age=raw_input(what age are you? )

 this will continue to loop until you give it something other than ''.

 Of course, you can build on this, you know, something like:

 checker = False

 while checker:
     age=raw_input(what age are you? )
     try:
         age = int(age)
         checker = True
     except TypeError:
       print you didn't enter an integer for an age!
       print try again!!!



Small correction: the exception you're looking for in this case is a
ValueError (after all, the argument provided has the correct type, but
its value can not be converted to an integer). int will throw
TypeError, but only if you supply an argument that is not a string or
number.

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


Re: [Tutor] FW: null inputs

2012-03-15 Thread ADRIAN KELLY

thanks very much i get it now...

 
  

 From: hugo.yo...@gmail.com
 Date: Thu, 15 Mar 2012 16:03:12 +0100
 Subject: Re: [Tutor] FW: null inputs
 To: eire1...@gmail.com
 CC: kellyadr...@hotmail.com; tutor@python.org
 
 On Thu, Mar 15, 2012 at 3:56 PM, James Reynolds eire1...@gmail.com wrote:
 
 
  You can't prevent users from entering whatever they feel like it, but you
  can prevent your program from processing that input and force them to try
  again.
 
  The typical way this is done is through a while loop:
 
  age = ''
 
  while age != ''
  age=raw_input(what age are you? )
 
  this will continue to loop until you give it something other than ''.
 
  Of course, you can build on this, you know, something like:
 
  checker = False
 
  while checker:
  age=raw_input(what age are you? )
  try:
  age = int(age)
  checker = True
  except TypeError:
print you didn't enter an integer for an age!
print try again!!!
 
 
 
 Small correction: the exception you're looking for in this case is a
 ValueError (after all, the argument provided has the correct type, but
 its value can not be converted to an integer). int will throw
 TypeError, but only if you supply an argument that is not a string or
 number.
 
 Hugo
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How do I get user input when running a python program?

2012-03-15 Thread Tamar Osher

Hi.  I am reading Python for the Absolute Beginner, finished chapter 4, and am 
trying to duplicate the author's games.  In order to know if I have properly 
created my new games, I need to get user input and see what happens.  How do I 
set things up on my computer so that I can get user input when my new program 
is being run?  I have Python 3.2.2 and a Windows7 64-bit computer.  I hope to 
hear from someone; thank you very much for helping me.  I am very appreciative!




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


Re: [Tutor] How do I get user input when running a python program?

2012-03-15 Thread Prasad, Ramit
Hi.  I am reading Python for the Absolute Beginner, finished chapter 4, and am 
trying to duplicate the author's games.  In order to know if I have properly 
created my new games, I need to get user input and see what happens.  How do I 
set things up on my computer so that I can get user input when my new program 
is being run?  I have Python 3.2.2 and a Windows7 64-bit computer.  I hope to 
hear from someone; thank you very much for helping me.  I am very appreciative!

How is the author doing it? What code do you have? What problems are you facing?
What errors are you getting (please copy/paste the full error message including 
stack trace)? 


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] stuck on null values

2012-03-15 Thread ADRIAN KELLY

Please can anyone tell me how to solve the problem i am having here, i am 
trying to loop if the value is left blank by the user but how can i then use 
the value and multiply it.  e.g. while number_child== i want to 
multiply the input i get.???
def main():print 
Welcome to the Travel 
Kiosk
adult=15child=5firstname=raw_input(Please enter your firstname: )
lastname=raw_input (Please enter your lastname: )
number_child=raw_input(Enter the number of kids: )
number_adults=raw_input(Enter the number of adults: )while 
number_child==:number_child=raw_input(Enter the number of kids: )   
 price=child*number_childprint 
___
Thank you, the Price will be: ,price
print___
main()


 

  

Adrian Kelly 
1 Bramble Close

Baylough

Athlone

County Westmeath

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


Re: [Tutor] stuck on null values

2012-03-15 Thread Joel Goldstick
On Thu, Mar 15, 2012 at 5:24 PM, ADRIAN KELLY kellyadr...@hotmail.com wrote:
 Please can anyone tell me how to solve the problem i am having here, i am
 trying to loop if the value is left blank by the user
 but how can i then use the value and multiply it.  e.g. while
 number_child== i want to multiply the input i get.???

 def main():
     print 
 

                 Welcome to the Travel Kiosk
 
 

     adult=15
     child=5
     firstname=raw_input(Please enter your firstname: )
     lastname=raw_input (Please enter your lastname: )
     number_child=raw_input(Enter the number of kids: )
     number_adults=raw_input(Enter the number of adults: )
     while number_child==:
         number_child=raw_input(Enter the number of kids: )
     price=child*number_child


     print 
 ___

 Thank you, the Price will be: ,price
     print
 ___
 

 main()






 Adrian Kelly
 1 Bramble Close
 Baylough
 Athlone
 County Westmeath

 0879495663

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

raw_input returns the values the user types as a string.  In python if
you have 3 * 'bob' the result will be bobbobbob

So you need to turn the number_child into a number like so:  int(number_child)

You will need to do the same thing for the number of adults.

That will get you started, but if your user types in something that
isn't a number, your program will fail.  See if you can get it to work
for good data and then come back with what happens when you type in
other than integers.

Also, when your program fails, it prints out what is called a
traceback.  When you get this situation, be sure to post the traceback
with your problem.  It helps figure out what went wrong


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


Re: [Tutor] How do I get user input when running a python program?

2012-03-15 Thread Walter Prins
Hi Tamar,

On 15 March 2012 17:59, Tamar Osher emeraldoff...@hotmail.com wrote:
 Hi.  I am reading Python for the Absolute Beginner, finished chapter 4, and
 am trying to duplicate the author's games.  In order to know if I have
 properly created my new games, I need to get user input and see what
 happens.  How do I set things up on my computer so that I can get user input
 when my new program is being run?  I have Python 3.2.2 and a Windows7 64-bit
 computer.  I hope to hear from someone; thank you very much for helping me.
  I am very appreciative!

Firstly, what version of the book are you using?  (Or more
specifically, what version of Python is the book using?)  You're just
setting yourself up for trouble if your book is using a substantially
different version of Python than you are.  (The first version of the
book, for example, came out in 2003 and uses Python 2.2...)  The
second edition came out around 2006 so probably also uses Python 2.x
so even if you're using that, I'd suggest you perhaps consider
uninstalling Python 3 and (for now at least) installing something
closer to what the book is using. (Sorry if this causes you trouble,
but IMHO it's probably better for you to not introduce more
unnecessary variables that make your learning more complicated that it
needs to be and using Python 3.x when your book is 2.x will make
things more complicated than it needs to be.)

Secondly, have you actually read the first 3 chapters?  I ask, because
by your question it appears you may not have, or may not have properly
absorbed the content.  For example, in the first chapter of the book
(at the least, the first version), your question is partially
answered.  I quote:

*Waiting for the user*


The last line of the program:

raw_input(\n\nPress the Enter key to exit.)

displays the prompt Press the Enter key to exit. and waits for the
user to press the Enter key.  Once the user presses the key, the
program ends. This is a nice trick to keep a console window open until
the user is done with an application.

Similarly, there's a section entitled Getting user input in chapter
2.  So, to echo Ramit, are you having trouble understanding how the
author does it in Chapter 1  2?  If not, what are you stuck on?

Regards,

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


[Tutor] how I overcame the problem I cannot run Python programs

2012-03-15 Thread Tamar Osher

I realized that my computer was running the programs.  The black box was 
flashing off and disappearing immediately, so that I never saw the programs.  
Also, I am using Notepad++, in addition to IDLE.  I am now able to see my 
programs and provide user input, when I use Notepad++.
Also, I still have not fully overcome, I am slowly on my way to success.
I am working vigorously on Python, but only 10% of my time is learning Python.  
The rest of my time is learning everything related to Python, to get my 
programs to work.
I greatly appreciate everyone's help!  I cannot thank each of you enough.  
Thanks for being there when I need someone!  Have a wonderful day!

 





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


Re: [Tutor] how I overcame the problem I cannot run Python programs

2012-03-15 Thread eire1130

That's the nature of things I'm afraid. 

I do about half of my development on windows. My recomendation, download 
eclipse and install pydev. IDE choice is always a touchy subject but for 
windows, this should be your choice.

I have notepad++ as well. Its great. But eclipse is better, especially for 
learning. I can't describe how much it helped me.




Sent from my Verizon Wireless BlackBerry

-Original Message-
From: Tamar Osher emeraldoff...@hotmail.com
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Thu, 15 Mar 2012 17:12:37 
To: Tutor@Python.orgtutor@python.org
Subject: [Tutor] how I overcame the problem I cannot run Python programs

___
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] more about how I overcame not being able to run my programs

2012-03-15 Thread Tamar Osher

I am very appreciative for the many valuable individuals who graciously take 
their precious time to help others in need.  Special thanks to:
Brian van den Broek,Bob Gailer,and Hugo Arts.
I followed all the instructions of Hugo, Bob, and Brian.  This is specifically 
what I am now doing so that I can see the programs that I run, and also be able 
to provide user input:
try:import os# my programfinally:input ('\n\t\t\tPress the enter 
key to continue.')os.system ('pause') 



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


Re: [Tutor] more about how I overcame not being able to run my programs

2012-03-15 Thread Alan Gauld

On 15/03/12 22:39, Tamar Osher wrote:


try:
import os
# my program
finally:
input ('\n\t\t\tPress the enter key to continue.')
os.system ('pause')


It's more conventional to put the import at the very top, before the 
try: line.


But otherwise what you have should be fine. There are other ways of 
doing it and eventually you may write programs that don't require the 
press enter... line and you can then miss out all of the code above. But 
for learning that's fine.


Or just run your programs inside IDLE or, as someone else suggested, 
Eclipse and PyDev (although personally that seems like overkill!)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] how I overcame the problem I cannot run Python programs

2012-03-15 Thread Mark Lawrence

On 15/03/2012 22:30, eire1...@gmail.com wrote:


That's the nature of things I'm afraid.

I do about half of my development on windows. My recomendation, download 
eclipse and install pydev. IDE choice is always a touchy subject but for 
windows, this should be your choice.

I have notepad++ as well. Its great. But eclipse is better, especially for 
learning. I can't describe how much it helped me.



I believe that eclipse is crap.  I tried it 10 years ago and gave up 
because it was so slow.  I tried it a couple of months ago for two weeks 
and again gave up for the same reasons.  Why not stick with pythonwin, 
it's perfectly adequate for my needs?


--
Cheers.

Mark Lawrence.

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


Re: [Tutor] more about how I overcame not being able to run my programs

2012-03-15 Thread Steven D'Aprano

Alan Gauld wrote:

On 15/03/12 22:39, Tamar Osher wrote:


try:
import os
# my program
finally:
input ('\n\t\t\tPress the enter key to continue.')
os.system ('pause')


It's more conventional to put the import at the very top, before the 
try: line.


True, but in this case, if there is an import error, the message will flash by 
without being read. Wrapping the *entire* program, imports and all, ensures 
that the program will pause regardless of what happens.



--
Steven

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


Re: [Tutor] how I overcame the problem I cannot run Python programs

2012-03-15 Thread Alan Gauld

On 16/03/12 00:29, Mark Lawrence wrote:

I have notepad++ as well. Its great. But eclipse is better, especially
for learning. I can't describe how much it helped me.


I believe that eclipse is crap.


No, it's not crap, it's one of the most powerful and extensible 
development tools available and used by thousands (millions?) of 
professional programmers worldwide. But...


 I tried it 10 years ago and gave up because it was so slow.

It's written in Java and 10 years ago few PCs had the horsepower to run 
Java well, and the Java compilers/VM were less efficient too.



I tried it a couple of months ago for two weeks and again gave up

 for the same reasons.

Unless you are still using the same 10 year old PC it shouldn't have 
been that bad! I certainly don't find it any slower than most large apps 
these days.



Why not stick with pythonwin, it's perfectly adequate for my needs?


For a beginner to python I tend to agree with you. Not because Eclipse 
is slow but because it's way over powered for the simple programs 
beginners write. If you want to develop a large application with 
dozens/hundreds of files and packages on Windows then Eclipse (or 
Netbeans etc) is a useful tool to have. And if you need to develop code 
in many different languages again, Eclipse will provide consistency. And 
if you need to build design models in UML you get a choice of top-end 
tools. But, for single-file programs Pythonwin and even IDLE are 
perfectly adequate.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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