Re: [Tutor] using sudo pip install

2017-04-20 Thread Random832
On Thu, Apr 20, 2017, at 15:48, Mats Wichmann wrote:
> On 04/20/2017 01:24 PM, bruce wrote:
> > Hey guys..
> > 
> > Wanted to get thoughts?
> > 
> > On an IRC chat.. someone stated emphatically...
> > 
> > Never do a "sudo pip install --upgrade..."
> > 
> > The claim was that it could cause issues, enought to seriously
> > (possibly) damage the OS..
> > 
> > So, is this true??
> 
> It wouldn't be recommended... if your Python is packaged by your
> distribution, you really shouldn't mess with the parts that come with
> those packages.  The odds of breaking anything badly are probably low
> (especially if what you're upgrading are the typical two - pip and
> distutils), but still..

My mental model of pip had always been that it would maintain a parallel
site-packages directory in /usr/local, rather than messing with anything
in /usr (which belongs to the distribution packaging system). That's
certainly where any *newly*-installed packages seem to end up. Even
learning in general why using pip as root is a bad idea, I had still
thought this was the case. Why isn't it?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] using sudo pip install

2017-04-20 Thread Mats Wichmann
On 04/20/2017 01:24 PM, bruce wrote:
> Hey guys..
> 
> Wanted to get thoughts?
> 
> On an IRC chat.. someone stated emphatically...
> 
> Never do a "sudo pip install --upgrade..."
> 
> The claim was that it could cause issues, enought to seriously
> (possibly) damage the OS..
> 
> So, is this true??

It wouldn't be recommended... if your Python is packaged by your
distribution, you really shouldn't mess with the parts that come with
those packages.  The odds of breaking anything badly are probably low
(especially if what you're upgrading are the typical two - pip and
distutils), but still..

But there's an easy workaround if you want to experiment with newer
stuff, as well as isolate one set of installs from another so they don't
end up fighting over conflicting versions (foo wants bar 13.0 while baz
wants bar 14.0): use virtual environments.  You can safely install and
upgrade whatever you want into a virtualenv, because it's an isolated
location; if it messes up, you can just remove the whole thing and
there's no harm done.


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


[Tutor] using sudo pip install

2017-04-20 Thread bruce
Hey guys..

Wanted to get thoughts?

On an IRC chat.. someone stated emphatically...

Never do a "sudo pip install --upgrade..."

The claim was that it could cause issues, enought to seriously
(possibly) damage the OS..

So, is this true??
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visual Studio Community 2017

2017-04-20 Thread Rafael Knuth
> PyCharm :)

I dumped VS 2017, after testing several IDEs I am perfectly happy with
PyCharm EDU :) It comes with Python 3.5 and importing & working with
libraries like matplotlib is really, really easy. PyCharm EDU is a
very nice IDE for me as a student
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 13:43, Alan Gauld via Tutor wrote:

> So the 7th element becomes
> divmod(7) -> 2,1
> 
> ie. element 7 maps to the 2nd cell, element 1

That should of course be the 3rd cell (0 based), oops.


-- 
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] What are the few senarios of data science testing using Python

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 11:48, John R wrote:

> I am just trying to understand that how it is possible to
> frame test cases on data science projcets using python! 

Can you clarify what you mean by "data science" projects?
Do you mean projects built in Python and how to use, say, unittest with
that code?

Or do you mean using Python to write a test rig for a project
implemented in some other language - say Javascript or R or SQL?

-- 
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] Could anyone provide a complex data processing automation testing example

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 11:56, John R wrote:

> Most of the examples in google are looking simple in automation so I am not
> getting an understanding of  how a complex data processing application is
> to be tested using python. 

Is this a different question to the other one you posted?
If so in what way?

If not please only post once, remember it is email so can
take several hours to be delivered and the readership is
spread around multiple timezones so it can take more
hours for everyone to see it and respond.

> Can anyone please provide some real time
> examples for my understanding?

