Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25473 > unrolled thread
| Started by | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| First post | 2012-07-17 09:45 +0100 |
| Last post | 2012-07-18 11:35 +0100 |
| Articles | 20 on this page of 106 — 32 participants |
Back to article view | Back to comp.lang.python
Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 09:45 +0100
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-17 06:03 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:24 +0100
Re: Encapsulation, inheritance and polymorphism Larry Hudson <orgnut@yahoo.com> - 2012-07-18 00:10 -0700
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-17 11:30 +0200
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:01 +0100
Re: Encapsulation, inheritance and polymorphism Dave Angel <d@davea.name> - 2012-07-17 07:23 -0400
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 06:37 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:44 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 06:53 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 14:35 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:01 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 09:16 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:26 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:30 -0400
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 12:57 -0500
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-17 14:18 +0200
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 14:29 +0100
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-17 09:52 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:23 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 17:26 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 17:46 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:07 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 20:29 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 20:39 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 20:52 +0100
Re: Encapsulation, inheritance and polymorphism John Ladasky <john_ladasky@sbcglobal.net> - 2012-08-18 23:05 -0700
Re: Encapsulation, inheritance and polymorphism John Ladasky <john_ladasky@sbcglobal.net> - 2012-08-18 23:05 -0700
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-17 18:57 -0400
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-17 10:29 -0700
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-18 04:01 +1000
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-17 12:51 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 19:18 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 19:36 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Cooper <amc96@cam.ac.uk> - 2012-07-18 01:46 +0100
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-17 20:54 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 10:06 +0100
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-18 14:01 +0200
Re: Encapsulation, inheritance and polymorphism "BartC" <bc@freeuk.com> - 2012-07-19 01:41 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 13:05 +0000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 15:40 +0100
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 01:04 +1000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:22 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 15:09 +1000
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-18 08:32 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 16:49 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:34 +0000
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-18 23:09 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-19 09:56 +0100
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-19 08:58 -0700
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 12:59 +0000
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-19 09:06 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 07:24 +0000
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-20 01:21 -0700
Re: Encapsulation, inheritance and polymorphism Paul Rudin <paul.nospam@rudin.co.uk> - 2012-07-19 18:22 +0100
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-19 13:20 -0500
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-20 04:28 +1000
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-19 13:50 -0500
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 08:11 +0000
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-20 02:08 -0700
Re: Encapsulation, inheritance and polymorphism "BartC" <bc@freeuk.com> - 2012-07-20 11:28 +0100
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-21 14:32 -0700
Re: Encapsulation, inheritance and polymorphism Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 16:36 +0000
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-19 16:47 -0400
Re: Encapsulation, inheritance and polymorphism John Gordon <gordon@panix.com> - 2012-07-19 21:01 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-20 08:20 +1000
Re: Encapsulation, inheritance and polymorphism John Gordon <gordon@panix.com> - 2012-07-19 22:23 +0000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 08:27 +0000
Re: Encapsulation, inheritance and polymorphism Virgil Stokes <vs@it.uu.se> - 2012-07-20 11:05 +0200
Re: Encapsulation, inheritance and polymorphism Hans Mulder <hansmu@xs4all.nl> - 2012-07-20 19:45 +0200
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-21 14:28 -0700
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-20 13:57 -0400
Re: Encapsulation, inheritance and polymorphism Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-19 15:13 -0600
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-19 17:30 -0400
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-20 10:00 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-19 02:11 -0400
Re: Encapsulation, inheritance and polymorphism Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 16:18 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-24 02:15 +1000
Re: Encapsulation, inheritance and polymorphism Robert Miles <robertmiles@teranews.com> - 2012-08-19 00:21 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-19 09:55 +0100
Re: Encapsulation, inheritance and polymorphism lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-19 12:50 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-19 13:06 +0100
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-17 11:43 -0700
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-17 15:05 -0400
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 20:33 +0100
Re: Encapsulation, inheritance and polymorphism Ian <hobson42@gmail.com> - 2012-07-17 19:59 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 12:58 +0000
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-18 09:07 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 14:31 +0000
Re: Encapsulation, inheritance and polymorphism Dave Angel <d@davea.name> - 2012-07-18 12:33 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:23 +0000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 12:43 +0000
Re: Encapsulation, inheritance and polymorphism Grant Edwards <invalid@invalid.invalid> - 2012-07-18 14:34 +0000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 15:48 +0100
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 01:09 +1000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 16:36 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:14 +0000
Re: Encapsulation, inheritance and polymorphism MRAB <python@mrabarnett.plus.com> - 2012-07-19 02:28 +0100
Re: Encapsulation, inheritance and polymorphism "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2012-07-19 16:52 +0000
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-18 10:00 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 13:01 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:24 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 19:21 +0100
Re: Encapsulation, inheritance and polymorphism MRAB <python@mrabarnett.plus.com> - 2012-07-17 18:43 +0100
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-17 12:56 -0500
Re: Encapsulation, inheritance and polymorphism Arnaud Delobelle <arnodel@gmail.com> - 2012-07-18 11:35 +0100
Page 1 of 6 [1] 2 3 4 5 6 Next page →
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 09:45 +0100 |
| Subject | Encapsulation, inheritance and polymorphism |
| Message-ID | <x_udnUHnRNWDu5jNnZ2dnUVZ8tudnZ2d@bt.com> |
Pythoners Python 2.7.3 Ubuntu Linux 12.04 LTS I've been taking a brief look at Python. From the tutorial documentation I get the following 'Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming'. I was expecting (hoping) to see in depth documentation relating to Class construction, extension mechanisms and runtime polymorphism. What I actually get is a confusion of Classes, modules, scripts and whatever else. Is Python truly OO or is it just one way to use the language. I see some documentation relating to classes but nothing on instantiation .. in fact the documentation appears to say that classes are used in a static way e.g ClassName.method(), and command line scripting is really outside the scope of other OO languages I have experienced. Is there a previous discussion in the group that I could read. Many thanks Lipska -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer.
[toc] | [next] | [standalone]
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| Date | 2012-07-17 06:03 -0400 |
| Message-ID | <mailman.2210.1342519472.4697.python-list@python.org> |
| In reply to | #25473 |
On Tue, Jul 17, 2012 at 4:45 AM, Lipska the Kat <lipska@lipskathekat.com> wrote:
> Is Python truly OO or is it just one way to use the language. I see some
> documentation relating to classes but nothing on instantiation .. in fact
> the documentation appears to say that classes are used in a static way e.g
> ClassName.method(), and command line scripting is really outside the scope
> of other OO languages I have experienced.
It doesn't look like you're reading the section on classes:
http://docs.python.org/tutorial/classes.html
You create a class like this:
class MyClass(MySuperclass1, MySuperclass2):
# class attributes and methods
attr = 3
def method(self): print self.attr
You can instantiate it by calling the class, as if it were a function:
myinstance = MyClass()
You call a method getting the method (myinstance.method), and then
calling that as if it were a function.
myinstance.method()
Polymorphism is "duck typed" -- that is, it's based on the
presence/absence of attributes and methods, not on declared interfaces
(Python has no interfaces). So, for example, "foo.read()" works on any
object bound to the name "foo", as long as it has a read method that
takes no parameters. This could be a file-like object, but it could
also be something completely different that just happens to have a
method by the same name.
> Is there a previous discussion in the group that I could read.
Man, I dunno, the list archives are impossible to navigate.
-- Devin
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 12:24 +0100 |
| Message-ID | <69-dnRfmT7kb1pjNnZ2dnUVZ8kSdnZ2d@bt.com> |
| In reply to | #25481 |
On 17/07/12 11:03, Devin Jeanpierre wrote: > On Tue, Jul 17, 2012 at 4:45 AM, Lipska the Kat<lipska@lipskathekat.com> wrote: >> Is Python truly OO or is it just one way to use the language. I see some >> documentation relating to classes but nothing on instantiation .. in fact >> the documentation appears to say that classes are used in a static way e.g >> ClassName.method(), and command line scripting is really outside the scope >> of other OO languages I have experienced. > > It doesn't look like you're reading the section on classes: > > http://docs.python.org/tutorial/classes.html Thanks, I wasn't, there is too much to do and not enough time to do it. So now I just need to chill out a bit and get into 'documentation reading mode' again > Polymorphism is "duck typed" -- Yes, I've been reading the wikipedia entry on this ... this type of polymorphism is not familiar to me ... I come from a Java background. more reading I guess. snip > -- Devin Thanks for your time and I'll try to do a bit better with the reading thing before asking more questions... not sure about this obsession with code indentation though :-| -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2012-07-18 00:10 -0700 |
| Message-ID | <3_-dnSE1NeHq_JvNnZ2dnUVZ_sadnZ2d@giganews.com> |
| In reply to | #25487 |
On 07/17/2012 04:24 AM, Lipska the Kat wrote:
...
> Thanks for your time and I'll try to do a bit better with the reading thing before asking more
> questions... not sure about this obsession with code indentation though :-|
>
I think it's inaccurate to call this indentation an obsession, it's part of Python's defined
syntax. It's used INSTEAD OF punctuation or keywords (like {} or BEGIN END). If you're already
used to indenting your code consistently, you'll be surprised at how quickly it becomes a
non-issue when you start using Python.
It's a bit dated, but you might find http://www.linuxjournal.com/article/3882 to be an
interesting read.
-=- Larry -=-
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Date | 2012-07-17 11:30 +0200 |
| Message-ID | <3vnfd9-343.ln1@satorlaser.homedns.org> |
| In reply to | #25473 |
Welcome! Am 17.07.2012 10:45, schrieb Lipska the Kat: > I was expecting (hoping) to see in depth documentation relating to Class > construction, extension mechanisms and runtime polymorphism. In addition to this forum for direct help and discussion, two suggestions: Firstly, it could help if you mentioned what programming languages you are fluent in, in order to help traditional misconceptions and to draw parallels. Secondly, http://docs.python.org is the central hub to tutorials and documentation. > What I actually get is a confusion of Classes, modules, scripts and > whatever else. Due to the very dynamic nature of Python, types (classes), modules and functions are themselves objects that can be manipulated. > Is Python truly OO or is it just one way to use the language. Python supports OOP, but it doesn't enforce it. You can use other paradigms, too. > I see some documentation relating to classes but nothing on > instantiation .. in fact the documentation appears to say that classes > are used in a static way e.g ClassName.method(), and command line > scripting is really outside the scope of other OO languages I have > experienced. I think you are confused. For the documentation, it would help to know which documentation exactly seems to make such claims. For the thing about commandline scripting, I'm afraid you will have to adjust your expectations. BTW: In general, you instantiate a class by just calling the class' name like a function. If e.g. ClassName is a class, ClassName() instantiates this class. Good luck! Uli
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 12:01 +0100 |
| Message-ID | <-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com> |
| In reply to | #25483 |
On 17/07/12 10:30, Ulrich Eckhardt wrote: > Welcome! > > Am 17.07.2012 10:45, schrieb Lipska the Kat: >> I was expecting (hoping) to see in depth documentation relating to Class >> construction, extension mechanisms and runtime polymorphism. > > In addition to this forum for direct help and discussion, two > suggestions: Firstly, it could help if you mentioned what programming > languages you are fluent in For the past 9 years I have been developing in Java, everything from device drivers (well firmware interfaces would be a better description) to serverside business logic implemented using POJOs and database interfaces along with some in depth work with earlier versions of J2EE including EJBs and of course the obligatory frameworks. There's more but you get the idea. My speciality if you like is the design of high availability real time business systems right from high level natural language specifications to detailed use cases and associated models in UML. I also do some implementation work although not so much these days. phew! my resume in a nutshell I suppose Earlier on in my career I did some fairly low level stuff in C and C++ although the mists of time and all that ... Anyway, I'm looking at Python as a rapid prototyping language. I have an idea and just want to get it down in basic outline code as quickly as possible before it departs my aging brain... I'm not used to using variables without declaring their type ... (well I used to do Visual Basic many years ago) It just seems so weird, and what's this obsession with 'correct' indentation of code ??? >in order to help traditional misconceptions > and to draw parallels. Secondly, http://docs.python.org is the central > hub to tutorials and documentation. > > >> What I actually get is a confusion of Classes, modules, scripts and >> whatever else. > > Due to the very dynamic nature of Python, types (classes), modules and > functions are themselves objects that can be manipulated. > > snip > >> I see some documentation relating to classes but nothing on >> instantiation .. in fact the documentation appears to say that classes > > are used in a static way e.g ClassName.method(), and command line > > scripting is really outside the scope of other OO languages I have > > experienced. > > I think you are confused. Highly likely > For the documentation, it would help to know > which documentation exactly seems to make such claims. For the thing > about commandline scripting, I'm afraid you will have to adjust your > expectations. I'll try to find it again > > BTW: In general, you instantiate a class by just calling the class' name > like a function. If e.g. ClassName is a class, ClassName() instantiates > this class. > > > Good luck! Thank you, and thank you for your kind response Lipska -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-07-17 07:23 -0400 |
| Message-ID | <mailman.2214.1342524217.4697.python-list@python.org> |
| In reply to | #25484 |
On 07/17/2012 07:01 AM, Lipska the Kat wrote: > <SNIP> > > Anyway, I'm looking at Python as a rapid prototyping language. > I have an idea and just want to get it down in basic outline code as > quickly as possible before it departs my aging brain... I'm not used > to using variables without declaring their type ... (well I used to do > Visual Basic many years ago) It just seems so weird, and what's this > obsession with 'correct' indentation of code ??? > Welcome to comp.lang.python. I hope you enjoy learning and using Python. Indentation isn't just custom in Python. It's part of the syntax. Other languages use braces, or keywords, to indicate scope, but Python uses indentation. Other than the occasional tab to confuse things, the rules are pretty simple. You must indent the body of a function, the scope of an if or else clause, or other similar language pieces (class, try, except, ...) Within such a scope, you cannot change indentation, except of course for a nested scope. At the end of such scope you must outdent to the previous state. The convention is to use 4 spaces per indentation, but the language will accept any amount, as long as it's consistent within any single scope. And although mixing tabs and space worked in Python 2.x, sort of, it's disallowed in Python 3. An expression may span multiple lines, but only if it's unambiguous to the compiler (eg. a pending left paren with no matching right paren yet). In that case. indentation of the subsequent lines is unrestricted. HTH -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2012-07-17 06:37 -0500 |
| Message-ID | <mailman.2215.1342525038.4697.python-list@python.org> |
| In reply to | #25484 |
On 7/17/2012 6:01 AM, Lipska the Kat wrote: > Anyway, I'm looking at Python as a rapid prototyping language. > I have an idea and just want to get it down in basic outline code as > quickly as possible before it departs my aging brain... I'm not used to > using variables without declaring their type ... (well I used to do > Visual Basic many years ago) It just seems so weird, and what's this > obsession with 'correct' indentation of code ??? "Pythonic" is (or at least should be) a word you encounter frequently in discussions of Python code. Learn what is considered Pythonic and then write Python code that way if you want to work with the language rather than fight it. Duck-typing is very Pythonic and so is readable code. As Dave mentioned, indentation is part of the syntax - blocks must be indented with either tabs or spaces (choose one - if you mix them ambiguously, an IndentationError will be raised). Try "from __future__ import braces" and "import this" for some insight. ;) The official tutorial gives a great overview of the language and has links to reference material that goes into greater detail: http://docs.python.org/tutorial/ (Python 2.7) http://docs.python.org/py3k/tutorial/ (Python 3.2) On a side note, I would highly recommend learning Python 3 (3.2 is the latest stable version) unless you have an explicit need for Python 2 (some major 3rd-party libraries have not been ported yet). Python 2 won't get any new features; it will simply get bug fixes until its EOL in 2014 (15?). -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 12:44 +0100 |
| Message-ID | <Q4KdndnfeZG5zZjNnZ2dnUVZ8qCdnZ2d@bt.com> |
| In reply to | #25488 |
On 17/07/12 12:37, Andrew Berg wrote: > On 7/17/2012 6:01 AM, Lipska the Kat wrote: >> Anyway, I'm looking at Python as a rapid prototyping language. snip > "Pythonic" is (or at least should be) a word you encounter frequently in > discussions of Python code. Learn what is considered Pythonic and then > write Python code that way if you want to work with the language rather > than fight it. Duck-typing is very Pythonic You're not kidding, the 'duck' example at http://en.wikipedia.org/wiki/Duck_typing made me check I hadn't overdone the medication this morning. That is just plain ...weird. It will take me a while to form non knee jerk opinions of this for sure. snip > On a side note, I would highly recommend learning Python 3 (3.2 is the > latest stable version) unless you have an explicit need for Python 2 > (some major 3rd-party libraries have not been ported yet). Python 2 > won't get any new features; it will simply get bug fixes until its EOL > in 2014 (15?). I'll check it out, thanks. Lipska -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2012-07-17 06:53 -0500 |
| Message-ID | <mailman.2216.1342526001.4697.python-list@python.org> |
| In reply to | #25489 |
On 7/17/2012 6:44 AM, Lipska the Kat wrote: > I'll check it out, thanks. I forgot to add this: http://wiki.python.org/moin/Python2orPython3 It's a little outdated (there is more progress toward py3k by 3rd-party libraries every day), but still quite helpful. -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-07-17 14:35 +0100 |
| Message-ID | <mailman.2221.1342532003.4697.python-list@python.org> |
| In reply to | #25489 |
On 17/07/2012 12:44, Lipska the Kat wrote: > > You're not kidding, the 'duck' example at > http://en.wikipedia.org/wiki/Duck_typing made me check I hadn't overdone > the medication this morning. That is just plain ...weird. It will take > me a while to form non knee jerk opinions of this for sure. > > Lipska > > It's difficult to get junkies off of their addictive substances but I'm sure that the qualities of Python will eventually overcome your Java habit :) -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 15:01 +0100 |
| Message-ID | <yNOdnQOZa8-C7ZjNnZ2dnUVZ8k6dnZ2d@bt.com> |
| In reply to | #25488 |
On 17/07/12 12:37, Andrew Berg wrote: > On 7/17/2012 6:01 AM, Lipska the Kat wrote: snip > On a side note, I would highly recommend learning Python 3 (3.2 is the > latest stable version) unless you have an explicit need for Python 2 > (some major 3rd-party libraries have not been ported yet). Python 2 > won't get any new features; it will simply get bug fixes until its EOL > in 2014 (15?). Wow, that was a blast from the past Just downloaded, unzipped, untarred, configured, made and installed python 3.2.3 ... it's YEARS since I've done this, makes me feel young again. Lispka -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2012-07-17 09:16 -0500 |
| Message-ID | <mailman.2223.1342534983.4697.python-list@python.org> |
| In reply to | #25502 |
On 7/17/2012 9:01 AM, Lipska the Kat wrote: > Wow, that was a blast from the past > Just downloaded, unzipped, untarred, configured, made and installed > python 3.2.3 ... it's YEARS since I've done this, makes me feel young again. Most Linux distributions should have a premade package for stable Python versions - apt-get install python3 or something like that. Python 2 is generally the default Python because of all the system scripts that haven't been ported to py3k. -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 15:26 +0100 |
| Message-ID | <FNKdnUnrKqSb65jNnZ2dnUVZ8vGdnZ2d@bt.com> |
| In reply to | #25504 |
On 17/07/12 15:16, Andrew Berg wrote: > On 7/17/2012 9:01 AM, Lipska the Kat wrote: >> Wow, that was a blast from the past >> Just downloaded, unzipped, untarred, configured, made and installed >> python 3.2.3 ... it's YEARS since I've done this, makes me feel young again. > Most Linux distributions should have a premade package for stable Python > versions - apt-get install python3 or something like that. Not as much fun though is it :-) Lipska -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2012-07-17 13:30 -0400 |
| Message-ID | <mailman.2230.1342546262.4697.python-list@python.org> |
| In reply to | #25502 |
On 7/17/2012 10:16 AM, Andrew Berg wrote: > On 7/17/2012 9:01 AM, Lipska the Kat wrote: >> Wow, that was a blast from the past >> Just downloaded, unzipped, untarred, configured, made and installed >> python 3.2.3 ... it's YEARS since I've done this, makes me feel young again. > Most Linux distributions should have a premade package for stable Python > versions - apt-get install python3 or something like that. I am just curious: how long will it take 'most Linux distributions' to premake the even better 3.3.0 (after it comes out) and change the default python3 to that? Do any of them have a premade 3.3.0b0 available? (In some ways, it is already better than 3.2.3.) -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2012-07-17 12:57 -0500 |
| Message-ID | <mailman.2236.1342547849.4697.python-list@python.org> |
| In reply to | #25502 |
On 7/17/2012 12:30 PM, Terry Reedy wrote: > (In some ways, it is already better than 3.2.3.) I certainly make heavy use of some of the new features. I'm not sure we can have enough separate exceptions for OS errors without exhausting every possibility and I might start looking for excuses to use the lzma module. :P -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Date | 2012-07-17 14:18 +0200 |
| Message-ID | <cp1gd9-iu3.ln1@satorlaser.homedns.org> |
| In reply to | #25484 |
Am 17.07.2012 13:01, schrieb Lipska the Kat: > On 17/07/12 10:30, Ulrich Eckhardt wrote: >> Am 17.07.2012 10:45, schrieb Lipska the Kat: >>> I was expecting (hoping) to see in depth documentation relating to Class >>> construction, extension mechanisms and runtime polymorphism. >> >> In addition to this forum for direct help and discussion, two >> suggestions: Firstly, it could help if you mentioned what programming >> languages you are fluent in > > For the past 9 years I have been developing in Java [...] Java is usually called an OOP language, because everything you do there is put into a class. Free functions don't exist, the closest you get is class-static functions (correct me if I'm wrong, I'm not really fluent in that language). In Python, you have the choice to use OOP, but you can also use free functions or mix those. > I'm not used to using variables without declaring their type As a C++ programmer (roughly 80%C++, 15%Python, 5%C) I know that feeling. Having types declared in advance just helps by having the compiler check if the passed arguments are correct. Not having this gives both freedom but also bears dangers. > what's this obsession with 'correct' indentation of code ??? You'll get used to it and then start loving it. ;) Uli
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-07-17 14:29 +0100 |
| Message-ID | <mailman.2220.1342531691.4697.python-list@python.org> |
| In reply to | #25484 |
On 17/07/2012 12:01, Lipska the Kat wrote: > > Anyway, I'm looking at Python as a rapid prototyping language. > > Lipska > One of the huge advantages of Python here is that you can simply blast stuff into the interactive prompt and see what happens, no need to write a script. -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-07-17 09:52 -0400 |
| Message-ID | <roy-29E9DF.09525917072012@news.panix.com> |
| In reply to | #25484 |
In article <-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com>,
Lipska the Kat <lipska@lipskathekat.com> wrote:
> I'm not used to using variables without declaring their type
If you truly wanted to recreate this type-bondage style of programming
in Python, it's easy enough to do.
Where you would write in C++:
// Type matching will get checked at compile-time
void my_function(MassivelyParallelFrobinator& mpf, OtherThing& ot) {
blah, blah, blah
}
you could write in Python:
# Type matching will get checked at run-time
def my_function(mpf, ot):
assert isinstance(mpf, MassivelyParallelFrobinator)
assert isinstance(ot, OtherThing)
but that's just not the way people write code in Python.
[toc] | [prev] | [next] | [standalone]
| From | Lipska the Kat <lipska@lipskathekat.com> |
|---|---|
| Date | 2012-07-17 15:23 +0100 |
| Message-ID | <FNKdnU7rKqT46JjNnZ2dnUVZ8vGdnZ2d@bt.com> |
| In reply to | #25500 |
On 17/07/12 14:52, Roy Smith wrote: > In article<-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com>, > Lipska the Kat<lipska@lipskathekat.com> wrote: > >> I'm not used to using variables without declaring their type > > If you truly wanted to recreate this type-bondage style of programming > in Python, it's easy enough to do. snip Well 'type-bondage' is a strange way of thinking about compile time type checking and making code easier to read (and therefor debug) but I'm not about to get into some religious war about declaring a variables type. I'll just say that I prefer to devote testing efforts to the real danger area which in my experience is 'user' input. Clients look dimly on runtime errors however they occur and if I can leave it to the compiler to check as much as possible then I'll take that. I do understand however that compiling an intepreted language doesn't really make sense however i'm sure there are interpreted languages that allow pre-execution type checking ... aren't there ? Oh yes, there's one called Java :-) Still, I'm sure you're only kidding around with me :-) Lipska -- Lipska the Kat: Troll hunter, Sandbox destroyer and Farscape dreamer of Aeryn Sun.
[toc] | [prev] | [next] | [standalone]
Page 1 of 6 [1] 2 3 4 5 6 Next page →
Back to top | Article view | comp.lang.python
csiph-web