Re: [Tutor] "Path tree"

2017-08-17 Thread Abdur-Rahmaan Janhangeer
in addition to the answers i'd say now you have the motivation to learn
python data structures and algorithms

http://interactivepython.org/runestone/static/pythonds/index.html

barnum and miller

it is free though i have not found a good pdf book form from where to
download, but you have the site anyway !

Now, the website has more materials than when i first knew it.

hope it helps !

Abdur-Rahmaan Janhangeer,
Mauritius
abdurrahmaanjanhangeer.wordpress.com

On 14 Aug 2017 02:28, "Michael C"  wrote:

Hi all:

I am trying to formulate a "path-finding" function, and I am stuck on this
problem:

Please look at the picture attached: Those dots are coordinates of (x,y),
and this tree can be thought of as a list of tuples, with each tuple
consisting of (x,y).  Now I am trying to make a function go through this
list of tuples and then return the "path." to go from, say, 4 to 8. If I
simply compute for the dot for shortest distance, then the solution would
be to go from 4 to 8 direct, but that doesn't work, because the correct
solution should have been 4,3,2,5,6,8.


How do I do this?

Thanks!
___
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] "Path tree"

2017-08-17 Thread Michael C
Ok, I will work with all these. Thx all!

On Aug 16, 2017 20:22, "Abdur-Rahmaan Janhangeer" 
wrote:

> in addition to the answers i'd say now you have the motivation to learn
> python data structures and algorithms
>
> http://interactivepython.org/runestone/static/pythonds/index.html
>
> barnum and miller
>
> it is free though i have not found a good pdf book form from where to
> download, but you have the site anyway !
>
> Now, the website has more materials than when i first knew it.
>
> hope it helps !
>
> Abdur-Rahmaan Janhangeer,
> Mauritius
> abdurrahmaanjanhangeer.wordpress.com
>
> On 14 Aug 2017 02:28, "Michael C"  wrote:
>
> Hi all:
>
> I am trying to formulate a "path-finding" function, and I am stuck on this
> problem:
>
> Please look at the picture attached: Those dots are coordinates of (x,y),
> and this tree can be thought of as a list of tuples, with each tuple
> consisting of (x,y).  Now I am trying to make a function go through this
> list of tuples and then return the "path." to go from, say, 4 to 8. If I
> simply compute for the dot for shortest distance, then the solution would
> be to go from 4 to 8 direct, but that doesn't work, because the correct
> solution should have been 4,3,2,5,6,8.
>
>
> How do I do this?
>
> Thanks!
> ___
> 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] Long post: Request comments on starting code and test code on chess rating project.

2017-08-17 Thread Neil Cerutti
On 2017-08-16, boB Stepp  wrote:
> On Tue, Aug 15, 2017 at 12:29 PM, Alan Gauld via Tutor
>  wrote:
>> On 15/08/17 15:09, Neil Cerutti wrote:
 There are a variety of reports that I would like to be able
 to print to screen or paper.  Things such as a "Top x List"
 of rated players, full rating list sorted from highest
 rating to lowest, rating lists for the current school year
 only or a particular past school year, and so.  ...
>>
>>> You really can do it, but to me this requirement argues for
>>> going back to a database backend. Why rewrite SQL?
>
> I just thought this would be an interesting problem type to
> tackle. No intentions of reinventing SQL!

If you think it'll be fun or interesting, that's a plenty good
reason to do it yourself. On the other hand, practicing the
Python DB-API can be fun and profitable, too. As a near total
neophyte to SQL and databases, attaining the skill of
incoporating sqlite3 into my Python projects took me a couple of
years of on/off again practice. But it has since saved me a ton
of effort.

-- 
Neil Cerutti

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


Re: [Tutor] Tutor Digest, Vol 162, Issue 42

2017-08-17 Thread Howard Lawrence
On Aug 17, 2017 3:17 AM,  wrote:

Send Tutor mailing list submissions to
tutor@python.org

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

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

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

