Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51304
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ramit.prasad@jpmorgan.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'essentially': 0.04; 'ideally': 0.04; 'syntax': 0.04; 'output': 0.05; 'string.': 0.05; 'completeness': 0.07; 'installed.': 0.07; 'linux,': 0.07; 'list?': 0.07; 'matches': 0.07; 'setup.': 0.07; 'string': 0.09; '[0,': 0.09; 'assuming': 0.09; 'delimited': 0.09; 'executable': 0.09; 'function,': 0.09; 'len(x)': 0.09; 'parameter': 0.09; 'parsing': 0.09; 'received:155': 0.09; 'steps:': 0.09; 'subject:Function': 0.09; 'runs': 0.10; 'python': 0.11; 'def': 0.12; 'gui': 0.12; 'assume': 0.14; '(it': 0.16; '(say': 0.16; '(windows)': 0.16; '2):': 0.16; '23,': 0.16; '2345': 0.16; 'determines': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'example)': 0.16; 'example).': 0.16; 'exe': 0.16; 'from:addr:jpmorgan.com': 0.16; 'integers,': 0.16; 'integers.': 0.16; 'normally,': 0.16; 'outputs': 0.16; 'parameter.': 0.16; 'range(0,': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'securities,': 0.16; 'sequence.': 0.16; 'specifying': 0.16; 'sure.': 0.16; 'threads.': 0.16; 'tkinter.': 0.16; 'tool.': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'usable': 0.16; 'thursday,': 0.16; 'all.': 0.16; 'ignore': 0.16; 'language': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'library': 0.18; 'bit': 0.19; 'trying': 0.19; 'meant': 0.20; 'command': 0.22; '>>>': 0.22; 'input': 0.22; 'example': 0.22; 'programming': 0.22; 'putting': 0.22; 'python?': 0.22; 'separate': 0.22; 'shell': 0.22; 'to:name :python-list@python.org': 0.22; 'print': 0.22; 'creating': 0.23; 'error': 0.23; 'replace': 0.24; 'specify': 0.24; 'looks': 0.24; '(or': 0.24; 'script': 0.25; 'right.': 0.26; 'pass': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'idea': 0.28; 'function': 0.29; "doesn't": 0.30; 'programming.': 0.30; 'specified': 0.30; "i'm": 0.30; 'code': 0.31; '25,': 0.31; 'invoke': 0.31; 'stands': 0.31; 'terms.': 0.31; 'values.': 0.31; 'anyone': 0.31; 'allows': 0.31; 'file': 0.32; 'probably': 0.32; 'received:169.254': 0.32; 'interface': 0.32; 'run': 0.32; 'text': 0.33; 'open': 0.33; 'linux': 0.33; 'running': 0.33; 'call.': 0.33; 'sense': 0.34; "i'd": 0.34; 'message.': 0.35; 'knowledge': 0.35; 'display': 0.35; 'created': 0.35; 'something': 0.35; 'case,': 0.35; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'purchase': 0.65; 'needing': 0.65; 'to:addr:gmail.com': 0.65; 'determine': 0.67; 'anything.': 0.68; 'subject': 0.69; 'fact,': 0.69; 'legal': 0.71; 'increasing': 0.74; 'sale': 0.75; 'click': 0.77; '2.7.': 0.84; 'received:169.254.8': 0.84; 'angel': 0.91; 'graphical': 0.91; 'directly.': 0.95; '2013': 0.98 |
| X-DKIM | OpenDKIM Filter v2.1.3 sz1.jpmchase.com r6QE8XGB008398 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1374847713; bh=ds7XkWL7M4C9nUn9SSW1/UEYNJTzFeLerREPNybP56Q=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:content-transfer-encoding:MIME-Version; b=EbYs1i3ttestMHSD43emZmLMMThFJ5Zc4RtvKQDWHBAGmdore5x1N4r7+kQ0mK3ZH c5KCCQQuF5a7NsdKVvsLuRDnUpPIijkrleG65IqhzjjMZv5VpZo4fhaf9RWhwxQqQJ 1XBF7RwnEE4lwE5BQyjy7PUnabNVDqXN52lI/IeQ= |
| X-AuditID | a97c8568-b7fe98e00000038f-78-51f282decbc7 |
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
| To | CTSB01 <scott.moore270@gmail.com>, "python-list@python.org" <python-list@python.org> |
| Subject | RE: Creating a Simple User Interface for a Function |
| Thread-Topic | Creating a Simple User Interface for a Function |
| Thread-Index | AQHOiXm5lj0RxhF6Pkao9ZY86wWzvpl15VxQ |
| Date | Fri, 26 Jul 2013 14:08:14 +0000 |
| References | <cebb4f86-c546-4283-a839-46393571cbb0@googlegroups.com> <mailman.5116.1374779986.3114.python-list@python.org> <97f8224f-e73b-4a4b-bf05-7cc3dba4e9d9@googlegroups.com> |
| In-Reply-To | <97f8224f-e73b-4a4b-bf05-7cc3dba4e9d9@googlegroups.com> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [10.67.79.47] |
| Content-Type | text/plain; charset="us-ascii" |
| content-transfer-encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-DLP-FWD | Yes |
| X-Brightmail-Tracker | H4sIAAAAAAAAA+NgFvrFKsWRmVeSWpSXmKPExsWy0tXaQPd+06dAgzkn+C2OtF5jtej9vIjF gclj56y77B4v5r9hC2CKamC0SczLyy9JLElVSEktTrZVcsksTs5JzMxNLVLQVfAqyM0vSk/M 00vOz1VSyEyxVTJRUijISUxOzU3NK7FVSiwoSM1LUbLjUsAANkBlmXkKqXnJ+SmZeem2Sp7B /roWFqaWuoZKdiEZmcUKqbmJmTkKCRvZMy5secRc0G1Q8f7+FuYGxoPKXYycHBICJhJvOv6x QdhiEhfurQeyuTiEBA4zSpz4spkFwjnIKPGu5xsrhLORUWLa9P+MIC1sAoYSx88+YQexRQSi JJ41tLGC2MICNhJHNxxg7mLkAIrbSlyYZgFRYiTR/+0JM4jNIqAq8fzuShYQm1cgROL504lQ 87cySjy5+5gdpJdTwEVidivYeEag676fWsMEYjMLiEvcejKfCeJqAYkle84zQ9iiEi8f/2OF sOUlXkx5yQZRryOxYPcnKFtbYtnC18wQewUlTs58wgKySkhATWLfelsQU0KAT2J7W/UERolZ SJbNQjJoFpJBs5AMWsDIsopRsjg3PcNEr7isSK+0WC+rIDc5I7E4VS8vtWQTIyjJ1LRm7GBc stz2EKMAB6MSD6+i08dAIdbEsuLK3EOMEhzMSiK8h7JOBgrxpiRWVqUW5ccXleakFh9irAKG 2URmKdHkfGACzCuJNzQ2szAwNTU0sDA0MqGKsJI4r9PaZ4FCAunAlJqdmlqQWgSznImDU6qB UaDbpkemaHtyC6Oc7y/feXF3ingaBF7PnPVMdpbEmi1zS+021E5WFxR3UNrY9meukOIGeeGN HBb6T2uzWc9+sbJffumPhqFM1vqdmSbh8w5Pj95zRIkz4vvx3cETuK6ZBf9ctbp41Zd1pq8k TzrI6/84szP2quqkrn9OFrPXZ7sss/i+2L74pBJLcUaioRZzUXEiAOcp3PWNAwAA |
| 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.5147.1374847717.3114.python-list@python.org> (permalink) |
| Lines | 193 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374847717 news.xs4all.nl 15871 [2001:888:2000:d::a6]:45115 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51304 |
Show key headers only | View raw
CTSB01 wrote:
> On Thursday, July 25, 2013 3:19:27 PM UTC-4, Dave Angel wrote:
> > On 07/25/2013 12:03 PM, CTSB01 wrote:
> >
> > > I have the following code that runs perfectly:
> >
> >
> > > def psi_j(x, j):
> >
> > > rtn = []
> >
> > > for n2 in range(0, len(x) * j - 2):
> >
> > > n = n2 / j
> >
> > > r = n2 - n * j
> >
> > > rtn.append(j * x[n] + r * (x[n + 1] - x[n]))
> >
> > > print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
> >
> > > return rtn
> >
> > No it doesn't run perfectly. It'll get a syntax error on the print
> >
> > function call. That's assuming you're still using Python 3.3. You
> >
> > really need to start by specifying your environment, without making us
> >
> > look back through previous threads from you.
> >
> > > This code takes a string x = [0,1,1,1,2] for example
> >
> > That's not a string. A string would be like
> >
> > xx = psi_j("0abcd1234")
> >
> > Perhaps you mean list? And is it a list of integers, or of arbitrary
> >
> > numbers? Are there any constraints on the sizes or signs of those numbers?
> >
> > > (it must always begin with 0) and a parameter j, say 2, and outputs a string (x = [0, 1, 2, 2, 2,
> 2, 2, 3] in this example).
> >
> > > It does this in two steps: First it decomposes some number m into a multiple of j and a remainder.
> >
> > Only if you replace the / with //. Or just use the function divmod():
> >
> > n, r = divmod(n2, m)
> >
> > > Then it runs this decomposition through a function on the rtn.append line.
> >
> > > Notice that this has cj - 1 terms where c is the number of terms in the input string and j is the
> parameter. Normally, we would like it to be able to calculate cj terms.
> >
> > > This is an issue with the function that I am more than happy to put aside for the moment.
> >
> > > My key interest is to be able to make this program
> >
> > So far you have a function, not a program. If you put it in a text file
> >
> > and run it from python, it'll do nothing but display a syntax error
> >
> > message. And when you fix that, it'll just run without doing anything.
> >
> > usable for someone who has no knowledge of programming. In
> >
> > particular, I need some kind of user interface that prompts
> >
> > > the user to input a string (ideally just by putting in numbers in the form 011123334 for example)
> and a parameter,
> >
> > > and then displays the output sequence. This is essentially what the program already does but the
> idea is to make it usable
> >
> > > for even the most technologically disinclined. Ideally it would do this without needing to run
> Python at all.
> >
> > Then why are you asking on the Python forum? Or perhaps you mean
> >
> > without him knowing he's running Python? In that case, use a shebang
> >
> > line at the beginning, which will tell Linux to automatically invoke the
> >
> > specified program (or programming language in this case).
> >
> > > If anyone is able to make this happen in Python I would be eternally grateful.
> >
> > If we assume you're running Python 3.3 on Linux, and the user is willing
> >
> > to us the terminal, then how about parsing the string from the command
> >
> > line he types? You can access it as011123334 a string from sys.argv,
> >
> > and convert it to separate numbers. Of course as it stands now, you
> >
> > cannot tell whether the user wanted
> >
> > 0,1,1,1,2,3,3,3,4
> >
> > or
> >
> > 0, 111, 23, 3, 3, 4
> >
> > or something else.
> >
> > DaveA
>
> Sorry Dave, to answer each part of your response:
>
> 1) I decided to use Python 2.7, and I will be sure to specify this in all future threads.
> 2) It is a list of positive integers. In fact, it is always going to be a list of positive increasing
> integers.
> 3) You're right. What I meant was that if after running that bit of code I enter
> >>> x = [0,1,2,3,4,5]
> >>> psi_j(x,2)
> I will get output that matches my requirements.
> 4) Yes, sorry that's what I meant (if I understood correctly). I was told elsewhere that I might want
> to try using tkinter. Essentially I'm trying to create a user interface that allows the user to just
> type in a string 01112345 for example, and choose a parameter (say j=2) and then click a button to run
> the function. 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.
Any UI will work whether graphical or command line. TK is a good choice if you assume that the user
has Python installed. If you are planning to create an exe (Windows) then you can probably
bundle any GUI library (wx/gtk/qt) but you might be limited by the support of the exe creating
tool. I have never created an executable like this, so I am not sure.
>
> So on top of the user interface I would also it looks like need to determine how to make Python change
> a string 01112345 into a list so that it does that automatically when the user clicks 'run'.
This really does not make sense to me. Does that mean 0, 1, 11, 23, 45 or 0, 111, 2345 or 0,11,
2345 or something else entirely? If you are doing this on the shell I would have the user pass
in a string of delimited values. "0,1,11,23,45" and then do a .split(',') on the string. If
you are doing this via GUI then you can create separate fields for each number or still ask
for a delimited string.
However, if the parameter (j=2) determines parsing of numbers then you can ignore my concerns.
>
> Would a shebang still be the right way to go?
The shebang is useful when executing a script from cmd/shell directly.
$ ./script.py
# rather than
$ python script.py
If you are making an executable (.exe in Windows) then I do not
think it will matter either way for 2.7.
>
> Thanks again Dave, apologies for the ambiguity.
~Ramit
This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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