What do you mean by "real time"? Data science and real-time
are two disciplines that very rarely go together. Most data
science is done in batch or offline mode, the only real-time
bits might be updates or single point queries.

I don't really understand what you are looking for.

-- 
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] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 10:33, Phil wrote:

>> So, for a Suduko grid put 3x3 Entry boxes into a Frame.
>> Then put 3x3 such frames into another frame.
> 
> OK, so I'll go back to my original idea and use edit boxes. A grid of 9 x 9 
> edit boxes does actually work and it makes it easy to keep track of the 
> digits. The first digit is [0,0], the first digit on the second line is [1,0] 
> etc. 

Nine 3 x 3 boxes could add some complication to digit tracking.

Its not too bad you can map the large 9x9 table to the smaller units
using divmod()

So the 7th element becomes
divmod(7) -> 2,1

ie. element 7 maps to the 2nd cell, element 1
You can create a simple helper function that takes an x,y pair from
the 9x9 view and returns two pairs identifying the cell coordinates.

And having the smaller 3x3 cells works when checking that each 3x3
cell has the 9 unique numbers too.

> I did actually get my canvas version to the point where I could 
> enter digits into the cells but I had to enter them in sequence

Yes, that's exactly the kind of problems you hit and its a
terrible user experience. Far better to use the facilities
the GUI gives you for free. For example tab will move the
cursor from cell to cell etc.

> Thank you for the table example. I'm not sure what "tab = DisplayTable" 

It creates an instance of the table.

tab = DisplayTable(top,   # the containing widget/frame
  ["Left","Right"],   # table headings
  [[1,2], # The table data, 3x2 items
   [3,4],
   [5,6]],
  datacolor='green')  # the color used to draw the data

Note:
the constructor allows other colours to be specified too
such as the headings the grid lines and the cell background.
You may want to hard code those in a simplified version of
my class.


Hopefully when you run it you'll understand, especially
if you tweak the example instance options. For example
here is a full featured version:

tab = DisplayTable(top,
   ["Left","middle","Right"],
   [[1,2,1],
[3,4,3],
[5,6,5]],
   datacolor='blue',
   cellcolor='yellow',
   gridcolor='red',
   hdcolor='black')


If still confused drop a question here.


-- 
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] classproperty: readonly and inheritance - not more needed

2017-04-20 Thread Steven D'Aprano
On Thu, Apr 20, 2017 at 10:39:57AM +0200, Thomas Güttler wrote:

> >- its hard to get classproperty to work right.
> 
> What is "righ"?
> 
> In my case a read-only classproperty is enough. Inheritance should be 
> supported.
> 
> I don't have a usecase for a setter.

The standard library is not just for you :-)

If Peter's solution is "good enough" for you, then great, go ahead and 
use it. But beware: of the two implementations I know, you cannot have 
both:

- access from instances;
- read-only property;

You can have access from instances, but then the classproperty is not 
read-only. Or you can have read-only access, but only from the class 
object.

Although I haven't studied Eryksun's solution yet, he may have found a 
work-around.

Good luck!


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


[Tutor] Could anyone provide a complex data processing automation testing example

2017-04-20 Thread John R
Hi All,

Most of the examples in google are looking simple in automation so I am not
getting an understanding of  how a complex data processing application is
to be tested using python. Can anyone please provide some real time
examples for my
understanding?

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


[Tutor] classproperty: readonly and inheritance - not more needed

2017-04-20 Thread Thomas Güttler



Am 19.04.2017 um 11:16 schrieb Steven D'Aprano:

On Wed, Apr 19, 2017 at 09:28:26AM +0200, Thomas Güttler wrote:

[code for a classproperty]


Nice, if it is that simple.

Is there a reason why this is not in the standard library?


I haven't had a chance to test Peter's classproperty code yet, but I
don't expect it to be that simple. People have asked for it before, and
even Guido himself (the inventor of Python) has agreed that if it
existed he'd use it, but the proposals have (so far) always stumbled on
two factors:

