X-Received: by 10.180.106.232 with SMTP id gx8mr1194260wib.2.1364765121535; Sun, 31 Mar 2013 14:25:21 -0700 (PDT) Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!209.85.212.215.MISMATCH!yt3no21769160wib.0!news-out.google.com!p18ni29722wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.134.4.91.MISMATCH!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'operator': 0.03; 'syntax': 0.04; 'output': 0.05; 'debug': 0.07; 'failing': 0.07; 'great.': 0.07; 'subject:code': 0.07; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'python': 0.11; 'language,': 0.12; 'added.': 0.16; 'ah,': 0.16; 'already,': 0.16; 'chris,': 0.16; 'dislike': 0.16; 'great!': 0.16; 'runs,': 0.16; 'script.)': 0.16; 'time.time()': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'help.': 0.21; 'cc:addr:python.org': 0.22; 'header :User-Agent:1': 0.23; '31,': 0.24; 'please?': 0.24; 'url:moin': 0.24; 'mon,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'appear': 0.29; 'correct': 0.29; 'chris': 0.29; "we'd": 0.29; 'am,': 0.29; 'points': 0.29; 'important.': 0.30; 'code': 0.31; 'posting': 0.31; 'reply.': 0.31; 'url:wiki': 0.31; 'indentation': 0.31; 'trivial': 0.31; 'probably': 0.32; 'supposed': 0.32; 'run': 0.32; 'quite': 0.32; 'url:python': 0.33; 'not.': 0.33; 'comment': 0.34; 'could': 0.34; 'subject:with': 0.35; 'received:209.85': 0.35; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'method': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'easiest': 0.38; 'rather': 0.38; 'anything': 0.39; 'most': 0.60; 'from:no real name:2**0': 0.61; 'march': 0.61; 'simply': 0.61; 'first': 0.61; "you'll": 0.62; "you've": 0.63; 'more': 0.64; 'minutes': 0.67; 'between': 0.67; 'biggest': 0.67; 'hour': 0.70; 'groups.': 0.74; 'lack': 0.78; '(sue': 0.84; 'me!': 0.84; 'sue': 0.84; 'twelve': 0.84; '2013': 0.98 X-Received: by 10.49.49.193 with SMTP id w1mr624284qen.3.1364765082430; Sun, 31 Mar 2013 14:24:42 -0700 (PDT) Newsgroups: comp.lang.python Date: Sun, 31 Mar 2013 14:24:42 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=99.233.107.10; posting-account=9KhqJwoAAACtxd9fjX3ptGbRoyWSd7VI References: <37f23623-8bf5-421a-ab6a-34ff622c69f1@googlegroups.com> <2912c674-e30b-4339-9344-1f460cb96b23@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Subject: Re: Help with python code! From: gerrymcgovern@gmail.com To: comp.lang.python@googlegroups.com Cc: python-list@python.org 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: , Message-ID: Lines: 134 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364765084 news.xs4all.nl 6891 [2001:888:2000:d::a6]:39954 X-Complaints-To: abuse@xs4all.nl Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:42414 On Sunday, March 31, 2013 5:21:00 PM UTC-4, Chris Angelico wrote: > On Mon, Apr 1, 2013 at 8:06 AM, jojo wrote: >=20 > > On Sunday, March 31, 2013 4:39:11 PM UTC-4, Chris Angelico wrote: >=20 > >> On Mon, Apr 1, 2013 at 7:10 AM, jojo wrote: >=20 > >> >=20 > >> > Im used to C# so the syntax looks bizarre to me! Any help would be g= reat. >=20 > >> >=20 > >> >=20 > >> >=20 > >> The first thing you'll need to understand about Python syntax is that >=20 > >> >=20 > >> indentation is important. By posting this code flush-left, you've >=20 > >> >=20 > >> actually destroyed its block structure. Could you post it again, with >=20 > >> >=20 > >> indentation, please? We'd then be in a much better position to help. >=20 > >> >=20 > >> >=20 > >> >=20 > >> Chris Angelico >=20 > > >=20 > > >=20 > > Hi Chris, thanks for your reply. See code below... >=20 >=20 >=20 > Ah, you appear to be posting from Google Groups. You may want to check >=20 > this page out, as a lot of people rather dislike GG posts. >=20 >=20 >=20 > http://wiki.python.org/moin/GoogleGroupsPython >=20 >=20 >=20 > The best method is simply to avoid Google Groups altogether. >=20 >=20 >=20 > Anyway, some code comments. (Though the biggest comment to make about >=20 > the code is its utter lack of comments. Not a good idea in any >=20 > language, for anything more than the most trivial script.) >=20 >=20 >=20 > > current_time =3D time.time() + 60*60+24*30 >=20 >=20 >=20 > This line doesn't, quite frankly, make a lot of sense; time.time() >=20 > returns the current time already, but then an offset of one hour and >=20 > twelve minutes is added. >=20 >=20 >=20 > > if m: >=20 > > sue =3D time.mktime( >=20 > > (int(m.group(7)), int(months[m.group(2)]), int(m.group(3)), >=20 > > int(m.group(4)), int(m.group(5)), int(m.group(6)), >=20 > > int(days[m.group(1)]), 0, 0) >=20 > > ) >=20 > > expire_time =3D (sue =AD current_time)/60/60/24 >=20 >=20 >=20 > Here's a likely problem. There's supposed to be an operator - probably >=20 > a plus sign - between sue and current_time. >=20 >=20 >=20 > > else: >=20 > > m =3D q.search(line) >=20 > > if m: >=20 > > cert_name =3D m.group(1) >=20 >=20 >=20 > And this last line needs indentation. >=20 >=20 >=20 > The very easiest way to debug Python code is to run it. If it runs, >=20 > great! See what output it made and whether it's correct or not. If it >=20 > doesn't, Python will give you an exception traceback that points you >=20 > to the failing line. Get familiar with them, as you'll be seeing them >=20 > a lot :) >=20 >=20 >=20 > Chris Angelico Ok, thanks Chris!!