Discussion:
Questions for porting unicode with backward compatibility
Chitrank Dixit
2013-05-21 08:32:17 UTC
Permalink
Hello Python Developers

I need to ask you some questions please answer me some questions

1) alternative to unichr() in python 3.3 (is it chr() or anything else is
available).

2) does using six module rather than doing some try catch stuff is a better
option.

3) does next() method behavior is same in both python 2.7 and python 3.3.




*Regards
*
*Chitrank Dixit
*
*IIPS-DAVV
*
*Indore (M.P.) , India *
*MCA
*
*trackleech.blogspot.in*
Lennart Regebro
2013-05-21 08:46:14 UTC
Permalink
On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit
Post by Chitrank Dixit
Hello Python Developers
I need to ask you some questions please answer me some questions
1) alternative to unichr() in python 3.3 (is it chr() or anything else is
available).
chr()
Post by Chitrank Dixit
2) does using six module rather than doing some try catch stuff is a better
option.
Depends on what, and how much of six you end up using.
Post by Chitrank Dixit
3) does next() method behavior is same in both python 2.7 and python 3.3.
As far as I know, yes.

//Lennart
Tim Golden
2013-05-21 08:52:52 UTC
Permalink
Post by Lennart Regebro
On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit
Post by Chitrank Dixit
3) does next() method behavior is same in both python 2.7 and python 3.3.
As far as I know, yes.
Since you mention the next() *method*: in Python 3, the iterator
protocol changed slightly. Previously, the protocol demanded that a
Python iterator have a .next() method which was invoked by the protocol
or by the next() builtin function. In Python 3, the iterator has a
.__next__() method instead. Otherwise, the protocol works as before:
"for x in iterable:" works as expected, and the next() builtin invokes
".__next__()" rather than ".next()"

TJG
Chitrank Dixit
2013-05-21 22:38:48 UTC
Permalink
Okay module six is made good but it lacks in some cases

I am referring this documentation of six module
http://pythonhosted.org/six/

and getting problem in this line *from six.moves import html_entities,
html_parser*
I have installed six module in both python 2 and python 3.3 but I am
getting problem in python 3.3 it says

Traceback (most recent call last):
File "html.py", line 34, in <module>
from six.moves import html_entities, html_parser
File "/usr/local/lib/python3.3/dist-packages/six.py", line 84, in __get__
result = self._resolve()
File "/usr/local/lib/python3.3/dist-packages/six.py", line 103, in
_resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.3/dist-packages/six.py", line 74, in
_import_module
__import__(name)
File
"/home/chitrank/Documents/Google_Summer_of_code/moinmoin_pre/Emeraldtree/EmeraldTree/emeraldtree/html.py",
line 34, in <module>
from six.moves import html_entities, html_parser
File "/usr/local/lib/python3.3/dist-packages/six.py", line 84, in __get__
result = self._resolve()
File "/usr/local/lib/python3.3/dist-packages/six.py", line 103, in
_resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.3/dist-packages/six.py", line 74, in
_import_module
__import__(name)
ImportError: No module named 'html.entities'; html is not a package

What could be the error please let me know


*Regards
*
*Chitrank Dixit
*
*IIPS-DAVV
*
*Indore (M.P.) , India *
*MCA
*
*trackleech.blogspot.in*
Post by Lennart Regebro
On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit
Post by Chitrank Dixit
Hello Python Developers
I need to ask you some questions please answer me some questions
1) alternative to unichr() in python 3.3 (is it chr() or anything else is
available).
chr()
Post by Chitrank Dixit
2) does using six module rather than doing some try catch stuff is a
better
Post by Chitrank Dixit
option.
Depends on what, and how much of six you end up using.
Post by Chitrank Dixit
3) does next() method behavior is same in both python 2.7 and python 3.3.
As far as I know, yes.
//Lennart
Lennart Regebro
2013-05-22 06:38:45 UTC
Permalink
On Wed, May 22, 2013 at 12:38 AM, Chitrank Dixit
Post by Chitrank Dixit
Okay module six is made good but it lacks in some cases
I am referring this documentation of six module
http://pythonhosted.org/six/
and getting problem in this line from six.moves import html_entities,
html_parser
I have installed six module in both python 2 and python 3.3 but I am getting
problem in python 3.3 it says
File "html.py", line 34, in <module>
from six.moves import html_entities, html_parser
File "/usr/local/lib/python3.3/dist-packages/six.py", line 84, in __get__
result = self._resolve()
File "/usr/local/lib/python3.3/dist-packages/six.py", line 103, in
_resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.3/dist-packages/six.py", line 74, in
_import_module
__import__(name)
File
"/home/chitrank/Documents/Google_Summer_of_code/moinmoin_pre/Emeraldtree/EmeraldTree/emeraldtree/html.py",
line 34, in <module>
from six.moves import html_entities, html_parser
File "/usr/local/lib/python3.3/dist-packages/six.py", line 84, in __get__
result = self._resolve()
File "/usr/local/lib/python3.3/dist-packages/six.py", line 103, in
_resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.3/dist-packages/six.py", line 74, in
_import_module
__import__(name)
ImportError: No module named 'html.entities'; html is not a package
What could be the error please let me know
Can you do this:

import html
print(html.__file__)

It sounds like the html module somehow has been shadowed by something else.

//Lennart
m***@v.loewis.de
2013-05-22 07:40:24 UTC
Permalink
Post by Chitrank Dixit
Post by Chitrank Dixit
File
"/home/chitrank/Documents/Google_Summer_of_code/moinmoin_pre/Emeraldtree/EmeraldTree/emeraldtree/html.py",
line 34, in <module>
import html
print(html.__file__)
It sounds like the html module somehow has been shadowed by something else.
My guess is that it is the html module from emeraldtree. Of course,
this *ought* to be
emeraldtree.html, not a toplevel html package. So it would also be
helpful to see whether
/home/chitrank/Documents/Google_Summer_of_code/moinmoin_pre/Emeraldtree/EmeraldTree/emeraldtree
happens to be in sys.path (which it ought not to).

Regards,
Martin

Martin v. Löwis
2013-05-21 16:30:18 UTC
Permalink
Post by Chitrank Dixit
1) alternative to unichr() in python 3.3 (is it chr() or anything else
is available).
2) does using six module rather than doing some try catch stuff is a
better option.
I agree with Lennart: "chr", and "it depends".
Post by Chitrank Dixit
3) does next() method behavior is same in both python 2.7 and python 3.3.
x=iter("foo")
x.next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str_iterator' object has no attribute 'next'

The next() *function* exists in both versions, and has the same behavior.

Regards,
Martin
Lennart Regebro
2013-05-21 17:03:28 UTC
Permalink
Yeah, sorry, I misread that.

//Lennart
Loading...