Re: [Tutor] Nested loop of I/O tasks

2009-11-24 Thread Dave Angel
Bo Li wrote: Dear Python I am new to Python and having questions about its usage. Currently I have to read two .csv files INCT and INMRI which are similar to this INCT NONAME 121.57 34.71 14.81 1.35 0 0 1 Cella 129.25 100.31 27.25 1.35 1 1 1 Chiasm 130.3 98.49 26.05 1.35 1 1 1 FMagnu

Re: [Tutor] Nested loop of I/O tasks

2009-11-24 Thread wesley chun
On Tue, Nov 24, 2009 at 2:42 PM, Bo Li wrote: > > I am new to Python and having questions about its usage. Currently I have to > read two .csv files INCT and INMRI which are similar to this: > [...] > I was a MATLAB user and am really confused by what happens with me. I wish > someone could help

Re: [Tutor] Nested loop of I/O tasks

2009-11-24 Thread Christian Witts
Bo Li wrote: Dear Python I am new to Python and having questions about its usage. Currently I have to read two .csv files INCT and INMRI which are similar to this INCT NONAME 121.57 34.71 14.81 1.350 0 1 Cella 129.25 100.31 27.25 1.351 1 1 Chiasm 1

Re: [Tutor] the art of testing

2009-11-24 Thread Nick
As well as the other replies, consider that you are doing "unit" testing: http://en.wikipedia.org/wiki/Unit_test One method is black-box testing, which is where the thing (class, function, module) you are testing is treated as a black box, something that takes input and returns output, and how i

Re: [Tutor] the art of testing

2009-11-24 Thread Dave Angel
Serdar Tumgoren wrote: That's a good start. You're missing one requirement that I think needs to be explicit. Presumably you're requiring that the XML be well-formed. This refers to things like matching and nodes, and proper use of quotes and escaping within strings. Most DOM parsers won

[Tutor] Nested loop of I/O tasks

2009-11-24 Thread Bo Li
Dear Python I am new to Python and having questions about its usage. Currently I have to read two .csv files INCT and INMRI which are similar to this INCT NONAME 121.57 34.71 14.81 1.35 0 0 1 Cella 129.25 100.31 27.25 1.35 1 1 1 Chiasm 130.3 98.49 26.05 1.35 1 1 1 FMagnum 114.89 144.94 -

Re: [Tutor] the art of testing

2009-11-24 Thread Alan Gauld
"Serdar Tumgoren" wrote Simple enough in theory, but the problem I'm hitting is where to begin with tests on data that is ALL over the place. I've just spent the last 2 days in a workshop with >30 of our company's end to end test team. These guys are professional testers, all they do is tes

[Tutor] How to get new messages from maildir?

2009-11-24 Thread chombee
I'm using the standard mailbox module to read a maildir, but it seems to be quite difficult to do some simple things. Is there any way to identify a message as new, unread, unseen or something similar? What about finding the most recent message? My aim is to write a program that will print out

Re: [Tutor] Alternatives to get IP address of a computer : which one should I use ?

2009-11-24 Thread Eike Welk
On Tuesday 24 November 2009, Shashwat Anand wrote: On my openSuse 11.0 machine your method doesn't work as intended: e...@lixie:~> python Python 2.5.2 (r252:60911, Dec 1 2008, 18:10:01) [GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on linux2 Type "help", "copyright", "credi

Re: [Tutor] the art of testing

2009-11-24 Thread spir
Serdar Tumgoren wrote: > Lie and Kent, > > Thanks for the quick replies. > > I've started writing some "requirements", and combined with your > advice, am starting to feel a bit more confident on how to approach > this project. > > Below is an excerpt of my requirements -- basically what I've

Re: [Tutor] Difficulty with csv files - line breaks

2009-11-24 Thread Albert Sweigart
Tim, I've checked your code and it seems to work as far as using newlines for the line terminator. The default line terminator is \r\n, which might not show up correctly in some text editors. Otherwise, try checking to see if you've specified a blank line for the line terminator. You can set it e

Re: [Tutor] the art of testing

2009-11-24 Thread Serdar Tumgoren
> That's a good start.  You're missing one requirement that I think needs to > be explicit.  Presumably you're requiring that the XML be well-formed.  This > refers to things like matching  and nodes, and proper use of > quotes and escaping within strings.  Most DOM parsers won't even give you a

Re: [Tutor] the art of testing

