Running programs on mobile phones
I have seen by chance a number of years ago a book on Python programming for running on mobile phones (of a certain producer only). What is the current state of the art in that? Could someone kindly give a few good literature references? Thanks in advance. M. K. Shen -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
Le mardi 22 avril 2014 08:30:45 UTC+2, Rustom Mody a écrit : > > > @ rusy > "Ive reworded it to make it clear that I am referring to the character-sets and not encodings." Very good, excellent, comment. An healthy coding scheme can only work properly with a unique characters set and the coding is achieved with the help of a unique operator. There is no other way to do it and that's the reason why we have to live today with all these coding schemes (unicode or not). Note: A coding scheme can be much more complex than the coding of "raw" characters (eg. CID fonts). > "So instead of using λ (0x3bb) we should use 𝝀 (0x1d740) or something > thereabouts like 𝜆" This is a very good understanding of unicode. The letter lambda is not the mathematical symbole lambda. Another example, the micro sign is not the greek letter mu which is not the mathematical mu. Shorly, it's maybe not a bad idea to use a plain ascii "lambda" instead of a wrong unicode point. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: How to properly get the microseconds from the timestamps?
2014-04-22 4:38 GMT+02:00 Igor Korot : ... datetime.datetime.fromtimestamp(1092787200/1000.0) > datetime.datetime(1970, 1, 13, 7, 33, 7, 20) > > Is there a way to know if the timestamp has a microseconds? > > Thank you. > -- Hi, I believe, in these cases, you can just test, whether there is a non-integer part in the timestamp in seconds, which will be stored as microseconds accordingly. >>> 1092787200/1000.0 1092787.2 0.2 s is stored (and shown in repr(...)) as 20 microseconds. There are some peculiarities in handling date and time calculations reliably as well as in the floating point math, but they don't seem to be involved here. -- https://mail.python.org/mailman/listinfo/python-list
Best Website Design Services by Professional Web Designing Company
Ave Infosys is a leading professional in Web Designing Company in Hyderabad India for the E-Business Industry.Ave Infosys are providing Best Website Development and Design Services in Hyderabad.Our company offers the Best Web Design & Development services, Web Hosting Services,Responsive and Mobile Designing services,Ecommerce websites services,Digital Marketing Services,Website Design Services. We have intensive web design and web skills merging with the quality essence of expertise should have component to help you to ascertain your internet presence or take it to the next level.we are the Best Web Design Company in Hyderabad. For More Details : Please contact: (+91) 40 40275321 Email : i...@aveinfosys.com Web : http://aveinfosys.com/website-design -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Tuesday, April 22, 2014 12:01:06 PM UTC+5:30, Ian wrote: > On Apr 22, 2014 12:01 AM, "Rustom Mody" wrote: > > As a unicode user (ok wannabe unicode user :D ) Ive > > written up some unicode ideas that have been discussed here in the > > last couple of weeks: > > http://blog.languager.org/2014/04/unicoded-python.html > I'm reminded of this satire: > http://www.ojohaven.com/fun/spelling.html Ha Ha!! Thanks much for that. Ive been looking for that for years but had no starting point for a search [For some reason I always thought it was Bernard Shaw] -- https://mail.python.org/mailman/listinfo/python-list
[ANN] Pylint 1.2 released
Hi there, Pylint 1.2 has been uploaded to pypi by the end of the last week! More info on this heavy release on http://www.logilab.org/blogentry/240019. As usual, feedback and comments welcome. Enjoy! -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework:http://www.cubicweb.org -- https://mail.python.org/mailman/listinfo/python-list
Strange syntax error, occurs only when script is executed directly
I am workin on a solaris 11 machine. The python version is 2.7.6 path to python is /opt/local/bin/python. These are the 15 first lines of the script: #! /opt/local/bin/python class vslice(object): def __init__(self, fun): self.fun = fun def __getitem__(self, inx): if not isinstance(inx, tuple): inx = inx, #if return self.fun(*inx) #end __getitem__ #end __vslice__ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Now if I execute the script by explicitly calling the interpreter everything works fine. # /opt/local/bin/python /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head Apr 21 15:12:38 conn=110982 fd=125 ACCEPT from IP=10.0.59.10:46238 (IP=10.0.128.65:389) Apr 21 15:12:38 conn=110982 op=0 BIND dn="uid=anonymous,ou=local,ou=people,o=global" method=128 Apr 21 15:12:38 conn=110982 op=0 BIND dn="uid=anonymous,ou=local,ou=people,o=global" mech=SIMPLE ssf=0 Apr 21 15:12:38 conn=110982 op=0 RESULT tag=97 err=0 text= Apr 21 15:12:38 conn=110982 op=1 SRCH base="ou=people,o=global" scope=2 deref=0 filter="(uid=anonymous)" Apr 21 15:12:38 conn=110982 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text= Apr 21 15:12:38 conn=110982 op=2 UNBIND Apr 21 15:12:38 conn=110982 fd=125 closed Apr 21 15:12:57 conn=110983 fd=125 ACCEPT from IP=10.1.28.235:39616 (IP=10.0.128.65:389) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= However if I call the script directly and want the #! line do its work I get the following error. # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' /usr/local/bin/ldapwatch: line 3: `class vslice(object):' I have no idea what is going on here. The persmision for /usr/local/bin/ldapwatch look fine: # ls -l /usr/local/bin/ldapwatch -rwxr-xr-x 1 root root 2092 Apr 22 10:05 /usr/local/bin/ldapwatch Does anyone have an idea where I should look to fix this? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On 22/04/2014 11:29, Antoon Pardon wrote: > I am workin on a solaris 11 machine. The python version is 2.7.6 > path to python is /opt/local/bin/python. > > These are the 15 first lines of the script: > > #! /opt/local/bin/python > > class vslice(object): > > def __init__(self, fun): > self.fun = fun > > def __getitem__(self, inx): > if not isinstance(inx, tuple): > inx = inx, > #if > return self.fun(*inx) > #end __getitem__ > #end __vslice__ > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > Now if I execute the script by explicitly calling the interpreter > everything works fine. > > # /opt/local/bin/python /usr/local/bin/ldapwatch /opt/local/log/openldap.log > | head > Apr 21 15:12:38 conn=110982 fd=125 ACCEPT from IP=10.0.59.10:46238 > (IP=10.0.128.65:389) > Apr 21 15:12:38 conn=110982 op=0 BIND > dn="uid=anonymous,ou=local,ou=people,o=global" method=128 > Apr 21 15:12:38 conn=110982 op=0 BIND > dn="uid=anonymous,ou=local,ou=people,o=global" mech=SIMPLE ssf=0 > Apr 21 15:12:38 conn=110982 op=0 RESULT tag=97 err=0 text= > Apr 21 15:12:38 conn=110982 op=1 SRCH base="ou=people,o=global" scope=2 > deref=0 filter="(uid=anonymous)" > Apr 21 15:12:38 conn=110982 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text= > Apr 21 15:12:38 conn=110982 op=2 UNBIND > Apr 21 15:12:38 conn=110982 fd=125 closed > > Apr 21 15:12:57 conn=110983 fd=125 ACCEPT from IP=10.1.28.235:39616 > (IP=10.0.128.65:389) > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > However if I call the script directly and want the #! line do its work I get > the following error. > > # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head > /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' > /usr/local/bin/ldapwatch: line 3: `class vslice(object):' > > I have no idea what is going on here. The persmision for > /usr/local/bin/ldapwatch look fine: > # ls -l /usr/local/bin/ldapwatch -rwxr-xr-x 1 root root 2092 Apr 22 10:05 > /usr/local/bin/ldapwatch Look for a dodgy line-feed / cr (or some other non-visible control character) at the end of the shebang line? TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
"Antoon Pardon" wrote in message news:535644a4.6060...@rece.vub.ac.be... >I am workin on a solaris 11 machine. The python version is 2.7.6 > path to python is /opt/local/bin/python. > [...] > > Now if I execute the script by explicitly calling the interpreter > everything works fine. > [...] > > However if I call the script directly and want the #! line do its work I > get the following error. > > # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head > /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' > /usr/local/bin/ldapwatch: line 3: `class vslice(object):' > I had something similar and it turned out that my script had 'CRLF' line endings instead of 'LF' only, and this caused the problem. I believe that the problem has nothing to do with python, but with how the shell interprets the '#!' line. My editor allows me to re-save a file using a different format, so I saved it as 'unix', reran it, and it worked. HTH Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On 22-04-14 12:42, Frank Millman wrote: > "Antoon Pardon" wrote in message > news:535644a4.6060...@rece.vub.ac.be... >> I am workin on a solaris 11 machine. The python version is 2.7.6 >> path to python is /opt/local/bin/python. >> > [...] >> Now if I execute the script by explicitly calling the interpreter >> everything works fine. >> > [...] >> However if I call the script directly and want the #! line do its work I >> get the following error. >> >> # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head >> /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' >> /usr/local/bin/ldapwatch: line 3: `class vslice(object):' >> > I had something similar and it turned out that my script had 'CRLF' line > endings instead of 'LF' only, and this caused the problem. I believe that > the problem has nothing to do with python, but with how the shell interprets > the '#!' line. > > My editor allows me to re-save a file using a different format, so I saved > it as 'unix', reran it, and it worked. My editor shows me a CR in the file. Just to be sure I used od -c on the file, this is the result: # od -c /usr/local/bin/ldapwatch | head -30 000 # ! / o p t / l o c a l / b i 020 n / p y t h o n \n \n c l a s s 040 v s l i c e ( o b j e c t ) : \n 060 \n \t d e f _ _ i n i t _ _ ( s 100 e l f , f u n ) : \n \t \t s e l 120 f . f u n = f u n \n \n \t d e 140 f _ _ g e t i t e m _ _ ( s e 160 l f , i n x ) : \n \t \t i f n 200 o t i s i n s t a n c e ( i n 220 x , t u p l e ) : \n \t \t \t i n 240 x = i n x , \n \t \t # i f \n \t 260 \t r e t u r n s e l f . f u n 300 ( * i n x ) \n \t # e n d _ _ g 320 e t i t e m _ _ \n # e n d _ _ 340 v s l i c e _ _ \n \n @ v s l i c 360 e \n d e f p r o j e c t ( l s 400 t , * a r g v ) : \n \t r e s u 420 l t = [ ] \n \t f o r a r g 440 i n a r g v : \n \t \t t m p 460 = l s t [ a r g ] \n \t \t i f 500 i s i n s t a n c e ( a r g , 520 s l i c e ) : \n \t \t \t r e s u l 540 t . e x t e n d ( t m p ) \n \t \t 560 e l s e : \n \t \t \t r e s u l t . 600 a p p e n d ( t m p ) \n \t \t # i 620 f \n \t # f o r \n \t r e t u r n 640 r e s u l t \n # e n d p r o j 660 e c t \n \t \t \n i m p o r t s y 700 s \n \n d e f I s N o n e ( a r 720 g ) : \n \t r e t u r n a r g =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- I see nothing that can cause a problem. I tried to search more specifically for troublesome characters but that didn't turn up anything. # od -c /usr/local/bin/ldapwatch | head -30 | grep '\\[^nt]' # So all special characters are either newlines or tabs. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On Tue, Apr 22, 2014 at 8:29 PM, Antoon Pardon wrote: > However if I call the script directly and want the #! line do its work I get > the following error. > > # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head > /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' > /usr/local/bin/ldapwatch: line 3: `class vslice(object):' That looks like bash trying to run Python code, so I'd look at something being wrong with the shebang processing. What's /opt/local/bin/python? Is it a symlink to something else? Some systems won't allow any such dereferencing, others (including modern Linux) allow a maximum of ten or thereabouts, counting one for every symlink or shebang'd script. If /opt/local/bin/python is a bouncer script that itself has a shebang, that might be your problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On 22-04-14 14:09, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 8:29 PM, Antoon Pardon > wrote: >> However if I call the script directly and want the #! line do its work I get >> the following error. >> >> # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head >> /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' >> /usr/local/bin/ldapwatch: line 3: `class vslice(object):' > That looks like bash trying to run Python code, so I'd look at > something being wrong with the shebang processing. What's > /opt/local/bin/python? Is it a symlink to something else? Some systems > won't allow any such dereferencing, others (including modern Linux) > allow a maximum of ten or thereabouts, counting one for every symlink > or shebang'd script. If /opt/local/bin/python is a bouncer script that > itself has a shebang, that might be your problem. > > ChrisA Yes that was it. I changed the first line of my script to: #!/opt/local/bin/python2.7 and it now works. Thanks. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Tue, 22 Apr 2014 02:07:58 -0700, wxjmfauth wrote: > Le mardi 22 avril 2014 08:30:45 UTC+2, Rustom Mody a écrit : >> >> >> >> > @ rusy > >> "Ive reworded it to make it clear that I am referring to the > character-sets and not encodings." > > Very good, excellent, comment. An healthy coding scheme can only work > properly with a unique characters set and the coding is achieved with > the help of a unique operator. There is no other way to do it and that's > the reason why we have to live today with all these coding schemes > (unicode or not). Note: A coding scheme can be much more complex than > the coding of "raw" characters (eg. CID fonts). >> "So instead of using λ (0x3bb) we should use 𝝀 (0x1d740) or >> something thereabouts like 𝜆" For those who cannot see them, they are: py> unicodedata.name('\U0001d740') 'MATHEMATICAL BOLD ITALIC SMALL LAMDA' py> unicodedata.name('\U0001d706') 'MATHEMATICAL ITALIC SMALL LAMDA' ("LAMDA" is the official Unicode name for Lambda.) > This is a very good understanding of unicode. The letter lambda is not > the mathematical symbole lambda. Another example, the micro sign is not > the greek letter mu which is not the mathematical mu. Depends what you mean by "is not". The micro sign is a legacy compatibility character, we shouldn't use it except for compatibility with legacy (non-Unicode) character sets. Instead, we should use the NFKC or NFKD normalization forms to convert it to the recommended character. py> import unicodedata py> a = '\N{GREEK SMALL LETTER MU}' # Preferred py> b = '\N{MICRO SIGN}' # Legacy py> a == b False py> unicodedata.normalize('NFKD', b) == a True py> unicodedata.normalize('NFKC', b) == a True As for the mathematical mu, there is no separate Unicode "maths symbol mu" so far as I am aware. One would simply use '\N{MICRO SIGN}' or '\N{GREEK SMALL LETTER MU}' to get a μ. Likewise, the λ used in mathematics is the Greek letter λ, not a separate symbol, just like the Latin letter x and the x used in mathematics are the same. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon wrote: > Yes that was it. I changed the first line of my script to: > > #!/opt/local/bin/python2.7 > > and it now works. Excellent! Shebangs are *extremely* specific, so you may want to consider using "/usr/bin/env python" to get a bit more flexibility. (Or "python2" or "python2.7" in place of "python", depending on how specific you want to be.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On Tue, 22 Apr 2014 12:29:56 +0200, Antoon Pardon wrote: > I am workin on a solaris 11 machine. The python version is 2.7.6 path to > python is /opt/local/bin/python. Are you sure about that? You ought to double check that /opt/local/bin/ python is what you think it is, and not (say) a symlink to a different binary. > These are the 15 first lines of the script: > > #! /opt/local/bin/python This being Solaris, what happens if you remove the space between the hash- bang and the path? On Linux it makes no difference, but Solaris tends to be a bit more idiosyncratic about things like this. [...] > However if I call the script directly and want the #! line do its work I > get the following error. > > # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head > /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `(' > /usr/local/bin/ldapwatch: line 3: `class vslice(object):' That's not a Python syntax error, so its something else failing before Python gets to see it. The only way I can reproduce this is to execute Python code using sh: [steve@ando ~]$ cat ./test2 class X(object): pass print X [steve@ando ~]$ ./test2 ./test2: line 1: syntax error near unexpected token `(' ./test2: line 1: `class X(object):' > Does anyone have an idea where I should look to fix this? Ask your local Solaris expert :-) This appears to be the same symptoms: http://www.linuxmisc.com/12-unix-shell/581d028236386dae.htm -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On Tue, Apr 22, 2014 at 10:36 PM, Steven D'Aprano wrote: >> These are the 15 first lines of the script: >> >> #! /opt/local/bin/python > > This being Solaris, what happens if you remove the space between the hash- > bang and the path? On Linux it makes no difference, but Solaris tends to > be a bit more idiosyncratic about things like this. I'm pretty sure the POSIX standard stipulates that a space there is optional. Should be no difference between "#!/" and "#! /" on any compliant OS. (But I can't right now find a citation for that, so I may be wrong.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On 22-04-14 14:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > Excellent! Shebangs are *extremely* specific, so you may want to > consider using "/usr/bin/env python" to get a bit more flexibility. The problem with that is that it doesn't work if python is not on the (standard) path, like in this case. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On Tue, Apr 22, 2014 at 11:01 PM, Antoon Pardon wrote: > On 22-04-14 14:26, Chris Angelico wrote: > >> On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon >> wrote: >>> Yes that was it. I changed the first line of my script to: >>> >>> #!/opt/local/bin/python2.7 >>> >>> and it now works. >> Excellent! Shebangs are *extremely* specific, so you may want to >> consider using "/usr/bin/env python" to get a bit more flexibility. > > The problem with that is that it doesn't work if python is not on > the (standard) path, like in this case. Ah! Well, that's why I said "consider using" rather than "you should use" :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On 2014-04-22 22:52, Chris Angelico wrote: > I'm pretty sure the POSIX standard stipulates that a space there is > optional. Should be no difference between "#!/" and "#! /" on any > compliant OS. (But I can't right now find a citation for that, so I > may be wrong.) I wondered this too, so went researching and found this: http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number which said that there was actually some contention that the space was required, but that the specs state that both with-and-without are permissible. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On Tue, Apr 22, 2014 at 11:22 PM, Tim Chase wrote: > On 2014-04-22 22:52, Chris Angelico wrote: >> I'm pretty sure the POSIX standard stipulates that a space there is >> optional. Should be no difference between "#!/" and "#! /" on any >> compliant OS. (But I can't right now find a citation for that, so I >> may be wrong.) > > I wondered this too, so went researching and found this: > > http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number > > which said that there was actually some contention that the space was > required, but that the specs state that both with-and-without are > permissible. Yeah, I read the Wikipedia page, but was looking for a citable standards document, and didn't find one. (Which may just mean I didn't look hard enough. Wasn't going to spend an hour on it.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Best Website Design Services by Professional Web Designing Company
On Tue, 22 Apr 2014 02:21:01 -0700, aveinfosys wrote: > Ave Infosys is a leading professional in Web Designing Company in > Hyderabad India for the > > E-Business Industry.Ave Infosys are providing Best Website Development > and Design Services > > in Hyderabad.Our company offers the Best Web Design & Development > services, Web Hosting > > Services,Responsive and Mobile Designing services,Ecommerce websites > services,Digital > > Marketing Services,Website Design Services. We have intensive web design > and web skills > > merging with the quality essence of expertise should have component to > help you to ascertain > > your internet presence or take it to the next level.we are the Best Web > Design Company in > > Hyderabad. > > For More Details : > > Please contact: (+91) 40 40275321 > > Email : i...@aveinfosys.com > > Web : http://aveinfosys.com/website-design Considering the poor quality of your own site it is hardly surprising that you have to resorts to spamming a totally unrelated newsgroup/ mailing list. -- Cache miss - please take better aim next time -- https://mail.python.org/mailman/listinfo/python-list
Google open positions at Shanghai/China ?
Hi guys, Anybody know if there are openning positions at Shanghai, China? Just ask for one of my friend in case someone here woring for Google:-) Although see some opened positions from google career, seems no actaully hire going on. Thanks. Wesley -- https://mail.python.org/mailman/listinfo/python-list
Re: Best Website Design Services by Professional Web Designing Company
On Tue, Apr 22, 2014 at 11:40 PM, alister wrote: > Considering the poor quality of your own site it is hardly surprising > that you have to resorts to spamming a totally unrelated newsgroup/ > mailing list. If you *must* respond to spam, please at least trim out the URLs so they don't get free exposure... ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Best Website Design Services by Professional Web Designing Company
On Wed, 23 Apr 2014 00:35:37 +1000, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 11:40 PM, alister > wrote: >> Considering the poor quality of your own site it is hardly surprising >> that you have to resorts to spamming a totally unrelated newsgroup/ >> mailing list. > > If you *must* respond to spam, please at least trim out the URLs so they > don't get free exposure... > > ChrisA Sorry :-( -- In the force if Yoda's so strong, construct a sentence with words in the proper order then why can't he? -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
Le mardi 22 avril 2014 14:21:40 UTC+2, Steven D'Aprano a écrit : > On Tue, 22 Apr 2014 02:07:58 -0700, wxjmfauth wrote: > > > > > Le mardi 22 avril 2014 08:30:45 UTC+2, Rustom Mody a écrit : > > >> > > >> > > >> > > >> > > > @ rusy > > > > > >> "Ive reworded it to make it clear that I am referring to the > > > character-sets and not encodings." > > > > > > Very good, excellent, comment. An healthy coding scheme can only work > > > properly with a unique characters set and the coding is achieved with > > > the help of a unique operator. There is no other way to do it and that's > > > the reason why we have to live today with all these coding schemes > > > (unicode or not). Note: A coding scheme can be much more complex than > > > the coding of "raw" characters (eg. CID fonts). > > >> "So instead of using λ (0x3bb) we should use 𝝀 (0x1d740) or > > >> something thereabouts like 𝜆" > > > > For those who cannot see them, they are: > > > > py> unicodedata.name('\U0001d740') > > 'MATHEMATICAL BOLD ITALIC SMALL LAMDA' > > py> unicodedata.name('\U0001d706') > > 'MATHEMATICAL ITALIC SMALL LAMDA' > > > > > > ("LAMDA" is the official Unicode name for Lambda.) > > > > > > > This is a very good understanding of unicode. The letter lambda is not > > > the mathematical symbole lambda. Another example, the micro sign is not > > > the greek letter mu which is not the mathematical mu. > > > > Depends what you mean by "is not". The micro sign is a legacy > > compatibility character, we shouldn't use it except for compatibility > > with legacy (non-Unicode) character sets. Instead, we should use the NFKC > > or NFKD normalization forms to convert it to the recommended character. > > > > > > py> import unicodedata > > py> a = '\N{GREEK SMALL LETTER MU}' # Preferred > > py> b = '\N{MICRO SIGN}' # Legacy > > py> a == b > > False > > py> unicodedata.normalize('NFKD', b) == a > > True > > py> unicodedata.normalize('NFKC', b) == a > > True > > > > As for the mathematical mu, there is no separate Unicode "maths symbol > > mu" so far as I am aware. One would simply use '\N{MICRO SIGN}' or > > '\N{GREEK SMALL LETTER MU}' to get a μ. > > > > Likewise, the λ used in mathematics is the Greek letter λ, not a separate > > symbol, just like the Latin letter x and the x used in mathematics are > > the same. > > Normalization is working fine, but it proofs nothing, it has to use some convention. There are several code points ranges (latin + greek), which can be used for mathematical purpose (different mu's). If you are interested, search for "unimath-symbols.pdf" on CTAN (I have all this stuff on my hd). ... "Likewise, the λ used in mathematics is the Greek letter λ, not a separate symbol, just like the Latin letter x and the x used in mathematics are the same. "... just like the Latin letter x and the x used in mathematics are the same. ... Oh! Definitively not. A tool with an unicode engine able to produce "math text" will certainly not use the same code point for a "textual x" or for a "mathematical x", even if one enter/type/hit the same "x". To be exaggeratedly stict, the real question is to know if a used "lambda" or "x" belongs to a "math unicode range" or not. This is quite a different approach. (Please no confusion with a "text litteral variable x"). A text processing tool will notice the difference, it will use different fonts. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: Running programs on mobile phones
> I have seen by chance a number of years ago a book on Python programming > for running on mobile phones (of a certain producer only). What is the > current state of the art in that? Could someone kindly give a few good > literature references? Thanks in advance. I'm not an expert, but take a look at http://kivy.org/. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Tuesday, April 22, 2014 12:01:06 PM UTC+5:30, Ian wrote: > On Apr 22, 2014 12:01 AM, "Rustom Mody" wrote: > > As a unicode user (ok wannabe unicode user :D ) Ive > > written up some unicode ideas that have been discussed here in the > > last couple of weeks: > > http://blog.languager.org/2014/04/unicoded-python.html > I'm reminded of this satire: > http://www.ojohaven.com/fun/spelling.html At the risk of 'explaining the joke' I believe it becomes comical due to the cumulating effect of suggesting ← for assignment and then using that. Since I dont like its look in any fonts that I can check, I am returning the (subsequent) examples to to good (or bad) old = Also the λ is unnecessarily contentions. Been replaced by more straightforward introductory examples. -- https://mail.python.org/mailman/listinfo/python-list
analyse Chinese language using Python code
How to analyse Chinese language using Python code? -- https://mail.python.org/mailman/listinfo/python-list
Re: analyse Chinese language using Python code
On Tuesday, April 22, 2014 3:04:39 PM UTC-4, linda.s wrote: > How to analyse Chinese language using Python code? You will need to program a pattern recognizer system. Are you interested in spoken chinese or written Kanji? xie xie JB -- https://mail.python.org/mailman/listinfo/python-list
Glade on Windows using Python
Using Windows 8.1 Update. I've loaded ActiveState python (version 2.7) --- installed OK. I don't need Glade, but I do want to use some Glade XML and run the python application. To run a Glade application this needs: from gi.repository import Gtk gi.repository is not available to import. Where can I find gi.repository?all searches to date have come up empty! Mary -- https://mail.python.org/mailman/listinfo/python-list
Why does isoformat() optionally not print the fractional seconds?
Python(3) let me down today. Better to be explicit, and all that, didn’t pan out for me. I have time series data being recorded in a mongo database (I love pymongo). I have an iOS app that consumes the data. Since JSON doesn’t have a time format, I have to stringify the times when transmitting between the two. To parse it on the obj-c side, I use NSDateFormatter *parser = [NSDateFormatter new]; parser = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [parser setDateFormat:@"-MM-dd'T'HH:mm:ss.S”]; NSDate *date = [parser dateFromString: thatJsonString]; Which was working swimmingly, until I started getting occasional and infrequent nil dates at times. I thought I had a storage issue or something with my REST api, or the server, or something. But it was simply now and then again, why 1000’s of data points, I managed to get 0 milliseconds from time to time, which resulted in the isoformat() I was using to suddenly leave off the .S part of the string. And since the parse then failed, the iOS side decided it wasn’t valid and returned a nil. Haven’t decided where/how I’ll work around it yet, but the isoformat() seemed unpythonic to me today. Thanks for hearing me whine. -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly
On 22/04/2014 13:52, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:36 PM, Steven D'Aprano > wrote: >>> These are the 15 first lines of the script: >>> >>> #! /opt/local/bin/python >> >> This being Solaris, what happens if you remove the space between the hash- >> bang and the path? On Linux it makes no difference, but Solaris tends to >> be a bit more idiosyncratic about things like this. > > I'm pretty sure the POSIX standard stipulates that a space there is > optional. Should be no difference between "#!/" and "#! /" on any > compliant OS. (But I can't right now find a citation for that, so I > may be wrong.) > > ChrisA > man execve 4.3BSD implicitly mandates a space given its description of the shebang line, while POSIX simply implies the presence of a space. I have recently had to check this point. All current kernel implementations I cared to check would strip whitespace around the interpreter, although Solaris was not one such implementation. ~Andrew -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On 22/04/2q014 13:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > > Excellent! Shebangs are *extremely* specific, so you may want to > consider using "/usr/bin/env python" to get a bit more flexibility. > (Or "python2" or "python2.7" in place of "python", depending on how > specific you want to be.) > > ChrisA > `man execve` "The interpreter must be a valid pathname for an executable which is not itself a script." This is (presumably) to avoid recursive walks of the filesystem trying to locate a valid interpreter to splat over the virtual address space of the currently executing process. ~Andrew -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange syntax error, occurs only when script is executed directly [solved]
On 22/04/2q014 13:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > > Excellent! Shebangs are *extremely* specific, so you may want to > consider using "/usr/bin/env python" to get a bit more flexibility. > (Or "python2" or "python2.7" in place of "python", depending on how > specific you want to be.) > > ChrisA > `man execve` "The interpreter must be a valid pathname for an executable which is not itself a script." This is (presumably) to avoid recursive walks of the filesystem trying to locate a valid interpreter to splat over the virtual address space of the currently executing process. ~Andrew -- https://mail.python.org/mailman/listinfo/python-list
Re: Why does isoformat() optionally not print the fractional seconds?
On 2014-04-23 01:05, Travis Griggs wrote: Python(3) let me down today. Better to be explicit, and all that, didn’t pan out for me. I have time series data being recorded in a mongo database (I love pymongo). I have an iOS app that consumes the data. Since JSON doesn’t have a time format, I have to stringify the times when transmitting between the two. To parse it on the obj-c side, I use NSDateFormatter *parser = [NSDateFormatter new]; parser = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [parser setDateFormat:@"-MM-dd'T'HH:mm:ss.S”]; NSDate *date = [parser dateFromString: thatJsonString]; Which was working swimmingly, until I started getting occasional and infrequent nil dates at times. I thought I had a storage issue or something with my REST api, or the server, or something. But it was simply now and then again, why 1000’s of data points, I managed to get 0 milliseconds from time to time, which resulted in the isoformat() I was using to suddenly leave off the .S part of the string. And since the parse then failed, the iOS side decided it wasn’t valid and returned a nil. Haven’t decided where/how I’ll work around it yet, but the isoformat() seemed unpythonic to me today. Thanks for hearing me whine. Omitting fractional seconds is permitted by the standard. There was a thread last year about it: Making datetime __str__ and isoformat more consistent https://mail.python.org/pipermail//python-ideas/2013-November/023913.html -- https://mail.python.org/mailman/listinfo/python-list
Unicode in Python
Chris Angelico wrote: > it's impossible for most people to type (and programming with a palette > of arbitrary syntactic tokens isn't my idea of fun)... Where's the suggestion to use a "palette of arbitrary tokens" ? I just tried a greek keyboard; ie do $ setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" -layout "us,gr" Thereafter typing abcdefghijklmnopqrstuvwxyz after a Shift-Alt gives αβψδεφγηιξκλμνοπ;ρστθωςχυζ One more Shift-Alt and back to roman IOW the extra typing cost for greek letters is negligible over the corresponding roman ones Of course - One would need to define such a keyboard (setxkb) - One would have to find similar technologies for other OSes (Im on debian; even ubuntu/unity grabs too many keys) -- https://mail.python.org/mailman/listinfo/python-list
object().__dict__
There are some basics about Python objects I don't understand. Consider this snippet: class X: pass ... x = X() dir(x) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] x.foo = 11 And now I want to make a simple object in a shorter way, without declaring X class: y = object() dir(y) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] y.foo = 12 Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute 'foo' The attribute list is different now and there's no __dict__ and the object does not accept new attributes. Please explain what's going on. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Wed, Apr 23, 2014 at 3:31 PM, Rustom Mody wrote: > Chris Angelico wrote: >> it's impossible for most people to type (and programming with a palette >> of arbitrary syntactic tokens isn't my idea of fun)... > > Where's the suggestion to use a "palette of arbitrary tokens" ? > > I just tried a greek keyboard; ie do > $ setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" -layout > "us,gr" > > Thereafter typing > abcdefghijklmnopqrstuvwxyz > after a Shift-Alt > gives > αβψδεφγηιξκλμνοπ;ρστθωςχυζ > > One more Shift-Alt and back to roman Okay. Now what about your other symbols? Your alternative assignment operator, for instance. How do you type that? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Tue, 22 Apr 2014 22:31:41 -0700, Rustom Mody wrote: > Chris Angelico wrote: >> it's impossible for most people to type (and programming with a palette >> of arbitrary syntactic tokens isn't my idea of fun)... > > Where's the suggestion to use a "palette of arbitrary tokens" ? > > I just tried a greek keyboard; ie do > $ setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" > -layout "us,gr" > > Thereafter typing > abcdefghijklmnopqrstuvwxyz > after a Shift-Alt > gives > αβψδεφγηιξκλμνοπ;ρστθωςχυζ > > One more Shift-Alt and back to roman > > IOW the extra typing cost for greek letters is negligible over the > corresponding roman ones 25 Unicode characters down, 1114000+ to go :-) There's not just the keyboard mapping. There's the mental cost of knowing which keyboard mapping you need ("is it Greek, Hebrew, or maths symbols?"), the cost of remembering the mapping from the keys you see on the keyboard to the keys they are mapped to ("is Ω mapped to O or W?") and so forth. If you know lambda-calculus, you might associate λ with functions, but if you don't, it's as obfuscated as associating Ч with raising exceptions. if not isinstance(obj, int): ЧTypeError("expected an int, got %r" % type(obj)) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: object().__dict__
Pavel Volkov writes: > The attribute list is different now and there's no __dict__ and the > object does not accept new attributes. > Please explain what's going on. It's a leaky abstraction, unfortunately. By default, all user-defined types will provide their instances with a ‘__dict__’ attribute, whic is a mapping to store the instance's attributes. But some types don't have that, and ‘object’ is one of them. It deliberately overrides the default behaviour, and has no ‘__dict__’ for its instances. >>> foo = object() >>> foo.bar = "spam" Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute 'bar' >>> foo.__dict__ Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute '__dict__' Your user-defined types, even though they inherit from ‘object’, will get a ‘__dict__’ as normal:: >>> class Bag: >>> """ A simple type to hold attributes. """ >>> Bag.__mro__ (, ) >>> foo = Bag() >>> foo.bar = "spam" >>> foo.__dict__ {'bar': 'spam'} See the discussion of ‘__slots__’, and note also that it's not recommended to use this unless you know exactly why you need it https://docs.python.org/3/reference/datamodel.html#slots>. I consider it a wart of Python that its ‘object’ instances lack the ability to gain arbitrary attributes in the way you expect. -- \ “Every man would like to be God, if it were possible; some few | `\ find it difficult to admit the impossibility.” —Bertrand | _o__)Russell, _Power: A New Social Analysis_, 1938 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: object().__dict__
On 23Apr2014 09:39, Pavel Volkov wrote: There are some basics about Python objects I don't understand. Consider this snippet: class X: pass ... x = X() dir(x) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] x.foo = 11 And now I want to make a simple object in a shorter way, without declaring X class: y = object() dir(y) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] y.foo = 12 Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute 'foo' The attribute list is different now and there's no __dict__ and the object does not accept new attributes. Please explain what's going on. The base "object" class has a fixed set of attributes; you can't add more. Almost every other class lets you add attributes, but the price for that is that it is slightly in memory footprint and slower to access. Look up the "__slots__" dunder var in the Python doco index: https://docs.python.org/3/glossary.html#term-slots You'll see it as a (rarely used, mostly discouraged) way to force a fixed set of attributes onto a class. As with object, this brings a smaller memory footprint and faster attribute access, but the price is flexibility. Cheers, Cameron Simpson Try being nothing but bored for 4 hours straight, and then tell me that there's no fear involved. - d...@elxr.jpl.nasa.gov (Dave Hayes) -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
On Tue, Apr 22, 2014 at 10:52 PM, Steven D'Aprano wrote: > There's not just the keyboard mapping. There's the mental cost of knowing > which keyboard mapping you need ("is it Greek, Hebrew, or maths > symbols?"), the cost of remembering the mapping from the keys you see on > the keyboard to the keys they are mapped to ("is Ω mapped to O or W?") > and so forth. If you know lambda-calculus, you might associate λ with > functions, [...] Or if you know Python and the name of the letter ("lambda"). But yes, typing out the special characters is annoying. I just use words. The only downside to using words is, how do you specify capital versus lowercase letters? "Gamma = ..." violates the style guide! :( -- Devin -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode in Python
Devin Jeanpierre writes: > But yes, typing out the special characters is annoying. I just use > words. I use words that describe the meaning, where feasible. > The only downside to using words is, how do you specify capital > versus lowercase letters? Why do you need to, for an identifier? If uppercase gamma is semantically different from lowercase gamma for identifying a value, then both are too terse and the meaning should be spelled out in a better chosen semantic name. -- \ “Some people have a problem, and they think “I know, I'll use | `\ Perl!”. Now they have some number of problems but they're not | _o__) sure whether it's a string or an integer.” —Benno Rice, 2011 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list