Today's Topics:

   1. Object takes no parameters (Howard Lawrence)
   2. Re: (no subject) (Zachary Ware)
   3. Re: Object takes no parameters (Alan Gauld)
   4. Re: (no subject) (Alan Gauld)
   5. Re: "Path tree" (Abdur-Rahmaan Janhangeer)
   6. Re: "Path tree" (Michael C)


-- Forwarded message --
From: Howard Lawrence <1019sh...@gmail.com>
To: tutor@python.org
Cc:
Bcc:
Date: Wed, 16 Aug 2017 17:08:47 -0700
Subject: [Tutor] Object takes no parameters
class Human:
 def _init_(self, n, o)
  self.name = n
  self.occupation = o

 def do_work(self):
 if self.occupation== 'tennis player':
print(self.name, 'plays tennis')

 elif self.occupation == 'actor':
print(self.name, 'shoots film')

 def speaks(self):
 print(self.name, 'how are you')

tom = Human('tom cruise', 'actor')
tom.do_work()
tom.speak()

Traceback most recent call last
File "c:\users\shaun\python\python35\human_class.py"line 16 in module
tom =Human('tom cruise', 'actor')
TypeError: object() takes no parameters

how to fix this?why it happens?
this happens whenever i try to do
class,this is from a tutorial



-- Forwarded message --
From: Zachary Ware 
To: tutor 
Cc: Howard Lawrence <1019sh...@gmail.com>
Bcc:
Date: Wed, 16 Aug 2017 20:02:23 -0500
Subject: Re: [Tutor] (no subject)
Hi Howard,

On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com>
wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):

Your issue is in this line, it should be `__init__` rather than
`_init_` (that is, two underscores before and after "init").

Hope this helps,
--
Zach



-- Forwarded message --
From: Alan Gauld 
To: tutor@python.org
Cc:
Bcc:
Date: Thu, 17 Aug 2017 02:11:43 +0100
Subject: Re: [Tutor] Object takes no parameters
On 17/08/17 01:08, Howard Lawrence wrote:
> class Human:
>  def _init_(self, n, o)
>   self.name = n
>   self.occupation = o
>

>
> tom = Human('tom cruise', 'actor')
>
> Traceback most recent call last
> File "c:\users\shaun\python\python35\human_class.py"line 16 in module
> tom =Human('tom cruise', 'actor')
> TypeError: object() takes no parameters
>
> how to fix this?why it happens?

If you look closely at your tutorial you will find that init()
has two underscores before and after the name:

def __init__()

rather than

def _init_()

The reason for your error is that all classes inherit from object.
So when you call Human() the interpreter looks for an __init__()
method and, not finding one(because yours only has one undercore),
it looks at the one defined in object. But the object init()
takes no parameters and so there is a mismatch between your
call to Human() and the object.__init__() definition.
Hence the error message.

To fix it use two underscores.

All of the "magic" methods used by Python have these double
underscores and  hence are often referred to as "dunder" methods.
You should avoid defining any new methods (ie new names) with
double underscores yourself, in case Python introduces  a
similar method in a future version.

HTH
--
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





-- Forwarded message --
From: Alan Gauld 
To: tutor@python.org
Cc:
Bcc:
Date: Thu, 17 Aug 2017 02:16:19 +0100
Subject: Re: [Tutor] (no subject)
On 16/08/17 23:36, Howard Lawrence wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):
>   self.HsNunber=Hs
>   self.Street=St
>   self.Town=Town
>   self.Zip=Zip
> Addr=Address (7, ' high st', 'anytown', ' 123 456')

That looks suspiciously like my tutorial ;-)

The answer is to use two underscores around init():

def __init__(...)

not

def _init_(...)

This is explained in more detail in a box at the end
of the data topic:

http://www.alan-g.me.uk/l2p/tutdata.htm

--
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


Hey it worked, two underscore did the job, :-) , it's your tutorial! so
look out there is more to come!.. thanks for your help


-- Forwarded message --
From: Abdur-Rahmaan Janhangeer 
To: Michael C 
Cc: tutor 
Bcc:
Date: Thu, 17 Aug 2017

[Tutor] Help....

