Hi, I've strange problem with using zfill in python scripts in Zope. My script is simple: -------------- import string outa = str1.zfill(6) return outa -------------- str1 is a parameter given by interface. Running the script gives me: Error Type: AttributeError Error Value: 'str' object has no attribute 'zfill' I understand the meaning of the error but why it's happening? Others functions like: outa = str1.upper() works great. Zope is in version 2.6.1 and Python in 2.2.1. Regards, -- Adam Szpakowski Silesian University of Technology - Institute of Physics Department of Optoelectronic e-mail: worf@optics.polsl.gliwice.pl
Adam, try import string return string.zfill(outa,6) David ----- Original Message ----- From: "Adam Szpakowski" <worf@optics.polsl.gliwice.pl> To: <zope@zope.org> Sent: Saturday, June 07, 2003 2:31 PM Subject: [Zope] problem with zfill
Hi,
I've strange problem with using zfill in python scripts in Zope.
My script is simple: -------------- import string outa = str1.zfill(6) return outa --------------
str1 is a parameter given by interface.
Running the script gives me:
Error Type: AttributeError Error Value: 'str' object has no attribute 'zfill'
I understand the meaning of the error but why it's happening?
Others functions like: outa = str1.upper() works great.
Zope is in version 2.6.1 and Python in 2.2.1.
Regards,
-- Adam Szpakowski Silesian University of Technology - Institute of Physics Department of Optoelectronic e-mail: worf@optics.polsl.gliwice.pl
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Sunday 08 of June 2003 00:28, David Hassalevris wrote:
try import string return string.zfill(outa,6)
It's no use. Same error. Beside in my example "outa" was intended to be an output string adn "str1" an input one. So if zfill() is the method for string type (same as upper()) the form: "11".zfill(5) should give "00011". But it still gives an error. Reagards, -- Adam Szpakowski Silesian University of Technology - Institute of Physics Department of Optoelectronic e-mail: worf@optics.polsl.gliwice.pl
Adam Szpakowski wrote:
"11".zfill(5) should give "00011". But it still gives an error.
The zfill method wasn't added to str types until python 2.2.2b1. http://python.org/2.2.2/NEWS.txt -- Jamie Heilman http://audible.transient.net/~jamie/ "Most people wouldn't know music if it came up and bit them on the ass." -Frank Zappa
On Sunday 08 of June 2003 10:32, Jamie Heilman wrote:
The zfill method wasn't added to str types until python 2.2.2b1. http://python.org/2.2.2/NEWS.txt
Thanks... that seems to be a solution to my problem. Regards, -- Adam Szpakowski Silesian University of Technology - Institute of Physics Department of Optoelectronic e-mail: worf@optics.polsl.gliwice.pl
zfill does not appear to be string method for the new syle (Python 2.X) strings. It is in the string module and so is accessed by import string string.zfill(string, width) In this case, zfill('11',5) produces '00011'. This works for me in a Python Script with Zope 2.5.1 and Python 2.1.3. On Sun, 8 Jun 2003, Adam Szpakowski wrote:
On Sunday 08 of June 2003 00:28, David Hassalevris wrote:
try import string return string.zfill(outa,6)
It's no use. Same error. Beside in my example "outa" was intended to be an output string adn "str1" an input one. So if zfill() is the method for string type (same as upper()) the form: "11".zfill(5) should give "00011". But it still gives an error.
Reagards,
-- Adam Szpakowski Silesian University of Technology - Institute of Physics Department of Optoelectronic e-mail: worf@optics.polsl.gliwice.pl
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Adam Szpakowski -
David Hassalevris -
Dennis Allison -
Jamie Heilman