- there are not a lot of uses for classproperty that ordinary property
  isn't "good enough" for;

- its hard to get classproperty to work right.


What is "righ"?

In my case a read-only classproperty is enough. Inheritance should be supported.

I don't have a usecase for a setter.

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


[Tutor] What are the few senarios of data science testing using Python

2017-04-20 Thread John R
Hi All,

I am just trying to understand that how it is possible to
frame test cases on data science projcets using python! could anyone
provide few sample real time senarios? I searched in google but couldnot
find anything suitable to my need. If anyone works on this type
of projects they can help me out


Thanks in advance,

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


[Tutor] classproperty, three times in virtualenv

2017-04-20 Thread Thomas Güttler



Am 19.04.2017 um 09:43 schrieb Alan Gauld via Tutor:

On 19/04/17 08:28, Thomas Güttler wrote:


Nice, if it is that simple.

Is there a reason why this is not in the standard library?


Probably because it is such a rare use case and because
its not that hard to do yourself if you really need it.

But the standard library, like any open source project,
develops as people need things. If nobody needs something
it will never be built and therefore never be added to
the library. I'd guess this falls into that category.


In my virtualenv it looks like it has three implementations. Maybe more with a 
different name.

user@host> find src/ lib/ -name '*.py'|xargs grep -Ei '(def|class) 
classproperty'

lib/python2.7/site-packages/logilab/common/decorators.py:class 
classproperty(object):
lib/python2.7/site-packages/django/utils/decorators.py:class 
classproperty(object):
lib/python2.7/site-packages/mptt/models.py:class classpropertytype(property):



Regards,
  Thomas


--
Thomas Guettler http://www.thomas-guettler.de/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter layout question

2017-04-20 Thread Phil
On Thu, 20 Apr 2017 09:27:27 +0100
Alan Gauld via Tutor  wrote:

> Eek! that's a recipe for premature baldness!

Baldness is not a problem, however, slowing the onset of dementia is the aim of 
this project.

> So, for a Suduko grid put 3x3 Entry boxes into a Frame.
> Then put 3x3 such frames into another frame.

OK, so I'll go back to my original idea and use edit boxes. A grid of 9 x 9 
edit boxes does actually work and it makes it easy to keep track of the digits. 
The first digit is [0,0], the first digit on the second line is [1,0] etc. Nine 
3 x 3 boxes could add some complication to digit tracking.

> Don't try to reinvent all of that yourself, it will
> result in tears. (Think about how you will control
> cursor movement, deletions, selections etc etc)

I did actually get my canvas version to the point where I could enter digits 
into the cells but I had to enter them in sequence so that the logic part of 
the program knew where the digits were. It was all becoming somewhat 
complicated.

Thank you for the table example. I'm not sure what "tab = DisplayTable" does at 
the moment, I'll have to run it to find out.

Thank you for your detailed answer, more food for though.

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


Re: [Tutor] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 19/04/17 23:48, Phil wrote:
> I created a 9 x 9 grid on a canvas which looks much better.

> I can display digits in the centre of the squares but 
> entering the digits from the keyboard seems to be beyond me.

Eek! that's a recipe for premature baldness!
Canvas is designed to display things not for user input.
Trying to read keypresses and the like is going to be very
hard to get right. Use the widgets that are designed for
that, namely Entry boxes.

As to layout, use Frames. Lots of frames.
Frames are the key to layout in most GUIs and especialy
so in Tkinter.

So, for a Suduko grid put 3x3 Entry boxes into a Frame.
Then put 3x3 such frames into another frame. Personally
I'd create a class to represent the 3x3 Entry frame
and then create 9 instances of these.

As to the spacing between widgets (the frames in
this case) use the various padx/pady and fill options.
You can have incredibly fine grained control over
layout using the tools that Tkinter gives you. If
you combine that with the different layout managers
(pack, grid,place) - which can be mixed and matched
as needed using more Frames - you have hugely
powerful control over layout.

