Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-15 Thread Alan Gauld

On 15/02/13 03:09, neubyr wrote:


I do have a doubt regarding this - e.g. how would I implement this if my
program/application is web based. For example, loading the text file
during web server start and stop.


For a long running process like a web server this is probably the wrong 
approach. You probably want to save the data more regularly - maybe even 
at the end of every user transaction. But with a web server we have the 
additional problem of usually wanting to handle multiple requests in 
parallel so storing data in memory gets more complicated - which takes 
us back to using a data base which pretty much handles all of that for you.


If you will only have a single request running at a time then you can 
use the same try/finally approach in your transaction processing code. 
But because they run  so often I'd add the 'dirty flag' idea that 
somebody else mentioned too so that you don;t sabve if no changes have 
been made.


A dirty flag is simply a global (or class) level variable (isDirty) that 
gets set by your code anytime you change the data. If a book changes its 
state it sets the flag to True. The save code then does something like


with open(filename) as store
   if Book.isDirty:
  for book in Book.instances:
  book.save(store)

That will ensure that any changes are saved but we don't waste time
if no changes exist.

--
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] Newbie Here -- Averaging Adding Madness Over a Given (x) Range?!?!

2013-02-15 Thread Michael J. McConachie
@Bob @David -- I gave you all the other parts to give you a background,
and context as it relates to my 'problem'.  My apologies if it seems
obfuscated.  I took an  hour to write that email, and revised it several
times in an attempt to provide good information.  Please disregard my OP.


On 02/14/2013 05:06 PM, bob gailer wrote:
 On 2/14/2013 3:55 PM, Michael McConachie wrote:
 [snip]

 I agree with dave angel - the specification is far from clear. please
 clarify. perhaps a simple example that goes from input to desired output.


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


Re: [Tutor] Newbie Here -- Averaging Adding Madness Over a Given (x) Range?!?!

2013-02-15 Thread Michael J. McConachie
@ Stephen,

Thank you for the answers.  I appreciate your understanding, and
patience; I understand that it was confusing (unintentionally) and
probably irritating to any of the seasoned tutor list members. 

Your examples helped greatly, and was the push I needed.  Happy Friday,
and thanks again,

Mike

