Re: [Tutor] Time frame for Py 3 Maturity

2013-04-21 Thread Alan Gauld

On 21/04/13 03:10, Jim Mooney wrote:


This is why we tend to recommend 2.7 for anyone doing serious work in
Python.


Understood. I am in no rush, but what do you think it the time frame
when Py 3 will be mature?


As Steven has already pointed out Python 3 itself is mature.
The problem is that many of the key 3rd party libraries have not
been ported yet or the ports are not stable. (Many others have
been so it depends what you need.)

But one of the problems in OpenSource is that the developments
are all done by volunteers. There is no central corporate
program of work to drive the porting process or set its priority
level. It just depends on what each project team sees as its
priority - adding features to the existing code, fixing bugs, or porting 
to Python3 (and thereafter maintaining 2 codebases...).


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Py 3 package maturity - good links

2013-04-21 Thread Jim Mooney
> On the other hand, from the perspective of "When will the *majority* of
> publicly-available libraries and packages support Python 3, then the answer
> is "Right now". The Python 3 Wall of Shame turned mostly green some time
> ago,
> and is now known as the Python 3 Wall of Superpowers:
>
> https://python3wos.appspot.com/
>
> Based on the number of downloads, almost three quarters of the Top 50
> Python
> packages support Python 3:
>
> http://py3ksupport.appspot.com/
>

Thanks. Very useful links to save that would have taken time for me to find
on my own.

As for "syllabus," probably a dream for a dynamic language ;')  I was
thinking of the time my brother, a Lit grad, gave me a syllabus of
literature to read - still working on it forty years later.

Jim
*
*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Py 3 package maturity - good links

2013-04-21 Thread Dave Angel

On 04/21/2013 12:24 PM, Jim Mooney wrote:

On the other hand, from the perspective of "When will the *majority* of
publicly-available libraries and packages support Python 3, then the answer
is "Right now". The Python 3 Wall of Shame turned mostly green some time
ago,
and is now known as the Python 3 Wall of Superpowers:

https://python3wos.appspot.com/

Based on the number of downloads, almost three quarters of the Top 50
Python
packages support Python 3:

http://py3ksupport.appspot.com/



Thanks. Very useful links to save that would have taken time for me to find
on my own.

As for "syllabus," probably a dream for a dynamic language ;')  I was
thinking of the time my brother, a Lit grad, gave me a syllabus of
literature to read - still working on it forty years later.




http://pymotw.com/2/
This could be one way to learn about new (to you) Python modules in 
a systematic way.


On the other hand, if you're looking for a syllabus of studying 
languages (plural), consider

   1) a dynamic language
   2) a compile one
   3) an assembler
   4) other(lisp, Forth, ML, Prolog, ...)

Each category is enough different that you have to learn all new habits. 
 But knowing each one is valuable when using the other three types.





--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Testing a method in a class with nosetests

2013-04-21 Thread Alex Baker
Hello,
I've been lurking tutor for the last couple months and have quite enjoyed it!

I'm having a problem testing a method using nosetests. The assignment (Learn 
Python the Hard Way) asks that I write tests for a package using assert_equal 
and assert_raises. I've conquered the assert_equals but I'm having issues with 
assert_raises. I can't figure out how am I supposed to test a method in a class 
with an __init__. I understand the assert_raises works assert_raises("ERROR", 
callable, parameters), and the parameters get sent to nosetests, but because of 
the __init__ I have no parameters to send.


# main module code
class ParserError(Exception):
    pass

class Parser(object):

    def __init__(self, word_list):
        self.word_list = word_list

    def parse_object(self):
        skip(self.word_list, 'stop')
        next = peek(self.word_list)

        if next == 'noun':
            return match(self.word_list, 'noun')
        if next == 'direction':
            return match(self.word_list, 'direction')
        else:
            raise ParserError("Expected a noun or direction next.")

# test code
from nose.tools import *
from ex48 import parser
from ex48 import lexicon

def _test_words(input):    
    words = lexicon.scan(input)
    test = parser.Parser(words)
    return test

def test_parse_object():    
    assert_equal(_test_words("the bear").parse_object(), 
                ('noun', 'bear'))
    assert_equal(_test_words("the the  princess").parse_object(),
                ('noun', 'princess'))
    assert_equal(_test_words("the nortH").parse_object(), 
                ('direction', 'north'))
    assert_raises("ParserError", _test_words("will fail"))

