what's the big deal for print()

2011-06-24 Thread pipehappy
Hi,

Why people want print() instead of print str? That's not a big deal
and the old choice is more natural. Anyone has some clue?
-- 
http://mail.python.org/mailman/listinfo/python-list


come back and find python 3

2011-02-26 Thread pipehappy
Hi, all

Just come back to use Python, but find something has changed in Python
3.
Like package name is no longer with capitalized char for each word in
the name;
convenient print is removed.

And I don't know why can someone inside explain
to me about this. I think old package name is better for read while
new is better
to code. And old print is good tool for new comers.

Any other notable change between this 2 version? Or is there links to
articles
about the changes not in a developer view but a user view?

Best

-- 
http://mail.python.org/mailman/listinfo/python-list


maybe this is a print odds

2006-11-05 Thread pipehappy
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!

-- 
http://mail.python.org/mailman/listinfo/python-list


about Python types and objects

2006-07-15 Thread pipehappy
Hi everyone:

I have read the booth python types and objects.  I think its book for
clearificating types and objects in python.  It says there will be a
book named python attributes and methods.  Do you know any information
about this book.  I am interested in it.

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


check type when assignment

2006-07-12 Thread pipehappy
Hello everyone:

Is there a way to check the type when do assignment?

if I write:
ab = bc
and want to make sure the return value of isinstance(bc, klass) is True
or I will raise
a exception.

Any suggestion?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use images at the bachground?

2006-07-11 Thread pipehappy
 hi all,
 how to get out of the python shell which is executing a command?
 how to use images in the background of a page in Tkinter?

on Unix, ctrl-c or ctrl-d may do the job.
on Windows, ctrl-z will do

-- 
http://mail.python.org/mailman/listinfo/python-list


know reference name in instance

2006-07-07 Thread pipehappy
Hello:

Is it possible for an instance know its name used by other part of
program.  I mean like this:

class test:
def __init__(self):
pass

when some one writes

x = test()

then one of attribute of x contain the name x

Is it possible?

I expect someone can tell me how to do it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: know reference name in instance

2006-07-07 Thread pipehappy

Fredrik Lundh wrote:

 pipehappy wrote:

  Is it possible for an instance know its name used by other part of
  program.  I mean like this:
 
  class test:
  def __init__(self):
  pass
 
  when some one writes
 
  x = test()
 
  then one of attribute of x contain the name x
 
  Is it possible?

 not really.

 and what should happen if you do, say

 x = test()
 y = x

I may choose the name when the class is initialized, other may choose
the newest name. It depends.
 or

 x = [test(), test(), test()]

 ?
None may be the good answer here.

 for more on this, see:

 http://pyfaq.infogami.com/how-can-my-code-discover-the-name-of-an-object

 /F
Yes, You are right. But variety of condition is not necessary
prohibiting the promotion of such question but provides the possibility
for different answer. So is there some way I can ask the environment to
tell me the name? 

With respect, I read your words and it's great.

-- 
http://mail.python.org/mailman/listinfo/python-list


error in ConfigParser

2006-06-27 Thread pipehappy
Hello everyone:

I came across the module ConfigParser and can use it correctly.

import ConfigParser
fp = open('test.cfg','w+')
config = ConfigParser.ConfigParser()
config.readfp(fp)
config.add_section('test')
config.set('test', 'haha', 'hehe')
print config.sections()
config.write(fp)

['test']
Traceback (most recent call last):
  File configparser.py, line 8, in ?
config.write(fp)
  File C:\Python24\lib\ConfigParser.py, line 369, in write
fp.write([%s]\n % section)
IOError: (0, 'Error')

I trace into the module and when executing the line fp.write([%s]\n
% section), I find every parameter is correct: fp is still a open file
object and section is 'test', I may miss something, but I just cannot
figure it out. Can someone tell me what's going wrong here?

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


how to tell the version of tk shipped with Python

2005-12-29 Thread pipehappy
I am a newbie to the Python and wonder how I can know version of tk
bound with Python

Can some one tell me?

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list