Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82374 > unrolled thread

Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

Started bySimon Evans <musicalhacksaw@yahoo.co.uk>
First post2014-12-11 11:21 -0800
Last post2014-12-15 06:41 +1100
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Text Code(from 'Getting Started in Beautiful Soup'  re: cd Soup   , returns 'Syntax Error, invalid syntax' Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-11 11:21 -0800
    Re: Text Code(from 'Getting Started in Beautiful Soup'  re: cd Soup   , returns 'Syntax Error, invalid syntax' sohcahtoa82@gmail.com - 2014-12-11 11:26 -0800
    Re: Text Code(from 'Getting Started in Beautiful Soup'  re: cd Soup , returns 'Syntax Error, invalid syntax' Dave Angel <davea@davea.name> - 2014-12-11 14:34 -0500
    Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup ,  returns 'Syntax Error, invalid syntax' Chris Angelico <rosuav@gmail.com> - 2014-12-12 06:40 +1100
    Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax' Dave Angel <davea@davea.name> - 2014-12-11 14:46 -0500
    Re: Text Code(from 'Getting Started in Beautiful Soup'  re: cd Soup   , returns 'Syntax Error, invalid syntax' Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-14 06:48 -0800
      Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup ,  returns 'Syntax Error, invalid syntax' Chris Angelico <rosuav@gmail.com> - 2014-12-15 06:41 +1100

#82374 — Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-12-11 11:21 -0800
SubjectText Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
Message-ID<4a9fc357-d743-471b-87e1-ef3573221816@googlegroups.com>
At the start of Chapter 3 of 'Getting Started in Beautiful Soup' it has said to create a html file, 'ecological 

pyramid.html' - which I have already done re:
----------------------------------------------------------------------------
<html>
<body>
<div class="ecopyramid">
<ul id= "producers">
<li class="producers">
<li class="producerlist">
<div class="name">plants</div>
<div class="number">100000</div>
</li>
<li class="producerlist">
<div class="name">algae</div>
<div class="number">100000</div>
</li>
</ul>
<ul id ="primaryconsumers">
<li class="primaryconsumerlist">
<div class="name">deer</div>
<div class-"number">1000</div>
</li
<li class="primaryconsumerlist">
<div class="name">deer</div>
<div class="number">1000</div>
</li>
<li class="primaryconsumerlist">
<div class="name">rabbit</div>
<div class="number">2000</div>
</li>
</ul>
<ul id="secondaryconsumers">
<li class="secondary consumerlist">
<div class="name">fox</div>
<div class="number">100</div>
</li>
<li class=secondaryconsumerlist">
<div class="name">bear</div>
<div class="number">100</div>
</li>
</ul>
<ul id="tertiaryconsumers">
<li class="tertiaryconsumerslist">
<div class="name">lion</div>
<div class="number">80</div>
</li>
<li class="tertiaryconsumerlist">
<div class="name">tiger</div>
<div class="number">50</div>
</li>
</ul>
</body>
</html>
----------------------------------------------------------------------------
and ran it okay in 'Explorer', and text then says to save it to a folder named 'Soup' which I have done. 
On the next page (30) it says to navigate to that folder with the following  code to the python console :-
 
cd Soup

however console rejects that code with the following return: - 
----------------------------------------------------------------------------
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> cd Soup
  File "<stdin>", line 1
    cd Soup
          ^
SyntaxError: invalid syntax
>>>
----------------------------------------------------------------------------
Thank you for reading, hope you can help.
Yours
Simon Evans

[toc] | [next] | [standalone]


#82375

Fromsohcahtoa82@gmail.com
Date2014-12-11 11:26 -0800
Message-ID<e64ae8da-0c45-410a-80a4-9b4a0fcb8b16@googlegroups.com>
In reply to#82374
On Thursday, December 11, 2014 11:21:52 AM UTC-8, Simon Evans wrote:
> At the start of Chapter 3 of 'Getting Started in Beautiful Soup' it has said to create a html file, 'ecological 
> 
> pyramid.html' - which I have already done re:
> ----------------------------------------------------------------------------
> <html>
> <body>
> <div class="ecopyramid">
> <ul id= "producers">
> <li class="producers">
> <li class="producerlist">
> <div class="name">plants</div>
> <div class="number">100000</div>
> </li>
> <li class="producerlist">
> <div class="name">algae</div>
> <div class="number">100000</div>
> </li>
> </ul>
> <ul id ="primaryconsumers">
> <li class="primaryconsumerlist">
> <div class="name">deer</div>
> <div class-"number">1000</div>
> </li
> <li class="primaryconsumerlist">
> <div class="name">deer</div>
> <div class="number">1000</div>
> </li>
> <li class="primaryconsumerlist">
> <div class="name">rabbit</div>
> <div class="number">2000</div>
> </li>
> </ul>
> <ul id="secondaryconsumers">
> <li class="secondary consumerlist">
> <div class="name">fox</div>
> <div class="number">100</div>
> </li>
> <li class=secondaryconsumerlist">
> <div class="name">bear</div>
> <div class="number">100</div>
> </li>
> </ul>
> <ul id="tertiaryconsumers">
> <li class="tertiaryconsumerslist">
> <div class="name">lion</div>
> <div class="number">80</div>
> </li>
> <li class="tertiaryconsumerlist">
> <div class="name">tiger</div>
> <div class="number">50</div>
> </li>
> </ul>
> </body>
> </html>
> ----------------------------------------------------------------------------
> and ran it okay in 'Explorer', and text then says to save it to a folder named 'Soup' which I have done. 
> On the next page (30) it says to navigate to that folder with the following  code to the python console :-
>  
> cd Soup
> 
> however console rejects that code with the following return: - 
> ----------------------------------------------------------------------------
> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> cd Soup
>   File "<stdin>", line 1
>     cd Soup
>           ^
> SyntaxError: invalid syntax
> >>>
> ----------------------------------------------------------------------------
> Thank you for reading, hope you can help.
> Yours
> Simon Evans

You're probably supposed to type that in your command-line console (Similar to a Linux terminal), not your Python console.  "cd" is a command-line console command.

[toc] | [prev] | [next] | [standalone]


#82376 — Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

FromDave Angel <davea@davea.name>
Date2014-12-11 14:34 -0500
SubjectRe: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
Message-ID<mailman.16864.1418326508.18130.python-list@python.org>
In reply to#82374
Please give your environment when starting a new thread.  Python version 
and OS version.  In this case, I'm guessing Windows, because I have to 
guess something to give a meaningful answer.

On 12/11/2014 02:21 PM, Simon Evans wrote:
> At the start of Chapter 3 of 'Getting Started in Beautiful Soup' it has said to create a html file, 'ecological
>
> pyramid.html' - which I have already done re:
>
<snip>
> ----------------------------------------------------------------------------
> and ran it okay in 'Explorer', and text then says to save it to a folder named 'Soup' which I have done.
> On the next page (30) it says to navigate to that folder with the following  code to the python console :-
>
> cd Soup
>
> however console rejects that code with the following return: -
> ----------------------------------------------------------------------------
> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> cd Soup
>    File "<stdin>", line 1
>      cd Soup
>            ^
> SyntaxError: invalid syntax
>>>>

cd is not a Python "command", it's a   cmd command.  In other words, you 
type that in your DOS box before starting Python.


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#82378 — Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

FromChris Angelico <rosuav@gmail.com>
Date2014-12-12 06:40 +1100
SubjectRe: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
Message-ID<mailman.16866.1418326806.18130.python-list@python.org>
In reply to#82374
On Fri, Dec 12, 2014 at 6:34 AM, Dave Angel <davea@davea.name> wrote:
> Please give your environment when starting a new thread.  Python version and
> OS version.  In this case, I'm guessing Windows, because I have to guess
> something to give a meaningful answer.
>
> On 12/11/2014 02:21 PM, Simon Evans wrote:
>> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
>> on win
>> 32

You mean like how he quoted his Python startup line, thus telling you
Python version, word size, and the fact that it's win32?

Granted, it would be nice to have that up front, rather than buried
deep in the text, but the information _is_ there.

ChrisA

[toc] | [prev] | [next] | [standalone]


#82379 — Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

FromDave Angel <davea@davea.name>
Date2014-12-11 14:46 -0500
SubjectRe: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
Message-ID<mailman.16867.1418327209.18130.python-list@python.org>
In reply to#82374
On 12/11/2014 02:40 PM, Chris Angelico wrote:
> On Fri, Dec 12, 2014 at 6:34 AM, Dave Angel <davea@davea.name> wrote:
>> Please give your environment when starting a new thread.  Python version and
>> OS version.  In this case, I'm guessing Windows, because I have to guess
>> something to give a meaningful answer.
>>
>> On 12/11/2014 02:21 PM, Simon Evans wrote:
>>> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
>>> on win
>>> 32
>
> You mean like how he quoted his Python startup line, thus telling you
> Python version, word size, and the fact that it's win32?
>
> Granted, it would be nice to have that up front, rather than buried
> deep in the text, but the information _is_ there.
>

Right of course.  My eyeballs didn't happen to scan that far to the 
right.  I was looking for drive letters or backslashes, or other clues, 
but missed the three-letter one "win" or for that matter the "MSC" one, 
which wouldn't actually have been conclusive.


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#82504

FromSimon Evans <musicalhacksaw@yahoo.co.uk>
Date2014-12-14 06:48 -0800
Message-ID<e2a4b5d4-2fd5-4877-95ab-42b0af9cc8d1@googlegroups.com>
In reply to#82374
Thanks Guys 
This book keeps swapping from the Python console to the Windows - without telling you, but it is the only book out there on 'Beautiful Soup' so I have got to put up with it. There's more problems with it, but I will start a new thread in regard of, I don't know if its related to the above or not. 
Yours 
Simon.

[toc] | [prev] | [next] | [standalone]


#82524 — Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

FromChris Angelico <rosuav@gmail.com>
Date2014-12-15 06:41 +1100
SubjectRe: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
Message-ID<mailman.16954.1418586083.18130.python-list@python.org>
In reply to#82504
On Mon, Dec 15, 2014 at 1:48 AM, Simon Evans <musicalhacksaw@yahoo.co.uk> wrote:
> Thanks Guys
> This book keeps swapping from the Python console to the Windows - without telling you, but it is the only book out there on 'Beautiful Soup' so I have got to put up with it. There's more problems with it, but I will start a new thread in regard of, I don't know if its related to the above or not.
> Yours

You may be able to recognize the consoles by their prompts. Python's
console is probably marked with ">>>" or "ipy>" or something, and the
Windows prompt most likely would have a path followed by ">"  (eg
"C:\>"). If the book's followed this convention, then you should be
able to figure things out easily enough once you get used to it.
Otherwise, look at the syntactic style: Windows command line, like
most command shells, uses a basic structure of command and arguments
separated by spaces, while Python uses a lot more symbols and
structural layout characters. But now we're getting into heuristics,
and there are some commands that work equally in Python and in Windows
(and do different things).

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web