Re: [Tutor] Limitation of int() in converting strings

2013-01-03 Thread eryksun
On Tue, Jan 1, 2013 at 12:07 AM, Steven D'Aprano wrote: > > Again, I was mistaken. x%1 is not suitable to get the fraction part of a > number in Python: it returns the wrong result for negative values. You need > math.modf: > > py> x = -99.25 > py> x % 1 # want -0.25 > 0.75 > py> math.modf(x) > (

Re: [Tutor] writing effective unittests

2013-01-03 Thread Peter Otten
Steven D'Aprano wrote: > Notice that tests are not necessarily definitive. I haven't tested that > spam(n) returns a string for every imaginable integer n, because there > are too many. Instead, I just test a small, representative sample. > > Likewise I haven't tested that spam() might succeed wh

Re: [Tutor] writing effective unittests

2013-01-03 Thread Albert-Jan Roskam
> Hi, > > I am trying to learn a bit of test-driven programming using unittests and > nosetests. I am having trouble finding resources that explain how to write > effective tests. I am not a programmer or a student, so I do not have access > to > collegues or classes. I'm hoping that someon

Re: [Tutor] how to struct.pack a unicode string?

2013-01-03 Thread eryksun
On Tue, Jan 1, 2013 at 1:29 AM, Steven D'Aprano wrote: > > 2 Since "wide builds" use so much extra memory for the average ASCII > string, hardly anyone uses them. On Windows (and I think OS X, too) a narrow build has been practical since the wchar_t type is 16-bit. As to Linux I'm most familiar

Re: [Tutor] Limitation of int() in converting strings

2013-01-03 Thread Oscar Benjamin
On 2 January 2013 17:59, Alan Gauld wrote: > On 01/02/2013 11:41 AM, Steven D'Aprano wrote: > >[SNIP] >> But __index__ is a special method that converts to int without rounding >> or truncating, intended only for types that emulate ints but not other >> numeric types: > > > And this was the new bi

Re: [Tutor] how to struct.pack a unicode string?

2013-01-03 Thread Steven D'Aprano
On 03/01/13 23:52, eryksun wrote: On Tue, Jan 1, 2013 at 1:29 AM, Steven D'Aprano wrote: 2 Since "wide builds" use so much extra memory for the average ASCII string, hardly anyone uses them. On Windows (and I think OS X, too) a narrow build has been practical since the wchar_t type is 16-

[Tutor] IronPython any tutors with experience out there?

2013-01-03 Thread Bjorn Madsen
Hello PythonTutor - I'm a scientist and very happy with python 2.7. I have been asked to assist a development program where everything is written in dotNET/ C# (visual studio 2012) and luckily Microsoft Visual Studio supports IronPython which is a clean Python implementation in C#, so I can use the

Re: [Tutor] writing effective unittests

2013-01-03 Thread Luke Thomas Mergner
* Albert-Jan Roskam wrote: > > > > Hi, > > > > > I am trying to learn a bit of test-driven programming using unittests and > > nosetests. I am having trouble finding resources that explain how to write > > effective tests. I am not a programmer or a student, so I do not have > > access to

Re: [Tutor] writing effective unittests

2013-01-03 Thread Tino Dai
I think what I need is a conceptual shift: how do python programmers use > unittests? > > Here at the Library, we use unit test to test the cases that have many known inputs. For example, some of the data could come in "foo bar baz", and some others could come in as "foo, bar, baz", and others coul

[Tutor] python as poetry

2013-01-03 Thread Jared Nielsen
I don't know if it's appropriate to post things like this on the list, but I've learned a lot from this group and thought I'd share something I think you all will enjoy: http://www.thehelloworldprogram.com/videos/poetry-corner-red-wheelbarrow/ ___ Tutor m

Re: [Tutor] writing effective unittests

2013-01-03 Thread Alan Gauld
On 03/01/13 19:46, Luke Thomas Mergner wrote: What am I missing? The biggest problem is that no one is explaining the rationale behind testing. See my other reply and check out the references to programming by contract, pre/post conditions and invariants. Those are all good things to test. I

Re: [Tutor] IronPython any tutors with experience out there?

2013-01-03 Thread Prasad, Ramit
Bjorn Madsen wrote: > > Hello PythonTutor > - I'm a scientist and very happy with python 2.7. I have been asked to assist > a development program where > everything is written in dotNET/ C# (visual studio 2012) and luckily > Microsoft Visual Studio supports IronPython > which is a clean Python i

Re: [Tutor] writing effective unittests

2013-01-03 Thread Steven D'Aprano
Hi Luke, My responses inline below. On 04/01/13 06:46, Luke Thomas Mergner wrote: I am on the digest version of the list, so I haven't gotten a copy of any replies. All the more reason not to be on the digest version. But you should have received replies *in the digest*. (By the way, thank

Re: [Tutor] IronPython any tutors with experience out there?

2013-01-03 Thread Alan Gauld
On 03/01/13 18:37, Bjorn Madsen wrote: However ... to interact with the c# modules which my colleagues wrote, I need to add "clr" references. Example: import clr clr.AddReferenceToFile("Mapack.dll") from Mapack import * dir() Unfortunately I can't get it to run So does anything work? Is th

Re: [Tutor] writing effective unittests

2013-01-03 Thread Brian van den Broek
On 3 January 2013 14:46, Luke Thomas Mergner wrote: > * Albert-Jan Roskam wrote: > >> >> >> > Hi, >> >> > >> > I am trying to learn a bit of test-driven programming using unittests and >> > nosetests. I am having trouble finding resources that explain how to write >> > effective tests. I am not a