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


Groups > comp.lang.python > #79761

Re: Classes and the command line

From Seymore4Head <Seymore4Head@Hotmail.invalid>
Newsgroups comp.lang.python
Subject Re: Classes and the command line
Date 2014-10-26 23:32 -0400
Message-ID <qver4ah6884ro8bun7k9drvoegh3v9rcec@4ax.com> (permalink)
References <8uar4a1pa6d631ktr33h8rau1ilf2rjvi3@4ax.com> <mailman.15220.1414379184.18130.python-list@python.org>
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


On Mon, 27 Oct 2014 14:06:11 +1100, Ben Finney
<ben+python@benfinney.id.au> wrote:

>Seymore4Head <Seymore4Head@Hotmail.invalid> writes:
>
>> I am trying to learn classes.
>> I am currently using Python 2.7 at the command line.
>
>(I think you mean “the interactive Python interpreter”, or just “the
>Python shell”.)
>
>Since you are learning Python, I will strongly recommend you ignore
>Python 2 unless it becomes unavoidable.
>
At the moment, it is unavoidable.  The instructors are teaching Python
2 so I have to learn Python 2, for now.

>Instead, learn Python 3 primarily; it is much better because it omits a
>bunch of legacy behaviour you don't need.
>
>> If you try to type commands at the [interactive shell] and make the
>> slightest mistake you have to start over.
>
>Right. There is line-by-line history, and editing enabled with the
>“readline” plug-in. (This is an advantage of using a programmer-friendly
>operating system, which MS Windows sadly is not.)
>
>> I was trying to copy and paste these instructions into the
>> [interactive Python shell].
>>
>> http://en.wikibooks.org/wiki/Python_Programming/Classes
>> >>> class Foo:
>> ...     def setx(self, x):
>> ...         self.x = x
>> ...     def bar(self):
>> ...         print self.x
>>
>> There is really no way to do that without pasting line by line is
>> there and adding deleting spaces?  And if you use spaces and tabs,
>> they are not the same.
>
>Right on all counts.
>
>The interactive Python shell is good for very quickly experimenting and
>demonstrating how Python actually behaves, statement by statement. But
>as you point out, it is not a good choice for anything more complex. It
>is a good learning and debugging tool.
>
>When you start to write larger units of code, like a class or a
>function, you can trade immediacy for flexibility: write your code into
>a text editor, save it to a file ‘foo.py’, then run that code at a
>separate OS command prompt by invoking ‘python foo.py’ in the terminal.
>
>That way, you can continue to adjust and tweak the code as you learn how
>your changes affect the code. You do need to keep invoking the actions
>separately – edit the file, save the file, run the file with Python –
>but this is what's needed when you want to run a program more than once
>anyway, so it's a good step to take.
>
>Find a good, *general-purpose* programmer's editor. Preferably licensed
>under free software terms, with a strong community supporting it, and
>available on all major platforms for when you switch to a decent
>programmer-friendly operating system.

I am actually using Notepad some too.

Thanks

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


Thread

Classes and the command line Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-26 22:27 -0400
  Re: Classes and the command line Rustom Mody <rustompmody@gmail.com> - 2014-10-26 20:05 -0700
    Re: Classes and the command line Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-26 23:28 -0400
      Re: Classes and the command line Terry Reedy <tjreedy@udel.edu> - 2014-10-28 00:14 -0400
  Re: Classes and the command line Ben Finney <ben+python@benfinney.id.au> - 2014-10-27 14:06 +1100
    Re: Classes and the command line Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-26 23:32 -0400
      Re: Classes and the command line alister <alister.nospam.ware@ntlworld.com> - 2014-10-27 11:17 +0000
        Re: Classes and the command line Chris Angelico <rosuav@gmail.com> - 2014-10-27 22:33 +1100
      Re: Classes and the command line Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-27 09:34 -0400
  Re: Classes and the command line Chris Angelico <rosuav@gmail.com> - 2014-10-27 14:10 +1100
    Re: Classes and the command line Rustom Mody <rustompmody@gmail.com> - 2014-10-26 20:18 -0700
      Re: Classes and the command line Chris Angelico <rosuav@gmail.com> - 2014-10-27 14:24 +1100
      Re: Classes and the command line Rustom Mody <rustompmody@gmail.com> - 2014-10-26 20:30 -0700
      Re: Classes and the command line Terry Reedy <tjreedy@udel.edu> - 2014-10-28 00:08 -0400
      Re: Classes and the command line Chris Angelico <rosuav@gmail.com> - 2014-10-28 15:57 +1100
    Re: Classes and the command line Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-26 23:33 -0400

csiph-web