pip trouble

2015-10-30 Thread Neal Becker
I have a custom-compiled numpy 1.10.0.  But as you see, pip wants to install 
a new numpy, even though the requirement (numpy>=1.6) was already satisfied.  
WTF?

All are installed into --user.

This is on fedora 22 linux. 

pip install --up --user matplotlib
Collecting matplotlib
  Using cached matplotlib-1.5.0.tar.gz
Collecting numpy>=1.6 (from matplotlib)
  Using cached numpy-1.10.1.tar.gz
Requirement already up-to-date: python-dateutil in 
./.local/lib/python2.7/site-packages (from matplotlib)
Collecting pytz (from matplotlib)
  Using cached pytz-2015.7-py2.py3-none-any.whl
Collecting cycler (from matplotlib)
  Using cached cycler-0.9.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib)
  Using cached pyparsing-2.0.5-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil->matplotlib)
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: numpy, pytz, six, cycler, pyparsing, 
matplotlib
  Found existing installation: numpy 1.10.0
DEPRECATION: Uninstalling a distutils installed project (numpy) has been 
deprecated and will be removed in a future version. This is due to the fact 
that uninstalling a distutils project will only partially uninstall the 
project.
Uninstalling numpy-1.10.0:
  Successfully uninstalled numpy-1.10.0
  Running setup.py install for numpy

-- 
https://mail.python.org/mailman/listinfo/python-list


problems using python in PowerShell

2015-10-30 Thread josephine ewers via Python-list
 Hi,I am doing an online training course to learn python but when I enter 
'python' in Microsoft PowerShell as I am supposed to do I always get an error 
message. 
Best regards,Josephine-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problems using python in PowerShell

2015-10-30 Thread Chris Angelico
On Sat, Oct 31, 2015 at 1:53 AM, josephine ewers via Python-list
 wrote:
> Hi,
> I am doing an online training course to learn python but when I enter
> 'python' in Microsoft PowerShell as I am supposed to do I always get an
> error message.

What error message, exactly?

Is Python installed? Which Python is installed? What OS are you
running? What is your $PATH (or %PATH%)? We can't help you with no
information.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UNABLE TO GET IDLE TO RUN

2015-10-30 Thread Michiel Overtoom
Hi,

Laura wrote:
> I think that it would be useful if IDLE spit out a warning

An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE 
gives a warning when you're trying to save a file with a name that would shadow 
an existing module?

Greetings,






-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UNABLE TO GET IDLE TO RUN

2015-10-30 Thread Laura Creighton
In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes:
>Hi,
>
>Laura wrote:
>> I think that it would be useful if IDLE spit out a warning
>
>An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE 
>gives a warning when you're trying to save a file with a name that would 
>shadow an existing module?
>
>Greetings,

You might want to add that idea here:
https://bugs.python.org/issue25514

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip trouble

2015-10-30 Thread Chris Warrick
On 30 October 2015 at 13:14, Neal Becker  wrote:
> I have a custom-compiled numpy 1.10.0.  But as you see, pip wants to install
> a new numpy, even though the requirement (numpy>=1.6) was already satisfied.
> WTF?
>
> All are installed into --user.
>
> This is on fedora 22 linux.
>
> pip install --up --user matplotlib
> Collecting matplotlib
>   Using cached matplotlib-1.5.0.tar.gz
> Collecting numpy>=1.6 (from matplotlib)
>   Using cached numpy-1.10.1.tar.gz
> Requirement already up-to-date: python-dateutil in
> ./.local/lib/python2.7/site-packages (from matplotlib)
> Collecting pytz (from matplotlib)
>   Using cached pytz-2015.7-py2.py3-none-any.whl
> Collecting cycler (from matplotlib)
>   Using cached cycler-0.9.0-py2.py3-none-any.whl
> Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib)
>   Using cached pyparsing-2.0.5-py2.py3-none-any.whl
> Collecting six>=1.5 (from python-dateutil->matplotlib)
>   Using cached six-1.10.0-py2.py3-none-any.whl
> Installing collected packages: numpy, pytz, six, cycler, pyparsing,
> matplotlib
>   Found existing installation: numpy 1.10.0
> DEPRECATION: Uninstalling a distutils installed project (numpy) has been
> deprecated and will be removed in a future version. This is due to the fact
> that uninstalling a distutils project will only partially uninstall the
> project.
> Uninstalling numpy-1.10.0:
>   Successfully uninstalled numpy-1.10.0
>   Running setup.py install for numpy
>
> --
> https://mail.python.org/mailman/listinfo/python-list

