Re: [Tutor] ASCII-Art circles, was Re: Why are expressions not allowed as parameters in function definition statements?

2016-06-20 Thread boB Stepp
On Mon, Jun 20, 2016 at 3:36 AM, Peter Otten <__pete...@web.de> wrote: > I'm now really sorry that I wrote that comment. It should have been > something like > > # I know that the following code is inefficient and produces > # underwhelming results. As its only purpose is to illustrate > # the vie

[Tutor] ASCII-Art circles, was Re: Why are expressions not allowed as parameters in function definition statements?

2016-06-20 Thread Peter Otten
boB Stepp wrote: > I have (Finally!) gotten a bit of time to look at Peter's answer to my > Model-View-Controller question from May 29th, particularly his > CircleImageView class to which he added a "#FIXME" comment. I'm now really sorry that I wrote that comment. It should have been something l

Re: [Tutor] ascii to/from AL32UTF8 conversion

2015-11-23 Thread Steven D'Aprano
On Sun, Nov 22, 2015 at 11:19:17PM -0500, bruce wrote: > Hi. > > Doing a 'simple' test with linux command line curl, as well as pycurl > to fetch a page from a server. > > The page has a charset of >>AL32UTF8. I had never heard of that before, so I googled for it. No surprise, it comes from Or

[Tutor] ascii to/from AL32UTF8 conversion

2015-11-22 Thread bruce
Hi. Doing a 'simple' test with linux command line curl, as well as pycurl to fetch a page from a server. The page has a charset of >>AL32UTF8. Anyway to conert this to straight ascii. Python is throwing a notice/error on the charset in another part of the test.. The target site is US based, so

Re: [Tutor] ASCII Conversion

2012-01-31 Thread Joel Goldstick
On Tue, Jan 31, 2012 at 4:06 AM, Russel Winder wrote: > On Tue, 2012-01-31 at 07:33 +0200, Christian Witts wrote: >> [...]o with >> `type(y) == int`, and to get the ASCII value of a character you can use >> `ord` like `ord('a') == 97`. And how to avoid your ValueError with a bad >> conversion, do

Re: [Tutor] ASCII Conversion

2012-01-31 Thread Russel Winder
On Tue, 2012-01-31 at 07:33 +0200, Christian Witts wrote: > [...]o with > `type(y) == int`, and to get the ASCII value of a character you can use > `ord` like `ord('a') == 97`. And how to avoid your ValueError with a bad > conversion, do your type checking before hand. isinstance ( y , int )

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Peter Otten
Peter Otten wrote: > if isint and y < -1 or y > 1: Sorry, I forgot the parentheses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Peter Otten
Michael Lewis wrote: > I am trying to do a simple test but am not sure how to get around ASCII > conversion of characters. I want to pass in y have the function test to > see if y is an integer and print out a value if that integer satisfies the > if statement. However, if I pass in a string, it's

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Blockheads Oi Oi
On 31/01/2012 05:33, Christian Witts wrote: On 2012/01/31 06:50 AM, Michael Lewis wrote: I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer sa

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Christian Witts
On 2012/01/31 06:50 AM, Michael Lewis wrote: I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer satisfies the if statement. However, if I pas

Re: [Tutor] ASCII Conversion

2012-01-30 Thread David Kidd
On Tue, Jan 31, 2012 at 15:50, Michael Lewis wrote: > ... However, if I pass in a string, it's converted to ASCII and will > still satisfy the if statement and print out value. How do I ensure that a > string is caught as a ValueError instead of being converted? It depends on what you want to do

[Tutor] ASCII Conversion

