Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Allan Tanaka via Tutor
I try to access it with http://0.0.0.0:8000/chart.html via Google Chrome, 
FireFox, and Opera.I don't think the python code is the problem right, or? 

On Saturday, 18 February 2017, 16:36, Alan Gauld via Tutor 
 wrote:
 

 
Please don't repeat post. We saw it the first time.
Please do post again with the extra information requested.

On 18/02/17 04:46, Allan Tanaka via Tutor wrote:
> Not completely sure why it doesn't open the chart on the web browser when i 
> type this in the windows command prompt (cmd) python -m SimpleHTTPServer port 
> 80.So first i type python ml.py data/sample.csv in cmd windows and then 
> python -m SimpleHTTPServer port 80, but it's not proceeding to the graph in 
> html??
> See attached image for screenshoot and complete .py file

One extra piece of information is how do you try to access the chart?
What url are you typing into ytour browser?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


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


[Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Pooja Bhalode
Hi,

The following code creates a list of checkboxes (each associated with
different variables) for the user to select from, after having selected the
ones that user wants, I am trying to add the selected variables to another
list so that the selected variables can be accessed later in the code.
However, when I try appending to the new list, it gets appended as PY_VAR
instead of the variable name associated.
Can someone please let me know where I am going wrong. I would really
appreciate it.
Thank you

Pooja
Code given below:

keqparam = IntVar()
delHrxnparam = IntVar()
kfparam = IntVar()
Afparam = IntVar()
ksimparam = IntVar()
Aparam = IntVar()
RAparam = IntVar()
RCparam = IntVar()

total_number_parameters = IntVar()
selectedparam = []
checkboxVars = [keqparam, delHrxnparam, kfparam, Afparam, ksimparam,
Aparam, RAparam, RCparam]

def EstimateParameters():
print "EstimateParameters"
paramroot = Toplevel(root)
paramroot.title("Selection of Parameters to be estimated")
def SelectAll():
for var in checkboxVars:
var.set(1)
def DeselectAll():
for var in checkboxVars:
var.set(0)

Button(paramroot, text = "Select all", command = SelectAll).grid(row = 0,
column = 2, sticky = W)
Button(paramroot, text = "Deselect all", command = DeselectAll).grid(row =
0, column = 3, sticky = W)
Label(paramroot, text = "Select all the parameters to be estimated:
").grid(row = 0, column = 0, sticky = W)
sticklabel = Label(paramroot, text = "1. Reversible reaction001")
sticklabel.grid(row = 1, column = 0, sticky = W)
Label(paramroot, text = u"\t A + B \u21cc D").grid(row = 3, column = 0,
sticky = W)
Checkbutton(paramroot, text = "K_eq", variable = keqparam).grid(row = 2,
column = 1, sticky = W)
Checkbutton(paramroot, text = u"\u0394Hrxn", variable =
delHrxnparam).grid(row = 3, column = 1, sticky = W)
Checkbutton(paramroot, text = "K_f", variable = kfparam).grid(row = 4,
column = 1, sticky = W)
Checkbutton(paramroot, text = "Eact_f", variable = Afparam).grid(row = 5,
column = 1, sticky = W)

sticklabel = Label(paramroot, text = "2. Simple reaction001")
sticklabel.grid(row = 10, column = 0, sticky = W)
Label(paramroot, text = u"\t A + C \u2192 E").grid(row = 12, column = 0,
sticky = W)
Checkbutton(paramroot, text = "Rate of reaction (k)", variable =
ksimparam).grid(row = 11, column = 1, sticky = W)
Checkbutton(paramroot, text = "Act Energy (A)", variable = Aparam).grid(row
= 12, column = 1, sticky = W)
Label(paramroot, text = "Order of reaction:").grid(row = 13, column=1,
sticky = W)
Checkbutton(paramroot, text = "Reactant A", variable = RAparam).grid(row =
13, column = 2, sticky = W)
Checkbutton(paramroot, text = "Reactant C", variable = RCparam).grid(row =
14, column = 2, sticky = W)

def SubmitParam():
global total_number_parameters
total_number_parameters = RCparam.get() + RAparam.get() + Aparam.get() +
ksimparam.get() + Afparam.get() + kfparam.get() + delHrxnparam.get() +
keqparam.get()
print total_number_parameters

for i in range(len(checkboxVars)):
if checkboxVars[i].get() == 1:
print checkboxVars[i]
selectedparam.append(checkboxVars[i])

print selectedparam


Button(paramroot, text = "Submit", command = SubmitParam).grid(row = 17,
column = 3, sticky =W)


butt1 = Button(explorer, text = "Parameters to be estimated",width = 15,
command = EstimateParameters)
butt1.pack(side = TOP)
butt1.config(font=("",9))

The highlighted area is where I am checking if the checkbutton is selected
and if selected, I am trying to append the variable name in the list
checkboxVar to the new list-selectedparam.

however, when I try to print selectedparam, I get the following output:
[, ]
And when I try to print out checkboxVar[i] which is just above the previous
line, I get PY_VAR2
PY_VAR3

Can someone please let me know where I am going wrong?

Thankyou

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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 02:44, Allan Tanaka via Tutor wrote:
> I try to access it with http://0.0.0.0:8000/chart.html via Google Chrome, 

> On 18/02/17 04:46, Allan Tanaka via Tutor wrote:
>> Not completely sure why it doesn't open the chart on the web browser 
>> when i type this in the windows command prompt (cmd)
>> python -m SimpleHTTPServer port 80.

First that should give an error... The syntax should be:

python -m SimpleHTTPServer 80

Which should then print a message like:

Serving HTTP on 0.0.0.0 port 80 ...

Second, you are starting the web server using port 80
but you are trying to access it using port 8000. You need
to change the server startup command or change the url
so that they match.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 03:06, Pooja Bhalode wrote:
> The following code creates a list of checkboxes

It would really help uif you posted in plain text.
The HTML/RTF is getting very hard to read with
no indentation.

> ones that user wants, I am trying to add the selected variables to another
> list so that the selected variables can be accessed later in the code.
> However, when I try appending to the new list, it gets appended as PY_VAR
> instead of the variable name associated.

> keqparam = IntVar()
> delHrxnparam = IntVar()
> kfparam = IntVar()
> Afparam = IntVar()
> ksimparam = IntVar()
> Aparam = IntVar()
> RAparam = IntVar()
> RCparam = IntVar()
> 
> total_number_parameters = IntVar()
> selectedparam = []

> checkboxVars = [keqparam, delHrxnparam, kfparam, Afparam, ksimparam,
> Aparam, RAparam, RCparam]
...

> def SubmitParam():
> global total_number_parameters
> total_number_parameters = RCparam.get() + RAparam.get() + Aparam.get() +
> ksimparam.get() + Afparam.get() + kfparam.get() + delHrxnparam.get() +
> keqparam.get()
> print total_number_parameters

I assume this works OK and you see the correct value printed?

> for i in range(len(checkboxVars)):
> if checkboxVars[i].get() == 1:
> print checkboxVars[i]
> selectedparam.append(checkboxVars[i])

So here you append an IntVar object.


How does an IntVar show up in a ptrint?

>>> from Tkinter import *
>>> top = Tk()
>>> v = IntVar()
>>> print(v)
PY_VAR0

Which is what you see. You need to use get() to get the value:

>>> print v.get()
0
>>>

> however, when I try to print selectedparam, I get the following output:
> [,  0x104829128>]
> And when I try to print out checkboxVar[i] which is just above the previous
> line, I get PY_VAR2
> PY_VAR3

Hopefully the reasons are now clear? You are seeing Python's
descriptions of the objects. To see the values you need to
use the get() method.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Allan Tanaka via Tutor
I have changed the syntax to be python -m SimpleHTTPServer 8000 to match my  ml 
python script.Still it doesn't work? Scracthing my head...See attached file for 
screenshoots


 

On Monday, 27 February 2017, 16:54, Alan Gauld via Tutor  
wrote:
 

 On 27/02/17 02:44, Allan Tanaka via Tutor wrote:
> I try to access it with http://0.0.0.0:8000/chart.html via Google Chrome, 

> On 18/02/17 04:46, Allan Tanaka via Tutor wrote:
>> Not completely sure why it doesn't open the chart on the web browser 
>> when i type this in the windows command prompt (cmd)
>> python -m SimpleHTTPServer port 80.

First that should give an error... The syntax should be:

python -m SimpleHTTPServer 80

Which should then print a message like:

Serving HTTP on 0.0.0.0 port 80 ...

Second, you are starting the web server using port 80
but you are trying to access it using port 8000. You need
to change the server startup command or change the url
so that they match.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


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


Re: [Tutor] UDP client

2017-02-27 Thread Phil

On 26/02/17 19:41, Peter Otten wrote:


Try

buf.decode("utf-8")


Thank you once again Peter.

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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:13, Allan Tanaka via Tutor wrote:
> I have changed the syntax to be python -m SimpleHTTPServer 8000 
> to match my  ml python script. Still it doesn't work?

Define "doesn't work"?

What happens? Do you see an error message - if so which one?
What happens if you use the base url?

http://0.0.0.0:8000

Do you get a list of files?
Is your chart.html listed? What happens if you click on the link?

The more specific information you give us the easier it is
for us to help you.

> Scracthing my head...See attached file for screenshoots

This is a text  based server it strips out binary
attachments as potential security risks. Cut 'n
paste the text instead.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 03:06, Pooja Bhalode wrote:

> for i in range(len(checkboxVars)):
> if checkboxVars[i].get() == 1:
>print checkboxVars[i]
>selectedparam.append(checkboxVars[i])

As a point of Pythonic style this would be better
written (and easier to read) as

for var in checkboxVars:
   if var.get() == 1:
  print var.get()
  selectedparam.append(var)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:24, Alan Gauld via Tutor wrote:
> On 27/02/17 10:13, Allan Tanaka via Tutor wrote:
>> I have changed the syntax to be python -m SimpleHTTPServer 8000 
>> to match my  ml python script. Still it doesn't work?

A couple of other things to check:

1) does check.html exist and have the content you
expect? What happens if you open it in Notepad say?

2) Does it have the right permissions to be opened
by the web server? Is it readable by users other
than yourself?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Allan Tanaka via Tutor
After typing python -m SimpleHTTPServer 8000 in CMD then i proceed to my google 
chrome and type http://allan-pc:8000/
That's where Directory listing for/
Then i proceed to http://allan-pc:8000/chart.html No chart image 
whatsoever...Blank webpageIn command prompt, the message after i type python -m 
SimpleHTTPServer 8000 is:Serving HTTP on 0.0.0.0 port 8000192.168.100.6 - - 
[27/Feb/2017 17.36.53] "GET / HTTP/1.1" 200 -

 