You used --up (aka -U, --upgrade).  That option tries to upgrade the
package you asked for *and* all dependencies. And since numpy 1.10.1
is newer than what you have installed, pip will try to install that.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip trouble

2015-10-30 Thread Neal Becker
Chris Warrick wrote:

> On 30 October 2015 at 13:14, Neal Becker  wrote:
>> I have a custom-compiled numpy 1.10.0.  But as you see, pip wants to
>> install a new numpy, even though the requirement (numpy>=1.6) was already
>> satisfied. WTF?
>>
>> All are installed into --user.
>>
>> This is on fedora 22 linux.
>>
>> pip install --up --user matplotlib
>> Collecting matplotlib
>>   Using cached matplotlib-1.5.0.tar.gz
>> Collecting numpy>=1.6 (from matplotlib)
>>   Using cached numpy-1.10.1.tar.gz
>> Requirement already up-to-date: python-dateutil in
>> ./.local/lib/python2.7/site-packages (from matplotlib)
>> Collecting pytz (from matplotlib)
>>   Using cached pytz-2015.7-py2.py3-none-any.whl
>> Collecting cycler (from matplotlib)
>>   Using cached cycler-0.9.0-py2.py3-none-any.whl
>> Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib)
>>   Using cached pyparsing-2.0.5-py2.py3-none-any.whl
>> Collecting six>=1.5 (from python-dateutil->matplotlib)
>>   Using cached six-1.10.0-py2.py3-none-any.whl
>> Installing collected packages: numpy, pytz, six, cycler, pyparsing,
>> matplotlib
>>   Found existing installation: numpy 1.10.0
>> DEPRECATION: Uninstalling a distutils installed project (numpy) has
>> been
>> deprecated and will be removed in a future version. This is due to the
>> fact that uninstalling a distutils project will only partially uninstall
>> the project.
>> Uninstalling numpy-1.10.0:
>>   Successfully uninstalled numpy-1.10.0
>>   Running setup.py install for numpy
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
> 
> You used --up (aka -U, --upgrade).  That option tries to upgrade the
> package you asked for *and* all dependencies. And since numpy 1.10.1
> is newer than what you have installed, pip will try to install that.
> 

How can I ask to upgrade just matplotlib, and not deps?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip trouble

2015-10-30 Thread Chris Angelico
On Sat, Oct 31, 2015 at 4:45 AM, Neal Becker  wrote:
> How can I ask to upgrade just matplotlib, and not deps?

Unconfirmed, but can you say:

pip install --up --user matplotlib numpy==1.10.0

? That should bind to an exact version.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip trouble

2015-10-30 Thread Mark Lawrence

On 30/10/2015 17:45, Neal Becker wrote:

Chris Warrick wrote:


On 30 October 2015 at 13:14, Neal Becker  wrote:

I have a custom-compiled numpy 1.10.0.  But as you see, pip wants to
install a new numpy, even though the requirement (numpy>=1.6) was already
satisfied. WTF?

All are installed into --user.

This is on fedora 22 linux.

pip install --up --user matplotlib
Collecting matplotlib
   Using cached matplotlib-1.5.0.tar.gz
Collecting numpy>=1.6 (from matplotlib)
   Using cached numpy-1.10.1.tar.gz
Requirement already up-to-date: python-dateutil in
./.local/lib/python2.7/site-packages (from matplotlib)
Collecting pytz (from matplotlib)
   Using cached pytz-2015.7-py2.py3-none-any.whl
Collecting cycler (from matplotlib)
   Using cached cycler-0.9.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib)
   Using cached pyparsing-2.0.5-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil->matplotlib)
   Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: numpy, pytz, six, cycler, pyparsing,
matplotlib
   Found existing installation: numpy 1.10.0
 DEPRECATION: Uninstalling a distutils installed project (numpy) has
 been
deprecated and will be removed in a future version. This is due to the
fact that uninstalling a distutils project will only partially uninstall
the project.
 Uninstalling numpy-1.10.0:
   Successfully uninstalled numpy-1.10.0
   Running setup.py install for numpy

--
https://mail.python.org/mailman/listinfo/python-list


You used --up (aka -U, --upgrade).  That option tries to upgrade the
package you asked for *and* all dependencies. And since numpy 1.10.1
is newer than what you have installed, pip will try to install that.



How can I ask to upgrade just matplotlib, and not deps?



Try https://pip.readthedocs.org/en/stable/reference/pip_install/ or "pip 
install --help"


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: problems using python in PowerShell