2012-01-30 Thread Michael Lewis
I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer satisfies the if statement. However, if I pass in a string, it's converted to ASCII and will s

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/28/2011 08:02 AM, Alex Hall wrote: >> On 1/28/11, Dave Angel wrote: >>> On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/28/2011 08:02 AM, Alex Hall wrote: On 1/28/11, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I fi

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Alex Hall wrote: >> >> I tried both of those and got a different error. I have since fixed it >> so I no longer have the exact text, but it was something about not >> supporting convertion from unicode. I finally ended up doing this: >> s

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I finally ended up doing this: self.title�ta.find("title").text.encode("utf-8"

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Peter Otten
Alex Hall wrote: > Hello again: > I have never seen this message before. I am pulling xml from a site's > api and printing it, testing the wrapper I am writing for the api. I > have never seen this error until just now, in the twelfth result of my > search: > UnicodeEncodeError: 'ASCII' codec can'

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'A

Re: [Tutor] ascii codec cannot encode character

2011-01-27 Thread Alex Hall
On 1/27/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hello again: >> I have never seen this message before. I am pulling xml from a site's >> api and printing it, testing the wrapper I am writing for the api. I >> have never seen this error until just now, in the twelfth result of my >> search

Re: [Tutor] ascii codec cannot encode character

2011-01-27 Thread Steven D'Aprano
Alex Hall wrote: Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'ASCII' codec can't encode ch

[Tutor] ascii codec cannot encode character

2011-01-27 Thread Alex Hall
Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'ASCII' codec can't encode character u'\u2019' i

[Tutor] 'ascii' codec can't decode byte

2010-12-10 Thread Susana Iraiis Delgado Rodriguez
Hello members: I need your help, I'm developing a python script to make an excel file... I've been working in this for a long time. The module will write some data from a .shp file. Unfortuanely that information has some characters unrecorgnized by ascii. I tried to fix this adding an unicode sent

Re: [Tutor] ASCII

2006-03-30 Thread andrew clarke
On Wed, Mar 29, 2006 at 01:51:30PM +0530, Kaushal Shriyan wrote: > > How do i use this ASCII values in my day to day activities, I am going > > through learning python, > > Its a very general question not related to python at all, I have a > minimum knowledge in ASCII just wanted to know how it i

Re: [Tutor] ASCII

2006-03-29 Thread Pujo Aji
Hello,Basicaly, You use ASCII or Unicode when you have to deal with character conversion for example coding with a different language symbol, chinese letter etc. Sincerely Yours,Pujo On 3/29/06, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: On 3/29/06, Pujo Aji <[EMAIL PROTECTED]> wrote:>> Hi Kaushal,

Re: [Tutor] ASCII

2006-03-29 Thread Kaushal Shriyan
On 3/29/06, Pujo Aji <[EMAIL PROTECTED]> wrote: > > Hi Kaushal, > > Please clarify the problem more specific. > Or you can tell us that you have a problem and want to use python to solve > it? > > Sincerely Yours, > pujo > > > On 3/29/06, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: > > > Hi All > >

Re: [Tutor] ASCII

2006-03-28 Thread Pujo Aji
Hi Kaushal,Please clarify the problem more specific.Or you can tell us that you have a problem and want to use python to solve it?Sincerely Yours,pujoOn 3/29/06, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: Hi AllHow do i use this ASCII values in my day to day activities, I am going throughlearning

[Tutor] ASCII

2006-03-28 Thread Kaushal Shriyan
Hi All How do i use this ASCII values in my day to day activities, I am going through learning python, Please illustrate with examples Thanks in Advance Regards Kaushal ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/t

Re: [Tutor] ASCII characters

2005-05-24 Thread Danny Yoo
On Tue, 24 May 2005, Kent Johnson wrote: > D. Hartley wrote: > > I have a question: what is the "opposite" of hex()? (i.e., like ord > > and chr). If I have > > > > '0x73', how can I get back to 115 or s? > > I don't know a really clean way to do this because '0x73' is not a legal > input value

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
D. Hartley wrote: > I have a question: what is the "opposite" of hex()? (i.e., like ord > and chr). If I have > > '0x73', how can I get back to 115 or s? I don't know a really clean way to do this because '0x73' is not a legal input value for int(). The simplest way is to use eval(): >>> eva

Re: [Tutor] ASCII characters

2005-05-24 Thread D. Hartley
I have a question: what is the "opposite" of hex()? (i.e., like ord and chr). If I have '0x73', how can I get back to 115 or s? Thanks! ~Denise > You need the ord() function and maybe hex() also: > >>> ord('s') > 115 > >>> hex(ord('s')) > '0x73' > > Kent > >

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
John Carmona wrote: > Thanks Kent for the reply, I am actually having trouble to find the > solution of the following exercise: > > ## Write a for loop that prints the ASCII code of each character in a > string name S.## > > I am ok with the for loop, put I don't know how get to print the ASCII

Re: [Tutor] ASCII characters

2005-05-24 Thread John Carmona
Thanks Kent for the reply, I am actually having trouble to find the solution of the following exercise: ## Write a for loop that prints the ASCII code of each character in a string name S.## I am ok with the for loop, put I don't know how get to print the ASCII code of each character with a st

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
John Carmona wrote: > I need to print all the ASCII characters within a string, how would I > delimit for example to print the first 100 only? Many thanks A string is a sequence and supports sequence operations including slices. So s[:100] gives the first 100 chars of a string. You might be i

[Tutor] ASCII characters

2005-05-24 Thread John Carmona
I need to print all the ASCII characters within a string, how would I delimit for example to print the first 100 only? Many thanks JC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ascii encoding

2005-01-26 Thread Alan Gauld
> Whether or not it's positive or negative depends on which side of GMT/UTC > you are, of course :) Note that the result in is seconds, too: Which is insane since timezones have nothing to do with time offsets. Especially at the second level! Oh well, nothing is perfect! Alan G. (Feeling picky

Re: [Tutor] ascii encoding

2005-01-25 Thread Max Noel
On Jan 26, 2005, at 02:56, Luis N wrote: In other words I have to do some arithmetic: import time time.timezone 0 The server is located in Dallas, Texas. Which means it's not properly configured. On UNIX systems, to configure the timezone, you must adjust /etc/localtime so that it's a symlink th

Re: [Tutor] ascii encoding

2005-01-25 Thread Max Noel
On Jan 26, 2005, at 02:44, Tony Meyer wrote: time.timezone gives you, I think, the offset between your current timezone and GMT. However, being myself in the GMT zone, I don't know exactly if the returned offset is positive or negative (it returns 0 here, which makes sense :D ). Whether or not it's

Re: [Tutor] ascii encoding

2005-01-25 Thread Luis N
In other words I have to do some arithmetic: >>> import time >>> time.timezone 0 The server is located in Dallas, Texas. On Wed, 26 Jan 2005 15:44:48 +1300, Tony Meyer <[EMAIL PROTECTED]> wrote: > > time.timezone gives you, I think, the offset between > > your current timezone and GMT. However,

RE: [Tutor] ascii encoding

2005-01-25 Thread Tony Meyer
> time.timezone gives you, I think, the offset between > your current timezone and GMT. However, being myself in the GMT zone, > I don't know exactly if the returned offset is positive or negative > (it returns 0 here, which makes sense :D ). Whether or not it's positive or negative depends on wh

Re: [Tutor] ascii encoding

2005-01-25 Thread Max Noel
On Jan 26, 2005, at 00:50, Luis N wrote: Ok, urllib.quote worked just fine, and of course so did urllib.pathname2url. I should have run a dir() on urllib. Those functions don't appear in http://docs.python.org/lib/module-urllib.html Now, how might one go about calculating the New York time off-se

Re: [Tutor] ascii encoding

2005-01-25 Thread Luis N
Ok, urllib.quote worked just fine, and of course so did urllib.pathname2url. I should have run a dir() on urllib. Those functions don't appear in http://docs.python.org/lib/module-urllib.html Now, how might one go about calculating the New York time off-set from GMT? The server is in the U.S. but

Re: [Tutor] ascii encoding

2005-01-24 Thread Kent Johnson
Kent Johnson wrote: >>> import re >>> def hexify(match): ... return '%%%X' % ord(match.group(0)) Ah, should be '%%%02X' ... Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ascii encoding

2005-01-24 Thread Kent Johnson
Luis N wrote: How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. urllib.quote_plus() is intended for this purpose though it doesn't have the result you ask for: >>> import urllib >>> s='2005-01-24 00:00:00.0'

Re: [Tutor] ascii encoding

2005-01-24 Thread Chad Crabtree
I got this from spyce http://spyce.sourceforge.net _url_ch = re.compile(r'[^A-Za-z0-9_.!~*()-]') # RFC 2396 section 2.3 def url_encode(o, **kwargs): '''Return URL-encoded string.''' return _url_ch.sub(lambda match: "%%%02X" % ord(match.group(0)), str(o)) It was just the first thing I found in

Re: [Tutor] ascii encoding

2005-01-24 Thread Max Noel
On Jan 24, 2005, at 23:29, Luis N wrote: How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. I've hunted through the standard library, but nothing seemed to jump out. The pathname2url in urllib seems to do wha

[Tutor] ascii encoding

2005-01-24 Thread Luis N
How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. I've hunted through the standard library, but nothing seemed to jump out. Thank You. ___ Tutor maillist - Tuto

[Tutor] ASCII encoding for a £ sign

2004-12-31 Thread David Holland
I ran a program with a "£" sign, and I got this message :- "sys:1: DeprecationWarning: Non-ASCII character '\xc2' in file birdgame32a.py on line 93, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details' I looked at the message but I am not sure what encoding to use fo