# nosetests output
ERROR: tests.parser_tests.test_parse_object
--
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/robotsmack/hack/python_projects/ex48/tests/parser_tests.py", 
line 17, in test_parse_object
    assert_raises("ParserError", _test_words("will fail"))
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py",
 line 456, in assertRaises
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py",
 line 113, in __exit__
TypeError: issubclass() arg 2 must be a class or tuple of classes

Obviously a bunch a code was snipped, but I don't think its relevant to my 
question. But just in case, I'm currently fumbling my way through putting up 
the whole package on GitHub.

Thanks in advance!
_Alex



 From: "tutor-requ...@python.org" 
To: tutor@python.org 
Sent: Sunday, April 21, 2013 4:00 AM
Subject: Tutor Digest, Vol 110, Issue 86
 

Send Tutor mailing list submissions to
    tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
    tutor-requ...@python.org

You can reach the person managing the list at
    tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Time frame for Py 3 Maturity (Jim Mooney)
   2. Re: Time frame for Py 3 Maturity (Steven D'Aprano)
   3. Re: 3to2? (Steven D'Aprano)
   4. Re: Time frame for Py 3 Maturity (Alan Gauld)


--

Message: 1
Date: Sat, 20 Apr 2013 19:10:23 -0700
From: Jim Mooney 
To: tutor@python.org
Subject: [Tutor] Time frame for Py 3 Maturity
Message-ID:
    
Content-Type: text/plain; charset="iso-8859-1"

> This is why we tend to recommend 2.7 for anyone doing serious work in
> Python.
>

Understood. I am in no rush, but what do you think it the time frame when
Py 3 will be mature? A year from now? Two years? At some point I might want
to use it more practically. Or maybe there will be huge inflation, I'll go
broke, and have to use it more practically ;')

Also, is there a good syllabus for the best way to progress in this
language? One can certainly get sidetracked.

-- 
*Jim Mooney

Today is the day that would have been tomorrow if yesterday was today
*
-- next part --
An HTML attachment was scrubbed...
URL: 


--

Message: 2
Date: Sun, 21 Apr 2013 14:02:36 +1000
From: Steven D'Aprano 
To: tutor@python.org
Subject: Re: [Tutor] Time frame for Py 3 Maturity
Message-ID: <517364dc.3080...@pearwood.info>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 21/04/13 12:10, Jim Mooney wrote:
>> This is why we tend to recommend 2.7 for anyone doing serious work in
>> Python.
>>
>
> Understood. I am in no rush, but what do you think it the time frame when
> Py 3 will be mature? A year from now

Re: [Tutor] Testing a method in a class with nosetests (Alex Baker)

2013-04-21 Thread Alex Baker
Dang, forgot to send in plain text! Sorry... 

Here is the GitHub link http://github.com/robotsmack/ex48



 From: "tutor-requ...@python.org" 
To: tutor@python.org 
Sent: Sunday, April 21, 2013 6:51 PM
Subject: Tutor Digest, Vol 110, Issue 87
 

Send Tutor mailing list submissions to
    tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
    tutor-requ...@python.org

You can reach the person managing the list at
    tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Py 3 package maturity - good links (Jim Mooney)
   2. Re: Py 3 package maturity - good links (Dave Angel)
   3. Testing a method in a class with nosetests (Alex Baker)


--

Message: 1
Date: Sun, 21 Apr 2013 09:24:06 -0700
From: Jim Mooney 
To: tutor@python.org
Subject: [Tutor] Py 3 package maturity - good links
Message-ID:
    
Content-Type: text/plain; charset="iso-8859-1"

> On the other hand, from the perspective of "When will the *majority* of
> publicly-available libraries and packages support Python 3, then the answer
> is "Right now". The Python 3 Wall of Shame turned mostly green some time
> ago,
> and is now known as the Python 3 Wall of Superpowers:
>
> https://python3wos.appspot.com/
>
> Based on the number of downloads, almost three quarters of the Top 50
> Python
> packages support Python 3:
>
> http://py3ksupport.appspot.com/
>

Thanks. Very useful links to save that would have taken time for me to find
on my own.

As for "syllabus," probably a dream for a dynamic language ;')  I was
thinking of the time my brother, a Lit grad, gave me a syllabus of
literature to read - still working on it forty years later.

Jim
*
*
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://mail.python.org/pipermail/tutor/attachments/20130421/f1a36fa0/attachment-0001.html>

--

Message: 2
Date: Sun, 21 Apr 2013 16:05:42 -0400
From: Dave Angel 
To: tutor@python.org
Subject: Re: [Tutor] Py 3 package maturity - good links
Message-ID: <51744696.2090...@davea.name>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 04/21/2013 12:24 PM, Jim Mooney wrote:
>> On the other hand, from the perspective of "When will the *majority* of
>> publicly-available libraries and packages support Python 3, then the answer
>> is "Right now". The Python 3 Wall of Shame turned mostly green some time
>> ago,
>> and is now known as the Python 3 Wall of Superpowers:
>>
>> https://python3wos.appspot.com/
>>
>> Based on the number of downloads, almost three quarters of the Top 50
>> Python
>> packages support Python 3:
>>
>> http://py3ksupport.appspot.com/
>>
>
> Thanks. Very useful links to save that would have taken time for me to find
> on my own.
>
> As for "syllabus," probably a dream for a dynamic language ;')  I was
> thinking of the time my brother, a Lit grad, gave me a syllabus of
> literature to read - still working on it forty years later.
>
>
>
http://pymotw.com/2/
     This could be one way to learn about new (to you) Python modules in 
a systematic way.

On the other hand, if you're looking for a syllabus of studying 
languages (plural), consider
    1) a dynamic language
    2) a compile one
    3) an assembler
    4) other    (lisp, Forth, ML, Prolog, ...)

