Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Python': 0.06; '(using': 0.07; 'context': 0.07; 'debug': 0.07; 'subject:Question': 0.07; 'subject:code': 0.07; 'string': 0.09; 'debugger': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; 'adjustment.': 0.16; 'argument.': 0.16; 'be:': 0.16; 'cc:name:python list': 0.16; 'created;': 0.16; 'expression.': 0.16; 'highlighted': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'things.': 0.19; 'working.': 0.19; 'seems': 0.21; 'command': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'install': 0.23; 'this?': 0.23; 'error': 0.23; '2.x': 0.24; 'why.': 0.24; 'question': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; '15,': 0.26; 'second': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'mix': 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; '3.x': 0.31; 'libraries': 0.31; 'quotes': 0.31; 'subject:About': 0.31; 'terminate': 0.31; 'file': 0.32; 'there.': 0.32; 'this.': 0.32; 'run': 0.32; 'another': 0.32; 'running': 0.33; "i'd": 0.34; 'could': 0.34; 'message.': 0.35; 'problem': 0.35; "can't": 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'books,': 0.36; 'controls': 0.36; 'idle': 0.36; 'right?': 0.36; 'vice': 0.36; 'turn': 0.37; 'easily': 0.37; 'pm,': 0.38; 'little': 0.38; 'anything': 0.39; 'does': 0.39; 'quote': 0.39; 'sure': 0.39; 'called': 0.40; 'how': 0.40; 'most': 0.60; 'tell': 0.60; "you're": 0.61; 'such': 0.63; 'to:addr:gmail.com': 0.65; 'world': 0.66; 'sample': 0.67; 'between': 0.67; 'believe': 0.68; 'sector': 0.72; 'clicking': 0.73; '3.4': 0.84; 'appreciative': 0.84; 'quote,': 0.84; 'treats': 0.84; 'working,': 0.84; 'differences': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=NFWJY0ivu3P7F4sPG/Uktg7QpAU5ZOFi17lmHH62S8g=; b=A4+/+/NweEXBl6gfRQFJqw1XxO5nrzQSGXRm1W5iW9EVKDVajZvQfCBOAAJAaqHbNq fhP5w0D16OdiccBUukpATyY0tkCrTSG/De/tIwf+ehGIal2q8A07sj+1+GMpu9JAWGIV Xz/5MZ/xGZatyxVvyNKQKD7mCwXU9lWoMBzu+JPqHj9VTC6av7drY4Iwr5DPR+VyI2tw 0aHmIkNHfwsa3hNfu0YjuSADIm008tIMZtTaqp0RL0VYHG8FGLV09ikXLBPzyuSbUlGc AeWmPXSMvg4NYb4e3wttugLAdOYBE+qR4exZbTIo9HZY86/6knXASBixAUVPygSE9fQN PDWg== MIME-Version: 1.0 X-Received: by 10.112.169.66 with SMTP id ac2mr15583592lbc.73.1413414561171; Wed, 15 Oct 2014 16:09:21 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Oct 2014 16:09:21 -0700 Subject: Re: Question About Running Python code From: Dan Stromberg To: ryguy7272 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413414563 news.xs4all.nl 2961 [2001:888:2000:d::a6]:57976 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79185 On Wed, Oct 15, 2014 at 3:50 PM, ryguy7272 wrote: > I'm trying to run this script (using IDLE 3.4) > I would be most appreciative if someone could respond to a few questions. > > The error that I get is this. > 'invalid syntax' You may get better help if you give the context of this message. > The second single quote in this line is highlighted pink. > print 'Downloading data from Yahoo for %s sector' % sector > > #1) That's very bizarre to mix single quotes and double quotes in a sing= le language. Does Python actually mix single quotes and double quotes? I'm not sure what you mean by "mix". C uses single quotes and double quotes, right? Python treats single quotes and double quotes pretty much interchangeably, except if you start a string with a single quote (for example), you can easily put a double quote inside it, and you must terminate the string with another single quote. And vice versa. > #2) In the Python 3.4 Shell window, I turn the debugger on by clicking '= Debugger'. Then I run the file I just created; it's called 'stock.py'. I = get the error immediately, and I can't debug anything so I can't tell what'= s going on. This is very frustrating. All the controls in the debugger ar= e greyed out. What's up with the debugger? You have Python 2.x code there. The differences between 2.x and 3.x are far from insurmountable, but it does require a little code adjustment. If you're a python novice, you might be better off running this under 2.x. I believe your debugger won't help until your code compiles. > #3) My final question is this? How do I get this code running? It seem= s like there is a problem with a single quote, which is just silly. I can'= t get the debugger working, so I can't tell what's going on. The only thin= s I know, or I think I know, is that the proper libraries seem to be instal= led, so that's one thing that's working. The print statement in 2.x has been made a print function in 3.x; that's likely necessary to fix, though not necessarily sufficient. EG in 2.x: print 'hello word', 6 while in 3.x that would be: print('hello world', 6) Interestingly, you can write a single command that works in both with: print('hello world {}'.format(6)) To 2.x, it's printing the result of a parenthesized expression. To 3.x, it's a function call with one argument. > I'd really appreciate it if someone could please answer my questions and = help me get this straightened out, so I can have some fun with Python. So = far, I've spent 2 months reading 4 books, and trying all kinds of sample co= de...and almost every single thing fails and I have no idea why. You may also need to install pytz, pandas and BeautifulSoup. I favor pip or pip3 for such things.