ANN: eGenix pyOpenSSL Distribution 0.13.4.1.0.1.9
ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.4.1.0.1.9 An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.4.1.0.1.9.html INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ NEWS This new release of the eGenix.com pyOpenSSL Distribution updates the included OpenSSL version to the latest OpenSSL 1.0.1h version and adds a few more context options: New in OpenSSL -- * Updated included OpenSSL libraries from OpenSSL 1.0.1h to 1.0.1i. See https://www.openssl.org/news/secadv_20140806.txt for a complete list of changes. Most fixes apply to the OpenSSL DTLS implementation, which pyOpenSSL currently does not support. The following fix is relevant for pyOpenSSL applications: - CVE-2014-3511: A flaw in the OpenSSL TLS server code allows a man-in-the-middle attacker to force a downgrade to TLS 1.0. New in pyOpenSSL * Compiled pyOpenSSL with OPENSSL_LOAD_CONF to have the OpenSSL libs automatically load the openssl.cnf configuration file. This allows easy configuration of additional OpenSSL parameters and defaults, locations of certificate files, hardware engines, etc. without having to change the application code. Please see the documentation for details. * Updated the included CA root certificate bundles to Mozilla's 2014-07-15 update. pyOpenSSL / OpenSSL Binaries Included - In addition to providing sources, we make binaries available that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64. We've also added egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. ___ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. MORE INFORMATION For more information about the eGenix pyOpenSSL Distribution, licensing and download instructions, please visit our web-site or write to sa...@egenix.com. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 14 2014) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: how to write file into my android phone?
On 10/08/2014 7:08 PM, Chris “Kwpolska” Warrick wrote: 2) the phone isn't necessarily visible on a pc as a drive at all. For example the Samsung gs4. This is actually true for ALL android devices, starting with Android 3.0. This isn't true for my Samsung gs2 running Android 4.1.2. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to write file into my android phone?
On Aug 14, 2014 8:11 AM, alex23 wuwe...@gmail.com wrote: On 10/08/2014 7:08 PM, Chris “Kwpolska” Warrick wrote: 2) the phone isn't necessarily visible on a pc as a drive at all. For example the Samsung gs4. This is actually true for ALL android devices, starting with Android 3.0. This isn't true for my Samsung gs2 running Android 4.1.2. Apparently, Samsung modified the feature for this phone, which shipped with 2.3 Gingerbread, to prevent breaking user experience. Galaxy S3 shipped with 4.0 ICS and uses MTP. -- Chris “Kwpolska” Warrick http://chriswarrick.com/ Sent from my SGS3. -- https://mail.python.org/mailman/listinfo/python-list
Re: a python console in bluestacks
On Aug 14, 2014 4:30 AM, luofeiyu elearn2...@gmail.com wrote: I have installed bluestacks(an android phone emulator) on my pc,and SL4A on it.Now i can run python thish way : 1.edit an file ending with .py, save it in /sdcard/sl4a/scripts/yourname.py. 2.open sl4a ,and click the file to make it run. Is there a python console to type python command to run python directly such as in pc ? Why are you using an Android emulator to run Python, a PC-first software?! Just install the Windows version from http://python.org/ and use that. -- Chris “Kwpolska” Warrick http://chriswarrick.com/ Sent from my SGS3. -- https://mail.python.org/mailman/listinfo/python-list
Re: newbee
On Aug 13, 2014 9:34 PM, Terry Reedy tjre...@udel.edu wrote: Have you verified that Idle *does* (not just *should*) run on RPi? (That would mean having tcl/tk running, with whatever *it* requires on linux.) I am working on Idle and the idea of people (especially hobbyists, students, and other amateurs) running it on microsystems would really please me. I don't have a RPi, but I know it is just a glorified ARM computer with terrible specs. But it is enough to run LXDE or other lightweight graphical environments, which means tcl/tk is VERY likely to work. You could also look up packages for Raspbian or other RPi-friendly distros and see python-tk there, or various Python tutorials for the device: http://davidbriddock.blogspot.com/2013/04/learn-python-installing-tkinter.html -- Chris “Kwpolska” Warrick http://chriswarrick.com/ Sent from my SGS3. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
in the manual https://docs.python.org/3.4/library/time.html %z Time zone offset indicating a positive or negative time difference from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal hour digits and M represents decimal minute digits [-23:59, +23:59]. %Z Time zone name (no characters if no time zone exists). t1='Sat, 09 Aug 2014 07:36:46 ' time.strptime(t1,%a, %d %b %Y %H:%M:%S ) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the same result? t3='Sat, 09 Aug 2014 07:36:46 +0400' time.strptime(t3,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The Directive %z has no any effect here,what is the matter? On 8/14/2014 10:01 AM, Ben Finney wrote: luofeiyu elearn2...@gmail.com writes: s=Aug how can i change it into 8 with some python time module? What is your purpose here? If you want to parse a text value into a structured time object, don't do it piece by piece. Use the ‘time.strptime’ function. import time input_time_text = 14 Aug 2014 input_time = time.strptime(input_text, %d %b %Y) input_time.tm_mon 8 -- https://mail.python.org/mailman/listinfo/python-list
Re: newbee
in 726715 20140813 103037 Chris Angelico ros...@gmail.com wrote: On Wed, Aug 13, 2014 at 9:57 AM, Frank Scafidi fpscaf...@gmail.com wrote: I just acquired a Raspberry Pi and want to program in Python. I was a PL/1 programmer back in the 60's 70's and Python is similar. I am struggling with some very fundamental things that I am not finding in the documentation. Can someone help me with the basics like how do I save a program I've written, reload it in Python, list the program once it's loaded? How do I edit a program? Are these command line functions? These sound like RPi questions, rather than Python questions. You may find knowledgeable people here on this list, but if not, I would advise hunting down an RPi mailing list or newsgroup and asking there. Most of us here use full computers, where questions like how do I save a file? are trivially easy... you may find, actually, that starting on a PC and then pushing the file to the RPi is the easiest way to work. comp.sys.rapberry-pi -- https://mail.python.org/mailman/listinfo/python-list
Re: a python console in bluestacks
On 14Aug2014 08:25, Chris =?utf-8?B?4oCcS3dwb2xza2HigJ0=?= Warrick kwpol...@gmail.com wrote: On Aug 14, 2014 4:30 AM, luofeiyu elearn2...@gmail.com wrote: I have installed bluestacks(an android phone emulator) on my pc,and SL4A on it.Now i can run python thish way : 1.edit an file ending with .py, save it in /sdcard/sl4a/scripts/ yourname.py. 2.open sl4a ,and click the file to make it run. Is there a python console to type python command to run python directly such as in pc ? Why are you using an Android emulator to run Python, a PC-first software?! Just install the Windows version from http://python.org/ and use that. Maybe he wants Python to run on the emulator? Just an idea... Cheers, Cameron Simpson c...@zip.com.au The wonderous pulp and fibre of the brain had been substituted by brass and iron; he had taught wheelwork to think. - Harry Wilmot Buxton 1832, referring to Charles Babbage and his difference engine. -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
python3.4 On 8/14/2014 10:12 AM, Tim Chase wrote: On 2014-08-14 10:01, luofeiyu wrote: help(int.__init__) Help on wrapper_descriptor: __init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. what is the / mean in __init__(self, /, *args, **kwargs) ? Where are you seeing this? Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature ^D Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
Please don't top-post your response. Instead, interleave your response and remove irrelevant quoted material. Use the Interleaved style URL:https://en.wikipedia.org/wiki/Posting_style#Interleaved_style. luofeiyu elearn2...@gmail.com writes: in the manual https://docs.python.org/3.4/library/time.html %zTime zone offset […] %ZTime zone name (no characters if no time zone exists). t1='Sat, 09 Aug 2014 07:36:46 ' time.strptime(t1,%a, %d %b %Y %H:%M:%S ) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) Your code examples will be easier to read if you follow PEP 8 (in this example, spaces around the operators as described in the style guide). t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the same result? The timezone in ‘t2’ will only be understood subject to the caveat: Support for the %Z directive is based on the values contained in tzname and whether daylight is true. Because of this, it is platform-specific except for recognizing UTC and GMT which are always known (and are considered to be non-daylight savings timezones). URL:https://docs.python.org/3/library/time.html#time.strptime So you'll need to see what your Python implementation supports (see ‘time.tzname’). The support for time zones is always a pain, because they *change* rapidly, arbitrarily, and with very little warning. Because of this, the Python standard library does not attempt to contain a timezone database, since it would almost immediately be out of date. Install the ‘pytz’ package to get the latest released timezone database supported in Python URL:https://pypi.python.org/pypi/pytz. -- \ “It is better to have loft and lost than to never have loft at | `\ all.” —Groucho Marx | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: a python console in bluestacks
i want to run python on my android phone ,to install python on bluestacks is to emulate it . On 8/14/2014 2:56 PM, Cameron Simpson wrote: On 14Aug2014 08:25, Chris =?utf-8?B?4oCcS3dwb2xza2HigJ0=?= Warrick kwpol...@gmail.com wrote: On Aug 14, 2014 4:30 AM, luofeiyu elearn2...@gmail.com wrote: I have installed bluestacks(an android phone emulator) on my pc,and SL4A on it.Now i can run python thish way : 1.edit an file ending with .py, save it in /sdcard/sl4a/scripts/ yourname.py. 2.open sl4a ,and click the file to make it run. Is there a python console to type python command to run python directly such as in pc ? Why are you using an Android emulator to run Python, a PC-first software?! Just install the Windows version from http://python.org/ and use that. Maybe he wants Python to run on the emulator? Just an idea... Cheers, Cameron Simpson c...@zip.com.au The wonderous pulp and fibre of the brain had been substituted by brass and iron; he had taught wheelwork to think. - Harry Wilmot Buxton 1832, referring to Charles Babbage and his difference engine. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
import sys sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' import time time.tzname ('China Standard Time', 'China Daylight Time') On 8/14/2014 3:25 PM, Cameron Simpson wrote: On 14Aug2014 14:52, luofeiyu elearn2...@gmail.com wrote: in the manual https://docs.python.org/3.4/library/time.html ┌──┬──┬─┐ │ │Time zone offset indicating a positive or negative time difference│ │ │%z│from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal │ │ │ │hour digits and M represents decimal minute digits [-23:59, +23:59]. │ │ ├──┼──┼─┤ │%Z│Time zone name (no characters if no time zone exists).│ │ └──┴──┴─┘ t1='Sat, 09 Aug 2014 07:36:46 ' time.strptime(t1,%a, %d %b %Y %H:%M:%S ) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the same result? What you get back a struct_time, which is little more than the numeric values extracted from a time string. And as far as the text you have supplied in your example, those values are the same. Regarding the difference, string in t2 has a time zone offset. My Python 3.4 doco says (about struct_time): Changed in version 3.3: tm_gmtoff and tm_zone attributes are available on platforms with C library supporting the corresponding fields in struct tm. Judging by your output, your C library does not support the tm_gmtoff and tm_zone fields in its C library struct tm. Please: tell us what specific version of Python you are using tell us what OS you're running on Then look up the localtime() or gmtime() functions for you C library and see what that documentation says about struct tm, which is what they and the C library strptime() return. t3='Sat, 09 Aug 2014 07:36:46 +0400' time.strptime(t3,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The Directive %z has no any effect here,what is the matter? The directive allows the strptime parser to keep recognising text. Imagine, for example, that the timezone were embedded in the middle of the string for some reason. It looks like you platform does not support storing the time zone information in the C library struct tm, and therefore it does not get exposed to the Python interpreter. Cheers, Cameron Simpson c...@zip.com.au What I want is Facts. Teach these boys and girls nothing but Facts. Facts alone are wanted in life. Plant nothing else, and root out everything else. - Charles DickensJohn Huffam 1812-1870 Hard Times [1854] -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
On 14Aug2014 15:30, luofeiyu elearn2...@gmail.com wrote: import sys sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' First, please post in an interleaved style so that we can see your responses underneath the text to which they relate. Thanks. Ok, you have Python 3.4.0. And (I am guessing from the MSC), some 64 bit Windows install? You will need to look up the Microsoft documentation to see whather your C library struct tm supports timezone information. Your Android phone will be running some flavour of Linux I believe. Someone who has used one may correct me here. import time time.tzname ('China Standard Time', 'China Daylight Time') Ok. Have a look at time.timezone. That may help you. Cheers, Cameron Simpson c...@zip.com.au On 8/14/2014 3:25 PM, Cameron Simpson wrote: On 14Aug2014 14:52, luofeiyu elearn2...@gmail.com wrote: in the manual https://docs.python.org/3.4/library/time.html ┌──┬──┬─┐ │ │Time zone offset indicating a positive or negative time difference│ │ │%z│from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal │ │ │ │hour digits and M represents decimal minute digits [-23:59, +23:59]. │ │ ├──┼──┼─┤ │%Z│Time zone name (no characters if no time zone exists). │ │ └──┴──┴─┘ t1='Sat, 09 Aug 2014 07:36:46 ' time.strptime(t1,%a, %d %b %Y %H:%M:%S ) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the same result? What you get back a struct_time, which is little more than the numeric values extracted from a time string. And as far as the text you have supplied in your example, those values are the same. Regarding the difference, string in t2 has a time zone offset. My Python 3.4 doco says (about struct_time): Changed in version 3.3: tm_gmtoff and tm_zone attributes are available on platforms with C library supporting the corresponding fields in struct tm. Judging by your output, your C library does not support the tm_gmtoff and tm_zone fields in its C library struct tm. Please: tell us what specific version of Python you are using tell us what OS you're running on Then look up the localtime() or gmtime() functions for you C library and see what that documentation says about struct tm, which is what they and the C library strptime() return. t3='Sat, 09 Aug 2014 07:36:46 +0400' time.strptime(t3,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The Directive %z has no any effect here,what is the matter? The directive allows the strptime parser to keep recognising text. Imagine, for example, that the timezone were embedded in the middle of the string for some reason. It looks like you platform does not support storing the time zone information in the C library struct tm, and therefore it does not get exposed to the Python interpreter. Cheers, Cameron Simpson c...@zip.com.au What I want is Facts. Teach these boys and girls nothing but Facts. Facts alone are wanted in life. Plant nothing else, and root out everything else. - Charles DickensJohn Huffam 1812-1870 Hard Times [1854] -- https://mail.python.org/mailman/listinfo/python-list
Re: a python console in bluestacks
On Thu, 14 Aug 2014 08:25:00 +0200, Chris “Kwpolska” Warrick wrote: Why are you using an Android emulator to run Python, a PC-first software?! Just install the Windows version from http://python.org/ and use that. If the OP's ultimate aim is to run Python under Android, running it under an Android emulator is a good first step (assuming you trust the emulator is a good match to actual Android). Or perhaps he wants to run an Android-only application, but wants to run it on his PC. In that case, an Android emulator may allow him to do so. Or if he wishes to do Android development on his PC, instead of poking at the virtual keyboard on a screen the size of your palm, being able to test the software on the PC (under emulation) rather than having to upload it to your phone is very useful. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
On 14Aug2014 14:52, luofeiyu elearn2...@gmail.com wrote: in the manual https://docs.python.org/3.4/library/time.html ┌──┬──┬─┐ │ │Time zone offset indicating a positive or negative time difference│ │ │%z│from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal │ │ │ │hour digits and M represents decimal minute digits [-23:59, +23:59]. │ │ ├──┼──┼─┤ │%Z│Time zone name (no characters if no time zone exists).│ │ └──┴──┴─┘ t1='Sat, 09 Aug 2014 07:36:46 ' time.strptime(t1,%a, %d %b %Y %H:%M:%S ) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the same result? What you get back a struct_time, which is little more than the numeric values extracted from a time string. And as far as the text you have supplied in your example, those values are the same. Regarding the difference, string in t2 has a time zone offset. My Python 3.4 doco says (about struct_time): Changed in version 3.3: tm_gmtoff and tm_zone attributes are available on platforms with C library supporting the corresponding fields in struct tm. Judging by your output, your C library does not support the tm_gmtoff and tm_zone fields in its C library struct tm. Please: tell us what specific version of Python you are using tell us what OS you're running on Then look up the localtime() or gmtime() functions for you C library and see what that documentation says about struct tm, which is what they and the C library strptime() return. t3='Sat, 09 Aug 2014 07:36:46 +0400' time.strptime(t3,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The Directive %z has no any effect here,what is the matter? The directive allows the strptime parser to keep recognising text. Imagine, for example, that the timezone were embedded in the middle of the string for some reason. It looks like you platform does not support storing the time zone information in the C library struct tm, and therefore it does not get exposed to the Python interpreter. Cheers, Cameron Simpson c...@zip.com.au What I want is Facts. Teach these boys and girls nothing but Facts. Facts alone are wanted in life. Plant nothing else, and root out everything else. - Charles DickensJohn Huffam 1812-1870 Hard Times [1854] -- https://mail.python.org/mailman/listinfo/python-list
how to write a function to make operation as a argument in the function
I want to write a function to make operation as a argument in the function. |def fun(op,x,y): return(x op y)| it is my target for the funciton: if op =+ fun(op,3,9) =12 if op =* fun(op,3,9) =27 How to write it? -- https://mail.python.org/mailman/listinfo/python-list
Re: a python console in bluestacks
On Aug 14, 2014 9:23 AM, luofeiyu elearn2...@gmail.com wrote: i want to run python on my android phone ,to install python on bluestacks is to emulate it . In this case, you can install QPython, which supports the SL4A modules and has a console. Or, you can install an app to access sh, like ConnectBot (though better apps likely exist.) Another alternative might be to use a real device with adb shell. -- Chris “Kwpolska” Warrick http://chriswarrick.com/ Sent from my SGS3. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
On 14/08/2014 02:46, luofeiyu wrote: s=Aug how can i change it into 8 with some python time module? If all else fails, read the instructions, so start here https://docs.python.org/3/library/datetime.html#module-datetime -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
On 14/08/2014 03:08, Ben Finney wrote: luofeiyu elearn2...@gmail.com writes: help(int.__init__) Help on wrapper_descriptor: __init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. what is the / mean in __init__(self, /, *args, **kwargs) ? I don't know, I haven't seen that before. It is confusing. At least it is acknowledged (“See [elsewhere] for accurate signature”) to be unhelpful. I suspect this is an artefact of the impedance mismatch between Python function signatures and the implementation of ‘int’ in C code. The “/” may be a placeholder for something the C implementation requires but that Python's function signature expectation doesn't allow. Perhaps Python 3's keyword-only arguments may one day help functions like that get implemented with a more useful signature, but I'm not holding my breath for that. Something to do with the Argement Clinic http://legacy.python.org/dev/peps/pep-0436/ ??? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: how to write a function to make operation as a argument in the function
On 14/08/2014 08:32, luofeiyu wrote: I want to write a function to make operation as a argument in the function. |def fun(op,x,y): return(x op y)| it is my target for the funciton: if op =+ fun(op,3,9) =12 if op =* fun(op,3,9) =27 How to write it? With a text editor after you've taken the trouble to read the docs instead of bombarding us with your questions. Start here https://docs.python.org/3/library/operator.html#module-operator As a slight aside would you stop top posting as well. If you have the audacity to ask what that means rather than search I will be sending my boys around. Please be aware, the 17 year old is a very, very vicious thug. He was taught by his granddad, who used to work for the Piranha Brothers, see http://en.wikipedia.org/wiki/Piranha_Brothers :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
pexpect - logging input AND output
i have a script running a few commands on a network device. i can't seem to figure out how to log both the input and output of what the pexpect script initiates and responds to. child = pexpect.spawn ('telnet '+ ip) child.expect ('.*:*') child.sendline (user) child.expect ('.*:*') child.sendline (password) child.expect(['.*#*', '.**']) child.sendline ('enable') child.expect (['Password:', '.*#*']) child.sendline (password) child.expect ('.*#*') child.sendline ('conf t') child.expect ('.*#*') child.sendline ('line vty 0 4') i have tried both these logging commands: child.logfile = open('log.txt', 'w') child.logfile=sys.stdout all i get is the input i send with expect/sendline combinations, i don't get any of what the device sends, only what i send the device: user password enable password conf t line vty 0 4 any ideas of what is the correct way to go about this? just can't get the output! -- https://mail.python.org/mailman/listinfo/python-list
ANN: eGenix pyOpenSSL Distribution 0.13.4.1.0.1.9
ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.4.1.0.1.9 An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.4.1.0.1.9.html INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ NEWS This new release of the eGenix.com pyOpenSSL Distribution updates the included OpenSSL version to the latest OpenSSL 1.0.1h version and adds a few more context options: New in OpenSSL -- * Updated included OpenSSL libraries from OpenSSL 1.0.1h to 1.0.1i. See https://www.openssl.org/news/secadv_20140806.txt for a complete list of changes. Most fixes apply to the OpenSSL DTLS implementation, which pyOpenSSL currently does not support. The following fix is relevant for pyOpenSSL applications: - CVE-2014-3511: A flaw in the OpenSSL TLS server code allows a man-in-the-middle attacker to force a downgrade to TLS 1.0. New in pyOpenSSL * Compiled pyOpenSSL with OPENSSL_LOAD_CONF to have the OpenSSL libs automatically load the openssl.cnf configuration file. This allows easy configuration of additional OpenSSL parameters and defaults, locations of certificate files, hardware engines, etc. without having to change the application code. Please see the documentation for details. * Updated the included CA root certificate bundles to Mozilla's 2014-07-15 update. pyOpenSSL / OpenSSL Binaries Included - In addition to providing sources, we make binaries available that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64. We've also added egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. ___ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. MORE INFORMATION For more information about the eGenix pyOpenSSL Distribution, licensing and download instructions, please visit our web-site or write to sa...@egenix.com. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 14 2014) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- https://mail.python.org/mailman/listinfo/python-list
Re: pexpect - logging input AND output
On Thu, Aug 14, 2014 at 6:59 PM, sj.constant...@gmail.com wrote: i have a script running a few commands on a network device. i can't seem to figure out how to log both the input and output of what the pexpect script initiates and responds to. child = pexpect.spawn ('telnet '+ ip) If that's not working for you, would it be easier instead to simply open a socket connection to port 23 on that IP address? Then you'd just write to the socket (and log what you write) and read from it (and log that). It's possible you'll see some TELNET or ANSI codes coming back, but I expect you won't have to send any of them. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[Q] is 'yield from' syntax sugar for 'for'+'yield'?
Question about 'yield from'. I understand that:: yield from xs is syntax suger of:: for x in xs: yield x And:: val = yield from xs is same as:: for x in xs: ret = yield x val = ret Is it true? Do I understand correctly? quote from https://docs.python.org/3/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator For simple iterators, yield from iterable is essentially just a shortened form of for item in iterable: yield item: -- regards, kwatch -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
On Thu, Aug 14, 2014 at 7:35 PM, Makoto Kuwata kwa...@gmail.com wrote: I understand that:: yield from xs is syntax suger of:: for x in xs: yield x Not just. It's like that for simple cases, but there are edge cases that are much more complicated to do manually, and are simply taken care of. Best would be to read the PEP itself: http://www.python.org/dev/peps/pep-0380/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
On Thu, Aug 14, 2014 at 6:38 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Aug 14, 2014 at 7:35 PM, Makoto Kuwata kwa...@gmail.com wrote: I understand that:: yield from xs is syntax suger of:: for x in xs: yield x Not just. It's like that for simple cases, but there are edge cases that are much more complicated to do manually, and are simply taken care of. Best would be to read the PEP itself: http://www.python.org/dev/peps/pep-0380/ ChrisA Thank you. It seems too complicated... I understand that 'val = yield from xs' is completely different from:: for x in xs: ret = yield x val = x Return value is propagated by StopIteration, like: it = iter(xs) try: while 1: yield next(it) except StopIteration as ex: val = ex.value Thanks. -- regards, kwatch -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
Makoto Kuwata kwa...@gmail.com: val = yield from xs is same as:: for x in xs: ret = yield x val = ret Is it true? Do I understand correctly? The return value is not one of the yielded values. Instead, it's the value returned by the generator/coroutine. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
On Thu, Aug 14, 2014 at 7:59 PM, Makoto Kuwata kwa...@gmail.com wrote: I understand that 'val = yield from xs' is completely different from:: for x in xs: ret = yield x val = x Return value is propagated by StopIteration, like: it = iter(xs) try: while 1: yield next(it) except StopIteration as ex: val = ex.value It's even more complicated than that. The PEP specifies the exact semantics. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
Makoto Kuwata kwa...@gmail.com: Thank you. It seems too complicated... I recommend you stop trying to associate the old yield with the new yield. Asyncio coroutines abuse yield from for a specific effect. The classic purpose of yield was to spoonfeed a sequence of return values to the caller. The coroutine meaning of yield from has nothing whatsoever to do about delivering computation results; instead, it denotes a state where a blocking operation is waited for and the control is handed off to other activities. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Object Systems
Il giorno mercoledì 13 agosto 2014 19:13:16 UTC+2, thequie...@gmail.com ha scritto: What is the difference between traits and roles? People keep using the same names to mean different concepts. For me traits are the things described here: http://www.iam.unibe.ch/~scg/Archive/Papers/Scha03aTraits.pdf I have no idea of what you mean by roles. -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Wed, 13 Aug 2014 07:39:20 -0400, Eric S. Johansson wrote: On 8/12/2014 9:46 PM, Chris Angelico wrote: On Wed, Aug 13, 2014 at 11:36 AM, Wesley nisp...@gmail.com wrote: If my questions make you guys not so happy, I am sorry and please just ignore. I just wanna a general suggestion here in the beginning. Why I need to write such program is just having such requirements, and has nothing to do with the coding work itself. Don't say something to prove you're so noble. The general suggestion you're getting is: Do not do this. Many of us here use CAPTCHAs and spend time keeping one step ahead of those who try to break them with software. By writing something to solve CAPTCHAs, you would be stealing time from those people. Don't do it. Am I sufficiently clear? you are clear but also missing a really good reason to break captchas. handicapped accessibility. Captchas are a huge barrier to access and in many cases push disabled users away from using a service with captchas. Sniplots of very valid complaints about Captcha usability /snip Decent (I use the term loosely because i am no fan either) Captcha systems also provide options for Audio to assist the Visually impaired. I am not sure how well it works but can only assume it is an improvement. One system I have seen removes the need fro captcha completly Instead it relies on Javascript AJAX a short time after loading the page it it requests a unique serial number from the server using which is added to the form as a hidden field. if this field SN is missing from the response then the request is rejected as coming from a Bot. since most bots do not (as far as I know) include a Javascript interpreter this process removes any additional burden from the end user. unfortunately at present in the battle between service providers scumm* the disabled population is an unfortunate victim. I can't think of another slightly polite word for people who spam or hack websites. -- Zeus gave Leda the bird. -- https://mail.python.org/mailman/listinfo/python-list
Re: Optional static typing
On Thu, Aug 14, 2014 at 12:02 AM, Steven D'Aprano st...@pearwood.info wrote: Does anyone here use function annotations? If so, what do you use them for? I've used them a little when converting Python to Cython, though I readily admit that I have no idea if what Cython accepts as a type declaration is compatible with whatever is being considered for 3.5. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: newbee
On Wed, 13 Aug 2014 15:31:37 -0400, Terry Reedy wrote: On 8/13/2014 7:55 AM, alister wrote: I am not in the same league as many of the posters here when it comes to Python but fortunately i do have two Raspberry Pi's :-) Great! We really someone with hands-on experience. I Hope the missing word there is welcome :-) if you are running the Pi connected to a TV/Monitor with the Gui enabled then you should have access to Idle Have you verified that Idle *does* (not just *should*) run on RPi? (That would mean having tcl/tk running, with whatever *it* requires on linux.) I am working on Idle and the idea of people (especially hobbyists, students, and other amateurs) running it on microsystems would really please me. Yes it does, but i tend to run mine headless (X forwarding is still an option though) but I prefer Geany, which i do run on the pi (with x forwarding) with no issues, just remember the Pi is not a particularly fast device. If you have any more questions post them back I hope I can help (Maybe I can become useful to this group as the R-Pi expert, Answering questions, sometimes after experiment and research, is a great way to learn. I would say it is the ONLY way to really learn, you never really understand something until you have broken it and then fixed it or tried to teach it to someone. -- Dungeons and Dragons is just a lot of Saxon Violence. -- https://mail.python.org/mailman/listinfo/python-list
Unable to run print('Réussi') on windows and on linux
Hello, This very simple program runs well on windows 7 # -*- utf8 -*- print('Réussi') But, when I start the vrey same file on Linux (ubuntu 14), I got: Traceback (most recent call last): File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) What should i do to let the same program run on both OS, without changes? Thank you for your answer Marc Vanhoomissen -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
On Thu, Aug 14, 2014 at 7:02 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Aug 14, 2014 at 7:59 PM, Makoto Kuwata kwa...@gmail.com wrote: I understand that 'val = yield from xs' is completely different from:: for x in xs: ret = yield x val = x Return value is propagated by StopIteration, like: it = iter(xs) try: while 1: yield next(it) except StopIteration as ex: val = ex.value It's even more complicated than that. The PEP specifies the exact semantics. ChrisA Well, I wrote the above code in order to describe `value is propagated by StopIteration' because I misunderstood that it is propagated by return value of yield statement (see my first post). I have known that `yield from` is very complicated (thanks to your reply). -- regards, kwatch -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
In article mailman.12994.1408021090.18130.python-l...@python.org, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Thu, 14 Aug 2014 17:47:00 +1000, Cameron Simpson c...@zip.com.au declaimed the following: Your Android phone will be running some flavour of Linux I believe. Someone who has used one may correct me here. Android /is/ the flavor G Though Google has probably done some things to it that make it not-Linux. A closer description might be that the Android phone is running some flavor of Android -- since the OEMs tend to put customized skins on the user interface level. The OEM marketing folks call that a product differentiator. Most everybody else calls it crapware. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
Dennis Lee Bieber wlfr...@ix.netcom.com writes: Android /is/ the flavor G Though Google has probably done some things to it that make it not-Linux. Android is definitely Linux, since that is the kernel Android runs. Remember that Linux is not an operating system; it is one part, the kernel. This is where it's very useful to have a distinct name to refer to the operating system. GNU is an operating system, Android is a completely different operating system. Both happen to have Linux as their kernel. -- \ “I went to San Francisco. I found someone's heart.” —Steven | `\Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit : Hello, This very simple program runs well on windows 7 # -*- utf8 -*- print('Réussi') But, when I start the vrey same file on Linux (ubuntu 14), I got: Traceback (most recent call last): File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) What should i do to let the same program run on both OS, without changes? Thank you for your answer Marc Vanhoomissen No problem on Ubuntu Python 3.2.3 (default, Feb 27 2014, 21:33:50) [GCC 4.6.3] on linux2 Type help, copyright, credits or license for more information. print(Réussi) Réussi Are you really using Python 3 ? $ python3 test.py -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit : Hello, This very simple program runs well on windows 7 # -*- utf8 -*- print('Réussi') But, when I start the vrey same file on Linux (ubuntu 14), I got: Traceback (most recent call last): File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) What should i do to let the same program run on both OS, without changes? the correct comment line should be : # -*- encoding: utf-8 -*- and it could be usefull to begin with #!/usr/bin/env python or #!/usr/bin/env python3 : $ cat réussi.py #!/usr/bin/env python # -*- encoding: utf-8 -*- print('Réussi'); ^D $ chmod +x réussi.py $ ./réussi.py Réussi $ python réussi.py Réussi -- https://mail.python.org/mailman/listinfo/python-list
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
Makoto Kuwata wrote: Question about 'yield from'. I understand that:: yield from xs is syntax suger of:: for x in xs: yield x Not quite syntactic sugar. For simple cases, it does exactly the same thing. For more complicated cases, no. Suppose you have a generator: def spam(): yield Spam! yield More spam! yield Delicious spam!!! and you have another generator which delegates to the spam generator: def lunch1(): for food in spam(): yield food yield plus a fried egg We can now re-write the generator using yield from: def lunch2(): yield from spam() yield plus a fried egg That saves one line of code. Big deal. Here, it is pure syntactic sugar. There are more interesting cases, where yield from is more powerful than the for-loop version. Here is an example with throw: py it = lunch1() # Create an iterator. py next(it) 'Spam!' py it.throw(ValueError) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 3, in lunch1 ValueError Notice that the ValueError is raised inside lunch1(). There is no easy way to push the exception back inside spam(). But with yield from, it works: py it = lunch2() # New yield from generator. py next(it) 'Spam!' py it.throw(ValueError) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 2, in lunch2 File stdin, line 2, in spam ValueError Of course, spam() is free to catch the exception and perform processing. And:: val = yield from xs is same as:: for x in xs: ret = yield x val = ret No. This is closer to what happens: # Not exactly this. # This is a simplified version. try: for x in xs: yield x except StopIteration as err: val = err.value The real version is much more complicated, 39 lines of code, and deals with generator .close() and .throw() methods, error checking, and various other issues. That is why yield from was added to Python. The simple case is too simple to care about, the complicated cases are too complicated to expect people to write their own solutions, so it was added to the language. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Hello YBM, I tried your suggestions, without improvement. Further, see my answer to Vincent Vande Vyre Thanks anyway. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Le jeudi 14 août 2014 15:22:52 UTC+2, Vincent Vande Vyvre a écrit : Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a �crit : Hello, This very simple program runs well on windows 7 # -*- utf8 -*- print('R�ussi') But, when I start the vrey same file on Linux (ubuntu 14), I got: Traceback (most recent call last): File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) What should i do to let the same program run on both OS, without changes? Thank you for your answer Marc Vanhoomissen No problem on Ubuntu Python 3.2.3 (default, Feb 27 2014, 21:33:50) [GCC 4.6.3] on linux2 Type help, copyright, credits or license for more information. print(R�ussi) R�ussi Are you really using Python 3 ? $ python3 test.py Actually, when I try using a terminal, it works: $ python3 test.py Réussi But when I issue the same command using webmin (v. 1.700 - shell command), I got: python3 test.py Traceback (most recent call last): File test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) So, I guess it is merely a problem of webmin. -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
I finished it ,but how to make it into more pythonic way such as min (dates, key = converter) here is my code times=['Sat, 09 Aug 2014 07:36:46 -0700', 'Fri, 8 Aug 2014 22:25:40 -0400', 'Sat, 9 Aug 2014 12:46:43 +1000', 'Sat, 9 Aug 2014 12:50:52 +1000', 'Sat, 9 Aug 2014 02:51:01 + (UTC)', 'Sat, 9 Aug 2014 13:03:24 +1000', 'Sat, 09 Aug 2014 13:06:28 +1000', 'Fri, 8 Aug 2014 20:48:44 -0700 (PDT)', 'Fri, 8 Aug 2014 23:52:09 -0700 (PDT)', 'Sat, 09 Aug 2014 09:15:50 +0200', 'Sat, 9 Aug 2014 01:49:54 -0600', 'Sat, 9 Aug 2014 01:57:18 -0600', 'Sat, 9 Aug 2014 17:54:23 +0800 (CST)', 'Sat, 9 Aug 2014 12:49:08 +0200', 'Sat, 9 Aug 2014 07:31:09 -0400', 'Sat, 9 Aug 2014 07:34:16 -0400', 'Sat, 09 Aug 2014 11:39:16 +', 'Sat, 9 Aug 2014 07:40:41 -0400', 'Sat, 9 Aug 2014 11:46:54 +', 'Sat, 09 Aug 2014 13:48:17 +0200', 'Sat, 09 Aug 2014 21:53:11 +1000', 'Sat, 09 Aug 2014 14:13:13 +0200', 'Sat, 09 Aug 2014 08:16:08 -0400', 'Sat, 09 Aug 2014 22:17:25 +1000', 'Sat, 09 Aug 2014 14:33:54 +0200', 'Sat, 9 Aug 2014 14:46:01 +0200', 'Sat, 09 Aug 2014 10:34:58 -0300', 'Sat, 09 Aug 2014 11:34:22 -0400', 'Sat, 09 Aug 2014 12:16:56 -0400', 'Sat, 09 Aug 2014 12:26:38 -0400', 'Sat, 09 Aug 2014 13:29:59 -0400', 'Sat, 09 Aug 2014 13:43:33 -0400', 'Sat, 9 Aug 2014 11:30:35 -0300', 'Sat, 09 Aug 2014 20:14:20 +0200', 'Sun, 10 Aug 2014 08:18:34 +1000', 'Sat, 9 Aug 2014 18:23:08 -0400 (EDT)', 'Sat, 09 Aug 2014 18:30:17 -0400', 'Sat, 09 Aug 2014 18:31:38 -0400', 'Sun, 10 Aug 2014 09:43:44 +1000', 'Sat, 9 Aug 2014 18:27:15 -0700 (PDT)', 'Sun, 10 Aug 2014 03:44:56 +0200', 'Sun, 10 Aug 2014 01:55:24 + (UTC)', 'Sun, 10 Aug 2014 02:01:06 + (UTC)', 'Sat, 9 Aug 2014 19:41:08 -0700 (PDT)', 'Sat, 9 Aug 2014 22:51:29 -0400 (EDT)', 'Sun, 10 Aug 2014 07:34:44 +0200', 'Tue, 5 Aug 2014 01:55:24 + (UTC)'] def changeToUnix(times): import time,calendar,re time_list=[] for time1 in times: pat='(.+?)([-|+]\d{4})(\(?.*\)?)' x=re.search(pat,time1) time_part=x.groups()[0].strip() tz_part=x.groups()[1] tz_acc=x.groups()[2].strip().replace('(','').replace(')','') num=int(tz_part[1:3]) if tz_acc in [,UTC,CST,GMT,EST,CST,PST]: num=num if tz_acc in [EDT]: num=num+2 if tz_acc in [CDT]: num=num+1 if tz_acc in [PDT]: num=num-1 op=tz_part[0] y=time.strptime(time_part,%a, %d %b %Y %H:%M:%S) if op==-:hour=int(y.tm_hour)-num if op==+:hour=int(y.tm_hour)+num time2=(y.tm_year,y.tm_mon,y.tm_mday,hour,y.tm_min,y.tm_sec) time_list.append(calendar.timegm(time2)) return(time_list) y=changeToUnix(times) times[y.index(min(y))] 'Tue, 5 Aug 2014 01:55:24 + (UTC)' You neglected to specify your Python version, but I'll assume at least 2.5. The min function did exactly as it's documented to do, found the minimum string, by alphabetical ordering. Since 'F' is less than 'T' it didn't need to look at the rest. If you had been sorting a list of datetime objects, it would have found the least of those. Your simplest answer is probably to write a function that converts a string like you have into a datetime object, say call it converter (). Then after testing it, you call min (dates, key = converter) Note I did NOT use parens on converter. I also used the name dates for the list, since it's a collection of dates. But that assumes you rename it in your code that gathered them. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
On 14/08/2014 15:04, marc.vanhoomis...@gmail.com wrote: Hello YBM, I tried your suggestions, without improvement. Further, see my answer to Vincent Vande Vyre Thanks anyway. I'm pleased to see that you have answers. In return would you please quote the context. Could you also access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
marc.vanhoomis...@gmail.com writes: What should i do to let the same program run on both OS, without changes? You'd want to set the locale on your Ubuntu box to a UTF8 locale. On the command line you'd run sudo dpkg-reconfigure locales and proceed from there, but I guess there might be gooey way to do that too. But really, it's a Linux configuration question, not a Python question. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Le 14/08/2014 15:31, YBM a écrit : Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit : Hello, This very simple program runs well on windows 7 # -*- utf8 -*- print('Réussi') But, when I start the vrey same file on Linux (ubuntu 14), I got: Traceback (most recent call last): File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) What should i do to let the same program run on both OS, without changes? the correct comment line should be : # -*- encoding: utf-8 -*- and it could be usefull to begin with #!/usr/bin/env python or #!/usr/bin/env python3 : $ cat réussi.py #!/usr/bin/env python # -*- encoding: utf-8 -*- print('Réussi'); ^D $ chmod +x réussi.py $ ./réussi.py Réussi $ python réussi.py Réussi Nothing to do with the file encoding. ... if the OP use really Python 3 -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
Le 14/08/2014 16:04, marc.vanhoomis...@gmail.com a écrit : Hello YBM, I tried your suggestions, without improvement. Further, see my answer to Vincent Vande Vyre Thanks anyway. This is indeed very surprising. Are you sure that you have *exactly* this line at the first or second (not later !) line of your script : # -*- encoding: utf-8 -*- if a single caracter differs, it would fail. -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
On 14/08/2014 15:10, luofeiyu wrote: How many times do you have to be asked not to top post before the message sinks in? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Code to Python 27 prompt to access a html file stored on C drive
Dear Programmers, I want to access a html file on my C drive, in the Python 27 prompt, all the examples I come across seem to require for access for the html file be on a server, rather than on the same computer's C drive. I want to do this as a prerequisite to writing webscraping code, surmising that if I can get the Python 27 prompt (inclusive of 'Beautiful Soup''Urllib' 'Requests' downloads ) to output pertinent html code from a html document, then I can proceed to use similar code to ouput html code from URL addresses, such as 'RacingPost.com' 'SportingLife.com''Oddschecker.com' and 'Bestbetting.com' which is what I am interested in working on. Hope you can help. Yours Simon Evans. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
YBM wrote: Le 14/08/2014 16:04, marc.vanhoomis...@gmail.com a écrit : Hello YBM, I tried your suggestions, without improvement. Further, see my answer to Vincent Vande Vyre Thanks anyway. This is indeed very surprising. Are you sure that you have *exactly* this line at the first or second (not later !) line of your script : # -*- encoding: utf-8 -*- if a single caracter differs, it would fail. That's not correct. The encoding declaration is very flexible. Any of these will be accepted: # This file uses the encoding: utf_8 # coding=UTF-8 # -*- coding: utf8 -*- # vim: set fileencoding=utf-8 : # Uses encoding:utf8 # I want my encoding=UtF_8 okay! textencoding= UTf-8 blah blah blah and many, many other varieties. The rules are: (1) It must be a comment; (2) It must be in the first or second line of the file; (3) It must match the regular expression rcoding[:=]\s*([-\w.]+) However, just because you declare the file to be UTF-8, doesn't mean it *actually is* UTF-8. If your text editor is configured to use (say) Latin-1, a UTF-8 encoding declaration will just give you garbage. * Fix your system to use UTF-8 by default. * Fix your editor to use UTF-8. * Add a UTF-8 encoding declaration. And then things should work. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Matplotlib Contour Plots
Hello all, I want to contour a scatter plot but I don't know how. Can anyone help me out? Cheers, Jamie -- https://mail.python.org/mailman/listinfo/python-list
Re: Code to Python 27 prompt to access a html file stored on C drive
On Thu, 14 Aug 2014 08:09:11 -0700, Simon Evans wrote: Dear Programmers, I want to access a html file on my C drive, in the Python 27 prompt, all the examples I come across seem to require for access for the html file be on a server, rather than on the same computer's C drive. I want to do this as a prerequisite to writing webscraping code, surmising that if I can get the Python 27 prompt (inclusive of 'Beautiful Soup''Urllib' 'Requests' downloads ) to output pertinent html code from a html document, then I can proceed to use similar code to ouput html code from URL addresses, such as 'RacingPost.com' 'SportingLife.com''Oddschecker.com' and 'Bestbetting.com' which is what I am interested in working on. Hope you can help. Yours Simon Evans. have you read the online tutorial http://crummy.com/software/BeautifulSoup/bs3/documentation.html modifying the example slightly to read from a file rather than inline code would give (typed direct so untested) from BeautifulSoup import BeautifulSoup as bs data =open('myfile').read() soup=bs(data) print soup.prettify() -- Due to the CDA, we no longer have a root account. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
marc.vanhoomis...@gmail.com wrote: Le jeudi 14 août 2014 15:22:52 UTC+2, Vincent Vande Vyvre a écrit : Are you really using Python 3 ? $ python3 test.py Actually, when I try using a terminal, it works: $ python3 test.py Réussi But when I issue the same command using webmin (v. 1.700 - shell command), I got: python3 test.py Traceback (most recent call last): File test.py, line 2, in module print('R\xe9ussi') UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) So, I guess it is merely a problem of webmin. I have no idea how that might interact with webmin, but you could try to set the environment variable PYTHONIOENCODING=utf-8 -- https://mail.python.org/mailman/listinfo/python-list
Re: Code to Python 27 prompt to access a html file stored on C drive
On Thu, Aug 14, 2014 at 9:33 AM, alister alister.nospam.w...@ntlworld.com wrote: On Thu, 14 Aug 2014 08:09:11 -0700, Simon Evans wrote: Dear Programmers, I want to access a html file on my C drive, in the Python 27 prompt, all the examples I come across seem to require for access for the html file be on a server, rather than on the same computer's C drive. I want to do this as a prerequisite to writing webscraping code, surmising that if I can get the Python 27 prompt (inclusive of 'Beautiful Soup''Urllib' 'Requests' downloads ) to output pertinent html code from a html document, then I can proceed to use similar code to ouput html code from URL addresses, such as 'RacingPost.com' 'SportingLife.com''Oddschecker.com' and 'Bestbetting.com' which is what I am interested in working on. Hope you can help. Yours Simon Evans. have you read the online tutorial http://crummy.com/software/BeautifulSoup/bs3/documentation.html modifying the example slightly to read from a file rather than inline code would give (typed direct so untested) from BeautifulSoup import BeautifulSoup as bs data =open('myfile').read() soup=bs(data) print soup.prettify() Alternatively you can continue to use urlopen and just pass it a file:// URL. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to run print('Réussi') on windows and on linux
On Thu, Aug 14, 2014 at 9:21 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: YBM wrote: Le 14/08/2014 16:04, marc.vanhoomis...@gmail.com a écrit : Hello YBM, I tried your suggestions, without improvement. Further, see my answer to Vincent Vande Vyre Thanks anyway. This is indeed very surprising. Are you sure that you have *exactly* this line at the first or second (not later !) line of your script : # -*- encoding: utf-8 -*- if a single caracter differs, it would fail. That's not correct. The encoding declaration is very flexible. Any of these will be accepted: # This file uses the encoding: utf_8 # coding=UTF-8 # -*- coding: utf8 -*- # vim: set fileencoding=utf-8 : # Uses encoding:utf8 # I want my encoding=UtF_8 okay! textencoding= UTf-8 blah blah blah and many, many other varieties. The rules are: (1) It must be a comment; (2) It must be in the first or second line of the file; (3) It must match the regular expression rcoding[:=]\s*([-\w.]+) However, just because you declare the file to be UTF-8, doesn't mean it *actually is* UTF-8. If your text editor is configured to use (say) Latin-1, a UTF-8 encoding declaration will just give you garbage. * Fix your system to use UTF-8 by default. * Fix your editor to use UTF-8. * Add a UTF-8 encoding declaration. And then things should work. And apart from all of that, if the OP is really using Python 3 then UTF-8 is the default source encoding anyway. -- https://mail.python.org/mailman/listinfo/python-list
Which OAuth library?
I need one for use with Flask, as I don't really have time to implement my own. Initially this will be for the Two-Legged case but I may well have to support the Three-Legged version later on. Open ID Connect may also be an option eventually. The basic idea is to provide an authorization/authentication service in a fairly conventional manner. My boss has told me to use OAuth, probably because he has experience with it and also to allow for third-party transactions. However it is not clear to me how I should decide between the various packages on offer. Any advice from experienced/informed users would be very welcome. Thanks ... Richard -- https://mail.python.org/mailman/listinfo/python-list
Re: Matplotlib Contour Plots
Jamie Mitchell wrote: Hello all, I want to contour a scatter plot but I don't know how. Can anyone help me out? Certainly. Which way did you come in? :-) Sorry, I couldn't resist. It took me literally 20 seconds to find this by googling for matplotlib contour plot, and it only took that long because I misspelled contour the first time. http://matplotlib.org/examples/pylab_examples/contour_demo.html Does this help? If not, please explain what experience you have with matplotlib, what you have tried, what you expected it to do, and what it did instead. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
luofeiyu elearn2...@gmail.com: y=time.strptime(time_part,%a, %d %b %Y %H:%M:%S) As I said, whether that works depends on your locale -- according to the reference documentation. In practice, I couldn't get that to fail in my tests. I would be on my guard, though. That might mean I couldn't use strptime to convert the dates. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
On Thu, Aug 14, 2014 at 8:10 AM, luofeiyu elearn2...@gmail.com wrote: I finished it ,but how to make it into more pythonic way such as min (dates, key = converter) The converter will be your changeToUnix function, but you'll need to rework it to convert a single, rather than the whole list. def changeToUnix(times): import time,calendar,re time_list=[] for time1 in times: pat='(.+?)([-|+]\d{4})(\(?.*\)?)' x=re.search(pat,time1) time_part=x.groups()[0].strip() tz_part=x.groups()[1] tz_acc=x.groups()[2].strip().replace('(','').replace(')','') num=int(tz_part[1:3]) if tz_acc in [,UTC,CST,GMT,EST,CST,PST]: num=num if tz_acc in [EDT]: num=num+2 if tz_acc in [CDT]: num=num+1 if tz_acc in [PDT]: num=num-1 op=tz_part[0] y=time.strptime(time_part,%a, %d %b %Y %H:%M:%S) if op==-:hour=int(y.tm_hour)-num if op==+:hour=int(y.tm_hour)+num time2=(y.tm_year,y.tm_mon,y.tm_mday,hour,y.tm_min,y.tm_sec) time_list.append(calendar.timegm(time2)) return(time_list) This looks way overly complicated. Why are you trying to mess with the time zone offset? strptime has a %z format code for parsing that (although I would recommend using datetime.datetime.strptime since I'm not sure how well time.strptime supports it). By adding the offset to the hour like that, you could end up with an hour that falls outside the accepted range. And I think you have your addition and subtraction switched around anyway -- in effect you're doubling the time zone offset, not converting to UTC. Also you would be losing the minutes part of the time zone offset if you were to get something like +0545. I also don't understand why you're special-casing and modifying three of the time zones. All you need to do is strip the parenthesized timezone off the string if it's present, and pass the result to datetime.datetime.strptime. -- https://mail.python.org/mailman/listinfo/python-list
Odd floor-division corner case
From http://bugs.python.org/issue22198 -0.5 // float('inf') -1.0 What should it be? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Odd floor-division corner case
On Thu, Aug 14, 2014 at 11:31 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: From http://bugs.python.org/issue22198 -0.5 // float('inf') -1.0 Looks like the result is the same for any negative dividend. What should it be? It's surprising, but I think it's correct. A negative infinitesimal would be less than 0, so its floor should be -1, not 0. -- https://mail.python.org/mailman/listinfo/python-list
Re: Which OAuth library?
On 14 August 2014 18:51 Richard Prosser ebizby...@gmail.com wrote: I need one for use with Flask, as I don't really have time to implement my own. You should not implement things on your own if there are existing and same implementations. Initially this will be for the Two-Legged case but I may well have to support the Three-Legged version later on. Open ID Connect may also be an option eventually. The basic idea is to provide an authorization/authentication service in a fairly conventional manner. My boss has told me to use OAuth, probably because he has experience with it and also to allow for third-party transactions. However it is not clear to me how I should decide between the various packages on offer. Any advice from experienced/informed users would be very welcome. Thanks ... Richard -- https://mail.python.org/mailman/listinfo/python-list Google hints at https://flask-oauthlib.readthedocs.org/en/latest/ and it's looking pretty good. There is also flask-oauth, but it seems quite outdated. -- Chris “Kwpolska” Warrick http://chriswarrick.com/ Sent from my SGS3. -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Wed, 13 Aug 2014 14:16:02 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: . . . and as computers get more powerful the intersection of {problems machines can't solve} and {problems humans can reliably solve} grows ever smaller. Which of the following eight sentences are sarcastic in tone? -- To email me, substitute nowhere-spamcop, invalid-net. -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Thu, Aug 14, 2014 at 12:37 PM, Peter Pearson ppearson@nowhere.invalid wrote: On Wed, 13 Aug 2014 14:16:02 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: . . . and as computers get more powerful the intersection of {problems machines can't solve} and {problems humans can reliably solve} grows ever smaller. Which of the following eight sentences are sarcastic in tone? People are actually pretty bad at identifying sarcasm, or at least agreeing on what it is [1] and there's a segment of the population who simply don't understand it at all, so you'd be trading one kind of inaccessibility for another. And you might be surprised at how good machines can be at identifying sarcasm [2]. Besides, this suffers from the problem of a limited pool of questions, in that the spambot could simply build up a database of which sentences that are used by the system are sarcastic and which are not, as determined by their human controllers. [1] http://psychcentral.com/blog/archives/2009/08/18/would-you-even-recognize-sarcasm/ [2] http://www.bbc.com/news/technology-23160583 -- https://mail.python.org/mailman/listinfo/python-list
PyMatch Tool.
Hello, I created this tool to help me develop on formatting text using regular expressions. Any questions, I am available. Thank you. Tool - https://github.com/rfunix/PyMatch -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On 8/14/2014 2:37 PM, Peter Pearson wrote: On Wed, 13 Aug 2014 14:16:02 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: . . . and as computers get more powerful the intersection of {problems machines can't solve} and {problems humans can reliably solve} grows ever smaller. Which of the following eight sentences are sarcastic in tone? and responses on this list alone show problems with detecting sarcasm (or snark). -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Fri, Aug 15, 2014 at 4:37 AM, Peter Pearson ppearson@nowhere.invalid wrote: Which of the following eight sentences are sarcastic in tone? You have a sarcasm sign? http://www.thinkgeek.com/product/e58f/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PyMatch Tool.
On Fri, Aug 15, 2014 at 5:50 AM, rafinha.u...@gmail.com wrote: Hello, I created this tool to help me develop on formatting text using regular expressions. Any questions, I am available. Thank you. Tool - https://github.com/rfunix/PyMatch How is this better than GNU sed? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Wed, 13 Aug 2014 07:39:20 -0400, Eric S. Johansson wrote: you are clear but also missing a really good reason to break captchas. handicapped accessibility. Captchas are a huge barrier to access and in many cases push disabled users away from using a service with captchas. That's as may be, but bozo is not trying to improve handicapped accessibility, he's trying to write a spambot. Please don't use the accessibility concerns surrounding captcha to justify writing spambot software. It doesn't help the accessibility argument to be seen to be pro spambot, in fact if anything it may damage it. I agree that there are more reasons not to use captcha these days than there are to use them, however I still don't advocate helping spambot bastards defeat them. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On Tue, 12 Aug 2014 18:36:21 -0700, Wesley wrote: I just wanna a general suggestion here in the beginning. OK, the general suggestion is that you take your spambot software, print it out on spiky metal sheets and ram it up your rectum. Why I need to write such program is just having such requirements. Yes, we understand that your spambot requires to decode captcha. We were just telling you in fairly polite terms that you should fuck off because we have no wish to help you. We tried polite, it didn't work, now I'm trying robustness and profanity. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
I am glad to hear that it is no necessary to create a complicated my function to change the time string. But in my computer the timezone offset do not work for me. I am in win7+python34. import sys sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' import time time.tzname ('China Standard Time', 'China Daylight Time') time.strptime(t1,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The %z does not work for me, how to adjust it my computer? On 8/15/2014 1:24 AM, Ian Kelly wrote: On Thu, Aug 14, 2014 at 8:10 AM, luofeiyu elearn2...@gmail.com wrote: I finished it ,but how to make it into more pythonic way such as min (dates, key = converter) The converter will be your changeToUnix function, but you'll need to rework it to convert a single, rather than the whole list. def changeToUnix(times): import time,calendar,re time_list=[] for time1 in times: pat='(.+?)([-|+]\d{4})(\(?.*\)?)' x=re.search(pat,time1) time_part=x.groups()[0].strip() tz_part=x.groups()[1] tz_acc=x.groups()[2].strip().replace('(','').replace(')','') num=int(tz_part[1:3]) if tz_acc in [,UTC,CST,GMT,EST,CST,PST]: num=num if tz_acc in [EDT]: num=num+2 if tz_acc in [CDT]: num=num+1 if tz_acc in [PDT]: num=num-1 op=tz_part[0] y=time.strptime(time_part,%a, %d %b %Y %H:%M:%S) if op==-:hour=int(y.tm_hour)-num if op==+:hour=int(y.tm_hour)+num time2=(y.tm_year,y.tm_mon,y.tm_mday,hour,y.tm_min,y.tm_sec) time_list.append(calendar.timegm(time2)) return(time_list) This looks way overly complicated. Why are you trying to mess with the time zone offset? strptime has a %z format code for parsing that (although I would recommend using datetime.datetime.strptime since I'm not sure how well time.strptime supports it). By adding the offset to the hour like that, you could end up with an hour that falls outside the accepted range. And I think you have your addition and subtraction switched around anyway -- in effect you're doubling the time zone offset, not converting to UTC. Also you would be losing the minutes part of the time zone offset if you were to get something like +0545. I also don't understand why you're special-casing and modifying three of the time zones. All you need to do is strip the parenthesized timezone off the string if it's present, and pass the result to datetime.datetime.strptime. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to change the time string into number?
On Thu, 14 Aug 2014 09:46:20 +0800, luofeiyu wrote: s=Aug how can i change it into 8 with some python time module? You don't need a time module for this, just use a dictionary: months = { Jan : 1, . , Dec: 12 } num = months[s] print num Fill in the rest of the months dictionary yourself, it shouldn't be too hard. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
On Thu, Aug 14, 2014 at 5:22 PM, luofeiyu elearn2...@gmail.com wrote: I am glad to hear that it is no necessary to create a complicated my function to change the time string. But in my computer the timezone offset do not work for me. I am in win7+python34. import sys sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' import time time.tzname ('China Standard Time', 'China Daylight Time') time.strptime(t1,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) time.strptime(t2,%a, %d %b %Y %H:%M:%S %z) time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The %z does not work for me, how to adjust it my computer? As I noted in my previous post, try using datetime.datetime.strptime instead. The time.strptime function depends on the C libraries to support it, while the datetime.strptime does not. -- https://mail.python.org/mailman/listinfo/python-list
Re: PyMatch Tool.
On Thu, Aug 14, 2014 at 5:49 PM, Chris Angelico ros...@gmail.com wrote: Tool - https://github.com/rfunix/PyMatch How is this better than GNU sed? I didn't look closely at the program, but I have an idea how I might use it. Back in the dawn of Internet time (before Y2K, Django, V8, etc) I developed and maintained a concert calendar website. It had a database of tour dates, and a bunch of handwritten HTML. And, I allowed people to describe their concert tour information in a slightly-higher-than-regex level (SLTRL). This facility allowed me to routinely process known tour date listings and update my listings with little, if any, manual intervention. Under the covers, of course, it used regular expressions. I had, as they say, two problems. My solution to failed matches (I was actually the heaviest user of the system) was to provide a textarea where you could paste in some tour dates as they appeared on an artist's website, then enter the SLTRL notation you thought described the dates. Most of the time things were pretty easy to handle, but every now and then it would fail. I would then start lopping of chunks of the SLTRL from the right and see if anything now matched, and if so, what was leftover. This tool might work in a similar fashion. Run it repeatedly on the same input with ever-more-complex patterns and groups until it matches everything. Then you're done and you paste the ugly mess into your code. Then you have two problems. wink Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
On 15/08/2014 00:22, luofeiyu wrote: I really don't understand why people here are spoon feeding you when you still insist on top posting. Ever heard the term manners? Oh what a stupid comment, obviously not. *plonk* -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: get the min date from a list
On Thu, Aug 14, 2014 at 5:44 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: I really don't understand why people here are spoon feeding you when you still insist on top posting. Ever heard the term manners? Oh what a stupid comment, obviously not. *plonk* Getting people to stop top-posting is a losing battle. Aren't there more important things to worry about? Like the NSA overstepping or the Fergeson, Missouri police? -- https://mail.python.org/mailman/listinfo/python-list
problem on top-post
when i search what top-post mean: *top-post*: n., v. [common] To put the newly-added portion of an email or Usenet response before the quoted part, as opposed to the more logical sequence of quoted portion first with original following. *bottom-post*: v.In a news or mail reply, to put the response to a news or email message after the quoted content from the parent message. This is correct form, and until around 2000 was so universal on the Internet that neither the term ‘bottom-post’ nor its antonym /top-post/ http://www.catb.org/%7Eesr/jargon/html/T/top-post.html existed. Hackers consider that the best practice is actually to excerpt only the relevent portions of the parent message, then intersperse the poster's response in such a way that each section of response appears directly after the excerpt it applies to. This reduces message bulk, keeps thread content in a logical order, and facilitates reading. the best way is to excerpt only the relevent portions of the parent message ,not top-post nor bottom-post , right? -- https://mail.python.org/mailman/listinfo/python-list
timedelta problem
In the python doc , https://docs.python.org/3.4/library/datetime.html A timedelta https://docs.python.org/3.4/library/datetime.html#datetime.timedelta object represents a duration, the difference between two dates or times. /class /datetime.timedelta(/days=0/, /seconds=0/, /microseconds=0/, /milliseconds=0/, /minutes=0/, /hours=0/, /weeks=0/) All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative. Only /days/, /seconds/ and /microseconds/ are stored internally. import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(-1, 61200))) datetime.datetime.strptime(t2,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(0, 25200))) problem : t1 is GMT time 2014 00:36:46 t2 is GMT time 2014 14:36:46 datetime.datetime.strptime do not give me the right answer. -- https://mail.python.org/mailman/listinfo/python-list
Re: problem on top-post
On 15Aug2014 09:47, luofeiyu elearn2...@gmail.com wrote: when i search what top-post mean: top-post: n., v. [common] To put the newly-added portion of an email or Usenet response before the quoted part, as opposed to the more logical sequence of quoted portion first with original following. bottom-post: v. In a news or mail reply, to put the response to a news or [...] existed. Hackers consider that the best practice is actually to excerpt only the relevent portions of the parent message, then intersperse the poster's response in such a way that each section of response appears directly after the excerpt it applies to. [...] the best way is to excerpt only the relevent portions of the parent message ,not top-post nor bottom-post , right? Generally, yes. It is what we try to use in this list, and applies in most technical forums. It makes replies read like a conversation, too. Thanks, Cameron Simpson c...@zip.com.au Shape without form, shade without colour, Paralysed force, gesture without motion;- T.S. Eliot, _The Hollow Men_ -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
Denis McMahon denismfmcma...@gmail.com writes: On Tue, 12 Aug 2014 18:36:21 -0700, Wesley wrote: […] We tried polite, it didn't work, now I'm trying robustness and profanity. The thread has been inactive for days, so it seems politeness *did* in fact work. Escalating to violent indimidating language (regardless of profanity) is unhelpful, please don't ever resort to that here. -- \ “I am the product of millions of generations of individuals who | `\ each fought against a hostile universe and won, and I aim to | _o__) maintain the tradition.” —Paul Z. Myers, 2009-09-12 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: problem on top-post
In mailman.13017.1408067250.18130.python-l...@python.org luofeiyu elearn2...@gmail.com writes: the best way is to excerpt only the relevent portions of the parent message ,not top-post nor bottom-post , right? The followup text appears underneath the quoted parent message, thus bottom-post. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: problem on top-post
luofeiyu elearn2...@gmail.com writes: the best way is to excerpt only the relevent portions of the parent message ,not top-post nor bottom-post , right? Correct; you should also interleave your responses in the context of the relevant quoted material. See at the link I provided for this style URL:https://en.wikipedia.org/wiki/Posting_style#Interleaved_style. Thanks for endeavouring to learn good communications etiquette. -- \“I was in Las Vegas, at the roulette table, having a furious | `\ argument over what I considered to be an odd number.” —Steven | _o__) Wright | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
luofeiyu elearn2...@gmail.com writes: import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(-1, 61200))) datetime.datetime.strptime(t2,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(0, 25200))) (Your examples will be easier to read – and you will help those who are helping you – if you conform to PEP 8 in the code, and don't break up the output when you copy it here.) problem : t1 is GMT time 2014 00:36:46 t2 is GMT time 2014 14:36:46 Not true; t1 and t2 are not in the “GMT” zone, they are in UTC-0700 and UTC+0700 respectively. Their value includes that. The instants they *represent* may be equal to the times-plus-timezone you've listed here, but their value is different. The value includes the timezone information, so they're different from what you show. datetime.datetime.strptime do not give me the right answer. What do you think the right answer would be in each case? Why? -- \ “The aim of science is not to open the door to infinite wisdom, | `\but to set some limit on infinite error.” —Bertolt Brecht, | _o__)_Leben des Galilei_, 1938 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu elearn2...@gmail.com wrote: import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(-1, 61200))) datetime.datetime.strptime(t2,%a, %d %b %Y %H:%M:%S %z) datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed elta(0, 25200))) problem : t1 is GMT time 2014 00:36:46 t2 is GMT time 2014 14:36:46 You have it backwards. t1 is a later time than t2. datetime.datetime.strptime do not give me the right answer. dt1 - dt2 datetime.timedelta(0, 50400) _.seconds // 3600 14 Looks correct to me. -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
On Thu, Aug 14, 2014 at 9:37 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu elearn2...@gmail.com wrote: t1 is GMT time 2014 00:36:46 t2 is GMT time 2014 14:36:46 You have it backwards. t1 is a later time than t2. datetime.datetime.strptime do not give me the right answer. dt1 - dt2 datetime.timedelta(0, 50400) _.seconds // 3600 14 Looks correct to me. Also: dt1.astimezone(datetime.timezone.utc) datetime.datetime(2014, 8, 9, 14, 36, 46, tzinfo=datetime.timezone.utc) dt2.astimezone(datetime.timezone.utc) datetime.datetime(2014, 8, 9, 0, 36, 46, tzinfo=datetime.timezone.utc) -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) Are you sure? When I try this I get: ValueError: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z' datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timedelta(-1, 61200))) And this: AttributeError: 'module' object has no attribute 'timezone' -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) Are you sure? When I try this I get: ValueError: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z' datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timedelta(-1, 61200))) And this: AttributeError: 'module' object has no attribute 'timezone' Both fail as you describe in 2.7, but in 3.4/3.5ish (my 'python3' is a bit of a mess, but it's something between those two I think), both work as per the OP's description. You both need to be clearer about version numbers, I think :) The OP did have a link to docs with 3.4 in the name, although that isn't proof necessarily. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: timedelta problem
On Thu, Aug 14, 2014 at 9:51 PM, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: import datetime t1='Sat, 09 Aug 2014 07:36:46 -0700' t2='Sat, 09 Aug 2014 07:36:46 +0700' datetime.datetime.strptime(t1,%a, %d %b %Y %H:%M:%S %z) Are you sure? When I try this I get: ValueError: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z' datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timedelta(-1, 61200))) And this: AttributeError: 'module' object has no attribute 'timezone' The datetime.timezone class was added in Python 3.2. -- https://mail.python.org/mailman/listinfo/python-list
Re: problem on top-post
John Gordon gor...@panix.com writes: In mailman.13017.1408067250.18130.python-l...@python.org luofeiyu elearn2...@gmail.com writes: the best way is to excerpt only the relevent portions of the parent message ,not top-post nor bottom-post , right? The followup text appears underneath the quoted parent message, thus bottom-post. “Bottom-post” usually refers to the inferior practice of quoting a message (entirely or large amounts) and then indiscriminately responding to all of it below all of the quoted text. The preferred style is “interleaved”, where responses are interleaved among the relevant parts of quoted material. Each response appears below only the relevant part. So no, the responses should not appear below the quoted *message*, but below the relevant *part* of the quoted material, followed potentially by more relevant quoted material and responses to those. (We agree that there should be no quoted material after all of your own responses; if you're not following quoted material with a relevant response, that part of the quoted material should be removed in your message.) With only a small, single point to respond to, the recommended “interleaved” style is identical to “bottom post” — in this message, for example. But “bottom post” is not preferred when there are multiple responses to multiple points, by one person or several. The “interleaved” style is the recommended etiquette. -- \ “The lift is being fixed for the day. During that time we | `\regret that you will be unbearable.” —hotel, Bucharest | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
[issue22065] Update turtledemo menu creation
Terry J. Reedy added the comment: # 3 on my list of patches to review and apply -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22065 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22191] warnings.__all__ incomplete
Serhiy Storchaka added the comment: See also issue20689. socket.__all__ is incomplete too. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22191 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22193] Add _PySys_GetSizeOf()
New submission from Serhiy Storchaka: Proposed patch adds private function _PySys_GetSizeOf(). It is needed for correct implementing of __sizeof__() methods: issue15490, issue15513, issue15381 (BytesIO.__sizeof__ is broken in 3.5). See discussion about it in issue15490. I extracted this patch in separate issue for its simplicity and because it is needed in other issues. -- assignee: serhiy.storchaka components: Interpreter Core files: _PySys_GetSizeOf.patch keywords: patch messages: 225294 nosy: loewis, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Add _PySys_GetSizeOf() type: enhancement versions: Python 2.7, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file36368/_PySys_GetSizeOf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22193 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO
Serhiy Storchaka added the comment: Here is a patch which optimizes readline() and readlines() methods of BytesIO and the __next__() method of BytesIO iterator. -- Added file: http://bugs.python.org/file36369/bytesio_faster_readline.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22191] warnings.__all__ incomplete
Jon Poler added the comment: Serhiy, should I submit these fixes as separate patches? E.g. one patch for the warnings module, and another for the socket module? More generally, should the items included in __all__ be derived from the items described in the documentation? For instance, only the functions listed in 18.1.2 https://docs.python.org/dev/library/socket.html#module-contents ? And finally, should a unittest be added for both of these modules to ensure that __all__ includes all of the desired publicly exposed elements? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22191 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22194] access to cdecimal / libmpdec API
New submission from Antoine Pitrou: Currently cdecimal exports no C API that I know of, and it makes sure the libmpdec symbols are kept private in the .so file. It would be nice for external C code (or, in general, non-Python code) to be able to access cdecimal objects, and make operations on them, without the huge overhead of the regular C Python API. -- messages: 225297 nosy: pitrou, skrah priority: normal severity: normal status: open title: access to cdecimal / libmpdec API type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22194 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO
Antoine Pitrou added the comment: I suppose this takes advantage of the libc's optimized memchr(). Any benchmarks? (patch looks fine, by the way) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22191] warnings.__all__ incomplete
Brett Cannon added the comment: Yes, please use separate patches attached to the appropriate bug. As for what should go into __all__, it's what is documented as the API of the module. As for tests, it doesn't hurt. =) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22191 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21795] smtpd.SMTPServer should announce 8BITMIME when supported and accept SMTPUTF8 without it
R. David Murray added the comment: Added some review comments. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21795 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22193] Add _PySys_GetSizeOf()
Martin v. Löwis added the comment: LGTM -- stage: patch review - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22193 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22195] Make it easy to replace print() calls with logging calls
New submission from Antoine Pitrou: Often an application (or e.g. a library's test suite), in its early development, will start making print() calls, and later will want to switch to the logging module. However the logging module doesn't offer any facility for this: you can't print() to a logger object, and loggers don't have a method that reflects print()'s signature. (note print() only uses the .write() and .flush() methods on its stream argument, so a simple wrapper may make the trick) -- components: Library (Lib) messages: 225302 nosy: pitrou, vinay.sajip priority: normal severity: normal status: open title: Make it easy to replace print() calls with logging calls type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22195 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com