Each category is enough different that you have to learn all new habits. 
  But knowing each one is valuable when using the other three types.




-- 
DaveA


--

Message: 3
Date: Sun, 21 Apr 2013 17:49:09 -0700 (PDT)
From: Alex Baker 
To: "tutor@python.org" 
Subject: [Tutor] Testing a method in a class with nosetests
Message-ID:
    <1366591749.43705.yahoomail...@web120205.mail.ne1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello,
I've been lurking tutor for the last couple months and have quite enjoyed it!

I'm having a problem testing a method using nosetests. The assignment (Learn 
Python the Hard Way) asks that I write tests for a package using assert_equal 
and assert_raises. I've?conquered the assert_equals but I'm having issues with 
assert_raises. I can't figure out how am I supposed to test a method in a class 
with an __init__. I understand the assert_raises works assert_raises("ERROR", 
callable, parameters), and the parameters get sent to nosetests, but because of 
the __init__ I have no parameters to send.


# 

Re: [Tutor] Testing a method in a class with nosetests

2013-04-21 Thread Steven D'Aprano

On 22/04/13 10:49, Alex Baker wrote:

Hello,
I've been lurking tutor for the last couple months and have quite enjoyed it!



Welcome, and congratulations on your first post! Unfortunately I have to start 
with a complaint :-( but it's NOT because you failed to post plain text, since 
you actually did.

When starting a new thread, please create a new, blank email, don't reply to an 
existing email. Especially not when that email is a digest containing four 
complete emails completely unrelated to your post! The end result is that at 
the bottom of your post is a copy of a complete digest, nearly 200 lines worth 
of unrelated, irrelevant stuff. (And we're lucky it was only 200 lines, during 
a busy week, digests could potentially be thousands of lines!) And then you 
compounded it by replying to the first email, and so ended up with those 200 
lines quoted TWICE.



I'm having a problem testing a method using nosetests. The assignment (Learn Python the 
Hard Way) asks that I write tests for a package using assert_equal and assert_raises. 
I've conquered the assert_equals but I'm having issues with assert_raises. I can't figure 
out how am I supposed to test a method in a class with an __init__. I understand the 
assert_raises works assert_raises("ERROR", callable, parameters), and the 
parameters get sent to nosetests, but because of the __init__ I have no parameters to 
send.



Unfortunately, I'm not familiar with nose, and so I'm guessing, but I would say 
replace this call:


assert_raises("ParserError", _test_words("will fail"))

with this:

assert_raises("ParserError", _test_words, "will fail")

or possibly this:

assert_raises("ParserError", _test_words, ["will fail"])



I expect that the first version fails because the call to _test_words() 
function raises an exception before nose gets to handle it. This is why 
assert_raises takes a function argument, followed by its argument.




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] is there an explicit eof to test in Py 3?

2013-04-21 Thread Jim Mooney
  I'm reading a book that suggests finding EOF when the readLine == ""

 But wouldn't that end erroneously on blank lines, that really contain