2017-08-17 Thread edmundo pierre via Tutor
I am trying to write a code to solve a system of equation at 2 variables. I 
used Tkinter to do it. I disigned everything, but I am just stocked when it 
comes to display the answer on the screen. 
That is the error I am having:   

Exception in Tkinter callbackTraceback (most recent call last):  File 
"C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py",
 line 1699, in __call__    return self.func(*args)  File 
"C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\ed.py", line 122, in 
Calculate    z = np.linalg.solve ( a, b)  File 
"C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\linalg\linalg.py",
 line 375, in solve    r = gufunc(a, b, signature=signature, extobj=extobj)  
File 
"C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\linalg\linalg.py",
 line 90, in _raise_linalgerror_singular    raise LinAlgError("Singular 
matrix")numpy.linalg.linalg.LinAlgError: Singular matrix

Hope to get help. Thank you!
Edwin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2017-08-17 Thread Howard Lawrence
Yes, it does.

On Aug 16, 2017 8:02 PM, "Zachary Ware" 
wrote:

Hi Howard,

On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com>
wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):

Your issue is in this line, it should be `__init__` rather than
`_init_` (that is, two underscores before and after "init").

Hope this helps,
--
Zach


Thanks it worked! Stick around, more to come
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2017-08-17 Thread Mats Wichmann
On 08/17/2017 05:45 AM, Howard Lawrence wrote:
> Yes, it does.
> 
> On Aug 16, 2017 8:02 PM, "Zachary Ware" 
> wrote:
> 
> Hi Howard,
> 
> On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com>
> wrote:
>> class Address:
>> def _init_(self,Hs,St,Town,Zip):
> 
> Your issue is in this line, it should be `__init__` rather than
> `_init_` (that is, two underscores before and after "init").
> 
> Hope this helps,


I would add that typography in a web browser, and sometimes even on the
printed page, may not make the double underscores ('dunder') actually
clearly look like two characters, so until one runs into this lesson The
Hard Way, it might be an easy mistake to make.


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


Re: [Tutor] Tutor Digest, Vol 162, Issue 42

2017-08-17 Thread Alan Gauld via Tutor
On 17/08/17 12:43, Howard Lawrence wrote:
> On Aug 17, 2017 3:17 AM,  wrote:
...
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."

Please follow the instructions. Change the subject line.
And don't post the entire digest, it's hard to find the
new content and everyone has already seen the messages.
And some people pay by the byte so it costs them money.
It is a good way to get people to stop reading your posts...

> Hey it worked, two underscore did the job, :-) , it's your tutorial! so
> look out there is more to come!.. thanks for your help

No problem, but if you read it closely it says that you
need two underscores both in the original section and
in the extra box at the end.

The double underscore issue is probably the most common
issue beginners have with that code so I tried to
emphasise it! Maybe I need to emphasise it in bold :-)

-- 
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....

2017-08-17 Thread Alan Gauld via Tutor
On 17/08/17 14:17, edmundo pierre via Tutor wrote:
> I am trying to write a code to solve a system of equation at 2 variables. 

> I used Tkinter to do it. 

More significantly you used numpy to do it and that seems
to be where the issues lie, not in Tkinter.

Numpy is part of SciPy which has a dedicated support forum

> I disigned everything, but I am just stocked when it> comes to display the 
> answer on the screen.

I'm not sure how you are using Tkinter here because you didn't
send any code but looking at the traceback your code is
getting called by Tkinter somehow.

That aside, the real issue seems to be here:

> File "C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\ed.py", 
> line 122, in Calculate
> z = np.linalg.solve ( a, b)  

> File 
> "C:\Users\edwin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\linalg\linalg.py",
>  
> line 90, in _raise_linalgerror_singular
> raise LinAlgError("Singular matrix") numpy.linalg.linalg.LinAlgError: 
> Singular matrix

I have no idea how the numpy stuff works but it looks like a data error,
maybe you are passing the wrong type?

But we'd need to see where 'a' and 'b' come from to be sure.

BTW its probably a bad idea to put your code (ed.py) inside the Python
folder structure, better to have a separate work space for your own
files. Especially if you install another version of Python and
want your code to work with it too.

-- 
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