Re: newbie question re classes and self

2017-03-29 Thread Rick Johnson
On Tuesday, March 28, 2017 at 3:09:45 AM UTC-5, loial wrote: > Can I pass self(or all its variables) to a class? > Basically, how do I make all the variables defined in self > in the calling python script available to the python class > I want to call? Your question, as presented, is difficult to

Re: newbie question re classes and self

2017-03-28 Thread Terry Reedy
On 3/28/2017 4:09 AM, loial wrote: Can I pass self(or all its variables) to a class? In Python, every argument to every function is an instance of some class. The function can access any attribute of the arguments it receives with arg.attribute. -- Terry Jan Reedy -- https://mail.python.o

Re: newbie question re classes and self

2017-03-28 Thread Peter Otten
loial wrote: > Can I pass self(or all its variables) to a class? > > Basically, how do I make all the variables defined in self in the calling > python script available to the python class I want to call? Inside a method you can access attributes of an instance as self.whatever: >>> class A: ..

newbie question re classes and self

2017-03-28 Thread loial
Can I pass self(or all its variables) to a class? Basically, how do I make all the variables defined in self in the calling python script available to the python class I want to call? -- https://mail.python.org/mailman/listinfo/python-list

Re: Classes - "delegation" question.

2014-12-25 Thread Ben Finney
Steven D'Aprano writes: > However, be warned that there are two subtly different models for > delegation. Here's the one that people seem to forget: > > http://code.activestate.com/recipes/519639-true-lieberman-style-delegation-in-python/ Very interesting! The recipe at that URL works only on P

Re: Classes - "delegation" question.