On 02/14/2013 05:48 PM, Steven D'Aprano wrote:
 On 15/02/13 07:55, Michael McConachie wrote:

 Essentially:

 1.  I have a list of numbers that already exist in a file.  I
 generate this file by parsing info from logs.
 2.  Each line contains an integer on it (corresponding to the number
 of milliseconds that it takes to complete a certain repeated task).
 3.  There are over a million entries in this file, one per line; at
 any given time it can be just a few thousand, or more than a million.

 Example:
 ---
 173
 1685
 1152
 253
 1623


 A million entries sounds like a lot to you or me, but to your
 computer, it's not. When you start talking tens or hundreds of
 millions, that's possibly a lot.

 Do you know how to read those numbers into a Python list? Here is the
 baby step way to do so:


 data = []  # Start with an empty list.
 f = open(filename)  # Obviously you have to use the actual file name.
 for line in f:  # Read the file one line at a time.
 num = int(line)  # Convert each line into an integer (whole number)
 data.append(num)  # and append it to the end of the list.
 f.close()  # Close the file when done.


 Here's a more concise way to do it:

 with open(filename) as f:
 data = [int(line) for line in f]



 Once you have that list of numbers, you can sum the whole lot:

 sum(data)


 or just a range of the items:

 sum(data[:100])  # The first 100 items.

 sum(data[100:200])  # The second 100 items.

 sum(data[-50:])  # The last 50 items.

 sum(data[1000:])  # Item 1001 to the end.  (See below.)

 sum(data[5:99:3])  # Every third item, starting at index 5 and ending
 at index 98.



 This is called slicing, and it is perhaps the most powerful and
 useful technique that Python gives you for dealing with lists. The
 rules though are not necessarily the most intuitive though.


 A slice is either a pair of numbers separated with a colon, inside the
 square brackets:

 data[start:end]

 or a triple:

 data[start:end:step]

 Any of these three numbers can be left out. The default values are:

 start=0
 end=length of the sequence being sliced
 step=1

 They can also be negative. If start or end are negative, they are
 interpreted as from the end rather than from the beginning.

 Item positions are counted from 0, which will be very familiar to C
 programmers. The start index is included in the slice, the end
 position is excluded.

 The model that you should think of is to imagine the sequence of items
 labelled with their index, starting from zero, and with a vertical
 line *between* each position. Here is a sequence of 26 items, showing
 the index in the first line and the value in the second:


 |0|1|2|3|4|5|6|7|8|9| ... |25|
 |a|b|c|d|e|f|g|h|i|j| ... |z |

 When you take a slice, the items are always cut at the left. So, if
 the above is called letters, we have:

 letters[0:4]  # returns abcd

 letters[2:8]  # returns cdefgh

 letters[2:8:2]  # returns ceg

 letters[-3:]  # returns xyz



 Eventually what I'll need to do is:

 1.  Index the file and/or count the lines, as to identify each line's
 positional relevance so that it can average any range of numbers that
 are sequential; one to one another.


 No need. Python already does that, automatically, when you read the
 data into a list.



 2.  Calculate the difference between any given (x) range.  In order
 to be able to ask the program to average every 5, 10, 100, 100, or
 10,000 etc. --  until completion.  This includes the need to dealing
 with stray remainders at the end of the file that aren't divisible by
 that initial requested range.

 I don't quite understand you here. First you say difference, then
 you say average. Can you show a sample of data, say, 10 values, and
 the sorts of typical calculations you want to perform, with the
 answers you expect to get?


 For example, here's 10 numbers:


 103, 104, 105, 109, 111, 112, 115, 120, 123, 128


 Here are the running averages of 3 values:

 (103+104+105)/3

 (104+105+109)/3

 (105+109+111)/3

 (109+111+112)/3

 (111+112+115)/3

 (112+115+120)/3

 (115+120+123)/3

 (120+123+128)/3


 Is that what you mean? If so, then Python can deal with this
 trivially, using slicing. With your data stored in list data, as
 above, I can say:


 for i in range(0, len(data)-3):  # Stop 3 from the end.
 print sum(data[i:i+3])


 to print the running sums taking three items at a time.



 The rest of your post just confuses me. Until you explain exactly what
 calculations you are trying to perform, I can't tell you how to
 perform them :-)





___
Tutor maillist  -  Tutor@python.org
To unsubscribe or 

Re: [Tutor] Newbie Here -- Averaging Adding Madness Over a Given (x) Range?!?!

2013-02-15 Thread Albert-Jan Roskam
snip
 Eventually what I'll need to do is:

 
 1.  Index the file and/or count the lines, as to identify each line's 
 positional relevance so that it can average any range of numbers that are 
 sequential; one to one another.

In other words: you would like to down-sample your data? For example, reduce a 
sampling frequency from 1000 samples/second (1KHz) to 100, by averaging every 
ten sequential data points?

 2.  Calculate the difference between any given (x) range.  In order to be 
 able 
 to ask the program to average every 5, 10, 100, 100, or 10,000 etc. -- until 
 completion.  This includes the need to dealing with stray remainders at the 
 end 
 of the file that aren't divisible by that initial requested range. 

In other words: you would like to calculate a running/moving average, with 
window size as a parameter?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Newbie Here -- Averaging Adding Madness Over a Given (x) Range?!?!

2013-02-15 Thread Michael J. McConachie
On 02/15/2013 04:03 PM, Albert-Jan Roskam wrote:
 snip
 Eventually what I'll need to do is:
 1.  Index the file and/or count the lines, as to identify each line's 
 positional relevance so that it can average any range of numbers that are 
 sequential; one to one another.
 In other words: you would like to down-sample your data? For example, reduce 
 a sampling frequency from 1000 samples/second (1KHz) to 100, by averaging 
 every ten sequential data points?
