Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Alan Gauld
On 23/01/16 04:14, boB Stepp wrote: > humdrum.sigh_strenght = 'high' > > was accepted and did not generate an error, it seemed to mean to me > that I was violating my object's data encapsulation. In fact you were adding to its encapsulation(*). Encapsulation means putting things in a box. You

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
On 23Jan2016 01:52, boB Stepp wrote: On Fri, Jan 22, 2016 at 11:04 PM, Cameron Simpson wrote: On 22Jan2016 22:14, boB Stepp wrote: All you're missing is realising that setting an attribute is not a special operation. I guess no matter how new one is to OOP, one nevertheless brings one's pre

Re: [Tutor] mock

2016-01-23 Thread Peter Otten
Alex Kleider wrote: > Some weeks (perhaps months) ago, I posted a question about testing > and got many responses but had trouble grasping the concepts > so I settled on the suggestion that I thought would be the easiest > to implement (using unittest.mock.) Here it is- > > """ > from Peter Otten

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Danny Yoo
> But if I am understanding everyone's comments correctly, Python allows > me write my classes in such a way, that public access to my object's > internals is controlled, in the sense that Python has coding > conventions that tell all of the quite intelligent, respectful, > consenting adults that m

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread boB Stepp
On Sat, Jan 23, 2016 at 3:30 AM, Cameron Simpson wrote: > On 23Jan2016 01:52, boB Stepp wrote: >> I guess no matter how new one is to OOP, one nevertheless brings one's >> preconceptions, however malformed, into the learning process. In my >> case, one of mine was that once a class is coded, a

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread boB Stepp
On Sat, Jan 23, 2016 at 12:07 PM, Danny Yoo wrote: > But Python has very little of this as a built-in part of the language. > Guarding who gets to touch something is instead done by convention and > by a very thin mechanism of name-mangling via an uncommonly-seen > character, the underscore "_".

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread boB Stepp
On Sat, Jan 23, 2016 at 12:55 PM, boB Stepp wrote: > I still would like to do this via a method, but I am currently stuck > on how to replace ??? with the attribute name I would like to insert: > > class Dog(object): > ... > > def add_attribute(self, attribute_name, attribute_value): >

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
On 23Jan2016 12:55, boB Stepp wrote: On Sat, Jan 23, 2016 at 3:30 AM, Cameron Simpson wrote: On 23Jan2016 01:52, boB Stepp wrote: I guess no matter how new one is to OOP, one nevertheless brings one's preconceptions, however malformed, into the learning process. In my case, one of mine was

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
On 23Jan2016 16:25, boB Stepp wrote: On Sat, Jan 23, 2016 at 12:55 PM, boB Stepp wrote: I still would like to do this via a method, but I am currently stuck on how to replace ??? with the attribute name I would like to insert: class Dog(object): ... def add_attribute(self, attribute_

[Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-23 Thread Ek Esawi
Hi All--- Sorry for posting again, but I have a problem that I tried several different ways to solve w/o success. I approached the problem from one angle and asked about it here; I got some good input using pandas, and structured array, but I am new to python and not very familiar with either to

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Alan Gauld
On 23/01/16 19:17, boB Stepp wrote: > "_single_leading_underscore : weak "internal use" indicator. E.g. from > M import * does not import objects whose name starts with an > underscore." > > My current understanding is to avoid "from M import *", but it is good > to know that this style of import

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Alan Gauld
On 23/01/16 09:30, Cameron Simpson wrote: > Alan will take you up on doing purer OO practices in Python. In pure OO objects should only expose methods and the data attributes should only be there to support the methods. As such, nobody outside the object has any need to know anything about it. An

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread boB Stepp
On Sat, Jan 23, 2016 at 7:20 PM, Alan Gauld wrote: > On 23/01/16 09:30, Cameron Simpson wrote: > >> Alan will take you up on doing purer OO practices in Python. > > In pure OO objects should only expose methods and the data > attributes should only be there to support the methods. > As such, nobod

[Tutor] Value of tracebacks to malicious attackers?

2016-01-23 Thread boB Stepp
>From page 202 of "Python Crash Course": "..., but it's also not a good idea to let users see tracebacks. Nontechnical users will be confused by them, and in a malicious setting, attackers will learn more than you want them to know from a traceback. For example, they'll know the name of your pro

Re: [Tutor] Value of tracebacks to malicious attackers?

2016-01-23 Thread Danny Yoo
> How much concern do you give this in designing and implementing your > production code? How far do you go in handling exceptions to ensure > that tracebacks cannot arise for a malicious user? Hi boB, We can plan ahead and develop a program to support different modes of operation . A "debug" o

Re: [Tutor] Value of tracebacks to malicious attackers?

2016-01-23 Thread boB Stepp
On Sun, Jan 24, 2016 at 12:43 AM, Danny Yoo wrote: >> How much concern do you give this in designing and implementing your >> production code? How far do you go in handling exceptions to ensure >> that tracebacks cannot arise for a malicious user? > We can plan ahead and develop a program to sup