2009-11-24 Thread Serdar Tumgoren
> I'm not really sure where you are going with this? This looks like a > data specification, but you said the data is poorly specified and not > under your control. So is this a specification of a data validator? > The short answer -- yes, these are specs for a data validator. And I should have be

Re: [Tutor] the art of testing

2009-11-24 Thread Dave Angel
Serdar Tumgoren wrote: Lie and Kent, Thanks for the quick replies. I've started writing some "requirements", and combined with your advice, am starting to feel a bit more confident on how to approach this project. Below is an excerpt of my requirements -- basically what I've learned from revie

Re: [Tutor] the art of testing

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 3:41 PM, Serdar Tumgoren wrote: > I've started writing some "requirements", and combined with your > advice, am starting to feel a bit more confident on how to approach > this project. > > Below is an excerpt of my requirements -- basically what I've learned > from reviewi

[Tutor] Difficulty with csv files - line breaks

2009-11-24 Thread Tim Goddard
What I'm trying to do is store a bunch of information into a .csv file. Each row will contain a date, webpage, etc of a job application. My difficulty is that it seems something I am doing is not recording the line breaks. I've read that \r\n are default in the csv module but so far I can not se

Re: [Tutor] Class understanding

2009-11-24 Thread Dave Angel
Che M wrote: Date: Tue, 24 Nov 2009 10:27:05 -0600 From: jammer10...@gmail.com To: tutor@python.org Subject: [Tutor] Class understanding Hi all... Have been attempting to understand classes... Been getting along without them for a while now and feel it's time to jump in What I want t

Re: [Tutor] the art of testing

2009-11-24 Thread Serdar Tumgoren
Lie and Kent, Thanks for the quick replies. I've started writing some "requirements", and combined with your advice, am starting to feel a bit more confident on how to approach this project. Below is an excerpt of my requirements -- basically what I've learned from reviewing the raw data using E

Re: [Tutor] the art of testing

2009-11-24 Thread Lie Ryan
Serdar Tumgoren wrote: Hi everyone, The list recently discussed the virtues of unit testing, and I was hoping someone could offer some high-level advice and further resources as I try to apply the TDD methodology. TDD is different from data validation. TDD ensures program correctness. Data val

Re: [Tutor] the art of testing

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 2:02 PM, Serdar Tumgoren wrote: > Hi everyone, > The list recently discussed the virtues of unit testing, and I was > hoping someone could offer some high-level advice and further > resources as I try to apply the TDD methodology. > > I'm trying to develop an application th

Re: [Tutor] (no subject)

2009-11-24 Thread Alan Gauld
"OkaMthembo" wrote When i started off i had pretty much the same questions. I think you need to start with the Python tutorial as it will show you the basics Unfortunately it won't if the OP is a complete beginner - and from his email it sounds like he is. The standard tutorial assumes qui

[Tutor] the art of testing

2009-11-24 Thread Serdar Tumgoren
Hi everyone, The list recently discussed the virtues of unit testing, and I was hoping someone could offer some high-level advice and further resources as I try to apply the TDD methodology. I'm trying to develop an application that regularly downloads some government data (in XML), parses the dat

Re: [Tutor] Class understanding

2009-11-24 Thread Che M
> Date: Tue, 24 Nov 2009 10:27:05 -0600 > From: jammer10...@gmail.com > To: tutor@python.org > Subject: [Tutor] Class understanding > > Hi all... Have been attempting to understand classes... Been getting > along without them for a while now and feel it's time to jump in > > What I want to

Re: [Tutor] Sorting Data in Databases

2009-11-24 Thread Che M
> That is a surprise to me. I did not know that Python would work with SQLite. Sure, as someone else said, Python comes with a LOT of libraries built right in when you download Python. This is known as "batteries included", that is, what comes with the standard distribution of Python. >

Re: [Tutor] Is pydoc the right API docs?

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 11:43 AM, Rich Lovely wrote: > 11/24 Kent Johnson : >> pydoc just shows the docstrings. It does not include the full text of >> the documentation. For that see >> http://python.org/doc/ > Although, iirc the online docs are generated by pydoc. No, they are created with Sp

Re: [Tutor] Is pydoc the right API docs?

2009-11-24 Thread Rich Lovely
11/24 Kent Johnson : > On Tue, Nov 24, 2009 at 5:06 AM, Nick > wrote: >> I'm not sure I'm using pydoc correctly.  I only seem to get abbreviated >> help rather than full documentation.  It happens often enough that I think >> I'm doing something wrong. > >> I found the answer using google, but tha