2014-12-18 Thread Steven D'Aprano
dieter wrote: > "Ivan Evstegneev" writes: >> I have a question about "delegation" coding pattern(I'm working with >> Python 3.4). > > Unlike Java, Python supports "multiple inheritance". This means > that you need "delegation" much more rarely in Python. > Python does not have much special suppo

Re: Classes - "delegation" question.

2014-12-17 Thread dieter
"Ivan Evstegneev" writes: > I have a question about "delegation" coding pattern(I'm working with Python > 3.4). Unlike Java, Python supports "multiple inheritance". This means that you need "delegation" much more rarely in Python. Python does not have much special support for delegation: usually,

RE: Classes - converting external function to class's method.

2014-12-15 Thread Ivan Evstegneev
t; From: Python-list [mailto:python-list- > bounces+webmailgroups=gmail@python.org] On Behalf Of Steven > D'Aprano > Sent: Monday, December 15, 2014 04:01 > To: python-list@python.org > Subject: Re: Classes - converting external function to class's method. > > Thomas 'Poi

Re: Classes - converting external function to class's method.

2014-12-14 Thread Steven D'Aprano
Thomas 'PointedEars' Lahn wrote: > Ivan Evstegneev wrote: > >> I have stuck a bit with this example(took this one from the book). >> >> Here are a description steps of what I've done till now: >> >> >> Step 1 - creating an empty namespace: >> >class rec: pass > > IMHO that is not actual

Re: Classes - converting external function to class's method.

2014-12-14 Thread Thomas 'PointedEars' Lahn
Terry Reedy wrote: > On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: >> Ivan Evstegneev wrote: >>> I have stuck a bit with this example(took this one from the book). >>> >>> Here are a description steps of what I've done till now: >>> >>> Step 1 - creating an empty namespace: >>> >> cl

Re: Classes - converting external function to class's method.

2014-12-14 Thread Terry Reedy
On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: Ivan Evstegneev wrote: I have stuck a bit with this example(took this one from the book). Here are a description steps of what I've done till now: Step 1 - creating an empty namespace: class rec: pass IMHO that is not actually creat

Re: Classes - converting external function to class's method.

2014-12-14 Thread Thomas 'PointedEars' Lahn
Ivan Evstegneev wrote: > I have stuck a bit with this example(took this one from the book). > > Here are a description steps of what I've done till now: > > > Step 1 - creating an empty namespace: > class rec: pass IMHO that is not actually creating a namespace; it is just declaring/def

RE: Classes - converting external function to class's method.

2014-12-14 Thread Ivan Evstegneev
7;Bob' > age = 40 > def method(obj): > return obj.name.upper() Moreover, regard to the "rec.method = uppername" As I can understand, in this case Python does make some changes to the function, but they are implicit. Am I right? Sincerely, Ivan >

Re: Classes - converting external function to class's method.

2014-12-14 Thread Steven D'Aprano
Ivan Evstegneev wrote: > Hello Everyone, > > I have stuck a bit with this example(took this one from the book). The example you are working on (adding external functions as methods) is actually a bit more complicated than it seems, as you have discovered. You have this: class rec: pass rec.name

Re: Classes

2014-11-03 Thread Gregory Ewing
Jean-Michel Pichavant wrote: Python uses the descriptor protocol which is basically getters and setters. It's is just hidden by a strange decorator syntax. This is about the interface, not the implementation. "Getters and setters" in this context means designing the API of your class to have th

Re: Classes

2014-11-03 Thread Gregory Ewing
Denis McMahon wrote: On Mon, 03 Nov 2014 06:29:39 +, Dan Sommers wrote: What's the difference between a Diamond and a Rhombus? Oops, I was thinking a rhombus was a general parallelogram, my mistake. Some diamonds are neither rhombuses nor parallelograms: http://minecraft.gamepedia.co

Re: Classes

2014-11-03 Thread Denis McMahon
On Mon, 03 Nov 2014 06:29:39 +, Dan Sommers wrote: > On Mon, 03 Nov 2014 03:12:32 +, Denis McMahon wrote: > >> Quadrilateral >> Parallelogram >> Square Rectangle Rhombus Diamond (4 sides eq) >> Trapezoid >> Arrowhead > > What's the difference between a Diamond and

Re: Classes

2014-11-03 Thread Greg Ewing
Jean-Michel Pichavant wrote: I agree with Steven on that one, while getters/setters are not the preferred way, they are not utterly wrong. I'm not saying that they're wrong in general, only that they're wrong for *Python*. This matters, because the course in question is purportedly teaching P

Re: Classes

2014-11-03 Thread Chris Angelico
On Tue, Nov 4, 2014 at 12:50 AM, Dennis Lee Bieber wrote: > On Mon, 3 Nov 2014 03:12:32 + (UTC), Denis McMahon > declaimed the following: > >>So: >> >>Quadrilateral >>Parallelogram >>Square >>Rectangle >>Rhombus >>Diamond (4 sides eq) >>Trapezoid >>

Re: Classes

2014-11-03 Thread Ian Kelly
On Nov 2, 2014 5:31 AM, "Denis McMahon" wrote: > And perhaps that also addresses the square - rectangle (or circle - > ellipse) issue - square, rectangle and rhombus are all forms of > quadrilateral, and perhaps should all inherit a base class Quadrilateral, > rather than trying (and partially fai

Re: Classes

2014-11-03 Thread Jean-Michel Pichavant
- Original Message - > From: "Gregory Ewing" > Steven D'Aprano wrote: > > Like all good Pythonistas[1], we hate Java and think that > > getter/setter > > methods are pointless. But come on, they're not *wrong*, > > What's wrong is the statement that getters and setters > are necessary to

Re: Classes

2014-11-02 Thread Dan Sommers
On Mon, 03 Nov 2014 03:12:32 +, Denis McMahon wrote: > Quadrilateral > Parallelogram > Square > Rectangle > Rhombus > Diamond (4 sides eq) > Trapezoid > Arrowhead What's the difference between a Diamond and a Rhombus? > Is an arrowhead a trapez

Re: Classes

2014-11-02 Thread Denis McMahon
On Sun, 02 Nov 2014 11:31:12 -0500, Dennis Lee Bieber wrote: > On Sun, 2 Nov 2014 12:27:06 + (UTC), Denis McMahon > declaimed the following: > >>On Sun, 02 Nov 2014 21:32:13 +1100, Tim Delaney wrote: >>> If course, that's probably because rectangles have a multitude of uses >>> for user int

Re: Classes

2014-11-02 Thread Larry Hudson
On 11/02/2014 01:50 AM, Denis McMahon wrote: [snip] from math import sqrt class SquareGeometryError(Exception): """The parameters create an illegal geometry for a square""" pass class Rectangle: def __init__(self,length,width): self.length=length self.width=wid

Re: Classes

2014-11-02 Thread Denis McMahon
On Sun, 02 Nov 2014 21:32:13 +1100, Tim Delaney wrote: > On 2 November 2014 20:50, Denis McMahon > wrote: > >> The question (I thought) was to write a class for Square that inherited >> a class Rectangle but imposed on it the additional constraints of a >> square over a rectangle, namely that le

Re: Classes

2014-11-02 Thread Gregory Ewing
Steven D'Aprano wrote: Like all good Pythonistas[1], we hate Java and think that getter/setter methods are pointless. But come on, they're not *wrong*, What's wrong is the statement that getters and setters are necessary to allow the implementation to change without changing the interface. That

Re: Classes

2014-11-02 Thread Tim Delaney
On 2 November 2014 20:50, Denis McMahon wrote: > > The question (I thought) was to write a class for Square that inherited a > class Rectangle but imposed on it the additional constraints of a square > over a rectangle, namely that length == width. > I'm late to the party and this has already be

Re: Classes

2014-11-02 Thread Denis McMahon
On Sat, 01 Nov 2014 12:42:10 -0400, Seymore4Head wrote: > OK Maybe I misunderstood the question. > > My answer to you then is ..I don't know. I will have to think about > it some more. The question (I thought) was to write a class for Square that inherited a class Rectangle but imposed on

Re: Classes

2014-11-01 Thread Seymore4Head
On Sat, 01 Nov 2014 12:00:46 -0400, Dennis Lee Bieber wrote: >On Fri, 31 Oct 2014 19:32:13 -0400, Seymore4Head > declaimed the following: > >> >>class Rectangle(object): >>def __init__(self, length, width=None): >>self.length = length >>if width is None: >>self.wid

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 5:12 PM, Ian Kelly wrote: > On Fri, Oct 31, 2014 at 7:06 PM, Steven D'Aprano > wrote: >> And there are times when using getters and setters is the right choice. >> Properties should only be used for quite lightweight calculations, because >> attribute access is supposed to

Re: Classes

2014-10-31 Thread Ian Kelly
On Fri, Oct 31, 2014 at 7:06 PM, Steven D'Aprano wrote: > And there are times when using getters and setters is the right choice. > Properties should only be used for quite lightweight calculations, because > attribute access is supposed to be fast. If your calculation is complex, > time-consuming

Re: Classes

2014-10-31 Thread Steven D'Aprano
Gregory Ewing wrote: > Seymore4Head wrote: >> The course is free. You can't beat the price. It is only for a few >> more weeks. > > But if it's teaching you things that are blatantly wrong > in relation to Python, it may be doing more harm than > good. Like all good Pythonistas[1], we hate Jav

Re: Classes

2014-10-31 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > What you are being taught is NOT PYTHON. Of course it is. It uses Python syntax, Python terminology, and the Python compiler. It might not be the preferred Python idiom or best practice, but it's still Python code. Exaggeration does not help anyone, it just makes us lo

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 19:22:13 -0400, Seymore4Head wrote: >On Fri, 31 Oct 2014 18:57:31 -0400, Dennis Lee Bieber > wrote: > >>On Fri, 31 Oct 2014 14:18:44 -0400, Seymore4Head >> declaimed the following: >> >>>On Fri, 31 Oct 2014 10:43:19 -0700, Rob Gaddi >>> wrote: >>> >>> Define a Square class

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 18:57:31 -0400, Dennis Lee Bieber wrote: >On Fri, 31 Oct 2014 14:18:44 -0400, Seymore4Head > declaimed the following: > >>On Fri, 31 Oct 2014 10:43:19 -0700, Rob Gaddi >> wrote: >> >> >>>Define a Square class, subclassed from Rectangle. Use getters/setters >>>to enforce that

Re: Classes

2014-10-31 Thread Gregory Ewing
Seymore4Head wrote: The course is free. You can't beat the price. It is only for a few more weeks. But if it's teaching you things that are blatantly wrong in relation to Python, it may be doing more harm than good. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 8:40 AM, Rob Gaddi wrote: > For this specific exercise, a Square is a subclass of Rectangle because > the point of Rectangle is to demonstrate that extraneous get/set > functions are completely unnecessary in Python. The point of > Square is to demonstrate that get/set func

Re: Classes

2014-10-31 Thread Rob Gaddi
On Fri, 31 Oct 2014 14:24:11 -0700 (PDT) sohcahto...@gmail.com wrote: > On Friday, October 31, 2014 1:51:23 PM UTC-7, Chris Angelico wrote: > > On Sat, Nov 1, 2014 at 4:43 AM, Rob Gaddi > > wrote: > > > Define a Square class, subclassed from Rectangle. Use getters/setters > > > to enforce that t

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 8:24 AM, wrote: > I've never heard of the Circle-Ellipse problem, and my first instinct to > Rob's post was to ask, why would you want to sub-class Rectangle into a > Square class? A square is just a special case of a Rectangle. Attempting > that kind of sub-classing w

Re: Classes

2014-10-31 Thread sohcahtoa82
On Friday, October 31, 2014 1:51:23 PM UTC-7, Chris Angelico wrote: > On Sat, Nov 1, 2014 at 4:43 AM, Rob Gaddi > wrote: > > Define a Square class, subclassed from Rectangle. Use getters/setters > > to enforce that the length and width must be equal. Confirm that > > length and width remain lock

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 4:43 AM, Rob Gaddi wrote: > Define a Square class, subclassed from Rectangle. Use getters/setters > to enforce that the length and width must be equal. Confirm that > length and width remain locked, and that perimeter() and area() work > correctly. Here we go again... ht

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 14:41:08 -0400, Joel Goldstick wrote: >On Fri, Oct 31, 2014 at 2:31 PM, ast wrote: >> >> "Seymore4Head" a écrit dans le message de >> news:rbf75ah9l1jp9e72gqr0ncu7bau8cnt...@4ax.com... >> >>> What material have you used to take you up to classes? >> >> >> It's a french class

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 14:18:44 -0400, Seymore4Head wrote: >On Fri, 31 Oct 2014 10:43:19 -0700, Rob Gaddi > wrote: > > >>Define a Square class, subclassed from Rectangle. Use getters/setters >>to enforce that the length and width must be equal. Confirm that >>length and width remain locked, and th

Re: Classes

2014-10-31 Thread Joel Goldstick
On Fri, Oct 31, 2014 at 2:31 PM, ast wrote: > > "Seymore4Head" a écrit dans le message de > news:rbf75ah9l1jp9e72gqr0ncu7bau8cnt...@4ax.com... > >> What material have you used to take you up to classes? > > > It's a french classroom on the web > http://openclassrooms.com/courses/apprenez-a-progra

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 19:31:01 +0100, "ast" wrote: > >"Seymore4Head" a écrit dans le message de >news:rbf75ah9l1jp9e72gqr0ncu7bau8cnt...@4ax.com... > >> What material have you used to take you up to classes? > >It's a french classroom on the web >http://openclassrooms.com/courses/apprenez-a-progr

Re: Classes

2014-10-31 Thread ast
"Seymore4Head" a écrit dans le message de news:rbf75ah9l1jp9e72gqr0ncu7bau8cnt...@4ax.com... What material have you used to take you up to classes? It's a french classroom on the web http://openclassrooms.com/courses/apprenez-a-programmer-en-python -- https://mail.python.org/mailman/lis

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 10:43:19 -0700, Rob Gaddi wrote: >Define a Square class, subclassed from Rectangle. Use getters/setters >to enforce that the length and width must be equal. Confirm that >length and width remain locked, and that perimeter() and area() work >correctly. class Rectangle:

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 12:39:34 -0500, Zachary Ware wrote: >On Fri, Oct 31, 2014 at 12:31 PM, Seymore4Head > wrote: >> I run across this page frequently. To me, this is examples. While >> examples can be quite useful, I don't call this a tutorial. I have >> found the answer to my question by sear

Re: Classes

2014-10-31 Thread Rob Gaddi
On Fri, 31 Oct 2014 13:18:00 -0400 Seymore4Head wrote: > On Sat, 01 Nov 2014 04:06:44 +1100, Steven D'Aprano > wrote: > > >Seymore4Head wrote: > > > >> Because the topic of that lesson was getter setter. > >> I can construct an __init___ but I was practicing get/set. > > > >What lesson is that

Re: Classes

2014-10-31 Thread Grant Edwards
On 2014-10-31, Seymore4Head wrote: > On Sat, 01 Nov 2014 04:06:44 +1100, Steven D'Aprano >>Let's make the class a bit easier to use, at the expense of doing a bit more >>work up front: >> >>class MyClass: >>def __init__(self, value, message): >>self.value = value >>self.messag

Re: Classes

2014-10-31 Thread Grant Edwards
On 2014-10-31, Seymore4Head wrote: > On Fri, 31 Oct 2014 15:49:43 + (UTC), Grant Edwards > wrote: > >>On 2014-10-31, Ian Kelly wrote: >>> On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head >>> wrote: Because the topic of that lesson was getter setter. I can construct an __init___ but I

Re: Classes

2014-10-31 Thread Rob Gaddi
On Fri, 31 Oct 2014 13:31:44 -0400 Seymore4Head wrote: > On Sat, 1 Nov 2014 04:02:33 +1100, Chris Angelico > wrote: > > >On Sat, Nov 1, 2014 at 3:47 AM, Seymore4Head > > wrote: > >> inbuilt tutorial? > >> > >> The course is free. You can't beat the price. It is only for a few > >> more weeks.

Re: Classes

2014-10-31 Thread Zachary Ware
On Fri, Oct 31, 2014 at 12:31 PM, Seymore4Head wrote: > I run across this page frequently. To me, this is examples. While > examples can be quite useful, I don't call this a tutorial. I have > found the answer to my question by searching this page several times, > but the biggest problem with t

Re: Classes

2014-10-31 Thread Marko Rauhamaa
Seymore4Head : > In this class, we will follow the practice of accessing the contents > of objects using methods known as getters and setters. The biggest problem in this OO disease is that it makes you think of objects as data containers instead of dynamic agents. An object is defined through i

Re: Classes

2014-10-31 Thread Seymore4Head
On Sat, 1 Nov 2014 04:02:33 +1100, Chris Angelico wrote: >On Sat, Nov 1, 2014 at 3:47 AM, Seymore4Head > wrote: >> inbuilt tutorial? >> >> The course is free. You can't beat the price. It is only for a few >> more weeks. >> >> Trying to learn from reading the Internet has no set direction. I >

Re: Classes

2014-10-31 Thread Seymore4Head
On Sat, 01 Nov 2014 04:06:44 +1100, Steven D'Aprano wrote: >Seymore4Head wrote: > >> Because the topic of that lesson was getter setter. >> I can construct an __init___ but I was practicing get/set. > >What lesson is that? Using getters/setters is discouraged in Python. > >> This stuff is coming

Re: Classes

2014-10-31 Thread Dave Angel
On 10/31/2014 12:31 PM, Seymore4Head wrote: In this class, we will follow the practice of accessing the contents of objects using methods known as getters and setters. While not required by Python, this practice encourages the user of the class to manipulates class objects solely via class metho

Re: Classes

2014-10-31 Thread Steven D'Aprano
Seymore4Head wrote: > Because the topic of that lesson was getter setter. > I can construct an __init___ but I was practicing get/set. What lesson is that? Using getters/setters is discouraged in Python. > This stuff is coming to me slowly. I need to rinse and repeat quite a > few more times,

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 3:47 AM, Seymore4Head wrote: > inbuilt tutorial? > > The course is free. You can't beat the price. It is only for a few > more weeks. > > Trying to learn from reading the Internet has no set direction. I > need a little nudge. More like a shove. https://docs.python.org/

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 10:05:03 +0100, "ast" wrote: > >"Seymore4Head" a écrit dans le message de >news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com... >> class pet: >>def set_age(self,age): >>self.age=age >>def get_age(self): >>return self.age >> pax=pet >> pax.set_age(4) >>

Re: Classes

2014-10-31 Thread Seymore4Head
On Sat, 1 Nov 2014 03:37:29 +1100, Chris Angelico wrote: >On Sat, Nov 1, 2014 at 3:31 AM, Seymore4Head > wrote: >[presumably quoting his course material] >> In this class, we will follow the practice of accessing the contents >> of objects using methods known as getters and setters. While not >>

Re: Classes

2014-10-31 Thread Chris Angelico
On Sat, Nov 1, 2014 at 3:31 AM, Seymore4Head wrote: [presumably quoting his course material] > In this class, we will follow the practice of accessing the contents > of objects using methods known as getters and setters. While not > required by Python, this practice encourages the user of the clas

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 15:49:43 + (UTC), Grant Edwards wrote: >On 2014-10-31, Ian Kelly wrote: >> On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head >> wrote: >>> Because the topic of that lesson was getter setter. >>> I can construct an __init___ but I was practicing get/set. >> >> Doesn't sound l

Re: Classes

2014-10-31 Thread Grant Edwards
On 2014-10-31, Ian Kelly wrote: > On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head > wrote: >> Because the topic of that lesson was getter setter. >> I can construct an __init___ but I was practicing get/set. > > Doesn't sound like a very good lesson to me. It's not. It's teaching java or C++ or s

Re: Classes

2014-10-31 Thread Ian Kelly
On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head wrote: > Because the topic of that lesson was getter setter. > I can construct an __init___ but I was practicing get/set. Doesn't sound like a very good lesson to me. Getters and setters are the Java way of doing things. The Pythonic way is to just u

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 09:59:30 GMT, alister wrote: >On Thu, 30 Oct 2014 17:34:57 -0400, Seymore4Head wrote: > >> On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson >> wrote: >> >>>On 10/30/2014 01:16 PM, Seymore4Head wrote: class pet: def set_age(self,age): self.age=age

Re: Classes

2014-10-31 Thread Mark Lawrence
On 31/10/2014 09:05, ast wrote: "Seymore4Head" a écrit dans le message de news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com... class pet: def set_age(self,age): self.age=age def get_age(self): return self.age pax=pet pax.set_age(4) Traceback (most recent call last): File "C

Re: Classes

2014-10-31 Thread Seymore4Head
On Fri, 31 Oct 2014 10:05:03 +0100, "ast" wrote: > >"Seymore4Head" a écrit dans le message de >news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com... >> class pet: >>def set_age(self,age): >>self.age=age >>def get_age(self): >>return self.age >> pax=pet >> pax.set_age(4) >>

Re: Classes

2014-10-31 Thread alister
On Thu, 30 Oct 2014 17:34:57 -0400, Seymore4Head wrote: > On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson > wrote: > >>On 10/30/2014 01:16 PM, Seymore4Head wrote: >>> class pet: >>> def set_age(self,age): >>> self.age=age >>> def get_age(self): >>> return self.age >>

Re: Classes

2014-10-31 Thread Chris Angelico
On Fri, Oct 31, 2014 at 8:18 PM, ast wrote: > > But this means that a method can create a new > attribute not previously created with __init__. > Is that correct ? That's always the case. There's nothing special about __init__ for creating attributes. ChrisA -- https://mail.python.org/mailman/l

Re: Classes

2014-10-31 Thread ast
"ast" a écrit dans le message de news:545350c3$0$23449$426a7...@news.free.fr... I am a beginner too, but I find it strange that your pet class has no __init__ method to construct instances It works anyway because __init__ is taken in the parent Class, probably Object. But this means that a

Re: Classes

2014-10-31 Thread ast
"Seymore4Head" a écrit dans le message de news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com... class pet: def set_age(self,age): self.age=age def get_age(self): return self.age pax=pet pax.set_age(4) Traceback (most recent call last): File "C:\Functions\test.py", line 18, i

Re: Classes

2014-10-30 Thread sohcahtoa82
On Thursday, October 30, 2014 2:37:54 PM UTC-7, Seymore4Head wrote: > On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson > wrote: > > >On 10/30/2014 01:16 PM, Seymore4Head wrote: > >> class pet: > >> def set_age(self,age): > >> self.age=age > >> def get_age(self): > >> r

Re: Classes

2014-10-30 Thread Seymore4Head
On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson wrote: >On 10/30/2014 01:16 PM, Seymore4Head wrote: >> class pet: >> def set_age(self,age): >> self.age=age >> def get_age(self): >> return self.age >> pax=pet >> pax.set_age(4) >> >> Traceback (most recent call last): >

Re: Classes

2014-10-30 Thread Larry Hudson
On 10/30/2014 01:16 PM, Seymore4Head wrote: class pet: def set_age(self,age): self.age=age def get_age(self): return self.age pax=pet pax.set_age(4) Traceback (most recent call last): File "C:\Functions\test.py", line 18, in pax.set_age(4) TypeError: set_age(

Re: Classes

2014-10-30 Thread Seymore4Head
On Thu, 30 Oct 2014 13:34:04 -0700, Rob Gaddi wrote: >On Thu, 30 Oct 2014 16:16:51 -0400 >Seymore4Head wrote: > >> class pet: >> def set_age(self,age): >> self.age=age >> def get_age(self): >> return self.age >> pax=pet >> pax.set_age(4) >> >> Traceback (most recent cal

Re: Classes

2014-10-30 Thread Seymore4Head
On Thu, 30 Oct 2014 13:33:01 -0700 (PDT), sohcahto...@gmail.com wrote: >On Thursday, October 30, 2014 1:19:57 PM UTC-7, Seymore4Head wrote: >> class pet: >> def set_age(self,age): >> self.age=age >> def get_age(self): >> return self.age >> pax=pet >> pax.set_age(4) >> >>

Re: Classes

2014-10-30 Thread sohcahtoa82
On Thursday, October 30, 2014 1:19:57 PM UTC-7, Seymore4Head wrote: > class pet: > def set_age(self,age): > self.age=age > def get_age(self): > return self.age > pax=pet > pax.set_age(4) > > Traceback (most recent call last): > File "C:\Functions\test.py", line 18, in >

Re: Classes

2014-10-30 Thread Rob Gaddi
On Thu, 30 Oct 2014 16:16:51 -0400 Seymore4Head wrote: > class pet: > def set_age(self,age): > self.age=age > def get_age(self): > return self.age > pax=pet > pax.set_age(4) > > Traceback (most recent call last): > File "C:\Functions\test.py", line 18, in > pax.se

Re: Classes and the command line

2014-10-27 Thread Chris Angelico
On Tue, Oct 28, 2014 at 3:08 PM, Terry Reedy wrote: >> It's inconsistent only because the default sys.ps2 is those dots, >> which aren't necessary in Idle. You could make it consistent by simply >> changing sys.ps2. > > > Nope. User code is executed in the user process. Its only effect on the >

Re: Classes and the command line

2014-10-27 Thread Terry Reedy
On 10/26/2014 11:28 PM, Seymore4Head wrote: I am going to be flexible on IDLE in the near future, but I wanted to try it the old fashion way. I already know using IDLE is better, but I am not sure using IDLE will invoke Python 2 and I am not sure how to change that at the moment. Currently, I

Re: Classes and the command line

2014-10-27 Thread Terry Reedy
On 10/26/2014 11:24 PM, Chris Angelico wrote: On Mon, Oct 27, 2014 at 2:18 PM, Rustom Mody wrote: On Monday, October 27, 2014 8:40:48 AM UTC+5:30, Chris Angelico wrote: You can get block-by-block history by using Idle. I find that fairly convenient for manipulating class/function definitions

Re: Classes and the command line

2014-10-27 Thread Seymore4Head
On Sun, 26 Oct 2014 23:32:08 -0400, Seymore4Head wrote: >On Mon, 27 Oct 2014 14:06:11 +1100, Ben Finney > wrote: > >>Seymore4Head 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

Re: Classes and the command line

2014-10-27 Thread Chris Angelico
On Mon, Oct 27, 2014 at 10:17 PM, alister wrote: > Notepad+ is also often suggested along with many other programmer editors/ > Integrated development environments (IDE). That would be Notepad++, and yes, it's fairly well recommended. It's based on the same edit component as SciTE, another good e

Re: Classes and the command line

2014-10-27 Thread alister
On Sun, 26 Oct 2014 23:32:08 -0400, Seymore4Head wrote: > On Mon, 27 Oct 2014 14:06:11 +1100, Ben Finney > wrote: > >>Seymore4Head 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”, o

Re: Classes and the command line

2014-10-27 Thread Jean-Michel Pichavant
- Original Message - > From: "Seymore4Head" > To: python-list@python.org > Sent: Monday, 27 October, 2014 3:27:18 AM > Subject: Classes and the command line > > I am trying to learn classes. > I am currently using Python 2.7 at the command line. > If you try to type commands at the comman

Re: Classes and the command line

2014-10-26 Thread Seymore4Head
On Mon, 27 Oct 2014 14:10:01 +1100, Chris Angelico wrote: >On Mon, Oct 27, 2014 at 2:06 PM, Ben Finney wrote: >> 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 sa

Re: Classes and the command line

2014-10-26 Thread Seymore4Head
On Mon, 27 Oct 2014 14:06:11 +1100, Ben Finney wrote: >Seymore4Head 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

Re: Classes and the command line

2014-10-26 Thread Rustom Mody
On Monday, October 27, 2014 8:48:52 AM UTC+5:30, Rustom Mody wrote: > On Monday, October 27, 2014 8:40:48 AM UTC+5:30, Chris Angelico wrote: > > On Mon, Oct 27, 2014 at 2:06 PM, Ben Finney wrote: > > > Right. There is line-by-line history, and editing enabled with the > > > "readline" plug-in. (Th

Re: Classes and the command line

2014-10-26 Thread Seymore4Head
Your message showed up as unavailable on my server I have to cut and paste Google Groups to reply. (I am going to change news servers probably tomorrow to try to fix that) So the quoting is going to be bad. Why not idle? And if in general you are at python 3, why 2.7 here? There are enough

Re: Classes and the command line

2014-10-26 Thread Chris Angelico
On Mon, Oct 27, 2014 at 2:18 PM, Rustom Mody wrote: > On Monday, October 27, 2014 8:40:48 AM UTC+5:30, Chris Angelico wrote: >> On Mon, Oct 27, 2014 at 2:06 PM, Ben Finney wrote: >> > Right. There is line-by-line history, and editing enabled with the >> > "readline" plug-in. (This is an advantage

Re: Classes and the command line

2014-10-26 Thread Rustom Mody
On Monday, October 27, 2014 8:40:48 AM UTC+5:30, Chris Angelico wrote: > On Mon, Oct 27, 2014 at 2:06 PM, Ben Finney wrote: > > 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, whic

Re: Classes and the command line

2014-10-26 Thread Chris Angelico
On Mon, Oct 27, 2014 at 2:06 PM, Ben Finney wrote: > 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.) You can get block-by-block history by using Idle.

Re: Classes and the command line

2014-10-26 Thread Rustom Mody
On Monday, October 27, 2014 8:00:04 AM UTC+5:30, Seymore4Head wrote: > I am trying to learn classes. > I am currently using Python 2.7 at the command line. Why not idle? And if in general you are at python 3, why 2.7 here? There are enough factor to learn ( and get confused)! Please dont add new o

Re: Classes and the command line

2014-10-26 Thread Ben Finney
Seymore4Head 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 unavoid

Re: classes and sub classes?

2013-04-15 Thread Neil Cerutti
On 2013-04-15, Peter Otten <__pete...@web.de> wrote: > Jason Friedman wrote: >>> NwInvDb = NetworkInventoryDatabase, yes you are correct, it >>> creates the database handle and makes it ready for use. >> >> I am interested in opinions. I for one dislike abbreviations >> on the theory that program

Re: classes and sub classes?

2013-04-15 Thread Peter Otten
Jason Friedman wrote: >> NwInvDb = NetworkInventoryDatabase, yes you are correct, it creates the > database handle and makes it ready for use. > > I am interested in opinions. I for one dislike abbreviations on the > theory > that programs are read more than they are written. I would probably u

Re: classes and sub classes?

2013-04-14 Thread MRAB
On 15/04/2013 02:38, Jason Friedman wrote: > NwInvDb = NetworkInventoryDatabase, yes you are correct, it creates the database handle and makes it ready for use. I am interested in opinions. I for one dislike abbreviations on the theory that programs are read more than they are written. I woul

Re: classes and sub classes?

2013-04-14 Thread Jason Friedman
> NwInvDb = NetworkInventoryDatabase, yes you are correct, it creates the database handle and makes it ready for use. I am interested in opinions. I for one dislike abbreviations on the theory that programs are read more than they are written. I would probably use this variable name: network_in

Re: classes and sub classes?

2013-04-09 Thread Robert Kern
On 2013-04-09 11:20, Morten Guldager wrote: 'Aloha Friends! I'm about to write an API against a huge propitiatory Oracle based network inventory database. The database have many different concepts stored in it's tables, can one concept can span over multiple tables. I would like to write a clas

  1   2   3   >