Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-08 Thread Dave Angel
On 04/07/2015 10:16 PM, boB Stepp wrote: Despite Mark's warning, I feel I must see if I understand what is going on here. Switching to Py 3.4 since I am now at home: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "l

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread Cameron Simpson
On 07Apr2015 21:16, boB Stepp wrote: Despite Mark's warning, I feel I must see if I understand what is going on here. Switching to Py 3.4 since I am now at home: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "licen

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread boB Stepp
On Mon, Apr 6, 2015 at 2:42 PM, Dave Angel wrote: > On 04/06/2015 03:20 PM, Emile van Sebille wrote: >> >> On 4/6/2015 7:54 AM, boB Stepp wrote: >>> [...] >> >> Maybe this form helps: >> >> Python 2.7.6 (default, Mar 22 2014, 22:59:56) >> [GCC 4.8.2] on linux2 >> Type "help", "copyright", "credi

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread boB Stepp
On Mon, Apr 6, 2015 at 12:54 PM, Dave Angel wrote: > On 04/06/2015 12:43 PM, boB Stepp wrote: > >> >> I was breaking down longer functions into smaller ones. Along the way >> I noticed I was passing an entire dictionary from one function to >> another. I only needed to pass one particular value, n

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread Emile van Sebille
On 4/6/2015 12:42 PM, Dave Angel wrote: On 04/06/2015 03:20 PM, Emile van Sebille wrote: Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d = {'a':'123'} >>> def func(s=d['a']): ... print s ... >

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Mark Lawrence
On 06/04/2015 20:20, Emile van Sebille wrote: On 4/6/2015 7:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print me

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 03:20 PM, Emile van Sebille wrote: On 4/6/2015 7:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Emile van Sebille
On 4/6/2015 7:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print me!' def func(d['n']): SyntaxError: invalid syn

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 12:43 PM, boB Stepp wrote: I was breaking down longer functions into smaller ones. Along the way I noticed I was passing an entire dictionary from one function to another. I only needed to pass one particular value, not the whole dictionary, so that is how I got into the issue I a

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread boB Stepp
Thanks, Joel! Thanks, Dave! On Mon, Apr 6, 2015 at 11:31 AM, Dave Angel wrote: [...] > Now, it's possible that what you're trying to do is something that can be > accomplished some other way. So please elaborate on your purpose in using > the syntax you did. Or supply a small program that sho

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 10:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print me!' def func(d['n']): SyntaxError: invalid

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Joel Goldstick
On Mon, Apr 6, 2015 at 11:20 AM, Joel Goldstick wrote: > On Mon, Apr 6, 2015 at 10:54 AM, boB Stepp wrote: >> Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. > d = {'n': 'Print me!'}

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Joel Goldstick
On Mon, Apr 6, 2015 at 10:54 AM, boB Stepp wrote: > Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d > {'n': 'Print me!'} d['n'] > 'Print me!' def fun

[Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread boB Stepp
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> d = {'n': 'Print me!'} >>> d {'n': 'Print me!'} >>> d['n'] 'Print me!' >>> def func(d['n']): SyntaxError: invalid syntax >>> def func(d): p

Re: [Tutor] Why is it not working?

2015-02-04 Thread boB Stepp
On Wed, Feb 4, 2015 at 6:12 PM, Antonio Zagheni wrote: > Hi there, > > I am a begginer in python and I'm trying to learn something about Tkinter. > > I did a game (the code is below) using Tkinter were two players have to fill > a row, a column or a diagonal with either 'X' or 'O'. > When it happ

Re: [Tutor] Why is it not working?

2015-02-04 Thread Alan Gauld
On 05/02/15 00:12, Antonio Zagheni wrote: from Tkinter import * ... jogador = 1 rodada = 1 fim = False Notice that fim is declared here as a global variable def analise(): global jogador, rodada But you do not include fim here print flag_botaoA1, flag_botaoA2, flag_botaoA3

[Tutor] Why is it not working?

2015-02-04 Thread Antonio Zagheni
Hi there, I am a begginer in python and I'm trying to learn something about Tkinter. I did a game (the code is below) using Tkinter were two players have to fill a row, a column or a diagonal with either 'X' or 'O'. When it happens, the code was supposed to recognize the winner ('Jogador 1 or 2

Re: [Tutor] Why is it...

2007-03-23 Thread Jay Mutter III
Got it - it needs the blank line to signal that code block has ended. Thanks On Mar 22, 2007, at 3:05 PM, Jason Massey wrote: In the interpreter this doesn't work: >>> f = open(r"c:\python24\image.dat") >>> line = f.readline() >>> while line: ... line = f.readline() ... f.close() Traceback

Re: [Tutor] Why is it...

2007-03-22 Thread Terry Carroll
On Thu, 22 Mar 2007, Jason Massey wrote: > In the interpreter this doesn't work: > > >>> f = open(r"c:\python24\image.dat") > >>> line = f.readline() > >>> while line: > ... line = f.readline() > ... f.close() > Traceback ( File "", line 3 > f.close() > ^ > SyntaxError: invalid synta

Re: [Tutor] Why is it...

2007-03-22 Thread Jason Massey
In the interpreter this doesn't work: f = open(r"c:\python24\image.dat") line = f.readline() while line: ... line = f.readline() ... f.close() Traceback ( File "", line 3 f.close() ^ SyntaxError: invalid syntax But this does: f = open(r"c:\python24\image.dat") line = f.readline()

Re: [Tutor] Why is it...

2007-03-22 Thread Kent Johnson
Jay Mutter III wrote: > Why is it that when I run the following interactively > > f = open('Patents-1920.txt') > line = f.readline() > while line: > print line, > line = f.readline() > f.close() > > I get an error message > > File "", line 4 > f.close() > ^ > SyntaxError: inv

[Tutor] Why is it...

2007-03-22 Thread Jay Mutter III
Why is it that when I run the following interactively f = open('Patents-1920.txt') line = f.readline() while line: print line, line = f.readline() f.close() I get an error message File "", line 4 f.close() ^ SyntaxError: invalid syntax but if i run it in a script there is no