Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82553
| References | <85wq5tpe0g.fsf@benfinney.id.au> |
|---|---|
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
| Date | 2014-12-15 01:39 -0600 |
| Subject | Re: Portable code: __import__ demands different string types between 2 and 3 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16976.1418629204.18130.python-list@python.org> (permalink) |
On Mon, Dec 15, 2014 at 1:29 AM, Ben Finney <ben+python@benfinney.id.au> wrote:
> How can I get that ‘__import__’ call, complete with its ‘fromlist’
> parameter, working correctly under both Python 2 and Python 3, keeping
> the ‘unicode_literals’ setting?
How about "str('bar')"?
> If some kind of kludge is needed to make it work between versions, is
> this a bug which should be fixed so “use Unicode for text” remains
> applicable advice?
Fixed in which version? The problem is that Python 2 mixes the
notions of strings and bytestrings, and the solution is Python 3.
I believe six also has a "give me a native string" function to help with this.
--
Zach
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Portable code: __import__ demands different string types between 2 and 3 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-12-15 01:39 -0600
csiph-web