On Monday, 27 February 2017, 17:25, Alan Gauld via Tutor  
wrote:
 

 On 27/02/17 10:13, Allan Tanaka via Tutor wrote:
> I have changed the syntax to be python -m SimpleHTTPServer 8000 
> to match my  ml python script. Still it doesn't work?

Define "doesn't work"?

What happens? Do you see an error message - if so which one?
What happens if you use the base url?

http://0.0.0.0:8000

Do you get a list of files?
Is your chart.html listed? What happens if you click on the link?

The more specific information you give us the easier it is
for us to help you.

> Scracthing my head...See attached file for screenshoots

This is a text  based server it strips out binary
attachments as potential security risks. Cut 'n
paste the text instead.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


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


[Tutor] Learning Objectives?

2017-02-27 Thread Leam Hall
Is there a list of Python skill progression, like "Intermediates should 
know  and Advanced should know ?" Trying to map out 
a well rounded study list.


Thanks!

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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Allan Tanaka via Tutor
Yes chart.html is listed but when clicked it, the page doesn't show anything. 
Just blank.In command prompt, the message after i clicked chart.html is like 
this:Serving HTTP on 0.0.0.0 port 8000192.168.100.6 - - [27/Feb/2017 
17.36.53] "GET / HTTP/1.1" 200 - 

