473,387 Members | 1,721 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.

maybe this is a print odds

I come this code:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>class He(object):
.... def __str__(self):
.... return "He"
....
>>hes = [He(),He(),He()]
print hes
[<__main__.He object at 0x00BE92D0>, <__main__.He object at
0x00BE9370>, <__main
__.He object at 0x00BE93B0>] # I expect output: [He,He,He]
>>print hes[0]
He
>>>
Do anyone know trick to overcome this or python has some proposal to
extend print that can do iterately print? I just want to get the way of
print which I my guess. Thanks a lot!

Nov 5 '06 #1
1 1019
pipehappy wrote:
I come this code:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>>class He(object):
... def __str__(self):
... return "He"
...
>>>hes = [He(),He(),He()]
print hes
[<__main__.He object at 0x00BE92D0>, <__main__.He object at
0x00BE9370>, <__main
__.He object at 0x00BE93B0>] # I expect output: [He,He,He]
>>>print hes[0]
He
>>>>

Do anyone know trick to overcome this or python has some proposal to
extend print that can do iterately print? I just want to get the way of
print which I my guess. Thanks a lot!
Lists print their items via repr(), not str():
>>class Ho(object):
.... def __str__(self):
.... return "That's a bit early, don't you think?"
.... def __repr__(self):
.... return "Ho"
....
>>print [Ho()] * 3
[Ho, Ho, Ho]
>>print Ho()
That's a bit early, don't you think?

Peter
Nov 5 '06 #2

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

Similar topics

4
by: James | last post by:
Hello All, I have a stored procedure which will act like a main/controller script which will then invoke more stored procedures (~20). Basically, it looks something like below: -- start...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
1
by: siva prasad | last post by:
hello, i have an appplication in which when i click a button then all the odds in a website are to be displayed. so i need Regular Expressions for identifing the odds.i am in the learner stage of...
1
by: Mamatha | last post by:
Hi I want to write regular expression for odds which related to sports in VB.NET. But i don't know how to write regular expression for odds. If anyone knows the solution or any related urls...
8
by: Grant Edwards | last post by:
How do you print a numpy array? I tried the obvious print a, print `a`, and print str(a), but none of them work on anything other than trivially small arrays. Most of my real data is elided and...
4
by: hardieca | last post by:
Has anyone heard of an open-source .NET engine that calculates the winning and losing percentages of hands? Regards, Chris
2
by: casscass | last post by:
hi, im having trouble with a java program. i need to know how to display only the odd numbers using a simple while loop. the user has to enter a number greater than or equal to 1 for example, i...
31
by: melinama | last post by:
Hello, I've looked through alt.html and this group for an answer to my question. However, I found only cranky arguments with, occasionally, bits of hard-to-understand code - out of context -...
8
by: highroller152 | last post by:
Not to step on anyone, but in reference to this thread on summing odds and evens, why not just use the 'continue' statement? So adding up the odds would look something like this: -on some event-...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.