Re: [Tutor] Multiprocessing with many input input parameters

2019-07-12 Thread Shall, Sydney via Tutor
Thanks Mike,

But I am still not clear.

do I write:

def f([x,y,z]) ?
How exactly do one write the function and how does one ensure that each 
positional argument is accounted for.

Dr. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01

From: Mike Barnett 
Sent: 11 July 2019 16:40
To: Shall, Sydney
Cc: tutor@python.org
Subject: RE: [Tutor] Multiprocessing with many input input parameters

If you're passing parameters as a list, then you need a "," at the end of the 
items.  Otherwise if you have something like a string as the only item, the 
list will be the string.

list_with_one_item = ['item one',]


@mike

-Original Message-----
From: Shall, Sydney 
Sent: Wednesday, July 10, 2019 11:44 AM
To: tutor@python.org
Subject: [Tutor] Multiprocessing with many input input parameters

I am using MAC OS X 10.14.5 on a MAC iBook I use Python 3.7.0 from Anaconda, 
with Spyder 3.3.3

I am a relative beginner.

My program models cell reproduction. I have written a program that models this 
and it works.

Now I want to model a tissue with several types of cells. I did this by simply 
rerunning the program with different inputs (cell characteristics). But now I 
want to send and receive signals between the cells in each population. This 
requires some sort of concurrent processing with halts at appropriate points to 
pass and receive signals.

I thought to use multiprocessing. I have read the documentation and reproduced 
the models in the docs. But I cannot figure out how to feed in the data for 
multiple parameters.

I have tried using Pool and it works fine, but I can only get it to accept 1 
input parameter, although multiple data inputs with one parameter works nicely.

So, my questions are;

  1.  Is multiprocessing the suitable choice.
  2.  if yes, how does one write a function with multiple input parameters.

Thank s in advance.

Sydney

Prodessor. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01

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


[Tutor] Multiprocessing with many input input parameters

2019-07-10 Thread Shall, Sydney via Tutor
I am using MAC OS X 10.14.5 on a MAC iBook
I use Python 3.7.0 from Anaconda, with Spyder 3.3.3

I am a relative beginner.

My program models cell reproduction. I have written a program that models this 
and it works.

Now I want to model a tissue with several types of cells. I did this by simply 
rerunning the program with different inputs (cell characteristics). But now I 
want to send and receive signals between the cells in each population. This 
requires some sort of concurrent processing with halts at appropriate points to 
pass and receive signals.

I thought to use multiprocessing. I have read the documentation and reproduced 
the models in the docs. But I cannot figure out how to feed in the data for 
multiple parameters.

I have tried using Pool and it works fine, but I can only get it to accept 1 
input parameter, although multiple data inputs with one parameter works nicely.

So, my questions are;

  1.  Is multiprocessing the suitable choice.
  2.  if yes, how does one write a function with multiple input parameters.

Thank s in advance.

Sydney

Prodessor. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble Downloading To MacOS Mojave 10.14.3 released mid 2014

2019-03-13 Thread Shall, Sydney via Tutor
On 13/03/2019 14:11, Paul McCombs wrote:
> On Wed, Mar 13, 2019, 5:05 AM Robert Landers  wrote:
> 
>> Hello Tutor,
>>
>> I am having trouble finding a python 3.7.2 download for my MacOS Mojave
>> 10.14.3 released mid 2014.
>> I would like to use Xcode to learn python.
>>
>> Is my OS too old?
>>
>> Please provide guidance.
>>
>> Thanks.
>> ___
>>
> 
> MacOS Mojave 10.14.3 was released in December 2018.
> 
> Python 3.7.2 is available for MacOS versions as early as 10.6, which came
> out in 2009.
> 
> Can you clarify what you mean?
> 
> Paul McCombs
> 
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.python.org%2Fdownloads%2Frelease%2Fpython-372%2Fdata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C6d5116a86151497caefd08d6a7d23e37%7C8370cf1416f34c16b83c724071654356%7C0sdata=XM0%2FLvaSE7wYpSfvZWuaKBYARoUGKCkBS9XWD2bZbzE%3Dreserved=0
> 
> macOS users
> 
> - For Python 3.7 releases, we provide two binary installer options for
> download. The default variant is 64-bit-only and works on macOS 10.9
> (Mavericks) and later systems. We also continue to provide a 64-bit/32-bit
> variant that works on all versions of macOS from 10.6 (Snow Leopard) on.
> Both variants now come with batteries-
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C6d5116a86151497caefd08d6a7d23e37%7C8370cf1416f34c16b83c724071654356%7C0sdata=8vKb0Mzx6M3QldhtDKDcnNNUXsuSFAvKGyX3lmwAXOU%3Dreserved=0
> 
I meant to add that I use Spyder 3.3.2 and that works fine too.

-- 

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble Downloading To MacOS Mojave 10.14.3 released mid 2014

2019-03-13 Thread Shall, Sydney via Tutor
On 13/03/2019 14:11, Paul McCombs wrote:
> On Wed, Mar 13, 2019, 5:05 AM Robert Landers  wrote:
> 
>> Hello Tutor,
>>
>> I am having trouble finding a python 3.7.2 download for my MacOS Mojave
>> 10.14.3 released mid 2014.
>> I would like to use Xcode to learn python.
>>
>> Is my OS too old?
>>
>> Please provide guidance.
>>
>> Thanks.
>> ___
>>
> 
> MacOS Mojave 10.14.3 was released in December 2018.
> 
> Python 3.7.2 is available for MacOS versions as early as 10.6, which came
> out in 2009.
> 
> Can you clarify what you mean?
> 
> Paul McCombs
> 
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.python.org%2Fdownloads%2Frelease%2Fpython-372%2Fdata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C6d5116a86151497caefd08d6a7d23e37%7C8370cf1416f34c16b83c724071654356%7C0sdata=XM0%2FLvaSE7wYpSfvZWuaKBYARoUGKCkBS9XWD2bZbzE%3Dreserved=0
> 
> macOS users
> 
> - For Python 3.7 releases, we provide two binary installer options for
> download. The default variant is 64-bit-only and works on macOS 10.9
> (Mavericks) and later systems. We also continue to provide a 64-bit/32-bit
> variant that works on all versions of macOS from 10.6 (Snow Leopard) on.
> Both variants now come with batteries-
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C6d5116a86151497caefd08d6a7d23e37%7C8370cf1416f34c16b83c724071654356%7C0sdata=8vKb0Mzx6M3QldhtDKDcnNNUXsuSFAvKGyX3lmwAXOU%3Dreserved=0
> 

