Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Re Following syntax error in Mac OX10.7 Terminal

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


s.pasoev at gmail

Jun 28, 2012, 10:30 AM

Post #1 of 7 (290 views)
Permalink
Re Following syntax error in Mac OX10.7 Terminal

You just have to consider that indentation matters in Python, so you
have to type the code in Python interpreter as you have written it
below, that is, press Tab before each line when you are inside the
'while (or any other like for, if, with, etc.) block.

a=0
while a<10:
a=a+1
print a

I can guess from your message that you aren't aware of one very
important Python feature, and maybe you also didn't willingly choose to
learn Python2 instead of Python3 ? In this case I would advise you to
consider both versions before choosing.

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


dthomas86 at me

Jun 29, 2012, 8:13 AM

Post #2 of 7 (262 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
> You just have to consider that indentation matters in Python, so you
> have to type the code in Python interpreter as you have written it
> below, that is, press Tab before each line when you are inside the
> 'while (or any other like for, if, with, etc.) block.
>
> a=0
> while a<10:
> a=a+1
> print a
>
> I can guess from your message that you aren't aware of one very
> important Python feature, and maybe you also didn't willingly choose to
> learn Python2 instead of Python3 ? In this case I would advise you to
> consider both versions before choosing.

Hi yeah I'm currently learning python 2 at the moment and the tutorial that I am studying doesn't explain about indentation.
--
http://mail.python.org/mailman/listinfo/python-list


python at mrabarnett

Jun 29, 2012, 8:21 AM

Post #3 of 7 (260 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

On 29/06/2012 16:13, David Thomas wrote:
> On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
>> You just have to consider that indentation matters in Python, so you
>> have to type the code in Python interpreter as you have written it
>> below, that is, press Tab before each line when you are inside the
>> 'while (or any other like for, if, with, etc.) block.
>>
>> a=0
>> while a<10:
>> a=a+1
>> print a
>>
>> I can guess from your message that you aren't aware of one very
>> important Python feature, and maybe you also didn't willingly choose to
>> learn Python2 instead of Python3 ? In this case I would advise you to
>> consider both versions before choosing.
>
> Hi yeah I'm currently learning python 2 at the moment and the tutorial that
> I am studying doesn't explain about indentation.
>
Really? Indentation is a basic feature of Python!
--
http://mail.python.org/mailman/listinfo/python-list


dthomas86 at me

Jun 29, 2012, 8:58 AM

Post #4 of 7 (265 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

On Friday, June 29, 2012 4:21:56 PM UTC+1, MRAB wrote:
> On 29/06/2012 16:13, David Thomas wrote:
> > On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
> >> You just have to consider that indentation matters in Python, so you
> >> have to type the code in Python interpreter as you have written it
> >> below, that is, press Tab before each line when you are inside the
> >> 'while (or any other like for, if, with, etc.) block.
> >>
> >> a=0
> >> while a<10:
> >> a=a+1
> >> print a
> >>
> >> I can guess from your message that you aren't aware of one very
> >> important Python feature, and maybe you also didn't willingly choose to
> >> learn Python2 instead of Python3 ? In this case I would advise you to
> >> consider both versions before choosing.
> >
> > Hi yeah I'm currently learning python 2 at the moment and the tutorial that
> > I am studying doesn't explain about indentation.
> >
> Really? Indentation is a basic feature of Python!

while {condition that the loop continues}:
{what to do in the loop}
{have it indented, usually four spaces}
{the code here is not looped}
{because it isn't indented}

Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.

Thanks for the help this community is great for help.
--
http://mail.python.org/mailman/listinfo/python-list


dthomas86 at me

Jun 29, 2012, 8:58 AM

Post #5 of 7 (259 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

On Friday, June 29, 2012 4:21:56 PM UTC+1, MRAB wrote:
> On 29/06/2012 16:13, David Thomas wrote:
> > On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
> >> You just have to consider that indentation matters in Python, so you
> >> have to type the code in Python interpreter as you have written it
> >> below, that is, press Tab before each line when you are inside the
> >> 'while (or any other like for, if, with, etc.) block.
> >>
> >> a=0
> >> while a<10:
> >> a=a+1
> >> print a
> >>
> >> I can guess from your message that you aren't aware of one very
> >> important Python feature, and maybe you also didn't willingly choose to
> >> learn Python2 instead of Python3 ? In this case I would advise you to
> >> consider both versions before choosing.
> >
> > Hi yeah I'm currently learning python 2 at the moment and the tutorial that
> > I am studying doesn't explain about indentation.
> >
> Really? Indentation is a basic feature of Python!

while {condition that the loop continues}:
{what to do in the loop}
{have it indented, usually four spaces}
{the code here is not looped}
{because it isn't indented}

Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.

Thanks for the help this community is great for help.
--
http://mail.python.org/mailman/listinfo/python-list


ben+python at benfinney

Jun 29, 2012, 9:02 AM

Post #6 of 7 (262 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

David Thomas <dthomas86 [at] me> writes:

> Hi yeah I'm currently learning python 2 at the moment and the tutorial
> that I am studying doesn't explain about indentation.

You might be better served by the official Python tutorial
<URL:http://docs.python.org/tutorial/>.

If you work through it from beginning to end, doing each exercise and
experimenting to be sure you understand before moving through, you will
get a good grounding in the fundamentals of the language.

--
\ “Don't worry about what anybody else is going to do. The best |
`\ way to predict the future is to invent it.” —Alan Kay |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


bahamutzero8825 at gmail

Jun 29, 2012, 7:05 PM

Post #7 of 7 (259 views)
Permalink
Re: Re Following syntax error in Mac OX10.7 Terminal [In reply to]

On 6/29/2012 10:58 AM, David Thomas wrote:
> Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.
The latest edition (3rd?) of Programming Python by Mark Lutz covers py3k
(it targets 3.0/3.1 IIRC, but the official Python docs cover the
differences between versions). The tutorial in the official docs is
short compared to a book, but it covers the basics well. The official
docs do cover each module in the standard library in great detail. It is
mainly reference, though there are a few tutorials (e.g. the logging
module has at least 2 tutorials).

If you are not restricted to 2.x, learn 3.2/3.3. 2.x is used mainly
because some major libraries (e.g., Twisted, Django) and/or other
dependencies do not support 3.x yet. There will be no 2.8, and 2.7 isn't
getting any new features AFAIK.
--
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.