'\n', in which case more lines might follow? What 'empties' are
considered equal in Python? I'm coming from javascript which has a
cluster of rules for that.

Yes, I know the easy way is a for loop, which automatically breaks on
eof, but at times I want to use a while loop and break out of it
explicitly on eof. But I can't seem to find an explicit eof marker in
python. Is there one?

--
Jim Mooney

Today is the day that would have been tomorrow if yesterday was today
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] multiple versions of python on windows?

2013-04-21 Thread Jim Mooney
My plan for starting on Py 3 may need some adjustment. I doiwnloaded
an irc client that needs Py 2.6 and I think Plone wants 2.7.

Is it possible to install multiple versions of python on the same
machine or will windows choke?

-- 
Jim Mooney

Today is the day that would have been tomorrow if yesterday was today
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] is there an explicit eof to test in Py 3?

2013-04-21 Thread Dave Angel

On 04/21/2013 09:35 PM, Jim Mooney wrote:

   I'm reading a book that suggests finding EOF when the readLine == ""

  But wouldn't that end erroneously on blank lines, that really contain
'\n', in which case more lines might follow? What 'empties' are
considered equal in Python? I'm coming from javascript which has a
cluster of rules for that.

Yes, I know the easy way is a for loop, which automatically breaks on
eof, but at times I want to use a while loop and break out of it
explicitly on eof. But I can't seem to find an explicit eof marker in
python. Is there one?



A little experimenting could have told you the answer.  readline() 
returns a newline character for a blank line, and an empty string for 
end of file.





--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] is there an explicit eof to test in Py 3?

2013-04-21 Thread eryksun
On Sun, Apr 21, 2013 at 9:35 PM, Jim Mooney  wrote:
> I'm reading a book that suggests finding EOF when the readLine == ""
>
>  But wouldn't that end erroneously on blank lines, that really contain
> '\n', in which case more lines might follow? What 'empties' are
> considered equal in Python? I'm coming from javascript which has a
> cluster of rules for that.

The newline (os.linesep) isn't stripped, though depending on the
"newline" option for open() it may be translated.

You shouldn't be testing equality. You know that reading from a file
returns either bytes or a string, so just rely on the boolean value.
Any type that implements __len_ (collections.abc.Sized) has an
implicit boolean value:

http://docs.python.org/3/reference/datamodel.html#object.__bool__

For example:

while True:
line = file.readline()
if not line:
break
process(line)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multiple versions of python on windows?

2013-04-21 Thread eryksun
On Sun, Apr 21, 2013 at 10:50 PM, Jim Mooney  wrote:
> My plan for starting on Py 3 may need some adjustment. I doiwnloaded
> an irc client that needs Py 2.6 and I think Plone wants 2.7.
>
> Is it possible to install multiple versions of python on the same
> machine or will windows choke?

Installing multiple versions is fine. Just disable the option to
update file type associations. When you installed Python 3, .py files
were associated with py.exe. This allows you to use a shebang to run a
script with a specific interpreter. Or in the console you can run a
specific version like this:

C:\>py -2.5 -c "import __hello__"  &:: -c runs a command
Hello world...
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multiple versions of python on windows?

2013-04-21 Thread Jim Mooney
On 21 April 2013 22:47, School  wrote:
> You can install multiple versions. The programs use the version they were 
> assigned to, so there shouldn't be any conflict.

This brings up the question of installing multiple versions of Wing
101 IDE. I forget the install but even if I can install in a different
directory for Py 2.7, Windows awful Registry might trip me up. I've
grown to love portables since they bypass Windows Worst Idea, but Wing
isn't one of them.

If anyone knows, does the paid version of wing allow to switch between
multipe installs? I know, this is probably a Wing discuss question,
but I'm burned out on joining discussion groups to ask one question,
since otherwise Wing is very easy to grasp.

-- 
Jim Mooney

Today is the day that would have been tomorrow if yesterday was today
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Testing a method in a class with nosetests

2013-04-21 Thread eryksun
On Sun, Apr 21, 2013 at 9:33 PM, Steven D'Aprano  wrote:
>
> it's NOT because you failed to post plain text, since you actually did.

Actually it's a multipart message with both plain text and HTML, with
the digest quoted in each version. It helps that the HTML is using
" " and  that map directly to "=A0" and "=0A". The  and
 tags are used for color and font styling, rather than layout.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor