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


Groups > comp.lang.python > #51267

Re: Creating a Simple User Interface for a Function

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Creating a Simple User Interface for a Function
Date 2013-07-25 19:46 -0400
References <cebb4f86-c546-4283-a839-46393571cbb0@googlegroups.com> <mailman.5116.1374779986.3114.python-list@python.org> <97f8224f-e73b-4a4b-bf05-7cc3dba4e9d9@googlegroups.com> <kssamv$jam$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.5124.1374796020.3114.python-list@python.org> (permalink)

Show all headers | View raw


Some additional comments.

On 7/25/2013 7:00 PM, Terry Reedy wrote:
> On 7/25/2013 4:58 PM, CTSB01 wrote:
>
>> 1) I decided to use Python 2.7, and I will be sure to specify this in
>> all future threads.
>
> Given that you are not using any libraries, let alone one that does not
> run on Python 3, I strongly recommend using the latest version (3.3).

It would be pretty easy to make your simple code run on both 3.x and 
2.6/7. Start your file (after any docstring or initial comment) with
from __future__ import division, print_function

Use "except XyxError as e:" instead of "except XyzError, e:".

> If users start the program at a command line, the core of an input
> function would be
>    numbers = input('Enter digits: ')  # see below
> You would need a more elaborate prompt printed first, and input checking
> with the request repeated if the input does not pass the check.

# To run on both 2.x and 3.x, put this after the __future__ import:
try:
     input = raw_input
except NameError:
     pass

>> I'd like to be
>> able to run send a .exe file that the user can just open up and use
>> with no further setup.
>
> There are programs that will package your code with an interpreter.

A Python pre-built binary is overkill for such a small function. The 
reason for doing so, packaging all dependencies together, does not 
apply. Any binary is limited to what machines it will run on.

> do give people the option to get just the program without installing a
> duplicate interpreter.

A Python file, especially if designed to run on 2.6, will run on most 
any recent installation.

-- 
Terry Jan Reedy

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


Thread

Creating a Simple User Interface for a Function CTSB01 <scott.moore270@gmail.com> - 2013-07-25 09:03 -0700
  Re: Creating a Simple User Interface for a Function Dave Angel <davea@davea.name> - 2013-07-25 15:19 -0400
    Re: Creating a Simple User Interface for a Function CTSB01 <scott.moore270@gmail.com> - 2013-07-25 13:58 -0700
      Re: Creating a Simple User Interface for a Function Terry Reedy <tjreedy@udel.edu> - 2013-07-25 19:00 -0400
      Re: Creating a Simple User Interface for a Function Dave Angel <davea@davea.name> - 2013-07-25 19:01 -0400
      Re: Creating a Simple User Interface for a Function Terry Reedy <tjreedy@udel.edu> - 2013-07-25 19:46 -0400
      RE: Creating a Simple User Interface for a Function "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2013-07-26 14:08 +0000

csiph-web