Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-18 Thread Prasad, Ramit
David Hutto wrote: If your app has a standard usage of phrases, you can place a file in that translates a tag into a particular language phrase. if submit_tag_selection == 'english': submit = 'Submit' if submit_tag_selection == 'english': submit = 'Soumettre' Of course

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-17 Thread Dwight Hutto
If your app has a standard usage of phrases, you can place a file in that translates a tag into a particular language phrase. if submit_tag_selection == 'english': submit = 'Submit' if submit_tag_selection == 'english': submit = 'Soumettre' Of course this could be done without the

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-11 Thread Alan Gauld
On 11/10/12 02:23, boB Stepp wrote: bytes have string methods as a convenience, such as find, split, and partition. They also have the method decode(), which uses a specified encoding such as utf-8 to create a string from an encoded bytes sequence. What is the intended use of byte types?

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-11 Thread eryksun
On Wed, Oct 10, 2012 at 9:23 PM, boB Stepp robertvst...@gmail.com wrote: aꘌꘌb = True aꘌꘌb True Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ = range(1, 6) Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ (1, 2, 3, 4, 5) Is doing this considered good programming practice? The examples were meant to highlight the absurdity of

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-11 Thread Dave Angel
On 10/11/2012 04:40 AM, eryksun wrote: On Wed, Oct 10, 2012 at 9:23 PM, boB Stepp robertvst...@gmail.com wrote: . What is the intended use of byte types? bytes objects are important for low-level data processing, such as file and socket I/O. The fundamental addressable value in a computer

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-11 Thread eryksun
On Thu, Oct 11, 2012 at 5:04 AM, Dave Angel d...@davea.name wrote: Actually, the upper limit for a decoded utf-8 character is at least 6 bytes. I think it's 6, but it's no less than 6. Yes, but what would be the point? Unicode only has 17 planes, up to code 0x10. It's limited by UTF-16.

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-11 Thread Dave Angel
On 10/11/2012 05:21 AM, eryksun wrote: On Thu, Oct 11, 2012 at 5:04 AM, Dave Angel d...@davea.name wrote: Actually, the upper limit for a decoded utf-8 character is at least 6 bytes. I think it's 6, but it's no less than 6. Yes, but what would be the point? Unicode only has 17 planes, up

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-10 Thread boB Stepp
On Tue, Oct 9, 2012 at 4:29 AM, eryksun eryk...@gmail.com wrote: snip Python 3 lets you use any Unicode letter as an identifier, including letter modifiers (Lm) and number letters (Nl). For example: aꘌꘌb = True aꘌꘌb True Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ = range(1, 6) Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-10 Thread Steven D'Aprano
On 11/10/12 12:23, boB Stepp wrote: On Tue, Oct 9, 2012 at 4:29 AM, eryksuneryk...@gmail.com wrote: snip Python 3 lets you use any Unicode letter as an identifier, including letter modifiers (Lm) and number letters (Nl). For example: aꘌꘌb = True aꘌꘌb True Ⅰ, Ⅱ, Ⅲ,

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-09 Thread eryksun
On Mon, Oct 8, 2012 at 10:35 PM, boB Stepp robertvst...@gmail.com wrote: I am not up (yet) on the details of Unicode that Python 3 defaults to for strings, but I believe I comprehend the general concept. Looking at the string escape table of chapter 2 it appears that Unicode characters can be

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-08 Thread boB Stepp
Steve, On Thu, Oct 4, 2012 at 6:28 AM, Steven D'Aprano st...@pearwood.info wrote: snip Now, ask me about *raw strings*, and the difference between Unicode and byte strings :) How can I resist asking! I am not in chapter 2 of my study text yet, but looking ahead raw strings seem to be a method

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-04 Thread Dave Angel
On 10/03/2012 11:11 PM, boB Stepp wrote: Thanks to all who responded. SNIP. What happens if str() or repr() is not supported by a particular object? Is an exception thrown, an empty string returned or something else I am not imagining? Let's try it and see: class A:pass ... a = A() a

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-04 Thread Steven D'Aprano
On 04/10/12 13:39, boB Stepp wrote: But not always. For example: py from decimal import Decimal as D py x = D(1.23) py print(str(x)) 1.23 py print(repr(x)) Decimal('1.23') These contrasting examples are very illuminating. So in print(str(x)) the object, D(1.23), is being converted into a

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-04 Thread Steven D'Aprano
On 04/10/12 13:11, boB Stepp wrote: What happens if str() or repr() is not supported by a particular object? Is an exception thrown, an empty string returned or something else I am not imagining? I don't think that is possible, at least not by accident or neglect. In Python 3, everything

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-04 Thread eryksun
On Wed, Oct 3, 2012 at 11:11 PM, boB Stepp robertvst...@gmail.com wrote: What happens if str() or repr() is not supported by a particular object? Is an exception thrown, an empty string returned or something else I am not imagining? The __str__ method inherited from object calls __repr__.

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-03 Thread boB Stepp
Thanks to all who responded. There was much more going on here than I ever would have suspected. I am glad I asked the questions I did. This has been very informative. On Tue, Oct 2, 2012 at 11:53 PM, Dave Angel d...@davea.name wrote: There are two operations supported by (most) objects that

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-03 Thread boB Stepp
On Wed, Oct 3, 2012 at 1:38 AM, Steven D'Aprano st...@pearwood.info wrote: snip The long answer is a bit more subtle, and rather long. I had initial suspicions this would be the case Thanks for yours and Dave's detailed exposition! [...] Python is no different: words, text if you will, that

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-02 Thread Dave Angel
On 10/02/2012 11:15 PM, boB Stepp wrote: After much diddling around I have finally settled on a text to study (Programming in Python 3, 2nd edition, by Mark Summerfield) and have defaulted to using IDLE, deferring worrying about editors/IDEs until I feel comfortable in Python. I am puzzled

Re: [Tutor] Why difference between printing string typing its object reference at the prompt?

2012-10-02 Thread Brian van den Broek
On 2 Oct 2012 23:17, boB Stepp robertvst...@gmail.com wrote: snip I am puzzled by the results of the following: x = Test x 'Test' print(x) Test I understand that 'Test' is the stored value in memory where the single quotes designate the value as being a string data type. So it