Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Bytes, Strings, Encoding

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


eric.pruitt at gmail

Jul 1, 2009, 5:47 PM

Post #1 of 3 (291 views)
Permalink
Bytes, Strings, Encoding

Hello,

I am working on the subprocess.Popen module for Python 2.7 and am now moving
my changes over to Python 3.1 however I am having trouble with the whole
byte situation and I can't quite seem to understand how to go back and forth
between bytes and strings. I am also looking for the Python 3k equivalent
for the Python 2.X built-in buffer class.

One version of the file with my modifications can be found here <
http://code.google.com/p/subprocdev/source/browse/subprocess.py?spec=svn5b570f8cbfcaae859091eb01b21b183aa5221af9&r=5b570f8cbfcaae859091eb01b21b183aa5221af9>.
Lines 1 - 15 are me attempting to get around certain changes between
Python 3.0 and Python 2.7. Further down on line 916, we have the function
"send" and "recv" in which I am having the most trouble with bytes and
strings.

Any help is appreciated. Feel free to comment on my blog
http://subdev.blogspot.com/ or reply to the last.

Thanks in advance,
Eric


benjamin at python

Jul 1, 2009, 6:48 PM

Post #2 of 3 (265 views)
Permalink
Re: Bytes, Strings, Encoding [In reply to]

2009/7/1 Eric Pruitt <eric.pruitt[at]gmail.com>:
> Hello,
>
> I am working on the subprocess.Popen module for Python 2.7 and am now moving
> my changes over to Python 3.1 however I am having trouble with the whole
> byte situation and I can't quite seem to understand how to go back and forth
> between bytes and strings. I am also looking for the Python 3k equivalent
> for the Python 2.X built-in buffer class.

Look at the "memoryview" type as a replacement for buffer.
io.Buffered* is not the same.

>
> One version of the file with my modifications can be found hereĀ  <
> http://code.google.com/p/subprocdev/source/browse/subprocess.py?spec=svn5b570f8cbfcaae859091eb01b21b183aa5221af9&r=5b570f8cbfcaae859091eb01b21b183aa5221af9
>>. Lines 1 - 15 are me attempting to get around certain changes between
> Python 3.0 and Python 2.7. Further down on line 916, we have the function
> "send" and "recv" in which I am having the most trouble with bytes and
> strings.

You translate between bytes and strings through encoding and decoding.
Have you read https://secure.wikimedia.org/wikipedia/en/wiki/Unicode?

>
> Any help is appreciated. Feel free to comment on my blog
> http://subdev.blogspot.com/ or reply to the last.

Have you talked with your mentor about these things?


--
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev[at]python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


josiah.carlson at gmail

Jul 2, 2009, 9:30 AM

Post #3 of 3 (260 views)
Permalink
Re: Bytes, Strings, Encoding [In reply to]

On Wed, Jul 1, 2009 at 6:48 PM, Benjamin Peterson<benjamin[at]python.org> wrote:
> 2009/7/1 Eric Pruitt <eric.pruitt[at]gmail.com>:
>> Hello,
>>
>> I am working on the subprocess.Popen module for Python 2.7 and am now moving
>> my changes over to Python 3.1 however I am having trouble with the whole
>> byte situation and I can't quite seem to understand how to go back and forth
>> between bytes and strings. I am also looking for the Python 3k equivalent
>> for the Python 2.X built-in buffer class.
>
> Look at the "memoryview" type as a replacement for buffer.
> io.Buffered* is not the same.

FYI, it is used slightly differently. Rather than x = buffer(y,
offset), you use x = memoryview(y)[offset:].

>> One version of the file with my modifications can be found here  <
>> http://code.google.com/p/subprocdev/source/browse/subprocess.py?spec=svn5b570f8cbfcaae859091eb01b21b183aa5221af9&r=5b570f8cbfcaae859091eb01b21b183aa5221af9
>>>. Lines 1 - 15 are me attempting to get around certain changes between
>> Python 3.0 and Python 2.7. Further down on line 916, we have the function
>> "send" and "recv" in which I am having the most trouble with bytes and
>> strings.
>
> You translate between bytes and strings through encoding and decoding.
> Have you read https://secure.wikimedia.org/wikipedia/en/wiki/Unicode?
>
>>
>> Any help is appreciated. Feel free to comment on my blog
>> http://subdev.blogspot.com/ or reply to the last.
>
> Have you talked with your mentor about these things?
>
>
> --
> Regards,
> Benjamin
> _______________________________________________
> Python-Dev mailing list
> Python-Dev[at]python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/josiah.carlson%40gmail.com
>
_______________________________________________
Python-Dev mailing list
Python-Dev[at]python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.