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


Groups > comp.lang.python > #66001 > unrolled thread

Top down Python

Started byJohn Allsup <pydev@allsup.co>
First post2014-02-12 07:05 +0000
Last post2014-02-13 12:06 +1100
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Top down Python John Allsup <pydev@allsup.co> - 2014-02-12 07:05 +0000
    Re: Top down Python John Gordon <gordon@panix.com> - 2014-02-12 07:40 +0000
      Re: Top down Python Chris Angelico <rosuav@gmail.com> - 2014-02-12 18:50 +1100
        Re: Top down Python Cousin Stanley <cousinstanley@gmail.com> - 2014-02-12 17:26 -0700
          Re: Top down Python Chris Angelico <rosuav@gmail.com> - 2014-02-13 12:06 +1100

#66001 — Top down Python

FromJohn Allsup <pydev@allsup.co>
Date2014-02-12 07:05 +0000
SubjectTop down Python
Message-ID<mailman.6729.1392188714.18130.python-list@python.org>
What is needed for proper learning is near-absolute simplicity.
Even one toy too many to play with is an intolerable distraction,
but one too few massively hampers learning and induces boredom.

I want to be able to say:
     1. Put a nice picture on the background.
     2. Put a terminal window with, say, 64x20 lines, dead centre.
     3. Run a simple REPL program written in Python or Ruby within it.
I do not really want to write any more lines of code than I need to.
Why do we not have langauges and libraries that can do the above
with only five lines of code (line 0 == setup, line 4 == cleanup).

Programming should be that efficient if we learn to make things
beautiful and not tolerate wastes of lines and characters, on
a global scale as well as locally to our projects.

Consider
====
#!/usr/bin/env python3

from myappfw import app
from myapp1 import repl
app.background = "Moutains1"
t = app.terminal.open(title="Typing commands One Oh One",position="centre",
     width="80%",height="72%",rows="20",columns="64")
exit(t.run(repl))
====

What Python would I need to write, as concise but readable as 
practically possible, so that the above program works as desired (for 
any repl that obeys the basic input-process-output behaviour of a repl)?

This is top-down design done right IMO (as described in Thinking Forth, 
by the way).

[toc] | [next] | [standalone]


#66002

FromJohn Gordon <gordon@panix.com>
Date2014-02-12 07:40 +0000
Message-ID<ldf8i5$hhk$1@reader1.panix.com>
In reply to#66001
In <mailman.6729.1392188714.18130.python-list@python.org> John Allsup <pydev@allsup.co> writes:

> I want to be able to say:
>      1. Put a nice picture on the background.
>      2. Put a terminal window with, say, 64x20 lines, dead centre.
>      3. Run a simple REPL program written in Python or Ruby within it.
> I do not really want to write any more lines of code than I need to.
> Why do we not have langauges and libraries that can do the above
> with only five lines of code (line 0 == setup, line 4 == cleanup).

You're asking for prepackaged libraries with extremely specific behavior.
Forgive me for making an analogy on the Internet, but your request is akin
to asking for a hammer that will automatically pound six-penny nails
through half-inch drywall, while facing south, on Tuesdays.

Such a hammer is great if those are your specific requirements, but
worthless otherwise.  It's much better to sell a generic hammer.  Sure,
it's a little more work for the user, but it will pound any type of nail
though a variety of surfaces.  I.e., it's reusable.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

[toc] | [prev] | [next] | [standalone]


#66005

FromChris Angelico <rosuav@gmail.com>
Date2014-02-12 18:50 +1100
Message-ID<mailman.6731.1392191435.18130.python-list@python.org>
In reply to#66002
On Wed, Feb 12, 2014 at 6:40 PM, John Gordon <gordon@panix.com> wrote:
> In <mailman.6729.1392188714.18130.python-list@python.org> John Allsup <pydev@allsup.co> writes:
>
>> I want to be able to say:
>>      1. Put a nice picture on the background.
>>      2. Put a terminal window with, say, 64x20 lines, dead centre.
>>      3. Run a simple REPL program written in Python or Ruby within it.
>> I do not really want to write any more lines of code than I need to.
>> Why do we not have langauges and libraries that can do the above
>> with only five lines of code (line 0 == setup, line 4 == cleanup).
>
> You're asking for prepackaged libraries with extremely specific behavior.
> Forgive me for making an analogy on the Internet, but your request is akin
> to asking for a hammer that will automatically pound six-penny nails
> through half-inch drywall, while facing south, on Tuesdays.
>
> Such a hammer is great if those are your specific requirements, but
> worthless otherwise.  It's much better to sell a generic hammer.  Sure,
> it's a little more work for the user, but it will pound any type of nail
> though a variety of surfaces.  I.e., it's reusable.

There is a reusable component to this: a "terminal window" GUI object.
If one existed, then this would be a matter of:

1) Create window
2) Put picture as background
3) Create terminal window with size 64x20 (which, IMO, is tiny)
4) Call on subprocess to handle REPL

Depending on how compact the code is, it might take 6-10 lines rather
than five, but it would be fairly short. However, it depends on being
able to simply "create terminal window" the way you "create button" or
"create entry field". As far as I know, this doesn't exist *anywhere*,
which is why I've written a number of MUD clients whose primary
purpose is to do exactly that.

ChrisA

[toc] | [prev] | [next] | [standalone]


#66123

FromCousin Stanley <cousinstanley@gmail.com>
Date2014-02-12 17:26 -0700
Message-ID<ldh3eu$n80$1@dont-email.me>
In reply to#66005
> ....
> 3) Create terminal window with size 64x20 
> (which, IMO, is tiny)
> .... 

  Maybe .... 

    64 characters x 20 lines

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

[toc] | [prev] | [next] | [standalone]


#66127

FromChris Angelico <rosuav@gmail.com>
Date2014-02-13 12:06 +1100
Message-ID<mailman.6812.1392253575.18130.python-list@python.org>
In reply to#66123
On Thu, Feb 13, 2014 at 11:26 AM, Cousin Stanley
<cousinstanley@gmail.com> wrote:
>> ....
>> 3) Create terminal window with size 64x20
>> (which, IMO, is tiny)
>> ....
>
>   Maybe ....
>
>     64 characters x 20 lines

Yes, but still tiny. Normal minimum would be 80x25 (maybe 80x24). I
like to go a lot larger. When I'm compiling code, I generally maximize
the window - on today's system, that's 190x51 - and for MUDding, I'll
usually go for roughly 90x∞, because I can. :) My current MUD window
is 89x32 visible, 89x∞ stored. 64x20 means everything's going to wrap,
and it won't take much to push text off the "screen".

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web