Don't try to reinvent all of that yourself, it will
result in tears. (Think about how you will control
cursor movement, deletions, selections etc etc)

BTW I posted a simple display-only grid here a
few weeks ago. It might prove helpful as a basis
for the 3x3 cells so, here it is again:

try:
  import Tkinter as tk  # v2
except ImportError:
  import tkinter as tk  # v3

class DisplayTable(tk.Frame):
def __init__(self, parent, headings, data,
 hdcolor='red', datacolor='black',
 gridcolor= 'black', cellcolor='white'):
tk.Frame.__init__(self, parent, bg=gridcolor)

if len(headings) != len(data[0]): raise ValueError
self.headings = headings

for index,head in enumerate(headings):
width = len(str(head))
cell = tk.Label(self,text=str(head),
bg=cellcolor, fg=hdcolor, width=width)
cell.grid(row=0,column=index, padx=1, pady=1)

for index,row in enumerate(data):
self.addRow(index+1,row,datacolor,cellcolor)

def addRow(self, row, data, fg='black', bg='white'):
for index, item in enumerate(data):
width = len(str(self.headings[index]))
cell = tk.Label(self,text=str(item),
fg=fg, bg=bg, width=width)
cell.grid(row=row, column=index, padx=1,pady=1)


if __name__ == "__main__":
top = tk.Tk()
tab = DisplayTable(top,
   ["Left","Right"],
   [[1,2],
[3,4],
[5,6]],
   datacolor='green')
tab.pack()
top.mainloop()



-- 
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] Tkinter layout question

2017-04-20 Thread Palm Tree
for entering digits on the canva i think better create a sort of sudoku
generator and display it on the canva in a create_text object.

On 20 Apr 2017 05:24, "Phil"  wrote:

> I'm looking for ideas here.
>
> A working solution for my sudoku solver is a 9 x 9 grid of entry boxes but
> it looks a bit basic. So I created a 9 x 9 grid on a canvas which looks
> much better. I can display digits in the centre of the squares but entering
> the digits from the keyboard seems to be beyond me. I experimented with
> entering a digit at the mouse location but it all seems to be too
> complicated. Perhaps someone can offer a repetitively simple solution?
>
> A second experiment involved the earlier grid of entry boxes but with a
> space between every third row and column. This seems to be more achievable,
> eventually.
>
> Something along these lines:
>
> for i in range(9):
> if i % 4 == 0:
> place a blank text label
> else:
> place an entry box
>
> So, how might I enter digits into a grid on a canvas or how could I create
> a space between a grid entry boxes?
>
> --
> Regards,
> Phil
> ___
> 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] Tkinter layout question - solved

2017-04-20 Thread Phil
On Wed, 19 Apr 2017 22:21:28 -0500

Just to save people answering this question unnecessarily I have solved the 
immediate problem. I can now enter a digit at the mouse coordinates. Some 
refinement is still necessary.

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


Re: [Tutor] Tkinter layout question

2017-04-20 Thread Phil
On Wed, 19 Apr 2017 22:21:28 -0500
boB Stepp  wrote:

Thank you Bob and Palm for your replies. They have given me something more tto 
think about.
ideas
> I don't know (now) how to solve your challenges below.  But if I were
> trying to figure this out, I would try to find more complex tkinter
> example applications

I have searched the Internet for hours looking for a game example. Most 
examples demonstrate the use of specific widgets including the canvas and 
frames but not in a class context. Putting the pieces together is difficult but 
I will persevere.

A reference book full of examples is the obvious way to go I suppose. However, 
it is difficult me to manage paper books because the space they take up and 
their weight. I do have one general Python e-book but following the few 
examples is tedious to the nth degree because the text of the examples is so 
small that I need a magnifying glass to read them.

Anyway, maybe I can justify one book, I'll give it some thought. The massive 
tome by Lutz comes to mind.

I'll give your keyboard entry suggestion some more thought.

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