On Monday, 27 February 2017, 17:40, Allan Tanaka  
wrote:
 

 After typing python -m SimpleHTTPServer 8000 in CMD then i proceed to my 
google chrome and type http://allan-pc:8000/
That's where Directory listing for/
Then i proceed to http://allan-pc:8000/chart.html No chart image 
whatsoever...Blank webpageIn command prompt, the message after i type python -m 
SimpleHTTPServer 8000 is:Serving HTTP on 0.0.0.0 port 8000192.168.100.6 - - 
[27/Feb/2017 17.36.53] "GET / HTTP/1.1" 200 -

 

On Monday, 27 February 2017, 17:25, Alan Gauld via Tutor  
wrote:
 

 On 27/02/17 10:13, Allan Tanaka via Tutor wrote:
> I have changed the syntax to be python -m SimpleHTTPServer 8000 
> to match my  ml python script. Still it doesn't work?

Define "doesn't work"?

What happens? Do you see an error message - if so which one?
What happens if you use the base url?

http://0.0.0.0:8000

Do you get a list of files?
Is your chart.html listed? What happens if you click on the link?

The more specific information you give us the easier it is
for us to help you.

> Scracthing my head...See attached file for screenshoots

This is a text  based server it strips out binary
attachments as potential security risks. Cut 'n
paste the text instead.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


   

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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:40, Allan Tanaka via Tutor wrote:
> After typing python -m SimpleHTTPServer 8000 in CMD 
> then i proceed to my google chrome and type http://allan-pc:8000/

