From chitrankdixit at gmail.com Tue May 14 11:44:30 2013 From: chitrankdixit at gmail.com (Chitrank Dixit) Date: Tue, 14 May 2013 15:14:30 +0530 Subject: [Python-porting] Python porting from 2 to 3.3.1 discuss Message-ID: Hello I am porting to python 3.3.1 with backward compatibility to python 2.7.3 but still some users of python 3.2 are left as the porting does not support python 3.2 users. So the upcoming versions are more likely to follow the python 3.3.1. *Regards * *Chitrank Dixit * *IIPS-DAVV * *Indore (M.P.) , India * *MCA * *trackleech.blogspot.in* -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Tue May 14 12:06:28 2013 From: regebro at gmail.com (Lennart Regebro) Date: Tue, 14 May 2013 12:06:28 +0200 Subject: [Python-porting] Python porting from 2 to 3.3.1 discuss In-Reply-To: References: Message-ID: On Tue, May 14, 2013 at 11:44 AM, Chitrank Dixit wrote: > Hello > > I am porting to python 3.3.1 with backward compatibility to python 2.7.3 but > still some users of python 3.2 are left as the porting does not support > python 3.2 users. Is this because of the lack of a u''-literal? //Lennart From chitrankdixit at gmail.com Thu May 16 21:59:03 2013 From: chitrankdixit at gmail.com (Chitrank Dixit) Date: Fri, 17 May 2013 01:29:03 +0530 Subject: [Python-porting] Questions regarding relative import Message-ID: Hello Python developers I am working on Porting to Python 2 to Python 3.3 and the refactoring using 2to3 says to use relative import at the place of the import. but ignoring the relative import does the work for both the python 2 as well as python 3.3 So Does 2to3 is made as per refactoring from python 2 to python 3.2 ? *Regards * *Chitrank Dixit * *IIPS-DAVV * *Indore (M.P.) , India * *MCA * *trackleech.blogspot.in* -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Fri May 17 06:47:41 2013 From: regebro at gmail.com (Lennart Regebro) Date: Fri, 17 May 2013 06:47:41 +0200 Subject: [Python-porting] Questions regarding relative import In-Reply-To: References: Message-ID: On Thu, May 16, 2013 at 9:59 PM, Chitrank Dixit wrote: > Hello Python developers > > I am working on Porting to Python 2 to Python 3.3 and the refactoring using > 2to3 says to use relative import at the place of the import. but ignoring > the relative import does the work for both the python 2 as well as python > 3.3 Absolute imports work in both Python 2 and Python 3, yes. Importing from within the module requires the relative syntax in Python 3. //Lennart From chitrankdixit at gmail.com Tue May 21 10:32:17 2013 From: chitrankdixit at gmail.com (Chitrank Dixit) Date: Tue, 21 May 2013 14:02:17 +0530 Subject: [Python-porting] Questions for porting unicode with backward compatibility Message-ID: 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* -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Tue May 21 10:46:14 2013 From: regebro at gmail.com (Lennart Regebro) Date: Tue, 21 May 2013 10:46:14 +0200 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit wrote: > 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() > 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. > 3) does next() method behavior is same in both python 2.7 and python 3.3. As far as I know, yes. //Lennart From mail at timgolden.me.uk Tue May 21 10:52:52 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 21 May 2013 09:52:52 +0100 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: <519B35E4.1090602@timgolden.me.uk> On 21/05/2013 09:46, Lennart Regebro wrote: > On Tue, May 21, 2013 at 10:32 AM, 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 From martin at v.loewis.de Tue May 21 18:30:18 2013 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 21 May 2013 18:30:18 +0200 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: <519BA11A.7020808@v.loewis.de> Am 21.05.13 10:32, schrieb 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". > 3) does next() method behavior is same in both python 2.7 and python 3.3. I disagree with Lennart: the next() *method* does not exist in Python 3.3: >>> x=iter("foo") >>> x.next() Traceback (most recent call last): File "", line 1, in AttributeError: 'str_iterator' object has no attribute 'next' The next() *function* exists in both versions, and has the same behavior. Regards, Martin From regebro at gmail.com Tue May 21 19:03:28 2013 From: regebro at gmail.com (Lennart Regebro) Date: Tue, 21 May 2013 19:03:28 +0200 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: <519BA11A.7020808@v.loewis.de> References: <519BA11A.7020808@v.loewis.de> Message-ID: On Tue, May 21, 2013 at 6:30 PM, "Martin v. L?wis" wrote: > I disagree with Lennart: the next() *method* does not exist in Python 3.3: Yeah, sorry, I misread that. //Lennart From chitrankdixit at gmail.com Wed May 22 00:38:48 2013 From: chitrankdixit at gmail.com (Chitrank Dixit) Date: Wed, 22 May 2013 04:08:48 +0530 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: 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 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 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* On Tue, May 21, 2013 at 2:16 PM, Lennart Regebro wrote: > On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit > wrote: > > 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() > > > 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. > > > 3) does next() method behavior is same in both python 2.7 and python 3.3. > > As far as I know, yes. > > //Lennart > -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Wed May 22 08:38:45 2013 From: regebro at gmail.com (Lennart Regebro) Date: Wed, 22 May 2013 08:38:45 +0200 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: On Wed, May 22, 2013 at 12:38 AM, Chitrank Dixit wrote: > 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 > 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 > 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 From martin at v.loewis.de Wed May 22 09:40:24 2013 From: martin at v.loewis.de (martin at v.loewis.de) Date: Wed, 22 May 2013 09:40:24 +0200 Subject: [Python-porting] Questions for porting unicode with backward compatibility In-Reply-To: References: Message-ID: <20130522094024.Horde.-_gIccKqDxzYEL4Fn86aYA7@webmail.df.eu> Quoting Lennart Regebro : >> File >> "/home/chitrank/Documents/Google_Summer_of_code/moinmoin_pre/Emeraldtree/EmeraldTree/emeraldtree/html.py", >> line 34, in > Can you do this: > > 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 From chitrankdixit at gmail.com Thu May 23 07:37:47 2013 From: chitrankdixit at gmail.com (Chitrank Dixit) Date: Thu, 23 May 2013 11:07:47 +0530 Subject: [Python-porting] Stuck with raw unicode literals Message-ID: Hello Python developers I am working on Python Porting 2.7 >=3.3 . unicode literals will be fine but still raw unicode literals is an issue (ur' '). I have found the solution in six module. This is the solution original python 2.7 code ur'Pythondev' using six module for py 2.7>=3.3 six.u(r'Pythondev') Does my solution is okay or something else is needed to do I am very confused with this. *Regards * *Chitrank Dixit * *IIPS-DAVV * *Indore (M.P.) , India * *MCA * *trackleech.blogspot.in* -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Thu May 23 08:00:54 2013 From: regebro at gmail.com (Lennart Regebro) Date: Thu, 23 May 2013 08:00:54 +0200 Subject: [Python-porting] Stuck with raw unicode literals In-Reply-To: References: Message-ID: On Thu, May 23, 2013 at 7:37 AM, Chitrank Dixit wrote: > Hello Python developers > > I am working on Python Porting 2.7 >=3.3 . unicode literals will be fine but > still raw unicode literals is an issue (ur' '). I have found the solution in > six module. > > This is the solution > > original python 2.7 code > ur'Pythondev' > > using six module for py 2.7>=3.3 > six.u(r'Pythondev') > > Does my solution is okay or something else is needed to do I am very > confused with this. Well the first question is why you need a raw unicode literal in the first place? Raw string literals simply interpret escape sequences literally, so that '\0x00' is interpreted as a four character string, while in normal strings it's interpreted as a once character string. Unicode literals are weird beasts, where most backslash escape sequences are interpreted literally, but not the Unicode escape sequences, so '\0x00' is four characters, but '\u0000' is one. The simplest way to handle it might simply to be to escape the backslashes, ie change ur'\0x57bla\foo' to u'\\0x57bla\\foo' //Lennart