[Tutor] Class understanding

2009-11-24 Thread Joe Bennett
Hi all... Have been attempting to understand classes... Been getting along without them for a while now and feel it's time to jump in What I want to do it start a log with the logging module... I have this working without classes, but want to try... Here is a snippet of the code that I am hack

Re: [Tutor] value of 'e'

2009-11-24 Thread Lie Ryan
Wayne Werner wrote: You might try writing your own factorial function that works with the decimal type and compare with the result you get from using the math library. There is no need for that, math.factorial will use python int/long object instead of the platform's integer as necessary.

Re: [Tutor] value of 'e'

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 7:01 AM, Wayne Werner wrote: > Well, upon inspection it seems that "The math module consists mostly of thin > wrappers around the platform C math library functions" - one would presume > those are accurate, but I don't know to how many places. You might try > writing your

Re: [Tutor] Is pydoc the right API docs?

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 5:06 AM, Nick wrote: > I'm not sure I'm using pydoc correctly.  I only seem to get abbreviated > help rather than full documentation.  It happens often enough that I think > I'm doing something wrong. > I found the answer using google, but that won't work if I'm offline.  

Re: [Tutor] value of 'e'

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 7:19 AM, Lie Ryan wrote: > Shashwat Anand wrote: >> >> How can it be done ? > import decimal, math D = decimal.Decimal decimal.getcontext().prec = 100 sum(D(1) / D(math.factorial(i)) for i in range(1000)) > Decimal('2.718281828459045235360287471352662497

Re: [Tutor] value of 'e'

2009-11-24 Thread Kent Johnson
On Tue, Nov 24, 2009 at 6:47 AM, Shashwat Anand wrote: > Followed by this discussion on Hacker News I checked this link and was > wondering how to calculate value of 'e' to a large extent > > as e = 1/0! + 1/1! +1/2! and so on... > so i wrote this: sum(1.0 / math.factorial(i) for i in ra

Re: [Tutor] value of 'e'

2009-11-24 Thread Lie Ryan
Shashwat Anand wrote: How can it be done ? >>> import decimal, math >>> D = decimal.Decimal >>> decimal.getcontext().prec = 100 >>> sum(D(1) / D(math.factorial(i)) for i in range(1000)) Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076 6303535475945713821785251664

[Tutor] Is pydoc the right API docs?

2009-11-24 Thread Nick
I'm not sure I'm using pydoc correctly. I only seem to get abbreviated help rather than full documentation. It happens often enough that I think I'm doing something wrong. For example, I want to upgrade my scripts to use .format() from using %. $ pydoc format Help on built-in function f

Re: [Tutor] value of 'e'

2009-11-24 Thread Wayne Werner
On Tue, Nov 24, 2009 at 5:47 AM, Shashwat Anand wrote: > > And then i went clueless !! > How can it be done ? > Well, upon inspection it seems that "The math module consists mostly of thin wrappers around the platform C math library functions" - one would presume those are accurate, but I don't k

[Tutor] value of 'e'

2009-11-24 Thread Shashwat Anand
Followed by this discussion on Hacker NewsI checked this link and was wondering how to calculate value of 'e' to a large extent as e = 1/0! + 1/1! +1/2! and so on... so i

Re: [Tutor] Sorting Data in Databases

2009-11-24 Thread Wayne Werner
On Mon, Nov 23, 2009 at 11:26 PM, Ken G. wrote: > I am getting more and more surprised of what Python can do. Very > comprehensive. It's a much safer bet to assume that Python can do ( http://xkcd.com/353/ ) anything ( http://xkcd.com/413/ ). You just have to install the

[Tutor] Alternatives to get IP address of a computer : which one should I use ?

2009-11-24 Thread Shashwat Anand
I was going through a python scrip woof ( http://www.home.unix-ag.org/simon/woof ) and there was a portion of the code dedicated to get IP address def find_ip (): if sys.platform == "cygwin": ipcfg = os.popen("ipconfig").readlines() for l in ipcfg: try: candidat

Re: [Tutor] understanding the behavious of parameter 'key' in sort

2009-11-24 Thread Shashwat Anand
it was a bit tricky, thanks :) On Tue, Nov 24, 2009 at 9:00 AM, Lie Ryan wrote: > Shashwat Anand wrote: > >> I intended to sort a list which sorts according to user-defined custom >> sorting-order. >> For example: If sorting-order is "zabc...wxy", then the output will be in >> lexicographically