OK, But to be safe I'd probably stick to 0.0.0.0 rather than your PC
name - it eliminates routing errors from the equation.

> That's where Directory listing for/

And did you see chart.html in that listing?

> Then i proceed to http://allan-pc:8000/chart.html 

How did you "proceed"?
Did you click the link in the directorty listing
or did you type it in by hand?

> No chart image whatsoever...Blank webpage

And have you checked that chart.htm is not empty
and that the html is valid?

What happens if you hand craft an html file and
try accessing that?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Allan Tanaka via Tutor
- And did you see chart.html in that listing?
Yes it's there
- How did you "proceed"?
Did you click the link in the directorty listing
or did you type it in by hand?
I click the link in directory listing
have you checked that chart.htm is not empty and that the html is valid?
As i click the chart.htm, it doesn't show anything. Just blank. Does it mean 
that i have checked chart.htm is not empty?
What happens if you hand craft an html file and try accessing that?If i type 
0.0.0.0:8000/chart.html, then the error is like this:
This site can’t be reached
The webpage at http://0.0.0.0:8000/chart.html might be temporarily down or it 
may have moved permanently to a new web address.ERR_ADDRESS_INVALID
 

On Monday, 27 February 2017, 18:11, Alan Gauld via Tutor  
wrote:
 

 On 27/02/17 10:40, Allan Tanaka via Tutor wrote:
> After typing python -m SimpleHTTPServer 8000 in CMD 
> then i proceed to my google chrome and type http://allan-pc:8000/

OK, But to be safe I'd probably stick to 0.0.0.0 rather than your PC
name - it eliminates routing errors from the equation.

> That's where Directory listing for/

And did you see chart.html in that listing?

> Then i proceed to http://allan-pc:8000/chart.html 

How did you "proceed"?
Did you click the link in the directorty listing
or did you type it in by hand?

> No chart image whatsoever...Blank webpage

And have you checked that chart.htm is not empty
and that the html is valid?

What happens if you hand craft an html file and
try accessing that?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


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


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 11:22, Allan Tanaka wrote:
> - And did you see chart.html in that listing?
> Yes it's there
>
> - How did you "proceed"?
> Did you click the link in the directorty listing
> or did you type it in by hand?
> I click the link in directory listing

OK, It looks like the server side is working OK.
That takes us back to the file itself.

> have you checked that chart.htm is not empty and that the html is valid?
> As i click the chart.htm, it doesn't show anything. Just blank.
> Does it mean that i have checked chart.htm is not empty?

No it just means the file exists but does not display. There are several
possible
reasons for that...

First, while it is displaying(or not!) in the browser right click and
choose
the "view source" option to see what the browser sees.

Next check that the file is not empty. The easiest way is to open in a
text editor such as Notepad - I'm guessing you use Windows?

Do you see any content?
Does it look like HTML

Second check that the file allows users to read its contents - check its
security permissions that it has read access.

Finally check that the html is valid. by running it through your favourite
html validator - for example htmltidy. You can find online validators
via google.

See how that goes.

-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

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


Re: [Tutor] Learning Objectives?

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:44, Leam Hall wrote:
> Is there a list of Python skill progression, like "Intermediates should 
> know  and Advanced should know ?" Trying to map out 
> a well rounded study list.

I'm not aware of such a list, and I'm not sure it's of much value.
Better to just learn what you need and use it. When you need
to learn more, learn it. The worst thing you can do is study an
arbitrary list of topics that don't have any relevance to
the problems you need to solve!

Nobody is going to ask for an intermediate programmer, or a
beginner programmer. They might ask for an expert, but if you
are really an expert you will know that already - and you
won't be able to become one by studying anything extra.

Once you are past the basics - ie. you can write a program
that does something useful, it's all about writing code and
learning as you go. And you never stop learning.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Learning Objectives?

2017-02-27 Thread leam hall
On Mon, Feb 27, 2017 at 9:28 AM, Alan Gauld via Tutor 
wrote:

> On 27/02/17 10:44, Leam Hall wrote:
> > Is there a list of Python skill progression, like "Intermediates should
> > know  and Advanced should know ?" Trying to map out
> > a well rounded study list.
>
> I'm not aware of such a list, and I'm not sure it's of much value.
> Better to just learn what you need and use it. When you need
> to learn more, learn it. The worst thing you can do is study an
> arbitrary list of topics that don't have any relevance to
> the problems you need to solve!
>
> Nobody is going to ask for an intermediate programmer, or a
> beginner programmer. They might ask for an expert, but if you
> are really an expert you will know that already - and you
> won't be able to become one by studying anything extra.
>
> Once you are past the basics - ie. you can write a program
> that does something useful, it's all about writing code and
> learning as you go. And you never stop learning.
>
>
> Hey Alan!