I am using MacOS Mojave 10.4.3.
I am also using Python 3.7.0 supplied by Anaconda.
It works fine.

Sydney


-- 

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem with creating paths

2018-10-17 Thread Shall, Sydney via Tutor

On 17/10/2018 18:18, Mats Wichmann wrote:

On 10/17/2018 10:07 AM, Shall, Sydney via Tutor wrote:

Firstly, I would like to thank Steven for reminding me of the assert
statement. I should have remembered this. It allowed me to isolate the
problem, which predictably (for me) was very elementary. I am too
embarrassed to say how simple the error was.

However, my original problem was not solved by correcting this error.

So, I will now try and narrow down the location of the problem and then
if I cannot solve it, I shall return for more good advice.

Many thanks to Steven and to Peter.


I'll weigh in with a mini- (and unasked-for-) lecture here:

this is often the point at which someone says "boy, I wish Python were
strongly typed, so things didn't change types in flight".

But in fact, the list didn't change types, it's still a list. In fact we
even know where that list is: it's the first element of that tuple you
ended up with. The _name_ you gave to that list carries no typing
meaning, however (although you can give it type hints that an external
tool could use to warn you that you are changing something).  So you
have somewhere given that name to a completely different object, a tuple
which contains your list and another element. So clearly what you're
looking for is the place that happens.

So here's a sketch of how you might use type hinting to find this, to
bring it back to something practical:


=== types.py:
from typing import List, Tuple

a: List[str] = [
 '/a/path',
 '/b/path',
]
print(type(a))
print(a)

a = (a, '/c/path')
print(type(a))
print(a)

=== this works just fine:
$ python3 types.py

['/a/path', '/b/path']

(['/a/path', '/b/path'], '/c/path')

=== but a hinting tool can see a possible issue:
$ mypy types.py
types.py:10: error: Incompatible types in assignment (expression has
type "Tuple[List[str], str]", variable has type "List[str]")



Thanks for this. Most helpful.
Sydney



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7Ca58896d72c374cda3c1508d63454b783%7C8370cf1416f34c16b83c724071654356%7C0sdata=OHZtedYdy0UHKDagLO1TI%2BUIjEJuzRjZjD4HRdSQmNI%3Dreserved=0




--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem with creating paths

2018-10-17 Thread Shall, Sydney via Tutor
Firstly, I would like to thank Steven for reminding me of the assert 
statement. I should have remembered this. It allowed me to isolate the 
problem, which predictably (for me) was very elementary. I am too 
embarrassed to say how simple the error was.


However, my original problem was not solved by correcting this error.

So, I will now try and narrow down the location of the problem and then 
if I cannot solve it, I shall return for more good advice.


Many thanks to Steven and to Peter.

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


[Tutor] problem with creating paths

2018-10-17 Thread Shall, Sydney via Tutor

I can now add to my previous email the following observation.

If I do not delete the output file and redo the test I get the following 
as the 'extra' entry in paths:



'/Users/sydney/AnacondaProjects/capital_reproduction/Current_Version/Results/20181017D/B_Cycle_Zero/Text_Files')

If however, I delete the output file and then redo the test I get the 
following as the 'extra' entry in paths:


 '/Users/sydney/.Trash/20181017D/B_Cycle_Zero/Text_Files')

This seems to be consistent.
The upper incorrect entry is item path19 in the list part of paths. I 
have studied every example of 'path19' in the program and I cannot find 
an explanation.


help!

Sydney


_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] problem with creating paths

2018-10-17 Thread Shall, Sydney via Tutor

I am a novice (at programming).
I use MAC OS 10.13.6
Anaconda.
Python 3.5.4
Spyder 3.5.6

I have just re-written a moderately complex program (a Class) on the 
advice of Alan and Steven. The rewriting proved to be very useful.


The working program uses instances of the Class with User chosen 
parameters. The output data seems correct to me.


So I then began redoing all the tests. The first Methods tested gave OK.
But I have just started testing a new Method and I get a Universal error 
in my tests. It says that the output file is already present. These 
files (paths) are correctly deleted by the 'teardown' Method, when only 
the earlier portion of the program is tested. But are not deleted with 
the last method tested.


After searching I have found this unexpected output illustrated in the 
copy-paste below.



test


The type of the paths is: 

The values of the paths are :


(   [ 
'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/',


'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D',

'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D/A_POCI_Input_Data',
.
.
.
.
   '/Users/sydney/AnacondaProjects/reproduction/Current_Version
/Results/20181017D/B_Cycle_Zero/Text_Files',
.
.
.

'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D/C_Final_Results/Plots/Population_Data/Ratios'],
'/Users/sydney/.Trash/20181017D/B_Cycle_Zero/Text_Files')



There are two items that are 'wrong' in this output.

1. The property 'paths' is defined in the program as a list and the 
items are added using paths.append(), yet the test says that when tested 
it is a tuple.
2. The tuple arises by the addition of the last entry in the file, AFTER 
the closing bracket of the list which is the first item in the tuple.


When I test the length of 'paths' I get a value of 2!

I apologise for the lengthy explanation, but I am at a loss.

I have looked for an error that might have added an item as a + and I 
find nothing.

The character of the final item is also puzzling to me.

I would much appreciate any guidance as to how I should search for the 
fault or error.


Sydney






_


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


[Tutor] Spyder - How to determine files that appear at start-up

2018-10-08 Thread Shall, Sydney via Tutor
My question concerns Spyder. I know that this is a Python list, but I 
also see that some people here also use Spyder. So, please forgive me.

My problem is simple. I cannot find out how I can determine the set of 
files that open at start-up. I am annoyed by the fact that I must 
manually load my set of working files each time that I start Spyder.

