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


Groups > comp.lang.python > #42411

Re: Help with python code!

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; '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; '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; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 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; '31,': 0.24; 'please?': 0.24; 'url:moin': 0.24; 'mon,': 0.24; 'looks': 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; 'message-id:@mail.gmail.com': 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; 'to:addr:python-list': 0.38; 'rather': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; '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
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=cTSaYNLfbWUIwvv1lxwY0FkeEZOLONtFlXtXChtS59A=; b=ef42RJz0pTqgzDaz/XrSjpXBrJSTvw4eVDw19ug8WTpxC9cBFJr0f7RRgzRLeULSRv nY2TVxuaJdzieXivp5mUlIiKeU3qMrtzcZ4JwnH5bQy7FYSIroL1Yk0M9PEN2JUabfd0 gLDgdDu9mbQbSYYdpjj2y8Hq7ZYDpL8T5hBqbJDkb1dvQRVLUNsy8Rq+SRYg4d0JPis0 arJ3tiybAw4lu3hL6j4HVFtM8l8Jn4byKalUuwDoVaKMFClcIxtqxAw5txb3ewA7L8zg rwaWR9k3l1pARPumSNAbMKA5BtJsRSK0zOG3x8pr3uoUufnUlcbJchN2JUavb7YEIQR+ Z2ng==
MIME-Version 1.0
X-Received by 10.220.231.199 with SMTP id jr7mr7374487vcb.70.1364764860147; Sun, 31 Mar 2013 14:21:00 -0700 (PDT)
In-Reply-To <2912c674-e30b-4339-9344-1f460cb96b23@googlegroups.com>
References <37f23623-8bf5-421a-ab6a-34ff622c69f1@googlegroups.com> <mailman.4027.1364762359.2939.python-list@python.org> <2912c674-e30b-4339-9344-1f460cb96b23@googlegroups.com>
Date Mon, 1 Apr 2013 08:21:00 +1100
Subject Re: Help with python code!
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4029.1364764868.2939.python-list@python.org> (permalink)
Lines 66
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364764868 news.xs4all.nl 6980 [2001:888:2000:d::a6]:36950
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42411

Show key headers only | View raw


On Mon, Apr 1, 2013 at 8:06 AM, jojo <gerrymcgovern@gmail.com> wrote:
> On Sunday, March 31, 2013 4:39:11 PM UTC-4, Chris Angelico wrote:
>> On Mon, Apr 1, 2013 at 7:10 AM, jojo wrote:
>>
>> > Im used to C# so the syntax looks bizarre to me! Any help would be great.
>>
>>
>>
>> The first thing you'll need to understand about Python syntax is that
>>
>> indentation is important. By posting this code flush-left, you've
>>
>> actually destroyed its block structure. Could you post it again, with
>>
>> indentation, please? We'd then be in a much better position to help.
>>
>>
>>
>> Chris Angelico
>
>
> Hi Chris, thanks for your reply. See code below...

Ah, you appear to be posting from Google Groups. You may want to check
this page out, as a lot of people rather dislike GG posts.

http://wiki.python.org/moin/GoogleGroupsPython

The best method is simply to avoid Google Groups altogether.

Anyway, some code comments. (Though the biggest comment to make about
the code is its utter lack of comments. Not a good idea in any
language, for anything more than the most trivial script.)

> current_time = time.time() + 60*60+24*30

This line doesn't, quite frankly, make a lot of sense; time.time()
returns the current time already, but then an offset of one hour and
twelve minutes is added.

>    if m:
>       sue = time.mktime(
>         (int(m.group(7)), int(months[m.group(2)]), int(m.group(3)),
>           int(m.group(4)), int(m.group(5)), int(m.group(6)),
>           int(days[m.group(1)]), 0, 0)
>         )
>         expire_time = (sue ­ current_time)/60/60/24

Here's a likely problem. There's supposed to be an operator - probably
a plus sign - between sue and current_time.

>        else:
>         m = q.search(line)
>         if m:
>         cert_name = m.group(1)

And this last line needs indentation.

The very easiest way to debug Python code is to run it. If it runs,
great! See what output it made and whether it's correct or not. If it
doesn't, Python will give you an exception traceback that points you
to the failing line. Get familiar with them, as you'll be seeing them
a lot :)

Chris Angelico

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 13:10 -0700
  Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 07:39 +1100
    Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:06 -0700
      Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:13 -0400
        Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:21 -0700
          Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:27 -0400
            Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:32 -0700
              Re: Help with python code! Alister <alister.ware@ntlworld.com> - 2013-04-01 17:54 +0000
            Re: Help with python code! rurpy@yahoo.com - 2013-03-31 14:46 -0700
          Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 08:35 +1100
            Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:41 -0700
            Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:41 -0700
          Re: Help with python code! Jason Friedman <jsf80238@gmail.com> - 2013-04-02 21:59 -0600
      Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 08:21 +1100
        Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:24 -0700
        Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:24 -0700
      Re: Help with python code! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-31 23:02 +0100
      Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 09:04 +1100
    Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:06 -0700
  Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:08 -0400

csiph-web