When I was coming up as a Linux guy I took the old SAGE guidelines and
studied each "level" in turn. It was useful for making me a well-rounded
admin and helped me put off some higher end stuff I wasn't really ready
for.

Things like Testing and documentation are useful, but only learning what
seems to bee needed for this one project seems harder for the new coder.
Most of us didn't know TDD was useful until we started doing it. Same for
documentation. It's sort of the "if we hired a junior or senior coder, what
basics would we want them to know?"

Thanks!

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


[Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Stephen P. Molnar

I had sent the following message to Anaconda Support:

I have just installed anaconda3-4.3.0 and upgraded Spyder to v-3.1.3.

When I open Spyder and run a python script that has run perfectly in a 
previous  version of Spyder I get the results that I expect,but with 
'Kernel died, restarting' and I get a new iPython console prompt. Also a 
popup that asks 'Do  you want to close this console?'.  If I answer 'No' 
I get the following in the Internal Console:



Spyder Internal Console

This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
  spy.app, spy.window, dir(spy)

Please don't use it to run your code

>>> WARNING:traitlets:kernel restarted
Traceback (most recent call last):
  File 
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/base_frontend_mixin.py", 
line 163, in _dispatch

handler(msg)
  File 
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/widgets/ipythonconsole/namespacebrowser.py", 
line 192, in _handle_execute_reply

super(NamepaceBrowserWidget, self)._handle_execute_reply(msg)
  File 
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/jupyter_widget.py", 
line 184, in _handle_execute_reply

super(JupyterWidget, self)._handle_execute_reply(msg)
  File 
"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/frontend_widget.py", 
line 492, in _handle_execute_reply

self._request_info['execute'].pop(msg_id)
KeyError: '50af986d-2e5c-4cef-aef4-827370619c86'

Very strange, and most annoying.

I received an answer:

I know a solution for this problem. I guess you are using Kaspersky 
product. You need to add "python.exe", and "pythonw.exe" of Anaconda 
specific into Exclusions list and make them trusted applications.



Where would I find such a list?  There is no mention of such a list in 
the Debian Handbook and a Google search didn't find anything that I 
could see would apply to solution to this problem.  Nothing I found 
about the Kaspersky product told me where (or how) to find an exclusion 
list.


I'm hoping that kind sole on this list can help em solve this problem.

Thanks in advance.

--
Stephen P. Molnar, Ph.D.Life is a fuzzy set
www.molecular-modeling.net  Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Marc Tompkins
On Mon, Feb 27, 2017 at 10:46 AM, Stephen P. Molnar 
wrote:

> I had sent the following message to Anaconda Support:
>
> I have just installed anaconda3-4.3.0 and upgraded Spyder to v-3.1.3.
>
> When I open Spyder and run a python script that has run perfectly in a
> previous  version of Spyder I get the results that I expect,but with
> 'Kernel died, restarting' and I get a new iPython console prompt. Also a
> popup that asks 'Do  you want to close this console?'.  If I answer 'No' I
> get the following in the Internal Console:
>
>
> Spyder Internal Console
>
> This console is used to report application
> internal errors and to inspect Spyder
> internals with the following commands:
>   spy.app, spy.window, dir(spy)
>
> Please don't use it to run your code
>
> >>> WARNING:traitlets:kernel restarted
> Traceback (most recent call last):
>   File 
> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/base_frontend_mixin.py",
> line 163, in _dispatch
> handler(msg)
>   File "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyde
> r/widgets/ipythonconsole/namespacebrowser.py", line 192, in
> _handle_execute_reply
> super(NamepaceBrowserWidget, self)._handle_execute_reply(msg)
>   File 
> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/jupyter_widget.py",
> line 184, in _handle_execute_reply
> super(JupyterWidget, self)._handle_execute_reply(msg)
>   File 
> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/frontend_widget.py",
> line 492, in _handle_execute_reply
> self._request_info['execute'].pop(msg_id)
> KeyError: '50af986d-2e5c-4cef-aef4-827370619c86'
>
> Very strange, and most annoying.
>
> I received an answer:
>
> I know a solution for this problem. I guess you are using Kaspersky
> product. You need to add "python.exe", and "pythonw.exe" of Anaconda
> specific into Exclusions list and make them trusted applications.
>
>
> Where would I find such a list?  There is no mention of such a list in the
> Debian Handbook and a Google search didn't find anything that I could see
> would apply to solution to this problem.  Nothing I found about the
> Kaspersky product told me where (or how) to find an exclusion list.
>
>
With the usual caveats that your question isn't Python-specific, here's the
page from Kaspersky's website on how to create exclusions:
https://support.kaspersky.com/2695#block2

But: are you actually running Kaspersky Antivirus on a Debian machine?
Nothing wrong with that if so, but it's pretty unusual.  If not, then you
need to push the Anaconda people a bit harder for ideas.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Marc Tompkins
On Mon, Feb 27, 2017 at 12:52 PM, Stephen P. Molnar 
wrote:

> On 02/27/2017 02:29 PM, Marc Tompkins wrote:
>
>> On Mon, Feb 27, 2017 at 10:46 AM, Stephen P. Molnar
>> mailto:s.mol...@sbcglobal.net>> wrote:
>>
>> I had sent the following message to Anaconda Support:
>>
>> I have just installed anaconda3-4.3.0 and upgraded Spyder to v-3.1.3.
>>
>> When I open Spyder and run a python script that has run perfectly in
>> a previous  version of Spyder I get the results that I expect,but
>> with 'Kernel died, restarting' and I get a new iPython console
>> prompt. Also a popup that asks 'Do  you want to close this
>> console?'.  If I answer 'No' I get the following in the Internal
>> Console:
>>
>>
>> Spyder Internal Console
>>
>> This console is used to report application
>> internal errors and to inspect Spyder
>> internals with the following commands:
>>spy.app, spy.window, dir(spy)
>>
>> Please don't use it to run your code
>>
>>  >>> WARNING:traitlets:kernel restarted
>> Traceback (most recent call last):
>>File
>> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtcon
>> sole/base_frontend_mixin.py",
>> line 163, in _dispatch
>>  handler(msg)
>>File
>> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyde
>> r/widgets/ipythonconsole/namespacebrowser.py",
>> line 192, in _handle_execute_reply
>>  super(NamepaceBrowserWidget, self)._handle_execute_reply(msg)
>>File
>> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtcon
>> sole/jupyter_widget.py",
>> line 184, in _handle_execute_reply
>>  super(JupyterWidget, self)._handle_execute_reply(msg)
>>File
>> "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtcon
>> sole/frontend_widget.py",
>> line 492, in _handle_execute_reply
>>  self._request_info['execute'].pop(msg_id)
>> KeyError: '50af986d-2e5c-4cef-aef4-827370619c86'
>>
>> Very strange, and most annoying.
>>
>> I received an answer:
>>
>> I know a solution for this problem. I guess you are using Kaspersky
>> product. You need to add "python.exe", and "pythonw.exe" of Anaconda
>> specific into Exclusions list and make them trusted applications.
>>
>>
>> Where would I find such a list?  There is no mention of such a list
>> in the Debian Handbook and a Google search didn't find anything that
>> I could see would apply to solution to this problem.  Nothing I
>> found about the Kaspersky product told me where (or how) to find an
>> exclusion list.
>>
>>
>> With the usual caveats that your question isn't Python-specific, here's
>> the page from Kaspersky's website on how to create exclusions:
>> https://support.kaspersky.com/2695#block2
>>
>> But: are you actually running Kaspersky Antivirus on a Debian machine?
>> Nothing wrong with that if so, but it's pretty unusual.  If not, then
>> you need to push the Anaconda people a bit harder for ideas.
>>
>
>
> To the best of my knowledge I am not running any anti-virus software. This
> has always been a Linux computer and there has been no need.
>
> In fact, this has only happened since I had to reinstall Debian v8.5 and
> all of the upgrades.
>
>
In that case, their answer was completely irrelevant to your problem.  I'm
afraid I don't know Anaconda at all, nor the Spyder IDE, so I really don't
have any insight - and, since this is the Python Tutor list, I don't know
whether anyone else here will either.  The Anaconda Community is probably
your best bet:
https://www.continuum.io/anaconda-community

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


Re: [Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Stephen P. Molnar

On 02/27/2017 02:29 PM, Marc Tompkins wrote:

On Mon, Feb 27, 2017 at 10:46 AM, Stephen P. Molnar
mailto:s.mol...@sbcglobal.net>> wrote:

I had sent the following message to Anaconda Support:

I have just installed anaconda3-4.3.0 and upgraded Spyder to v-3.1.3.

When I open Spyder and run a python script that has run perfectly in
a previous  version of Spyder I get the results that I expect,but
with 'Kernel died, restarting' and I get a new iPython console
prompt. Also a popup that asks 'Do  you want to close this
console?'.  If I answer 'No' I get the following in the Internal
Console:


Spyder Internal Console

This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
   spy.app, spy.window, dir(spy)

Please don't use it to run your code

 >>> WARNING:traitlets:kernel restarted
Traceback (most recent call last):
   File

"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/base_frontend_mixin.py",
line 163, in _dispatch
 handler(msg)
   File

"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/widgets/ipythonconsole/namespacebrowser.py",
line 192, in _handle_execute_reply
 super(NamepaceBrowserWidget, self)._handle_execute_reply(msg)
   File

"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/jupyter_widget.py",
line 184, in _handle_execute_reply
 super(JupyterWidget, self)._handle_execute_reply(msg)
   File

"/home/comp/Apps/anaconda3/lib/python3.6/site-packages/qtconsole/frontend_widget.py",
line 492, in _handle_execute_reply
 self._request_info['execute'].pop(msg_id)
KeyError: '50af986d-2e5c-4cef-aef4-827370619c86'

Very strange, and most annoying.

I received an answer:

I know a solution for this problem. I guess you are using Kaspersky
product. You need to add "python.exe", and "pythonw.exe" of Anaconda
specific into Exclusions list and make them trusted applications.


Where would I find such a list?  There is no mention of such a list
in the Debian Handbook and a Google search didn't find anything that
I could see would apply to solution to this problem.  Nothing I
found about the Kaspersky product told me where (or how) to find an
exclusion list.


With the usual caveats that your question isn't Python-specific, here's
the page from Kaspersky's website on how to create exclusions:
https://support.kaspersky.com/2695#block2

But: are you actually running Kaspersky Antivirus on a Debian machine?
Nothing wrong with that if so, but it's pretty unusual.  If not, then
you need to push the Anaconda people a bit harder for ideas.



To the best of my knowledge I am not running any anti-virus software. 
This has always been a Linux computer and there has been no need.


In fact, this has only happened since I had to reinstall Debian v8.5 and 
all of the upgrades.


--
Stephen P. Molnar, Ph.D.Life is a fuzzy set
www.molecular-modeling.net  Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Learning Objectives?

2017-02-27 Thread Mats Wichmann
On 02/27/2017 07:57 AM, leam hall wrote:

> When I was coming up as a Linux guy I took the old SAGE guidelines and
> studied each "level" in turn. It was useful for making me a well-rounded
> admin and helped me put off some higher end stuff I wasn't really ready
> for.
> 
> Things like Testing and documentation are useful, but only learning what
> seems to bee needed for this one project seems harder for the new coder.
> Most of us didn't know TDD was useful until we started doing it. Same for
> documentation. It's sort of the "if we hired a junior or senior coder, what
> basics would we want them to know?"
> 
> Thanks!
> 
> Leam

Just as a suggestion,

I think if you look at the curriculum of various training courses,
books, online tutorial series you will get each author's view of what a
logical progression is. There are probably as many different
progressions as there are people expressing an opinion, but it seems to
me the flow is at least roughly aligned when I glance at these from time
to time.

For example (this is no endorsement, just a site I do peer at now and
then and so remember it), look here:

http://www.python-course.eu/python3_course.php

the left bar has a kind of order that's not insane (except I'd be
looking at files in the first 10 minutes, but that's just me); then
there's a tab called "advanced topics": forking, threads, etc. and then
some stuff you look at if you need it: wsgi, mod_python, sql connectors.
And then another tab for a great big "external" topics like NumPy,
Machine Learning and there are lots more in that category like Django,
Flask, SciPy, and so on - all can be considered "advanced" because
they're not the language itself, but stuff some people might expect you
to be proficient in for a given job that's billed as a "Python Job".

If you're looking at abstract base classes in your first few days,
that's probably not the right order ;)

I even have a bit of a bone to pick with the TDD movement, not that it's
a bad idea by itself, but when treated as a "religion" it seems to lead
to a mindset that unit tests alone are sufficient to prove a codebase,
when integration testing is just as important.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Help with this question

2017-02-27 Thread Johnny Hh
write a python function called find_most_freq() that returns the element of
a given list that occurs the most frequently. If there are ties, take the
number found first.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 20:52, Stephen P. Molnar wrote:

> To the best of my knowledge I am not running any anti-virus software. 
> This has always been a Linux computer and there has been no need.

There are threats to Linux just fewer of them, plus you could
be used as a host to pass on damaged files so you probably
should run an AV program at least periodically. Clam is a
popular option.

But that aside, Marc is right this has nothing to do with the
focus of this mailing list so you are more likely to get responses
back on the Anaconda list. Just be sure to point outyou are on
Linux with no active AV software running.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


[Tutor] feedback on simple python code

2017-02-27 Thread Ryan Smith
Hi all,

New python student here. I have been using O¹reilly¹s "Python Beyond the
Basics: Object Oriented Programming video series". In one of the
assignments we are to write a simple inheritance hierarchy of three
classes that write to text files. I have actually written the code for the
assignment and it runs as well as meets the requirements of the
assignment. I am posting to get feedback on how I can improve this and
making it more pythonic and concise.

Please keep in mind that I am simply ³simulating" writing to a log file
and a tabbed delimited file, so I¹m not necessarily looking for which
modules I could have to create actual log files or writing to actual csv
files. The output of the code should be two text files with text written
to them that have been passed to the instance of each respective object.

#!/usr/bin/env python

import abc
import datetime

class WriteFile(object):
__metaclass__ = abc.ABCMeta


@abc.abstractmethod
def write(self,text):
"""Write to file"""
return 


class LogFile(WriteFile):
def __init__(self,fh):
self.fh = fh


def write(self, text):
date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
entry = "{0} {1}{2}".format(date, text, '\n')
with open(self.fh, 'a') as f:
f.write(entry)

class DelimWrite(WriteFile):
def __init__(self, fh, delim):
self.fh = fh
self.delim = delim


def write(self, text):
with open(self.fh, 'a') as f:
entry = ""
for item in text:
if self.delim in item:
entry += ' "{0}"{1} '.format(item,self.delim)
else:
entry += item+self.delim
f.write(entry.strip(self.delim) + '\n')




if __name__ == "__main__":


log = LogFile('log.txt')
log.write('This is a log message')
log.write('This is another log message')


d = DelimWrite('test.csv',',')
d.write([Œ1¹,¹2¹,¹3¹])
d.write(['a','this, that','c¹])#Double quote item if delimiter
included as list item
d.write([Œbasketball¹,'football¹,'golfball'])




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


Re: [Tutor] Learning Objectives?

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 14:57, leam hall wrote:

>> I'm not aware of such a list, and I'm not sure it's of much value.
>> Better to just learn what you need and use it. ...

> When I was coming up as a Linux guy I took the old SAGE guidelines and
> studied each "level" in turn. It was useful for making me a well-rounded
> admin and helped me put off some higher end stuff I wasn't really ready
> for.

Its an individual choice, so if it works for you don't let
me stop you :-) But I still don't know of any such list.

> documentation. It's sort of the "if we hired a junior or senior coder, what
> basics would we want them to know?"

That's the thing. I've never, in 40 years in IT, seen
anyone advertise for a junior programmer. Just doesn't seem to
happen. It's a bit like having a headache and asking for a
weak pain killer...

There are places offered for programming apprenticeships,
but they assume you are starting from scratch.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] Help with this question

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 22:00, Johnny Hh wrote:
> write a python function called find_most_freq() that returns the element of
> a given list that occurs the most frequently. If there are ties, take the
> number found first.

OK, You've shown us the exercise, now show us your attempt at a solution.

Here is a starter:

def find_most_freq():
# your code here
return element

Now show us how you think you fill that in. Or tell us where
and how you are stuck.



-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: [Tutor] feedback on simple python code

2017-02-27 Thread Danny Yoo
Hi Ryan,

Let's take a look...

Overloading the "write" method to take in different types of arguments
looks a bit suspicious.


You have a superclass that defines a write method, and you have two
subclasses that implement that method.  However, your first
implementation, LogFile.write, appears to take in a string, while the
second, DelimWrite.write,  appears to take a list of strings.

That's what looks somewhat problematic.  According to inheritance
rules, the methods of subclasses should be able to take the same kind
of input as specified in the superclass.  You can read more about this
in https://en.wikipedia.org/wiki/Liskov_substitution_principle, but
it's roughly saying that if you have a superclass, subclass methods
should do their thing on the same kind of data.  Violating this can
lead to code that is hard to understand.

To solve this: I'd recommend normalizing the input if you have that
option.  If you can make the input always be a list of strings, that
would be one way to resolve this problem.  Alternatively, if you can
make the input always be a single string, then that would solve this
problem too.


Please feel free to ask questions.  Good luck!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor