Re: scalar vs array and program control

2015-07-26 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote: > Laura Creighton wrote: >> and to create a class where none was before to make it more object- >> oriented. > > I did not need to, but, again, it was more obvious that way. I could also > have used an existing class, and its existing or newly added method. > AI

Re: scalar vs array and program control

2015-07-26 Thread Thomas 'PointedEars' Lahn
Laura Creighton wrote: > […] "Thomas 'PointedEars' Lahn" writes: >> Laura Creighton wrote: >>> […] "Thomas 'PointedEars' Lahn" [writes]: Laura Creighton wrote: > […] You really cannot make your code 'more functional' and 'more > object-oriented' at the same time -- more in one style

Re: scalar vs array and program control

2015-07-25 Thread Steven D'Aprano
On Sat, 25 Jul 2015 02:18 pm, Seb wrote: > Hello, > > I'm fairly new to Python, struggling to write in a more object-oriented, > functional style. I just wrote a function that takes two arrays > representing sine (y) and cosine (x) angle coordinates, and returns the > angle in degrees. Alas, y

Re: scalar vs array and program control

2015-07-25 Thread Laura Creighton
In a message of Sat, 25 Jul 2015 18:53:33 +0200, "Thomas 'PointedEars' Lahn" wr ites: >Laura Creighton wrote: > >> […] "Thomas 'PointedEars' Lahn" [writes]: >>> Laura Creighton wrote: […] You really cannot make your code 'more functional' and 'more object-oriented' at the same time -- mo

Re: scalar vs array and program control

2015-07-25 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote: > # > class A: > def __init__ (self, v=0): > self._value = v > > def foo (self, f, b): > return f(f, self._value, b) I mean return f(self._value, b) -- Poin

Re: scalar vs array and program control

2015-07-25 Thread Thomas 'PointedEars' Lahn
Laura Creighton wrote: > […] "Thomas 'PointedEars' Lahn" [writes]: >> Laura Creighton wrote: >>> […] You really cannot make your code 'more functional' and 'more >>> object-oriented' at the same time -- more in one style implies less >>> in the other. >> How did you get that idea? > > Because pu

Re: scalar vs array and program control

2015-07-25 Thread Sebastian P . Luque
On Sat, 25 Jul 2015 14:44:43 +0200, Laura Creighton wrote: > And because I was rushed and posted without revision I left out > something important. >> So this is, quite likely, the pattern that you are looking for: >> try: all_your_code_which_is_happy_with_non_scalars except >> WhateverErrorPyt

Re: scalar vs array and program control

2015-07-25 Thread Peter Otten
Seb wrote: > Hello, > > I'm fairly new to Python, struggling to write in a more object-oriented, > functional style. I just wrote a function that takes two arrays > representing sine (y) and cosine (x) angle coordinates, and returns the > angle in degrees. I had initially written the function t

Re: scalar vs array and program control

2015-07-25 Thread Laura Creighton
In a message of Sat, 25 Jul 2015 14:57:14 +0200, "Thomas 'PointedEars' Lahn" wr ites: >Laura Creighton wrote: > >> […] You really cannot make your code 'more functional' and 'more object- >> oriented' at the same time -- more in one style implies less in the other. > >How did you get that idea? B

Re: scalar vs array and program control

2015-07-25 Thread Thomas 'PointedEars' Lahn
Laura Creighton wrote: > […] You really cannot make your code 'more functional' and 'more object- > oriented' at the same time -- more in one style implies less in the other. How did you get that idea? -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.

Re: scalar vs array and program control

2015-07-25 Thread Laura Creighton
And because I was rushed and posted without revision I left out something important. >So this is, quite likely, the pattern that you are looking for: > >try: > all_your_code_which_is_happy_with_non_scalars >except WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: > whatever_you_wan

Re: scalar vs array and program control

2015-07-25 Thread Chris Angelico
On Sat, Jul 25, 2015 at 9:01 PM, Laura Creighton wrote: > How did I know to look for ValueErrors? > int("1.2") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1.2' > > Cause that is what Python gives you. If it had given

Re: scalar vs array and program control

2015-07-25 Thread Laura Creighton
You have a bit of a problem, in that "functional" and "object-oriented" are two different styles of programming. You really cannot make your code 'more functional' and 'more object-oriented' at the same time -- more in one style implies less in the other. I think you may have got the mistaken ide

scalar vs array and program control

2015-07-24 Thread Seb
Hello, I'm fairly new to Python, struggling to write in a more object-oriented, functional style. I just wrote a function that takes two arrays representing sine (y) and cosine (x) angle coordinates, and returns the angle in degrees. I had initially written the function to take array-like argume