[Tutor] Tutor Digest, Vol 128, Issue 22

Henry henry at sa-hk.com
Fri Oct 10 10:32:09 CEST 2014


Hi

I am new to programming.

After I created two text files(the text file is most consist of numbers),
its class is "<class '_io.TextIOWrapper'>", how can I compare this class
with two text files?

Please give me a hint which area I should look under? Set? List?

Thanks
Henry

On Fri, Oct 10, 2014 at 12:04 PM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>         tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request at python.org
>
> You can reach the person managing the list at
>         tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>    1. Re: Renaming Files in Directory (Alan Gauld)
>    2. alternative Python 2.6 install? (Albert-Jan Roskam)
>    3. (no subject) (William Becerra)
>    4. Re: (no subject) (Joel Goldstick)
>    5. Re: (no subject) (Martin A. Brown)
>    6. Re: (no subject) (Alan Gauld)
>    7. Installing both Python 2.7 and Python 3.4 on Windows 7 Pro
>       64-bit: Install Python 2.7 FIRST! (boB Stepp)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 09 Oct 2014 12:02:34 +0100
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Renaming Files in Directory
> Message-ID: <m15q0a$7i1$1 at ger.gmane.org>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> On 09/10/14 00:58, Felisha Lawrence wrote:
> > Hello,
> > I have the following program
> >
> >
> >   import os
> >
> > path = '/Users/felishalawrence/testswps/vol1'
> > for file in os.listdir(path):
> >          newFile = path+file[:file.rindex("v")]+"v20"
> >
> >          print newFile
> >
> > and I want to output the results of the 'newFile' variable into the
> > directory specified by the 'path' variable.
>
> You want the os.rename function.
>
> Also you should use os.path.join() to create the path rather than string
> addition. It will ensure the correct separators are used
> for the OS.
>
> You might also want to look at glob.glob() rather than listdir
> to get a listing of files matching a wildcard pattern.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 9 Oct 2014 18:32:01 +0000 (UTC)
> From: Albert-Jan Roskam <fomcl at yahoo.com>
> To: Python Tutor Mailing List <tutor at python.org>
> Subject: [Tutor] alternative Python 2.6 install?
> Message-ID:
>         <
> 1529317176.81747.1412879521526.JavaMail.yahoo at jws10743.mail.gq1.yahoo.com>
>
> Content-Type: text/plain; charset=UTF-8
>
> Hi,
>
>
> I need to install Python 2.6 on my Debian system to check some code.*)
> What is the easiest way to do this? Simply "sudo apt-get install
> python2.6"? I know I can also compile it and then do make altinstall, but I
> prefer apt-get. I am kinda paranoid that I might accidentally change my
> system Python version.
>
>
>
> Thank you!
>
>
>
> Regards,
>
> Albert-Jan
>
>
> *)
>
> albertjan at debian:~$ uname -a
> Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux
> albertjan at debian:~$ python -c "import sys; print sys.version_info"
> sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> All right, but apart from the sanitation, the medicine, education, wine,
> public order, irrigation, roads, a
>
> fresh water system, and public health, what have the Romans ever done for
> us?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 9 Oct 2014 20:38:02 +0200
> From: William Becerra <wbecerra1 at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] (no subject)
> Message-ID:
>         <CAF1DC4VdVnjRNxuf5gmRseS2bEv2TLVN6Vb2Qrn=
> Tiax3CcaQQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I'm new to programming. Started reading the book 'How to think like a
> computer Scientist-learning with python'. I'm now in chapter 3 sub-chapter
> 3.4 Math functions.
>
> When I write the following code:
>
> import maths;
> decibel = math.log10 (17.0);
> angle = 1.5;
> height = math.sin(angle);
> print height;
>
> I get the following error:
>
> Traceback (most recent call last):
>   File "C:/Python27/test", line 1, in <module>
>     import maths;
> ImportError: No module named maths
>
> I don't know what I'm doing wrong?
> >From what I've read the maths module is supposed to come with the python
> installation package.
> I'm using a windows 8 operating system
> python 2.7.8
> please help?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20141009/5670d430/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 4
> Date: Thu, 9 Oct 2014 20:03:23 -0400
> From: Joel Goldstick <joel.goldstick at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] (no subject)
> Message-ID:
>         <CAPM-O+w6=
> NrkYw6uNtAYkfttot+Ot3x1taF3oa5ew0kEWYDSPw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Oct 9, 2014 8:00 PM, "William Becerra" <wbecerra1 at gmail.com> wrote:
> >
> > I'm new to programming. Started reading the book 'How to think like a
> computer Scientist-learning with python'. I'm now in chapter 3 sub-chapter
> 3.4 Math functions.
> >
> > When I write the following code:
> >
> > import maths;
> import math
>
> You added s
>
> > decibel = math.log10 (17.0);
> > angle = 1.5;
> > height = math.sin(angle);
> > print height;
> >
> > I get the following error:
> >
> > Traceback (most recent call last):
> >   File "C:/Python27/test", line 1, in <module>
> >     import maths;
> > ImportError: No module named maths
> >
> > I don't know what I'm doing wrong?
> > From what I've read the maths module is supposed to come with the python
> installation package.
> > I'm using a windows 8 operating system
> > python 2.7.8
> > please help?
> >
> >
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20141009/787fbf3e/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 5
> Date: Thu, 9 Oct 2014 17:13:51 -0700
> From: "Martin A. Brown" <martin at linux-ip.net>
> To: William Becerra <wbecerra1 at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] (no subject)
> Message-ID: <alpine.LNX.2.00.1410091704080.1349 at dagger.wonderfrog.net>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
>
> Hi there and welcome!
>
> > import maths;
> > decibel = math.log10 (17.0);
> > angle = 1.5;
> > height = math.sin(angle);
> > print height;
> >
> > Traceback (most recent call last):
> >  File "C:/Python27/test", line 1, in <module>
> >    import maths;
> > ImportError: No module named maths
>
> Oops!  It's a nice error report, though!  Python tried to locate a
> module called 'maths' and was not able to find it.
>
> What happens if you try:
>
>    import math
>
> N.B.  You say 'import maths'--assume that this import succeeded.  A
> few lines later, there's a line 'math.log10(17.0)' which seems to be
> trying to use something from a module called 'math' not 'maths'.
>
> > I don't know what I'm doing wrong?
>
> Computers are so picky.
>
> > From what I've read the maths module is supposed to come with the python
> > installation package.
>
> The 'math' library is a standard library module for quite awhile
> now.  Here's a possibly useful online link, which describes that
> module:
>
>    https://docs.python.org/2/library/math.html
>
> This is just more documentation support, in addition to the book you
> are reading.
>
> > I'm using a windows 8 operating system
> > python 2.7.8
> > please help?
>
> One other issue I might point out.  The semicolon at the end of the
> line (statement) is a feature of other programming languages with
> which you may be familiar (C, Java, Perl), but it is not necessary
> and, in fact, discouraged in Python.
>
> So, rid yourself of the semicolons and enjoy the benefits of a
> trivially cleaner syntax.
>
> Enjoy!
>
> -Martin
>
> P.S. Thanks for your clear question and letting us know your OS and
> Python version, as well.
>
> --
> Martin A. Brown
> http://linux-ip.net/
>
>
> ------------------------------
>
> Message: 6
> Date: Fri, 10 Oct 2014 01:36:25 +0100
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] (no subject)
> Message-ID: <m179m9$clv$1 at ger.gmane.org>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> On 09/10/14 19:38, William Becerra wrote:
>
> > import maths;
>
> Python, like most languages speaks American English
> so its math not maths.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> ------------------------------
>
> Message: 7
> Date: Thu, 9 Oct 2014 22:57:24 -0500
> From: boB Stepp <robertvstepp at gmail.com>
> To: tutor <tutor at python.org>
> Subject: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows
>         7 Pro 64-bit: Install Python 2.7 FIRST!
> Message-ID:
>         <
> CANDiX9LG2y7XNGLsruqjNtY7GZYN5VWEm-E2sha1o0LLqB2Xsw at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I am hoping to save other people the grief I just worked through. I
> wanted to run both Python 2 and 3 on my windows PC, and, after
> googling this topic found that with Python 3.3 or later one could
> easily do both. So I merrily installed Python 3.4.2 first and then
> Python 2.7.8. A Python 3 program that had been working fine suddenly
> stopped working. After working down to a test portion of code that
> isolated the culprit I realized my Python 3 program was being
> interpreted by Python 2. I soon found that installing Python 2 first
> and then 3 enabled both to happily coexist. If there was a mention
> about the order of installation anywhere during my searches, I missed
> it. Anyway, I hope that my experience helps some other newbie who
> wants to play around with both major versions.
>
> --
> boB
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> https://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> End of Tutor Digest, Vol 128, Issue 22
> **************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141010/0c68dc1a/attachment-0001.html>


More information about the Tutor mailing list