2015-10-30 Thread Random832
Dennis Lee Bieber  writes:
> On Sat, 31 Oct 2015 02:09:27 +1100, Chris Angelico 
>>On Sat, Oct 31, 2015 at 1:53 AM, josephine ewers via Python-list
>>> Hi,
>>> I am doing an online training course to learn python but when I enter
>>> 'python' in Microsoft PowerShell as I am supposed to do I always get an
>>> error message.
>>
>>What error message, exactly?
>>
>>Is Python installed? Which Python is installed? What OS are you
>>running? What is your $PATH (or %PATH%)? We can't help you with no
>>information.
>>
>   I'd add: is the behavior the same if using the regular Windows
> "command
> prompt" instead of PowerShell? PowerShell tends to have lots of security
> aspects that prevent some things from running unless the security level has
> been changed.

Also, is this on the console PowerShell or PowerShell ISE?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UNABLE TO GET IDLE TO RUN

2015-10-30 Thread Terry Reedy

On 10/30/2015 12:29 PM, Laura Creighton wrote:

In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes:

Hi,

Laura wrote:

I think that it would be useful if IDLE spit out a warning


An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE 
gives a warning when you're trying to save a file with a name that would shadow 
an existing module?



You might want to add that idea here:
https://bugs.python.org/issue25514


A warning requires a list to check against.  I just suggested on 
python-ideas the addition of a 'module' module, similar to the 'keyword' 
module, that would have the needed lists and functions.  Support for the 
idea (on python-ideas list) is welcome.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Python 3 Cheat Sheet v2.0

2015-10-30 Thread Steven D'Aprano
On Sat, 31 Oct 2015 06:56 am, Laurent Pointal wrote:

> Hello,
> 
> I just updated my one recto-verso sheet Python 3 Cheat Sheet
> 
> https://perso.limsi.fr/pointal/python:memento


Very nice! Thank you!


Some small typos in the English version:

Page 2, Conditional loop statement:

"☝ be careful of inifinite loops !"

Should be "infinite".
Remove space between "loops" and exclamation mark.


Page 2, Display/Input:

"items to display: litteral values, variables, expressions"

Should be "literal".


Page 2, Strings formatting:

"Conversion: s (readable text) or r (litteral representation)"

Should be "literal".



Some errors of fact:

Page 2, Generator of int sequences:

"range returns a «generator»" 

This is not correct, `range` returns a lazy immutable sequence where the
values are constructed as needed, not in advance.

https://docs.python.org/3/library/functions.html#func-range


Page 2, Files:

"text file → read/write only strings, convert from/to required type"

While that is true for text files, it implies that open() always uses text
files. This is not correct. You can open binary files too, and read/write
raw bytes:

https://docs.python.org/3/library/functions.html#open
https://docs.python.org/3/glossary.html#term-binary-file




-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unittests and serial workflows

2015-10-30 Thread Steven D'Aprano
On Tue, 27 Oct 2015 03:10 pm, Fabien wrote:

> Hi all,
> 
> I am not trained as a software developer and have only superficial
> knowledge about the theories and good practices of software testing.
> 
> Say I have several tasks (functions) A(), B(), C(), etc., each of them
> depending on the previous one. My understanding of unit testing is that
> each function should be tested alone and each test should be
> independent, 

Yes, that's the standard definition of unit testing.

However, unit testing frameworks are often perfectly well suited to other
forms of tests, like regression tests, integration tests, and others.
Sometimes it is perfectly reasonable to write a test which, strictly
speaking, doesn't fall under the unit test definition.



> so that currently my tests look like this: 
> 
> class TestTasks(unittest.TestCase):
> 
>  def test_a(self):
>  out = A()
>  self.assertStuffs(out)
> 
>  def test_b(self):
>  tmp = A()
>  out = B(tmp)
>  self.assertStuffs(out)

That's fine and meets the definition of a unit tests. Unit tests are allowed
to assume that other components of the module are working.

In test_b, you assume that A() is working correctly, and test B(). If A() is
not in fact working correctly, then the test may be invalid, or a bug in
A() may cause cascading failures: test_a will hopefully fail, and test_b
then fail as well.

Sometimes you want to avoid such cascading failures. To do that, rather than
call A() inside test_b, you create a simulation of A(), or hard-code a
value that could have been generated by A(). Such things are often called
mocks and stubs. Something like this perhaps:

def test_a(self):
out = A()
self.assertEqual(out, (1, 2, 3, 4))

def test_b(self):
tmp = (1, 2, 3, 4)
out = B(tmp)
self.assertStuffs(out)