I think so.  When I said 'index' in my OP, I wasn't sure how to explain
that each line would be used positionally to identify each group of (x)
among themselves.  (That's all I meant.)  I am trying to identify
gradient(s) in order to determine performance 'thresholds' if they
exist.  We are noting that as the number of tasks (already performed)
increases, a noticeable decrease in the performance of a certain
repeated task exists.  I am trying to determine that point/elbow in the
performance curve.  I have been asked to identify, and plot the overall
'average performance' with varying levels of granularity.  (Averaging
10, by 100, by 1000, etc.)

The file I mentioned in my OP contains the measurement of time it takes
to complete these repeated tasks.  Each entry is on it's own line. The
recorded data is in literal order of completion.  I am averaging those
(ms time entries) in sets of (x) to keep from having to compute the
difference in time for each completed task individually.

  ie:
   Lines 1-10, (11-20, 21-30 -- to completion) are averaged and
read into a list, or hash in order.
  or:
   Lines 1-100, (101-200, 201-300 -- to completion) are averaged
and read into a list, or hash in order.
  or:
   Lines 1-1000, (1001-2000, 2001-3000 -- to completion) are
averaged and read into a list, or hash in order.

   etc, etc.
 2.  Calculate the difference between any given (x) range.  In order to be 
 able 
 to ask the program to average every 5, 10, 100, 100, or 10,000 etc. -- 
 until 
 completion.  This includes the need to dealing with stray remainders at the 
 end 
 of the file that aren't divisible by that initial requested range. 
 In other words: you would like to calculate a running/moving average, with 
 window size as a parameter?
Yes.

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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Joel Goldstick
On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski
spiceninj...@gmail.comwrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.comwrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python Programming for
 the Absolute Beginner and am starting with a simple Game Over Program.
  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.  You have
 presented your code in a way that can't be.  Can you actually copy your
 program and paste it into an email message.  Also, Windows, Linux, Mac?



 That's it. It is supposed to bring up a window that says Game Over and
 at the bottom say Press enter Key to exit and when you press the enter
 key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid syntax Now,
 if I just put print Game Over then it says Game Over UNDERNEATH the
 code I just printed!
 now I am following the book to the *pixel* and that is not what is
 supposed to happen!
 Please email me back as soon as you get this...(if you are not to busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


You need to unindent the raw_input like so:

print Game Over
raw_input(\n\nPress Enter Key to Exit)

In python you indent code blocks (like for loops, if statements, function
blocks, etc.).  You can't just indent from one line to the next in
sequential code or you will be told its a syntax error



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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Joel Goldstick
On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski
spiceninj...@gmail.comwrote:

 It Didn't work.


First of all, reply to all.  You are sending messages to me only, not to
the group.  Other's may be able to help you better than I can.

Second.  It didn't work is not a useful answer.

So you have a file with two lines in it.  The first has a print statement.
The second has a raw_input statement.  When you run it, what happens
exactly? Do you get a traceback message telling you what the error is, and
on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.comwrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python Programming for
 the Absolute Beginner and am starting with a simple Game Over Program.
  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.  You have
 presented your code in a way that can't be.  Can you actually copy your
 program and paste it into an email message.  Also, Windows, Linux, Mac?



 That's it. It is supposed to bring up a window that says Game Over
 and at the bottom say Press enter Key to exit and when you press the
 enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid syntax
 Now, if I just put print Game Over then it says Game Over UNDERNEATH
 the code I just printed!
 now I am following the book to the *pixel* and that is not what is
 supposed to happen!
 Please email me back as soon as you get this...(if you are not to
 busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements, function
 blocks, etc.).  You can't just indent from one line to the next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Joel Goldstick
Are you using python 2 or python 3?


On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski
spiceninj...@gmail.comwrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New Window
 and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a split
 second and if you look quickly enough then you can see Invalid Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
 joel.goldst...@gmail.comwrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only, not to
 the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, what
 happens exactly? Do you get a traceback message telling you what the error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python Programming
 for the Absolute Beginner and am starting with a simple Game Over
 Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.  You
 have presented your code in a way that can't be.  Can you actually copy
 your program and paste it into an email message.  Also, Windows, Linux, 
 Mac?



 That's it. It is supposed to bring up a window that says Game Over
 and at the bottom say Press enter Key to exit and when you press the
 enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid syntax
 Now, if I just put print Game Over then it says Game Over UNDERNEATH
 the code I just printed!
 now I am following the book to the *pixel* and that is not what is
 supposed to happen!
 Please email me back as soon as you get this...(if you are not to
 busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Joel Goldstick
On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick joel.goldst...@gmail.comwrote:

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
 Window and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a split
 second and if you look quickly enough then you can see Invalid Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


Sorry, you said above python 3.  In python 3 raw_input was changed to
input.  so change that and it will work for you.
There are some differences between 2 and 3 that you will need to look out
for.  Go to the python.org site to learn about them.  Your book was written
for python 2 it seems



 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick joel.goldst...@gmail.com
  wrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only, not to
 the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, what
 happens exactly? Do you get a traceback message telling you what the error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python Programming
 for the Absolute Beginner and am starting with a simple Game Over
 Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.  You
 have presented your code in a way that can't be.  Can you actually copy
 your program and paste it into an email message.  Also, Windows, Linux, 
 Mac?



 That's it. It is supposed to bring up a window that says Game
 Over and at the bottom say Press enter Key to exit and when you 
 press
 the enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid syntax
 Now, if I just put print Game Over then it says Game Over 
 UNDERNEATH
 the code I just printed!
 now I am following the book to the *pixel* and that is not what is
 supposed to happen!
 Please email me back as soon as you get this...(if you are not to
 busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the next 
 in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Joel Goldstick
so copy the code and the error message here


On Fri, Feb 15, 2013 at 5:42 PM, Deborah Piotrowski
spiceninj...@gmail.comwrote:

 I did what you said, nothing changed.
 same errors, same syntax message.
 I suggest you run it on your IDLE to see if it works.


 On Fri, Feb 15, 2013 at 3:31 PM, Joel Goldstick 
 joel.goldst...@gmail.comwrote:




 On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick joel.goldst...@gmail.com
  wrote:

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
 Window and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a
 split second and if you look quickly enough then you can see Invalid
 Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


 Sorry, you said above python 3.  In python 3 raw_input was changed to
 input.  so change that and it will work for you.
 There are some differences between 2 and 3 that you will need to look out
 for.  Go to the python.org site to learn about them.  Your book was
 written for python 2 it seems



 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only, not
 to the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, what
 happens exactly? Do you get a traceback message telling you what the error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python
 Programming for the Absolute Beginner and am starting with a simple 
 Game
 Over Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.  You
 have presented your code in a way that can't be.  Can you actually 
 copy
 your program and paste it into an email message.  Also, Windows, 
 Linux, Mac?



 That's it. It is supposed to bring up a window that says Game
 Over and at the bottom say Press enter Key to exit and when you 
 press
 the enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid
 syntax Now, if I just put print Game Over then it says Game Over
 UNDERNEATH the code I just printed!
 now I am following the book to the *pixel* and that is not what
 is supposed to happen!
 Please email me back as soon as you get this...(if you are not to
 busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the 
 next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Jos Kerc
Sorry, sent before finishing...

If you changed raw_input, as asked.
Now, it complains about print 'Game Over'
Should become print('Game Over')


On Sat, Feb 16, 2013 at 12:10 AM, Jos Kerc josk...@gmail.com wrote:

 No, not same. At lea


 On Fri, Feb 15, 2013 at 11:44 PM, Joel Goldstick joel.goldst...@gmail.com
  wrote:

 so copy the code and the error message here


 On Fri, Feb 15, 2013 at 5:42 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 I did what you said, nothing changed.
 same errors, same syntax message.
 I suggest you run it on your IDLE to see if it works.


 On Fri, Feb 15, 2013 at 3:31 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
 Window and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a
 split second and if you look quickly enough then you can see Invalid
 Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


 Sorry, you said above python 3.  In python 3 raw_input was changed to
 input.  so change that and it will work for you.
 There are some differences between 2 and 3 that you will need to look
 out for.  Go to the python.org site to learn about them.  Your book
 was written for python 2 it seems



 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only,
 not to the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, what
 happens exactly? Do you get a traceback message telling you what the 
 error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python
 Programming for the Absolute Beginner and am starting with a 
 simple Game
 Over Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.
 You have presented your code in a way that can't be.  Can you 
 actually copy
 your program and paste it into an email message.  Also, Windows, 
 Linux, Mac?



 That's it. It is supposed to bring up a window that says Game
 Over and at the bottom say Press enter Key to exit and when you 
 press
 the enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid
 syntax Now, if I just put print Game Over then it says Game 
 Over
 UNDERNEATH the code I just printed!
 now I am following the book to the *pixel* and that is not
 what is supposed to happen!
 Please email me back as soon as you get this...(if you are not
 to busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the 
 next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com

 ___
 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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Jos Kerc
No, not same. At lea


On Fri, Feb 15, 2013 at 11:44 PM, Joel Goldstick
joel.goldst...@gmail.comwrote:

 so copy the code and the error message here


 On Fri, Feb 15, 2013 at 5:42 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 I did what you said, nothing changed.
 same errors, same syntax message.
 I suggest you run it on your IDLE to see if it works.


 On Fri, Feb 15, 2013 at 3:31 PM, Joel Goldstick joel.goldst...@gmail.com
  wrote:




 On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
 Window and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a
 split second and if you look quickly enough then you can see Invalid
 Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


 Sorry, you said above python 3.  In python 3 raw_input was changed to
 input.  so change that and it will work for you.
 There are some differences between 2 and 3 that you will need to look
 out for.  Go to the python.org site to learn about them.  Your book was
 written for python 2 it seems



 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only, not
 to the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, what
 happens exactly? Do you get a traceback message telling you what the 
 error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python
 Programming for the Absolute Beginner and am starting with a 
 simple Game
 Over Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.
 You have presented your code in a way that can't be.  Can you 
 actually copy
 your program and paste it into an email message.  Also, Windows, 
 Linux, Mac?



 That's it. It is supposed to bring up a window that says Game
 Over and at the bottom say Press enter Key to exit and when you 
 press
 the enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid
 syntax Now, if I just put print Game Over then it says Game 
 Over
 UNDERNEATH the code I just printed!
 now I am following the book to the *pixel* and that is not what
 is supposed to happen!
 Please email me back as soon as you get this...(if you are not
 to busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the 
 next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com

 ___
 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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Mark Lawrence

On 15/02/2013 22:31, Joel Goldstick wrote:


Sorry, you said above python 3.  In python 3 raw_input was changed to
input.  so change that and it will work for you.
There are some differences between 2 and 3 that you will need to look
out for.  Go to the python.org http://python.org site to learn about
them.  Your book was written for python 2 it seems



In Python 3 the syntax error is caused by print not having brackets, not 
the as it happens the incorrect call to raw_input.


--
Cheers.

Mark Lawrence

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


Re: [Tutor] New User-Need-Help

2013-02-15 Thread Jos Kerc
On Sat, Feb 16, 2013 at 12:20 AM, Deborah Piotrowski spiceninj...@gmail.com
 wrote:

 It works, but it doesn't open a window. It just says that stuff under the
 code. How do you open a window?





Depends...
How do you run the script? From Idle, command prompt?



 On Fri, Feb 15, 2013 at 4:14 PM, Jos Kerc josk...@gmail.com wrote:

 Sorry, sent before finishing...

 If you changed raw_input, as asked.
 Now, it complains about print 'Game Over'
 Should become print('Game Over')


 On Sat, Feb 16, 2013 at 12:10 AM, Jos Kerc josk...@gmail.com wrote:

 No, not same. At lea


 On Fri, Feb 15, 2013 at 11:44 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:

 so copy the code and the error message here


 On Fri, Feb 15, 2013 at 5:42 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 I did what you said, nothing changed.
 same errors, same syntax message.
 I suggest you run it on your IDLE to see if it works.


 On Fri, Feb 15, 2013 at 3:31 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:

 Are you using python 2 or python 3?


 On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
 Window and type in the code:
 print Game Over
 raw_input(\n\nPress Enter Key to exit)
 and save the file on my desktop.
 I double-click it and it opens a black window with gray text for a
 split second and if you look quickly enough then you can see Invalid
 Sytnax.
 If I do the same code in the Interactive Window then it highlights
 raw_input and says Invalid Syntax

 Are you using python 2 or python 3?


 Sorry, you said above python 3.  In python 3 raw_input was changed to
 input.  so change that and it will work for you.
 There are some differences between 2 and 3 that you will need to look
 out for.  Go to the python.org site to learn about them.  Your book
 was written for python 2 it seems



 On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 It Didn't work.


 First of all, reply to all.  You are sending messages to me only,
 not to the group.  Other's may be able to help you better than I can.

 Second.  It didn't work is not a useful answer.

 So you have a file with two lines in it.  The first has a print
 statement.  The second has a raw_input statement.  When you run it, 
 what
 happens exactly? Do you get a traceback message telling you what the 
 error
 is, and on what line?





 On Fri, Feb 15, 2013 at 3:05 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 5:03 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:



 On Fri, Feb 15, 2013 at 2:58 PM, Joel Goldstick 
 joel.goldst...@gmail.com wrote:




 On Fri, Feb 15, 2013 at 4:45 PM, Deborah Piotrowski 
 spiceninj...@gmail.com wrote:

 Hi,


 I am very new to Python, I am using the e-book Python
 Programming for the Absolute Beginner and am starting with a 
 simple Game
 Over Program.  This is the code:which is extremely simple!
 printGame Over raw_input(\n\nPress Enter Key to exit)


 welcome Nicholas


 One important thing about python is indentation is important.
 You have presented your code in a way that can't be.  Can you 
 actually copy
 your program and paste it into an email message.  Also, Windows, 
 Linux, Mac?



 That's it. It is supposed to bring up a window that says
 Game Over and at the bottom say Press enter Key to exit and 
 when you
 press the enter key it is supposed to exit(big suprise).
 But all it does is highlight raw_input and says invalid
 syntax Now, if I just put print Game Over then it says Game 
 Over
 UNDERNEATH the code I just printed!
 now I am following the book to the *pixel* and that is not
 what is supposed to happen!
 Please email me back as soon as you get this...(if you are
 not to busy).

 Thanks,Nicholas

 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Joel Goldstick
 http://joelgoldstick.com



 Sorry, I am using Windows 7 Ultimate 32-bit with Python 3.3
 Here is the code in exact form
 print Game Over
  raw_input(\n\nPress Enter Key to Exit)
 Thanks,
 Nicholas


 You need to unindent the raw_input like so:


 print Game Over
 raw_input(\n\nPress Enter Key to Exit)

 In python you indent code blocks (like for loops, if statements,
 function blocks, etc.).  You can't just indent from one line to the 
 next in
 sequential code or you will be told its a syntax error



 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Joel Goldstick
 http://joelgoldstick.com




 --
 Nicholas J. Piotrowski




 --
 Joel Goldstick
 http://joelgoldstick.com

 ___
 

Re: [Tutor] New User-Need-Help

2013-02-15 Thread Dave Angel

On 02/15/2013 06:28 PM, Mark Lawrence wrote:

On 15/02/2013 22:31, Joel Goldstick wrote:


Sorry, you said above python 3.  In python 3 raw_input was changed to
input.  so change that and it will work for you.
There are some differences between 2 and 3 that you will need to look
out for.  Go to the python.org http://python.org site to learn about
them.  Your book was written for python 2 it seems



In Python 3 the syntax error is caused by print not having brackets, not
the as it happens the incorrect call to raw_input.



Can we please kill this thread?  Somehow it got transported from 
python-list to tutor, but all the OP posts are on python-list.  That 
combined with top-posting and the OP using a different name in their 
signature than in the email address makes the whole thing very confusing.


Besides, three hours ago, the OP (Nicholas/Deborah) posted a Solved 
message:


 WAIT!! It works now, I just needed to save it in script.
 Thank you guys so much!!
 My best regards, Nicholas


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


Re: [Tutor] Tutor Digest, Vol 108, Issue 58

2013-02-15 Thread Claira
Hi, I signed up a while ago, but I didn't really understand anything. I
have a basic question that maybe someone can help with. I'll like to
integrate yelp data -- http://www.programmableweb.com/api/yelp -- onto
google maps -- http://www.programmableweb.com/api/google-maps -- like how
http://www.trulia.com/real_estate/New_York-New_York has it under
Amenities. But I want it on maps.google.com because I have no idea how to
put the map on a separate webpage.

I'll like to know if I need python for this :)




On Fri, Feb 15, 2013 at 7:03 PM, tutor-requ...@python.org wrote:

 Send Tutor mailing list submissions to
 tutor@python.org

 To subscribe or unsubscribe via the World Wide Web, visit
 http://mail.python.org/mailman/listinfo/tutor
 or, via email, send a message with subject or body 'help' to
 tutor-requ...@python.org

 You can reach the person managing the list at
 tutor-ow...@python.org

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Tutor digest...


 Today's Topics:

1. Re: New User-Need-Help (Mark Lawrence)
2. Re: New User-Need-Help (Jos Kerc)


 --

 Message: 1
 Date: Fri, 15 Feb 2013 23:28:23 +
 From: Mark Lawrence breamore...@yahoo.co.uk
 To: tutor@python.org
 Subject: Re: [Tutor] New User-Need-Help
 Message-ID: kfmg8g$7d4$1...@ger.gmane.org
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 On 15/02/2013 22:31, Joel Goldstick wrote:
 
  Sorry, you said above python 3.  In python 3 raw_input was changed to
  input.  so change that and it will work for you.
  There are some differences between 2 and 3 that you will need to look
  out for.  Go to the python.org http://python.org site to learn about
  them.  Your book was written for python 2 it seems
 

 In Python 3 the syntax error is caused by print not having brackets, not
 the as it happens the incorrect call to raw_input.

 --
 Cheers.

 Mark Lawrence



 --

 Message: 2
 Date: Sat, 16 Feb 2013 02:03:22 +0100
 From: Jos Kerc josk...@gmail.com
 To: Deborah Piotrowski spiceninj...@gmail.com
 Cc: tutor@python.org tutor@python.org
 Subject: Re: [Tutor] New User-Need-Help
 Message-ID:
 CAKs9EsuoPF1tK3mq5a-RP0a+9951v6Q=
 d-pnxu0xomtxq2y...@mail.gmail.com
 Content-Type: text/plain; charset=iso-8859-1

 On Sat, Feb 16, 2013 at 12:20 AM, Deborah Piotrowski 
 spiceninj...@gmail.com
  wrote:

  It works, but it doesn't open a window. It just says that stuff under the
  code. How do you open a window?





 Depends...
 How do you run the script? From Idle, command prompt?

 
 
  On Fri, Feb 15, 2013 at 4:14 PM, Jos Kerc josk...@gmail.com wrote:
 
  Sorry, sent before finishing...
 
  If you changed raw_input, as asked.
  Now, it complains about print 'Game Over'
  Should become print('Game Over')
 
 
  On Sat, Feb 16, 2013 at 12:10 AM, Jos Kerc josk...@gmail.com wrote:
 
  No, not same. At lea
 
 
  On Fri, Feb 15, 2013 at 11:44 PM, Joel Goldstick 
  joel.goldst...@gmail.com wrote:
 
  so copy the code and the error message here
 
 
  On Fri, Feb 15, 2013 at 5:42 PM, Deborah Piotrowski 
  spiceninj...@gmail.com wrote:
 
  I did what you said, nothing changed.
  same errors, same syntax message.
  I suggest you run it on your IDLE to see if it works.
 
 
  On Fri, Feb 15, 2013 at 3:31 PM, Joel Goldstick 
  joel.goldst...@gmail.com wrote:
 
 
 
 
  On Fri, Feb 15, 2013 at 5:29 PM, Joel Goldstick 
  joel.goldst...@gmail.com wrote:
 
  Are you using python 2 or python 3?
 
 
  On Fri, Feb 15, 2013 at 5:28 PM, Deborah Piotrowski 
  spiceninj...@gmail.com wrote:
 
  Ok, so I made a shortcut to IDLE(GUI) and I open it up. click New
  Window and type in the code:
  print Game Over
  raw_input(\n\nPress Enter Key to exit)
  and save the file on my desktop.
  I double-click it and it opens a black window with gray text for a
  split second and if you look quickly enough then you can see
 Invalid
  Sytnax.
  If I do the same code in the Interactive Window then it highlights
  raw_input and says Invalid Syntax
 
  Are you using python 2 or python 3?
 
 
  Sorry, you said above python 3.  In python 3 raw_input was changed
 to
  input.  so change that and it will work for you.
  There are some differences between 2 and 3 that you will need to
 look
  out for.  Go to the python.org site to learn about them.  Your book
  was written for python 2 it seems
 
 
 
  On Fri, Feb 15, 2013 at 3:12 PM, Joel Goldstick 
  joel.goldst...@gmail.com wrote:
 
 
 
 
  On Fri, Feb 15, 2013 at 5:09 PM, Deborah Piotrowski 
  spiceninj...@gmail.com wrote:
 
  It Didn't work.
 
 
  First of all, reply to all.  You are sending messages to me only,
  not to the group.  Other's may be able to help you better than I
 can.
 
  Second.  It didn't work is not a useful answer.
 
  So you have a file with two lines in it.  The first has a print
  statement.  The second has a raw_input statement.  

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-15 Thread Steven D'Aprano

On 15/02/13 16:38, eryksun wrote:

On Thu, Feb 14, 2013 at 4:33 PM, Prasad, Ramit
ramit.pra...@jpmorgan.com  wrote:

My knee jerk response is a try/finally block, but I am sure there
are better ways.


The atexit.register decorator hooks sys.exitfunc:

http://docs.python.org/2/library/atexit



I find a try...finally block more readable and obvious than a hidden
atexit function. At least the try...finally block is explicit:


try:
main()
finally:
do_stuff()


while atexit can be set anywhere and isn't obvious. It's also somewhat
risky, since you never know when some library you import will silently
replace it with their own hook.

Also, keep in mind that you can't rely on atexit hooks to run. Or the
finally block for that matter. They can fail to run when:


- the Python process is killed from the outside, say using kill -9
  under Linux;

- or the entire computer goes down, say after a power failure;

- or the operating system crashes and takes everything else down;

- or something calls os._exit() while your code is running, say some
  external library.


So if you're serious about saving data, you cannot afford to wait until
the program quits before saving the user's work. You should be saving
whenever the user makes some change.



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