Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Steve Hayes Newsgroups: comp.lang.python Subject: Re: Using Python for date calculations Date: Fri, 21 Nov 2014 12:15:03 +0200 Organization: Khanya Publications Lines: 23 Message-ID: References: Reply-To: hayesstw@yahoo.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="28e2e7d20fb3e347cb9cc06b8a7034ff"; logging-data="8613"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19b8HL8OxoQgw4AJrcin+H3jqaJ2QIhaf0=" X-Newsreader: Forte Free Agent 2.0/32.652 Cancel-Lock: sha1:CQuUaQGW1ND4vMzSoUF5LGQzrHg= Xref: csiph.com comp.lang.python:81186 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() function in Python 2 should be >avoided. Instead, use int(raw_input("Year: ")) and correspondingly >Age. It's much safer and clearer than what you have, which is an alias >for eval(raw_input("Year: ")) - very dangerous. I though input() was OK for integers. -- Steve Hayes from Tshwane, South Africa Web: http://www.khanya.org.za/stevesig.htm Blog: http://khanya.wordpress.com E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk