Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Point Object

Reply
Thread Tools

Point Object

 
 
pjmulla@googlemail.com
Guest
Posts: n/a
 
      01-05-2008
I am nes to python and need some help. Can anyone lead me in the
right direction to create and print a Point object, and then use id to
print the object's unique identifier. Translate the hexadecimal form
into decimal and confirm that they match.

Any help woul be much appreciated.

Pete
 
Reply With Quote
 
 
 
 
Marc 'BlackJack' Rintsch
Guest
Posts: n/a
 
      01-05-2008
On Sat, 05 Jan 2008 03:37:33 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> I am nes to python and need some help. Can anyone lead me in the
> right direction to create and print a Point object, and then use id to
> print the object's unique identifier. Translate the hexadecimal form
> into decimal and confirm that they match.


The right direction would be the tutorial in the docs I guess:

http://docs.python.org/tut/tut.html

What do you mean by the "hexadecimal form"? `id()` returns ordinary
`int`\s and not strings.

Ciao,
Marc 'BlackJack' Rintsch
 
Reply With Quote
 
 
 
 
Soviut
Guest
Posts: n/a
 
      01-06-2008
On Jan 5, 6:37 am, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:
> I am nes to python and need some help. Can anyone lead me in the
> right direction to create and print a Point object, and then use id to
> print the object's unique identifier. Translate the hexadecimal form
> into decimal and confirm that they match.
>
> Any help woul be much appreciated.
>
> Pete


You shouldn't have to compare the hex IDs. Just a simple comparison
operator will work:

firstPoint = Point()
secondPoint = Point()
print(firstPoint == secondPoint)

result: True
 
Reply With Quote
 
bearophileHUGS@lycos.com
Guest
Posts: n/a
 
      01-06-2008
Pete:
> Translate the hexadecimal form
> into decimal and confirm that they match.


No need to convert the IDs...


Soviut:
> You shouldn't have to compare the hex IDs. Just a simple comparison
> operator will work:
>
> firstPoint = Point()
> secondPoint = Point()
> print(firstPoint == secondPoint)
>
> result: True


Remember about __eq__ and "is":

class Foo:
def __init__(self, x):
self.x = x
def __eq__(self, other):
return self.x == other.x

f1 = Foo(1)
f2 = Foo(2)
f3 = Foo(2)
f4 = f3
print f1 == f2, f1 is f2 # False False
print f2 == f3, f2 is f3 # True False
print f3 == f4, f3 is f4 # True True

Bye,
bearophile
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
point to point protocol Gopi VHDL 1 07-13-2004 02:37 PM
help, please!! cisco 827H point per point configuration javi Cisco 1 10-16-2003 07:33 AM



Advertisments