Now, even if A() is buggy and returns something invalid, the argument to B()
is fine and you can test B() in isolation to A().

 
> And so forth. The order in which unittest is running the test is not the
> one given by the code (it seems to be alphabetical?) so that I am not
> guaranteed that my functions are tested in the right order (my real
> tasks of course are not sorted alphabetically).

In my opinion, if your unit tests need to be run in a specific order, they
aren't sufficiently isolated. But, I accept that sometimes reality bites,
and you have to deal with tests which aren't sufficiently isolated. You
don't have time to fix the tests, and you can't fix the code you're
testing. Sucks to be you... 

It's times like that you want to use a *subclass* of unittest which gives
you a predictable order. Have fun writing one :-)


> Furthermore, it is inefficient since task A() is going to be run many
> times. 

You shouldn't care (too much) about the efficiency of tests. You don't want
them to be *horribly* inefficient, of course, but it it takes 30 seconds to
run the tests, who cares? Even a minute or so is no big deal.

A big test suite like that for Python itself, with dozens of modules to be
tested, might take ten minutes to run, just long enough for you to stretch
your legs, get the cobwebs out of your brain, and make a coffee.

Of course you need the ability to run individual test suites, for those
rapid debug/run tests/debug cycles. But don't worry about optimizing each
test. That's a waste of time, and likely to introduce bugs into the tests
themselves. Write your tests in the simplest, most fool-proof way you can,
and don't be too clever.


> Of course I could run all the tasks once, store the results and 
> run my tests afterwards one by one but this contradicts somehow the idea
> of unit testing. And I like to be able to run each test alone (in
> PyCharm a mouse click alone starts a single test).
> 
> My question(s): is Unittest the "right" framework for my needs? Should I
> move to Nosetests? Any hint to a useful, not too long document about
> testing framework and good practices?

http://thedailywtf.com/articles/Testing-Done-Right

And of course, read the Daily WTF for plenty of examples of what not to do.
They have plenty of examples of bad testing.




-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unittests and serial workflows

2015-10-30 Thread Chris Angelico
On Sat, Oct 31, 2015 at 12:28 PM, Steven D'Aprano  wrote:
>> And so forth. The order in which unittest is running the test is not the
>> one given by the code (it seems to be alphabetical?) so that I am not
>> guaranteed that my functions are tested in the right order (my real
>> tasks of course are not sorted alphabetically).
>
> In my opinion, if your unit tests need to be run in a specific order, they
> aren't sufficiently isolated. But, I accept that sometimes reality bites,
> and you have to deal with tests which aren't sufficiently isolated. You
> don't have time to fix the tests, and you can't fix the code you're
> testing. Sucks to be you...

If the order of test execution affects the overall pass/fail of the
test set, then yes, that's a problem. But if, as in the OP's example,
some tests assume the correct operation of features tested
individually elsewhere, it would be kinda nice to say "do these
low-level tests first, and if they pass, go on to test these
higher-level features". Is there a way to express that in unittest?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UNABLE TO GET IDLE TO RUN

2015-10-30 Thread Terry Reedy

On 10/30/2015 9:15 PM, Terry Reedy wrote:

On 10/30/2015 12:29 PM, Laura Creighton wrote:

In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes:

Hi,

Laura wrote:

I think that it would be useful if IDLE spit out a warning


An ounce of prevention is worth a pound of cure. Maybe it's an idea
that IDLE gives a warning when you're trying to save a file with a
name that would shadow an existing module?



You might want to add that idea here:
https://bugs.python.org/issue25514


This is a different issue than IDLE avoiding clashes.  I opened
https://bugs.python.org/issue25522


A warning requires a list to check against.  I just suggested on
python-ideas the addition of a 'module' module, similar to the 'keyword'
module, that would have the needed lists and functions.


Guido pointed me to sys.builtin_module_names, which is needed for the 
issue above.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Unittests and serial workflows

2015-10-30 Thread Laura Creighton
In a message of Sat, 31 Oct 2015 12:46:53 +1100, Chris Angelico writes:
>If the order of test execution affects the overall pass/fail of the
>test set, then yes, that's a problem. But if, as in the OP's example,
>some tests assume the correct operation of features tested
>individually elsewhere, it would be kinda nice to say "do these
>low-level tests first, and if they pass, go on to test these
>higher-level features". Is there a way to express that in unittest?
>
>ChrisA
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I know how to do this with pytest
http://pytest.org/dev/example/parametrize.html#a-quick-port-of-testscenarios

Since this is a port of something Robert Collins wrote for unittest,
I am pretty sure you can do it there, as well, but I haven't researched
the how.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list