Re: [Tutor] Unit testing: Just the API or internal use only methods, too?

2019-07-16 Thread Mats Wichmann
On 7/16/19 4:41 PM, boB Stepp wrote: > Peter Otten, while responding to one of my questions in the past, > mentioned something in passing that apparently has been mulling around > in the back of my head. I don't recall his exact words, but he > essentially said that I should be testing the public

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Cameron Simpson
On 16Jul2019 23:49, Alan Gauld wrote: On 16/07/2019 22:56, Mats Wichmann wrote: thrown. This gets watered down to the mantra "Don't throw exceptions from within constructors." Does this carry over to Python? If you mean __init__, that's not a constructor, so you should set your mind at res

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Steven D'Aprano
On Tue, Jul 16, 2019 at 04:29:15PM -0500, James Hartley wrote: > I ask this having more C++ knowledge than sense. > > There is an adage in the halls of everything Stroustrup that one needs to > think about how resource allocation will be unwound if an exception is > thrown. This gets watered down

Re: [Tutor] Unit testing: Just the API or internal use only methods, too?

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 23:41, boB Stepp wrote: > essentially said that I should be testing the public interface to my > classes, but not the methods only used internally by the class and not > meant to be publicly accessible. I suspect he meant that you should publish the tests for the API but not neces

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 22:56, Mats Wichmann wrote: >> thrown. This gets watered down to the mantra "Don't throw exceptions from >> within constructors." Does this carry over to Python? > > If you mean __init__, that's not a constructor, so you should set your > mind at rest :) It's more properly an

[Tutor] Unit testing: Just the API or internal use only methods, too?

2019-07-16 Thread boB Stepp
Peter Otten, while responding to one of my questions in the past, mentioned something in passing that apparently has been mulling around in the back of my head. I don't recall his exact words, but he essentially said that I should be testing the public interface to my classes, but not the methods

[Tutor] How would I replace the data of a Pandas Series with the values of a dictionary?

2019-07-16 Thread Daniel Bosah
Hi all, I have a problem trying to match items in a dict and pandas series in Python. I have a dict ( called city_dict )of cities and city_id's ; for each city ( which is a key in the dict ), a unique city_id is a value in that dict. So for example, city_dict = { New York : 1001, LA : 1002, Chic

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Mats Wichmann
On 7/16/19 3:29 PM, James Hartley wrote: > I ask this having more C++ knowledge than sense. > > There is an adage in the halls of everything Stroustrup that one needs to > think about how resource allocation will be unwound if an exception is > thrown. This gets watered down to the mantra "Don't

[Tutor] raising exceptions in constructor code?

2019-07-16 Thread James Hartley
I ask this having more C++ knowledge than sense. There is an adage in the halls of everything Stroustrup that one needs to think about how resource allocation will be unwound if an exception is thrown. This gets watered down to the mantra "Don't throw exceptions from within constructors." Does t

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-16 Thread Peter Otten
Chip Wachob wrote: > I tried it anyhow, with this being an example of my source data: > > "Record Length",202,"Points",-0.005640001706,1.6363 > "Sample Interval",5e-09,s,-0.005639996706,1.65291 > "Trigger Point",1128000,"Samples",-0.005639991706,1.65291 > "Trigger Time",0.341197,s,-0.00563998

Re: [Tutor] Object references in Python

2019-07-16 Thread Mats Wichmann
On 7/16/19 2:33 PM, Steven D'Aprano wrote: > x = Parrot() > > Now x is a reference to a Parrot instance. y remains a reference to the > list. > > x.colour is a reference to the string "blue" (by default). > > x.speak is a reference to the "speak" method of Parrot objects. > > > > Does this

Re: [Tutor] Object references in Python

2019-07-16 Thread Steven D'Aprano
On Tue, Jul 16, 2019 at 12:08:10PM +, AHIA Samuel wrote: > Please what are references in Python development? x = 19 y = x The name "x" is a reference to the int 19; the name y is a reference to the same int. x = "Hello world" Now the name "x" is a reference to the string "Hello world". y

Re: [Tutor] Impersonation

2019-07-16 Thread Jim
On 7/15/19 9:36 PM, Jim wrote: Mats, Hopefully you recognize my email address as someone you have given advice concerning Python. Over the last month or so I have received at least 3 emails supposedly coming from you that I am sure you did not send. The from line is:  Mats Wichmann The b

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-16 Thread David Rock
> On Jul 16, 2019, at 04:31, Alan Gauld via Tutor wrote: > > On 16/07/2019 09:59, Oscar Benjamin wrote: > >>> All true, but sed - once you get used to it! - is easier IMHO >>> and usually faster than Python - it's written in C... >> >> I always think I'll like sed but whenever I actually try t

[Tutor] Object references in Python

2019-07-16 Thread AHIA Samuel
Please what are references in Python development? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 09:59, Oscar Benjamin wrote: >> All true, but sed - once you get used to it! - is easier IMHO >> and usually faster than Python - it's written in C... > > I always think I'll like sed but whenever I actually try to use it I > just can't get the syntax together. Id been using awk

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-16 Thread Oscar Benjamin
On Tue, 16 Jul 2019 at 01:44, Alan Gauld via Tutor wrote: > > On 15/07/2019 21:28, Mats Wichmann wrote: > > > course Python can do that too, by working line-at-a-time, explicitly by > > calling readlines() or implicitly by looping over the file handle. The > > latter looks something like this; > >