Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Fri, 21 Nov 2014 15:07:39 -0500, Denis Beauregard wrote: >On Fri, 21 Nov 2014 14:35:14 -0500, Dennis Lee Bieber > wrote in soc.genealogy.computing: > >>On Fri, 21 Nov 2014 10:35:19 +0200, Steve Hayes >>declaimed the following: >> >> >>>This Python script does it for me. >>> >>>year = input("

Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Sat, 22 Nov 2014 06:51:15 +1100, Paul Blair wrote: >On 22-Nov-2014 6:35 am, Dennis Lee Bieber wrote: >> On Fri, 21 Nov 2014 10:35:19 +0200, Steve Hayes >> declaimed the following: >> >> >>> This Python script does it for me. >>> >>> year = input("Year: ") >>> age = input("Age: ") >>> born = y

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Sat, Nov 22, 2014 at 4:07 PM, Steve Hayes wrote: > On Fri, 21 Nov 2014 14:50:36 -0500, Dennis Lee Bieber > wrote: > >>On Fri, 21 Nov 2014 12:15:03 +0200, Steve Hayes >>declaimed the following: >> >>>On Fri, 21 Nov 2014 19:40:22 +1100, Chris Angelico wrote: >>> On Fri, Nov 21, 2014 at 7:3

Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Fri, 21 Nov 2014 14:50:36 -0500, Dennis Lee Bieber wrote: >On Fri, 21 Nov 2014 12:15:03 +0200, Steve Hayes >declaimed the following: > >>On Fri, 21 Nov 2014 19:40:22 +1100, Chris Angelico wrote: >> >>>On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes wrote: This Python script does it for me

Re: Using Python for date calculations

2014-11-21 Thread Paul Blair
On 22-Nov-2014 6:35 am, Dennis Lee Bieber wrote: On Fri, 21 Nov 2014 10:35:19 +0200, Steve Hayes declaimed the following: This Python script does it for me. year = input("Year: ") age = input("Age: ") born = year-age print 'Year of birth:', born It's so simple, so elementary, that it's not

Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Fri, 21 Nov 2014 17:03:12 +, duncan smith wrote: >On 21/11/14 08:35, Steve Hayes wrote: >> I've finally found a use for Python. >> >> When, in the course of my genealogy research, I look at census or burial >> records, I often want to work out a person's date of birth from their age. >>

Re: Using Python for date calculations

2014-11-21 Thread duncan smith
On 21/11/14 08:35, Steve Hayes wrote: > I've finally found a use for Python. > > When, in the course of my genealogy research, I look at census or burial > records, I often want to work out a person's date of birth from their age. > It's a simple matter of mental arithmetic, but I sometimes get i

Re: Using Python for date calculations

2014-11-21 Thread Mark Lawrence
On 21/11/2014 15:50, Steve Hayes wrote: On Fri, 21 Nov 2014 10:20:06 +, Mark Lawrence As I'm using Python 2 and I asked the question, I'm grateful that the answer was given in my dialect. Luddite :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do

Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Fri, 21 Nov 2014 10:20:06 +, Mark Lawrence wrote: >On 21/11/2014 08:50, Gary Herron wrote: >> On 11/21/2014 12:35 AM, Steve Hayes wrote: >>> I've finally found a use for Python. >>> >>> When, in the course of my genealogy research, I look at census or burial >>> records, I often want to wo

Re: Using Python for date calculations

2014-11-21 Thread Ned Batchelder
On 11/21/14 9:55 AM, Steven D'Aprano wrote: - Use your OS facilities to run that process in a chroot jail. If you are interested, this is the facility that edX uses to run untrusted Python code on the servers: https://github.com/edx/codejail -- Ned Batchelder, http://nedbatchelder.com -- h

Re: Using Python for date calculations

2014-11-21 Thread Steven D'Aprano
random...@fastmail.us wrote: > Out of curiosity, is there a way to use eval "safely" (i.e. strictly > limiting what it has access to) across a privilege boundary? This also > comes up for pickle and other serialization formats that can store > arbitrary classes (i.e. call arbitrary constructors).

Re: Using Python for date calculations

2014-11-21 Thread alister
On Fri, 21 Nov 2014 08:54:23 -0500, random832 wrote: > On Fri, Nov 21, 2014, at 05:33, alister wrote: >> the problem with input is code-injection which is very similar to sql >> injection (httpd://xkcd.com/327). >> >> the data entered by the user is processed as if it was python code, >> this mea

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Sat, Nov 22, 2014 at 12:58 AM, wrote: > On Fri, Nov 21, 2014, at 05:47, Chris Angelico wrote: >> Now, maybe you want it to eval. There are times when I conceptually >> want "enter an integer", but it makes good sense to be able to type >> "1+2" and have it act as if I typed "3". That's fine...

Re: Using Python for date calculations

2014-11-21 Thread random832
On Fri, Nov 21, 2014, at 05:47, Chris Angelico wrote: > Now, maybe you want it to eval. There are times when I conceptually > want "enter an integer", but it makes good sense to be able to type > "1+2" and have it act as if I typed "3". That's fine... but if you > want eval, write eval into your co

Re: Using Python for date calculations

2014-11-21 Thread random832
On Fri, Nov 21, 2014, at 05:33, alister wrote: > the problem with input is code-injection which is very similar to sql > injection (httpd://xkcd.com/327). > > the data entered by the user is processed as if it was python code, this > means the user could enter a command (or sequence of commands)

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Fri, Nov 21, 2014 at 9:33 PM, alister wrote: > the data entered by the user is processed as if it was python code, this > means the user could enter a command (or sequence of commands) that cause > serious problems to you computer including but not limited to:- > > Installing a virus > Deleting

Re: Using Python for date calculations

2014-11-21 Thread alister
On Fri, 21 Nov 2014 10:20:06 +, Mark Lawrence wrote: > On 21/11/2014 08:50, Gary Herron wrote: >> On 11/21/2014 12:35 AM, Steve Hayes wrote: >>> I've finally found a use for Python. >>> >>> When, in the course of my genealogy research, I look at census or >>> burial records, I often want to wo

Re: Using Python for date calculations

2014-11-21 Thread alister
On Fri, 21 Nov 2014 12:15:03 +0200, Steve Hayes wrote: > On Fri, 21 Nov 2014 19:40:22 +1100, Chris Angelico > wrote: > >>On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes >>wrote: >>> This Python script does it for me. >>> >>> year = input("Year: ") >>> age = input("Age: ") >>> born = year-age print

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Fri, Nov 21, 2014 at 9:20 PM, Mark Lawrence wrote: > As we're now firmly heading into the Python 3 era would people please be > kind enough to use the Python 3 links. I know it's only a single character > change but it's the principle to me. TIA. The OP was clearly using Python 2 (as evidenc

Re: Using Python for date calculations

2014-11-21 Thread Mark Lawrence
On 21/11/2014 08:50, Gary Herron wrote: On 11/21/2014 12:35 AM, Steve Hayes wrote: I've finally found a use for Python. When, in the course of my genealogy research, I look at census or burial records, I often want to work out a person's date of birth from their age. It's a simple matter of men

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Fri, Nov 21, 2014 at 9:15 PM, Steve Hayes wrote: > On Fri, 21 Nov 2014 19:40:22 +1100, Chris Angelico wrote: > >>On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes wrote: >>> This Python script does it for me. >>> >>> year = input("Year: ") >>> age = input("Age: ") >>> born = year-age >>> print 'Ye

Re: Using Python for date calculations

2014-11-21 Thread Steve Hayes
On Fri, 21 Nov 2014 19:40:22 +1100, Chris Angelico wrote: >On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes wrote: >> This Python script does it for me. >> >> year = input("Year: ") >> age = input("Age: ") >> born = year-age >> print 'Year of birth:', born > >One thing to be careful of: The input()

Re: Using Python for date calculations

2014-11-21 Thread Gary Herron
On 11/21/2014 12:35 AM, Steve Hayes wrote: I've finally found a use for Python. When, in the course of my genealogy research, I look at census or burial records, I often want to work out a person's date of birth from their age. It's a simple matter of mental arithmetic, but I sometimes get it wr

Re: Using Python for date calculations

2014-11-21 Thread Chris Angelico
On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes wrote: > This Python script does it for me. > > year = input("Year: ") > age = input("Age: ") > born = year-age > print 'Year of birth:', born One thing to be careful of: The input() function in Python 2 should be avoided. Instead, use int(raw_input("Y

Using Python for date calculations

2014-11-21 Thread Steve Hayes
I've finally found a use for Python. When, in the course of my genealogy research, I look at census or burial records, I often want to work out a person's date of birth from their age. It's a simple matter of mental arithmetic, but I sometimes get it wrong, and mislead myself. There are calculato