Thanks.

Sydney


_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary

2018-09-23 Thread Shall, Sydney via Tutor

On 23/09/2018 13:04, Peter Otten wrote:

Peter Otten wrote:


Maybe you could sort the already-sorted property_b again, with some random
offset:


import itertools
def wiggled(items, sigma):

... counter = itertools.count()
... def key(item): return random.gauss(next(counter), sigma)
... return sorted(items, key=key)
...


One more example:


s = """\

... But my actual scientific problem requires that the correlation should be
... only approximate and I do not know how close to to a perfect correlation
... it should be. So, I need to introduce some lack of good correlation when
... I set up the correlation. How to do that is my problem.
... """

print(textwrap.fill(" ".join(wiggled(s.split(), 2

But actual my scientific the requires that problem should only
correlation approximate be and not do I know how close to a perfect to
correlation should it So, be. I to lack need some introduce
correlation I of good when set correlation. up How to the that do
problem. is my

:)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C185332cee28f49ed465108d6214ce8ab%7C8370cf1416f34c16b83c724071654356%7C0sdata=GBAb%2FdY2zrBqSwOl33ejT%2BzzknQx5RYNXsNEqZQXCX4%3Dreserved=0


Thanks. Most useful.

Sydney

--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary

2018-09-23 Thread Shall, Sydney via Tutor

On 23/09/2018 10:42, Peter Otten wrote:

Shall, Sydney via Tutor wrote:


What I want is the following.

I have:

property_a = [1, 6, 2, 4]
property_b = [62, 73, 31 102]


Result should approximately be:

property_b = [31, 102, 62, 73]


That is both lists change in value in exactly the same order.

Now, this is easy to achieve. I could simply sort both lists is
ascending order and I would then have an exact alignment of values is
ascending order. The correlation would be a perfect linear relationship,
I suppose.

But my actual scientific problem requires that the correlation should be
only approximate and I do not know how close to to a perfect correlation
it should be. So, I need to introduce some lack of good correlation when
I set up the correlation. How to do that is my problem.

I hope this helps to clarify what my problem is.


Maybe you could sort the already-sorted property_b again, with some random
offset:


import itertools
def wiggled(items, sigma):

... counter = itertools.count()
... def key(item): return random.gauss(next(counter), sigma)
... return sorted(items, key=key)
...

wiggled(range(20), 3)

[0, 5, 2, 4, 1, 6, 7, 8, 3, 9, 11, 10, 13, 14, 16, 12, 18, 17, 19, 15]

wiggled([31, 102, 62, 73], .8)

[102, 31, 62, 73]

wiggled([31, 102, 62, 73], .8)

[31, 102, 62, 73]

wiggled([31, 102, 62, 73], .8)

[31, 102, 62, 73]

wiggled([31, 102, 62, 73], .8)

[31, 62, 102, 73]


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7Cb9cbdce8c20e45dd3ff508d621390143%7C8370cf1416f34c16b83c724071654356%7C0sdata=yNo7hMVl7dYmH6d74MBaab5e5g6bPoWoqkza5TS1bXY%3Dreserved=0




Thanks to Oscar and to Pater for their help. They have set me on the 
correct path.
The crucial advice to was to look at the randomisation procedures. I 
have used a procedure similar to that suggested by Peter and it works well.


Cheers,

Sydney

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary

2018-09-23 Thread Shall, Sydney via Tutor

On 21/09/2018 00:01, Oscar Benjamin wrote:

Sydney wrote and Alan forwarded:



I have, I suspect, an elementary problem that I am too inexperienced to
resolve.

I have two numpy arrays, each representing the values of a specific
property of a set of cells.

Now, I want to associate the two values for each cell, that is for each
index of the numpy array. But I want to associate them ROUGHLY, that
means, APPROXIMATELY, so that there is a weak, linear correlation
between the values representing one property and the values representing
the second property of each individual cell.

Up to now I have used the following procedure.
I have divided each population of values into four segments based on the
value of the standard deviation thus.

1. values > mean + 1 std (sigma)
2. values > mean but < mean + 1 std (sigma)
3. values < mean but > mean + 1 std (sigma)
4. values < mean + 1 std (sigma).

Then I randomly select a value from group 1 for the first property and I
associate it with a randomly selected sample of the second property from
its group 1. And so on through the total population. This gave me a very
rough linear association between the two properties, but I am wondering
whether I can do it in a simpler and better way.



Hi Sydney,

I feel like I would definitely be able to solve your problem if I
understood what you're talking about (I'm sure others here could as well).
Please don't be put off by this but I don't think you've explained it very
well.

Perhaps if you give an example of what the input and output of this
operation is supposed to look like then you would get a response. The
example might look like:

I have these arrays as input:


property_a = [1, 6, 2, 4]
property_b = [6, 3, 4, 6]


Then I want a function that gives me this output


associated_values = myfunction(a, b)
associated_values

[1, 3, 5, 2]

Some explanation why you want this, how you know that's the output you
want, and what any of it means would likely help...

If you already have something that does what you want then it would make
sense to show it but if your code is complicated then please try to
simplify it and use only a small amount of data when showing it here. There
is some advice for posting this kind of thing to a mailing list here:
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsscce.org%2Fdata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C77fe09364c79190308d61f4d4112%7C8370cf1416f34c16b83c724071654356%7C0sdata=DAhLxDli1vM%2BBcRXKemRo0sa%2BVJErJPZ%2Bwy5UHvUR4s%3Dreserved=0

--
Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutordata=01%7C01%7Csydney.shall%40kcl.ac.uk%7C77fe09364c79190308d61f4d4112%7C8370cf1416f34c16b83c724071654356%7C0sdata=Benb%2BsxqZr1Rhdj8jG81KRurndfNVnBGx0%2B3z9VXd54%3Dreserved=0


Thank you Oscar. Fair comment.

What I want is the following.

I have:
> property_a = [1, 6, 2, 4]
> property_b = [62, 73, 31 102]

Result should approximately be:
> property_b = [31, 102, 62, 73]

That is both lists change in value in exactly the same order.

Now, this is easy to achieve. I could simply sort both lists is 
ascending order and I would then have an exact alignment of values is 
ascending order. The correlation would be a perfect linear relationship, 
I suppose.


But my actual scientific problem requires that the correlation should be 
only approximate and I do not know how close to to a perfect correlation 
it should be. So, I need to introduce some lack of good correlation when 
I set up the correlation. How to do that is my problem.


I hope this helps to clarify what my problem is.

Sydney

--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] try, except syntax

2018-08-02 Thread Shall, Sydney

MAC OS X 10.13.6

Anaconda python 3.6.5

Anaconda IPython 6.4.0

I am having difficulty in using the try, except form.

I copy and paste a minimal program to illustrate my problem.


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  2 15:41:15 2018

@author: sydney
"""
uvc = 2
msg = "Bad argument provided, the value of uvc must be a float."

try:
    type(uvc) == float
except TypeError as e:
    print(e, msg)

try:
    0.0 > uvc < 1.0
except ValueError:
    print("Bad argument provided. The value of uvc must be "
  "greater than 0.0 and less than 1.0.")




if type(uvc) != float:
    raise TypeError("Bad argument provided. And this is also old test."
    " The value of UVC must be a float. This is old test")
if uvc < 0.0 or uvc > 1.0:
    raise ValueError("Bad argument provided. The value of uvc must be "
 "greater than 0.0 and less than 1.0. This is old 
test")



My problem is this.

The two, 'if statements' at the end of the little program work as 
intended. And I have been using them in a larger program for some time 
and they have been checked regularly and they work as intended.


I am now rewriting a class, as recommended by both Alan and Steven, in 
which I have previously used these formulations.


This time, I thought that perhaps it would be more "pythonic" to write 
them as try, except. But I cannot find the correct format. I have read 
and reread the books and the documentation, but I am clearly stupid 
today. Either I do not need this change or I have written the try, 
except incorrectly. I am sure that I am making an elementary mistake.


Will someone please show tell me whether I should use try, except 
instead of if ... and then what is the correct syntax.


Thanks as always.

--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]

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


Re: [Tutor] how to change the command "string" on a tkinter Button?

2018-07-28 Thread Shall, Sydney

On 27/07/2018 23:40, Alan Gauld via Tutor wrote:

On 27/07/18 11:55, Shall, Sydney wrote:

On 01/07/2018 11:19, Steven D'Aprano wrote:

Even better would be to learn a form of VCS (version control system)
such as Mercurial (hg) or git. Depending on the text editor you are
using, it may have VCS integration available.


Does Spyder have a VCS?


Dunno, sorry...


Could you list a few text-editors that do have VCS, please.


It's not so much that they have a VCS but that they integrate
with an existing VCS. So they will typically have menu options
for checking in/out a file or locking/unlocking it. Typically
you can configure which VCS they use from a list of common
options, in some cases you can define the command line to
use for each menu action.

vim, emacs, Eclipse, Netbeans, VisualStudio etc all
support VCS to varying degrees.

But you still need to install and configure a VCS
engine such as CVS, SVN, Hg or git etc.


Thanks, that clarifies it for me. I shall learn to use GIT.

Sydney

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


Re: [Tutor] how to change the command "string" on a tkinter Button?

2018-07-27 Thread Shall, Sydney

On 01/07/2018 11:19, Steven D'Aprano wrote:

On Sun, Jul 01, 2018 at 03:32:59PM +1000, Chris Roy-Smith wrote:





"Save As..." before engaging in big changes is your friend :-)

Even better would be to learn a form of VCS (version control system)
such as Mercurial (hg) or git. Depending on the text editor you are
using, it may have VCS integration available.




Does Spyder have a VCS?
Could you list a few text-editors that do have VCS, please.


--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Everything in one file?

2018-07-18 Thread Shall, Sydney

On 24/05/2018 03:27, Steven D'Aprano wrote:
> On Tue, May 22, 2018 at 03:46:50PM +0530, aishwarya selvaraj wrote:
>>   Dear all,
>>   I have created 2 classes in 2 separate files.
>
> If you have learned the bad habit from Java of putting every class in a
> separate file, you should unlearn that habit for your Python code. There
> is no need to put every class in a separate file, and it usually leads
> to complicated dependencies and circular imports.
>
>

I am an slightly more than a beginner.
I have not met this advice from Steven D'Aprano before, so I have some 
questions.


I have constructed a program which has a parent class and a child class 
and I have them in two different files. I import the parent class into 
the child class and create instances with the child class. This works fine.
But, would it be better to have both classes in one file? Would then the 
child class 'know' that the parent class is in the file?


And further. I have a function which sets up all the suitable data 
structures into which this function will put the information supplied by 
the user. I import this file too into both the parent and the child class.
Would the instances with which I actually work, 'know' that this 
function is there if it is simply present in the same file?


--
Sydney



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


Re: [Tutor] RAD GUI Development (like Visual Studio/VBA)

2018-07-01 Thread Shall, Sydney

On 30/06/2018 19:21, Alan Gauld via Tutor wrote:
> On 30/06/18 11:50, Shall, Sydney wrote:
>
>>> And if you want to try using Jython or MacPython(?)
>>> you can use the native GUI builders for those:
>>> - Eclipse/Netbeans (Java)
>>> - XDeveloper (MacOS) - I tried this once and it kind of works...
>>>
>> Alan,
>>
>> Could you expand a bit on the use of XDeveloper.
>> I have need of some such utility for my project and I use a MAC OS X.
> I've only gone through the tutorial and made some tweaks
> to the resulting code but it seemed to work pretty much
> as usual for Cocoa projects using Objective C.
>
> You layout the UI then connect the widgets to your code
> (which is in Python of course).
>
> The PyObjC project is here:
>
> https://pythonhosted.org/pyobjc/
>
> The tutorial I used is here:
>
> https://pythonhosted.org/pyobjc/tutorials/firstapp.html
>
> Note that it is old, but I only have an iBook from 2001
> running MacOS Lion, so age wasn't an issue for me!
> Thank you.
I shall spend some time studying the two sites and see what I can make 
of it.


Sydney



_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RAD GUI Development (like Visual Studio/VBA)

2018-06-30 Thread Shall, Sydney

On 30/06/2018 00:34, Alan Gauld via Tutor wrote:

On 29/06/18 16:05, Glen wrote:


Can someone advise on a RAD, drag and drop style graphical form/dialog
creator? Akin to VBA or Visual Studio that will work with Python?


There is nothing even close to the VB GUI builder for Python.

That's because Python has to cover many GUI frameworks,
VB only has to deal with one. Which is why VB is pretty
much useless for anything other than Windows...

But there are some GUI tools available:
- Glade  - PyQt/Side?
- SpecTcl - Tkinter
- Dabo - WxPython (customised for simple DB apps)

I've tried all of them and only Dabo worked for me,
but Davo wasn't really suitable for my particular
project at the time. But YMMV

There are some others I haven't tried too
- Kivy, Blackadder(??)

And if you want to try using Jython or MacPython(?)
you can use the native GUI builders for those:
- Eclipse/Netbeans (Java)
- XDeveloper (MacOS) - I tried this once and it kind of works...


Alan,

Could you expand a bit on the use of XDeveloper.
I have need of some such utility for my project and I use a MAC OS X.

Thanks.

--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Problem with testing - container

2018-03-29 Thread Shall, Sydney

I have a problem with a specific test, I think.

I use a Mac with OS X 10.13.3
I use Anaconda with Python 3.5

I have been writing tests for a Class that I have written. I am not 
finished yet, but there are already nearly 400 tests. The tests run and 
return OK. [After cleaning up many silly mistakes that I made.]


However, now, when I run the tests (Unittest) I get the following warning:

lib/python3.5/unittest/case.py:1092: FutureWarning: elementwise 
comparison failed; returning scalar instead, but in the future will 
perform elementwise comparison

  if member in container:
...

No other information is given.

My problem is, how do I find out where exactly the problem originates.
--
Sydney
--

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] problem with a sub-class

2017-11-30 Thread Shall, Sydney

I am almost a beginner.
I have an error message which I cannot understand.
My problem is with constructing a sub-class.

I use;
MAC OS V10.13.1
Anaconda Python 3.5

My base Class works properly and all 136 tests of the Base Class are 
correct.


My sub-class is constructed as follows:

import sys
import random
import numpy as np
import pylab
import copy
import Population_InitV8 as POCI
import Population_ProductivityV24 as POCWP

line 27 : class SimulateCycleZero(POCWP):
line 28 : def __init__(self, dirname_p):

The program follows on from this.

The error message is as follows:


  File 
"/Users/sydney/AnacondaProjects/Capital/Capital_with_productivity/Current_Versions/Simulate_Cycle_Zero_V3.py", 
line 27, in 

class SimulateCycleZero(POCWP):

TypeError: module.__init__() takes at most 2 arguments (3 given)


My problem is that I do not understand to which file the word 'module' 
in the error message applies.


It seems to me that somewhere I am providing 3 arguments when only a 
maximum of two are required.


When I do the following, I get the same error message.

line 27 : class SimulateCycleZero(POCWP):
line 28 : def __init__(self):

I would appreciate some guidance , please.

Sydney
_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] unittest difficulty

2017-07-19 Thread Shall, Sydney

I am learning to use unittest.

I have written a program that runs as it should.
247 tests give me a satisfactory answer.

I have now added one more test and I get an error which I do not understand.

The two relevant tests are:

 def test_type_capitalsadvanced(self):
self.assertEqual(type(self.capitalsadvanced), numpy.ndarray)

 def test_zero_in_capitalsadvanced(self):
self.assertIn(self.capitalsadvanced, 0.0)

The error message is:

Traceback (most recent call last):
  File 
"/Users/sydney/Capital/Capital_with_productivity/Current_Versions/testPOCWP_V2.py", 
line 320, in test_zero_in_capitalsadvanced

self.assertIn(self.capitalsadvanced, 0.0)
  File "/Users/sydney/anaconda/lib/python3.6/unittest/case.py", line 
1077, in assertIn

if member not in container:
TypeError: argument of type 'float' is not iterable

Final output from the tests is :

Ran 247 tests in 1.179s

FAILED (failures=9, errors=1)

The failures all arise from a 'nan'.
It is this problem that I am trying to resolve.

My problem is that the first test tells me correctly that the object 
capitalsadvanced is a numpy.ndarray. But the second test error message 
says it is a float.


I should add that the program creates the initial data set by making use 
of the random function which is given a mean to work with. Thus each 
test run will be with different input data. But repeated tests show the 
same errors.


Any guidance will be very welcome.

Sydney

_

Professor Sydney Shall
Department of Haematology/Oncology
Phone: +(0)2078489200
E-Mail: sydney.shall
[Correspondents outside the College should add @kcl.ac.uk]
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Shall, Sydney

On 29/03/2013 11:39, Amit Saha wrote:

On Fri, Mar 29, 2013 at 9:35 PM, Amit Saha amitsaha...@gmail.com wrote:

On Fri, Mar 29, 2013 at 9:33 PM, Ghadir Ghasemi
ghasemm...@leedslearning.net wrote:

Hi guys I am trying to create part of a vending machine. The section below is 
if the user wants to insert 50p coins. It works but when I entered a non 
integer like 'dfsdf', the program just broke. Is there a way that the program 
can check if the input is an integer, and if it is, then the program does all 
the calculations, but if it isn't the program just keeps asking for an input? 
Thanks. Here is the section.

fiftypencecoins = int(input(how many 50p coins do you want to insert or press 'e' 
to exit : ))
if fiftypencecoins == 'e':
 break
else:
  currentmoney += fiftypencecoins * 5/10
  print(your newly updated credit is £ + str(currentmoney) + 0)

Is this Python 3 or Python 2 ?

May be that's not relevant. So anyway, if you want to see whether the
int() function will be successful on your input, you need to check
whether the input constitutes of only digits.

I can think of two ways:

1. Easy and naive way: for each character in the input, check whether
it is between [0-1]
2. Use regular expressions: http://docs.python.org/2/library/re.html

-Amit.



or;
where x is the input == fiftypencecoins;

return isinstance(x, int)

will return True or False

Then you can proceed as you wish.

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


[Tutor] Importing data from a file.

2013-03-21 Thread Shall, Sydney

I have an elementary question provoked by another post today.

1. Is it the case that ALL imported data from a file is a string?
2. Does this therefor imply that said data has to be processed 
appropriately to generate the data in the form required by the program?

3. Are there defined procedures for doing the required processing?

With many thanks,

Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


Re: [Tutor] Importing data from a file.

2013-03-21 Thread Shall, Sydney

On 21/03/2013 13:54, Amit Saha wrote:

On Thu, Mar 21, 2013 at 11:43 PM, Shall, Sydney sydney.sh...@kcl.ac.uk wrote:

I have an elementary question provoked by another post today.

1. Is it the case that ALL imported data from a file is a string?
2. Does this therefor imply that said data has to be processed appropriately
to generate the data in the form required by the program?

To the best of my knowledge, yes to both of your queries. Once you
have the element you want to process, you can make use of the type
converting functions (int(), float().. ) and use them appropriately.


3. Are there defined procedures for doing the required processing?

If you meant conversion functions, int() and float() are examples of
those. You of course  (most of the times) have to make use of string
manipulation functions (strip(), rstrip(), etc) to extract the exact
data item you might be looking for. So, they would be the building
blocks for your processing functions.

I hope that makes some things clear.

-Amit.


Yes, Thanks. This is now quite clear.
Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


Re: [Tutor] Importing data from a file.

2013-03-21 Thread Shall, Sydney

On 21/03/2013 16:17, Alan Gauld wrote:

On 21/03/13 13:43, Shall, Sydney wrote:

I have an elementary question provoked by another post today.

1. Is it the case that ALL imported data from a file is a string?


Assuming you mean data read from a file rather than modules imported 
using 'import' then the answer is 'it depends'.


Most files are text files and the data is stored as strings and 
therefore when you read them back they will be strings. You then 
convert them to the native data using int(), float() etc.


Some files are binary files and then the data read back will be bytes 
and need to be decoded into the original data. This is often done 
using the struct module.


Either way if you use the Python read() operation on a file
you will get back a bunch of bytes. What those bytes represent depends 
on how they were written. How they are interpreted is down to the 
programmer.




2. Does this therefor imply that said data has to be processed
appropriately to generate the data in the form required by the program?


Yes, always.


3. Are there defined procedures for doing the required processing?


Yes, for the standard types. For custom types and arbitrary binary 
data you need to find out what the original encoding was and reverse it.


HTH,


Thank you Alan, That was most useful.
Cheers,
Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


[Tutor] converting upper case to lowercase and vice-versa

2013-03-15 Thread Shall, Sydney

I am just learning Python and my book does not solve my problem.
I have not yet been successful in searching the Python 2.7.3 tutorial
I am doing an encryption exercise.

Python 2.7.3
MAC OS X 10.6.8

What is the correct syntax to covert English characters from uppercase 
to lowercase and from lowercase to uppercase?


With many thanks,

Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


Re: [Tutor] BMI calc

2013-03-13 Thread Shall, Sydney

On 13/03/2013 00:05, Soliman, Yasmin wrote:

Hello all,

I'm new to python and its been a stuggle so far. I'm attempting to create a BMI 
calculator in Wing 101 4.1. I keep getting syntax errors:

def calc_BMI(weight,height):
 return (weight/(height*height))*703.0
if bmi =18.5:
 print 'underweight'
elif bmi = 18.5 and bmi =24.9:
 print 'normal weight'
elif bmi =25 and bmi =29.9:
 print 'overweight'
elif bmi =30:
 print 'obese'

Also, height should be converted to inches and I have not the slightest clue 
how to so. Any help would be much appreciated.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Hi,
I am also a newbie, but I wish to learn, so I offer the following 
corrections.


# Note. I do note know what units you are using.
# I would use scientific, metric units. So you need to divide both 
weight and height by a suitable conversion factors.
# Then you will not need the number 703.0, and the units in the second 
and third lines would be Kg/m. [Kilogram/Metre)


def calc_BMI(weight,height):
bmi = (weight/(height*height))*703.0
print 'Your BMI is : ', BMI 'weight units/height units.' # You need to put 
the correct text here.
if bmi =18.5:
print 'underweight'
if  18.5 = bmi = 24.9:
print 'normal weight'
if  25.0 = bmi = 29.9:
print 'overweight'
if bmi = 30:
print 'obese'
return

I hope that I am halfway correct.
With best wishes,
Sydney


--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


[Tutor] BMI calc

2013-03-13 Thread Shall, Sydney


On 13/03/2013 00:05, Soliman, Yasmin wrote:

Hello all,

I'm new to python and its been a stuggle so far. I'm attempting to create a BMI 
calculator in Wing 101 4.1. I keep getting syntax errors:

def calc_BMI(weight,height):
 return (weight/(height*height))*703.0
if bmi =18.5:
 print 'underweight'
elif bmi = 18.5 and bmi =24.9:
 print 'normal weight'
elif bmi =25 and bmi =29.9:
 print 'overweight'
elif bmi =30:
 print 'obese'

Also, height should be converted to inches and I have not the slightest clue 
how to so. Any help would be much appreciated.
___
Tutor maillist  -Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Hi,
I am also a newbie, but I wish to learn, so I offer the following 
corrections.


Yes, as someone pointed out, it would be better if several of the print 
statements were return, as corrected below.

# Note. I do note know what units you are using.
# I would use scientific, metric units. So you need to divide both 
weight and height by a suitable conversion factors.
# Then you will not need the number 703.0, and the units in the second 
and third lines would be Kg/m. [Kilogram/Metre)


def calc_BMI(weight,height):
bmi = (weight/(height*height))*703.0
print 'Your BMI is : ', BMI 'weight units/height units.' # You need to put 
the correct text here.
if bmi =18.5:
return ' You are underweight.'
if  18.5 = bmi = 24.9:
return 'Your weight is in the normal range.'
if  25.0 = bmi = 29.9:
return 'You are overweight.'
if bmi = 30:
return 'You are, I regret, obese.'



I hope that I am halfway correct.
With best wishes,
Sydney


--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


Re: [Tutor] BMI calc

2013-03-13 Thread Shall, Sydney

On 13/03/2013 12:21, Peter Otten wrote:

Shall, Sydney wrote:


I am also a newbie, but I wish to learn, so I offer the following
corrections.
# Note. I do note know what units you are using.
# I would use scientific, metric units. So you need to divide both
weight and height by a suitable conversion factors.
# Then you will not need the number 703.0, and the units in the second
and third lines would be Kg/m. [Kilogram/Metre)

def calc_BMI(weight,height):
  bmi = (weight/(height*height))*703.0
  print 'Your BMI is : ', BMI 'weight units/height units.' # You need

to put the correct text here.

  if bmi =18.5:
  print 'underweight'
  if  18.5 = bmi = 24.9:
  print 'normal weight'
  if  25.0 = bmi = 29.9:
  print 'overweight'
  if bmi = 30:
  print 'obese'
  return

A problem that I have not seen addressed yet:

What will this print for the guy who is 75.0 in high and weighs 200.0 lb?

His bmi is


height = 75.0
weight = 200.0
weight/(height*height)*703.0

24.995

That's neither normal nor overweight, according to your categorisation.

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



Yes, you are right, of course.
Thanks for reminding me that we are dealing with floats.
I should have used approximations, with an (epsilon) error range.
I will remember if future, I hope.

Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] following on

2013-02-19 Thread Shall, Sydney

On 19/02/2013 02:15, Steven D'Aprano wrote:hon modules.



Many people will advise that learning C is a good idea. I understand 
their arguments, but as an old curmudgeon I can say I don't like C and 
I think the world would be much better without it :-)




Does this comment extend to C++? :-)

Could the experts, please, recommend a beginner's book to learn the 
principles of good programming?


Ta muchly,

Sydney

--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-04 Thread Shall, Sydney

Dear David,
Many thanks for this information.
It was exactly what I needed.
It anyone wants Emacs editor for MAC OS X 10.6, this is the place to 
find it.


I would also like to say that I am deeply impressed with the knowledge 
and generosity of the people on this list.

Thanks.
Sydney




On 04/02/2013 14:58, David Rock wrote:

* Shall, Sydney sydney.sh...@kcl.ac.uk [2013-02-03 16:47]:

On 03/02/2013 13:13, Jonatán Guadamuz wrote:

El 03/02/2013, a las 06:53 a.m., Shall, Sydney
sydney.sh...@kcl.ac.uk escribió:


Dear Alan,
I installed Cocoa emacs successfully.
But it does not run on OS X 10.6.8.
The notes with it say that it was built for 10.4.
Where may I look for an update, please?
With many thanks for your help.
Sydney

Maybe you can look here

aquamacs.org

The first hit I get googling for cocoa emacs returns:
http://emacsformacosx.com/

Perhaps that will work for you.  I've tested that it works on my system,
at least (works = it ran).




--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-03 Thread Shall, Sydney

Dear Alan,
I installed Cocoa emacs successfully.
But it does not run on OS X 10.6.8.
The notes with it say that it was built for 10.4.
Where may I look for an update, please?
With many thanks for your help.
Sydney


On 02/02/2013 17:49, Alan Gauld wrote:

On 02/02/13 12:57, Shall, Sydney wrote:

Dear Aurelien,
Would you please explain how one installs GNU Emacs on a MAC using OS X
v10.6.


Last time I looked it was already installed. Just type emacs at a 
Terminal prompt.


You can also get a Cocoa version that run in a separate Window, try 
Google for Cocoa emacs...







--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-03 Thread Shall, Sydney



Thanks Jonatan.
Sydney


On 03/02/2013 13:13, Jonatán Guadamuz wrote:

El 03/02/2013, a las 06:53 a.m., Shall, Sydney
sydney.sh...@kcl.ac.uk escribió:


Dear Alan,
I installed Cocoa emacs successfully.
But it does not run on OS X 10.6.8.
The notes with it say that it was built for 10.4.
Where may I look for an update, please?
With many thanks for your help.
Sydney

Maybe you can look here

aquamacs.org




--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-02 Thread Shall, Sydney

Two free good text editors for the MAC are;
1. Komodo
2. Text Wrangler.
hth
Sydney



On 01/02/2013 17:11, Simon Yan wrote:




On Fri, Feb 1, 2013 at 9:18 PM, Dustin Guerri dustingue...@gmail.com 
mailto:dustingue...@gmail.com wrote:


Thanks for replying, Simon.  I have no particular reason to use
Xcode - what would you recommend instead ?

I would recommend start off from a simple text editor that has basic 
syntax highlighting features. There are a number of options out there.

TextMate is a good choice, a little pricy.
VIM, if you are a terminal guy
Even Python IDLE is a good choice you wanted to edit just a few simple 
.py files.


I would suggest give it a look in the Mac App Store and you will find 
a few other good ones too.




*Dustin Guerri*
Mobile : (+ 34) 625 857 967 tel:%28%2B%2034%29%20625%20857%20967
dustingue...@gmail.com mailto:dustingue...@gmail.com

LinkedIn
http://www.linkedin.com/profile/view?id=16395850trk=tab_pro

Contact me: Google Talk dustinguerri Skype dustinguerri
Get a signature like this.

http://r1.wisestamp.com/r/landing?promo=20dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20
CLICK HERE.

http://r1.wisestamp.com/r/landing?promo=20dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20



On 1 February 2013 13:05, Simon Yan simon...@fedoraproject.org
mailto:simon...@fedoraproject.org wrote:




On Thu, Jan 17, 2013 at 6:47 AM, Dustin Guerri
dustingue...@gmail.com mailto:dustingue...@gmail.com wrote:

Hi there,

I'm trying to create a plain text file called hello.py
with the following text :

print('hello world')
raw_input('Press any key to continue')

I'd then like to run this program with Python Launcher on
a Mac.

I'd lke to use Xcode as my text editor.  Once I have Xcode
open, which template should I use to input the text ?

I don't think there is a file type of Python that you can
create from Xcode.
Just curious, why would you want to use XCode as a Python editor?


Thanks,

*Dustin Guerri*
Mobile : (+ 34) 625 857 967
tel:%28%2B%2034%29%20625%20857%20967
dustingue...@gmail.com mailto:dustingue...@gmail.com |
www.vimeo.com/dustinguerri/pop
http://www.vimeo.com/dustinguerri/pop

LinkedIn
http://www.linkedin.com/profile/view?id=16395850trk=tab_pro
Contact me: Google Talk dustinguerri Skype dustinguerri
Get a signature like this.

http://r1.wisestamp.com/r/landing?promo=20dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20
CLICK HERE.

http://r1.wisestamp.com/r/landing?promo=20dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20


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




-- 
Regards,

YeeYaa (Simon Yan)

http://simonyan.fedorapeople.org/





--
Regards,
YeeYaa (Simon Yan)

http://simonyan.fedorapeople.org/


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



--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk

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


Re: [Tutor] First Python Test

2013-02-02 Thread Shall, Sydney

Text Wrangler is a free, cut-down version of BB-Edit, I think.
Sydney



On 02/02/2013 09:31, Jamie Griffin wrote:

* Simon Yan simon...@fedoraproject.org [2013-02-02 01:11:12 +0800]:


I would recommend start off from a simple text editor that has basic syntax
highlighting features. There are a number of options out there.
TextMate is a good choice, a little pricy.
VIM, if you are a terminal guy
Even Python IDLE is a good choice you wanted to edit just a few simple .py
files.

I would suggest give it a look in the Mac App Store and you will find a few
other good ones too.

I believe the editor of choice on Mac OS X these days is BBEdit -
again, a bit expensive. TextMate used to be good but there are
better ones out there now. Personally, I prefer the commandline
editors, vi or vim which is already installed on Mac OS X. I haven't
used the Xcode editor before but if it's what you're comfortable
with then it's probably best to stick with it.


Primary Key: 4096R/1D31DC38 2011-12-03
Key Fingerprint: A4B9 E875 A18C 6E11 F46D  B788 BEE6 1251 1D31 DC38
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor




--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-02 Thread Shall, Sydney

Dear Aurelien,
Would you please explain how one installs GNU Emacs on a MAC using OS X 
v10.6.
I cannot find a binary package. The GNU site seems to me to have only 
source code packages.

Mille fois merci.
Sydney


On 02/02/2013 09:54, Aurélien DESBRIÈRES wrote:

hmm ... you should use GNU Emacs, it's Free in price and license!

Extensible Text Editor with a cool Python-mode ;-)

Jamie Griffin ja...@kode5.net writes:


* Simon Yan simon...@fedoraproject.org [2013-02-02 01:11:12 +0800]:


I would recommend start off from a simple text editor that has basic syntax
highlighting features. There are a number of options out there.
TextMate is a good choice, a little pricy.
VIM, if you are a terminal guy
Even Python IDLE is a good choice you wanted to edit just a few simple .py
files.

I would suggest give it a look in the Mac App Store and you will find a few
other good ones too.

I believe the editor of choice on Mac OS X these days is BBEdit -
again, a bit expensive. TextMate used to be good but there are
better ones out there now. Personally, I prefer the commandline
editors, vi or vim which is already installed on Mac OS X. I haven't
used the Xcode editor before but if it's what you're comfortable
with then it's probably best to stick with it.


Primary Key: 4096R/1D31DC38 2011-12-03
Key Fingerprint: A4B9 E875 A18C 6E11 F46D  B788 BEE6 1251 1D31 DC38
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-02 Thread Shall, Sydney

You are correct, of course.
OK. So Bluefish is the Free open-source GNU editor and it is suitable 
for Python.

We will have a complete menagerie soon.
Thanks.
Sydney


On 02/02/2013 13:23, Aurélien DESBRIÈRES wrote:

Join #emacs on irc.freenode.net and ask them.

I do not bring any support for non free Operating System nor
BrainWashing ones ;-)

Shall, Sydney sydney.sh...@kcl.ac.uk writes:


Dear Aurelien,
Would you please explain how one installs GNU Emacs on a MAC using OS
X v10.6.
I cannot find a binary package. The GNU site seems to me to have only
source code packages.
Mille fois merci.
Sydney


On 02/02/2013 09:54, Aurélien DESBRIÈRES wrote:

hmm ... you should use GNU Emacs, it's Free in price and license!

Extensible Text Editor with a cool Python-mode ;-)

Jamie Griffin ja...@kode5.net writes:


* Simon Yan simon...@fedoraproject.org [2013-02-02 01:11:12 +0800]:


I would recommend start off from a simple text editor that has basic syntax
highlighting features. There are a number of options out there.
TextMate is a good choice, a little pricy.
VIM, if you are a terminal guy
Even Python IDLE is a good choice you wanted to edit just a few simple .py
files.

I would suggest give it a look in the Mac App Store and you will find a few
other good ones too.

I believe the editor of choice on Mac OS X these days is BBEdit -
again, a bit expensive. TextMate used to be good but there are
better ones out there now. Personally, I prefer the commandline
editors, vi or vim which is already installed on Mac OS X. I haven't
used the Xcode editor before but if it's what you're comfortable
with then it's probably best to stick with it.


Primary Key: 4096R/1D31DC38 2011-12-03
Key Fingerprint: A4B9 E875 A18C 6E11 F46D  B788 BEE6 1251 1D31 DC38
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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


Re: [Tutor] First Python Test

2013-02-02 Thread Shall, Sydney

Thanks for both your comments, Alan. I am wiser now.
Sydney

On 02/02/2013 17:50, Alan Gauld wrote:

On 02/02/13 15:27, Shall, Sydney wrote:


OK. So Bluefish is the Free open-source GNU editor and it is suitable
for Python.



No thats emacs.
Bluefish is an open source web editor(HTML, CSS etc).

It may support Python but its not an ideal IDE.





--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel  Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk


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