473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Point Object

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
Jan 5 '08 #1
3 1894
On Sat, 05 Jan 2008 03:37:33 -0800, pj*****@googlemail.com 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
Jan 5 '08 #2
On Jan 5, 6:37 am, "pjmu...@googlemail.com" <pjmu...@googlemail.com>
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
Jan 6 '08 #3
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
Jan 6 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Piotre Ugrumov | last post by:
How can I implement a function that calculate the coordinates of a point, in 3 dimensional space? The function take 6 value (x, y, z, v(velocity), corner alfa, corner beta). The prototype is...
1
by: ypjofficial | last post by:
Dear All, According to OOPs , a base class pointer can to point to derived class object....call this as fact1 But somehow I am not comfortable while understanding this concept. The explanaition...
42
by: x-pander | last post by:
Is is guaranteed, that a pointer to any object in C points exactly at the lowest addressed byte of this object? Specifcally is it possible for any platform/os/compiler combination that: (char...
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
1
by: Bilo | last post by:
Need Help with System.Drawing.Point b = new System.Drawing.Point(int x , int y) I want to move a window when mous is down and mous is moving private void label1_MouseMove(object sender,...
2
by: Phil Galey | last post by:
I'm trying to create a Point object and set it at X = 0.5, Y = 0.5. I've tried the following two ways: -------------------------------------------------------- Dim pt as new...
5
by: pcnerd | last post by:
I want to create a program that will do graphics like math functions & fractals & stuff. I've been browsing thru books at the bookstores. Apparently, the Point object replaced Pset. The books...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
4
by: Roger Frost | last post by:
I need to draw a single point with WPF but there doesn't seem to be a class that represents the most fundamental geometric object. Any idea's? -- Roger Frost "Logic Is Syntax Independent"
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.