Ten awesome things you are missing out on if you're still using Python 2
http://www.asmeurer.com/python3-presentation/slides.html#1 (The web UI is a bit ~~crap~~ minimialist. Use the left and right arrow keys to advance backwards and forwards among the slides.) -- Steve Emoji: a small, fuzzy, indistinct picture used to replace a clear and perfectly comprehensible word. -- https://mail.python.org/mailman/listinfo/python-list
Key differences between Python 2 and 3 with examples
And no, it's not just that Python 3 is The Future[1] and Python 2 is The Past. http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html [1] https://circleci.com/blog/its-the-future/ -- Steve Emoji: a small, fuzzy, indistinct picture used to replace a clear and perfectly comprehensible word. -- https://mail.python.org/mailman/listinfo/python-list
Re: Key differences between Python 2 and 3 with examples
On Mon, May 8, 2017 at 5:57 PM, Steven D'Aprano wrote: > And no, it's not just that Python 3 is The Future[1] and Python 2 is The > Past. > > > http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html > Error in page: print('Python', python_version()) print('strings are now utf-8 \u03BCnico\u0394é!') Python 3.4.1 strings are now utf-8 μnicoΔé! This is *not* UTF-8. This is Unicode. The difference may seem trivial, but it's one of the things that causes confusion when people try to encode and decode strings. Otherwise fairly accurate, with the caveat that a lot of what's been removed from Py3 was already the non-recommended way as of 2.7 (eg "raise Exception, message" or "except Exception, exc"). Well-written modern Py2 code shouldn't see these as problems, but if you're porting an old codebase, you'll need to cope with these things. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Practice Python
Python - Exercise 5 Do you want us to solve these problems for you? The answers here: https://www.youtube.com/watch?v=nwHPM9WNyw8&t=36s A strange way to publish code. Lutz -- https://mail.python.org/mailman/listinfo/python-list
packaging python code
Hi, I have simple piece of code which uses two libraries (numpy and openpyxl). The script is called from another application. Currently, if someone wants to run my program, he has to first install the python completely via its installer. Is there any way to pack my .py with all required libraries and create a self running package? Something like building exe file with static libraries. Therefore, the user won't install any thing manually. Please let me know if there is such procedure. Regards, Mahmood -- https://mail.python.org/mailman/listinfo/python-list
Re: packaging python code
Is there any way to pack my .py with all required libraries and create a self running package? Take a look at PyInstaller: * http://www.pyinstaller.org/ * https://pyinstaller.readthedocs.io/en/stable/ Lutz -- https://mail.python.org/mailman/listinfo/python-list
Re: Key differences between Python 2 and 3 with examples
Chris Angelico writes: > On Mon, May 8, 2017 at 5:57 PM, Steven D'Aprano wrote: > > http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html > > Error in page: Good catch. But the author likely won't read this message. You can contact them via email with that correction, according to a link at the bottom of that article. -- \“It is always a silly thing to give advice, but to give good | `\ advice is absolutely fatal.” —Oscar Wilde, _The Portrait of Mr. | _o__) W. H._, 1889-07 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
[GIS] Keeping only POIs X kms from a trace?
Hello Archie's Campings* offers a pretty thorough list of campsites in Europe. Problem is, files are only country-size, so the number of waypoints is overwhelming (Here's the UK for instance**). To plan bike tours, I'd like to… 1) import a trace from a GPX file, 2) import Archie's list for a given country, 3) filter that list to only keep campsites that are 5 kms from the route, and 4) export the output to a GPX file. Since a "gpxpy" Python module is available, I assume this can be done just with a script instead of an expert application like QGIS… but I know nothing about GIS. Can the above be done with a Python script? Thank you. * http://www.archiescampings.eu/ ** https://s7.postimg.org/4mck58dbf/Archie.s.Campings.UK.png -- https://mail.python.org/mailman/listinfo/python-list
[GIS] Keeping only POIs X kms from a trace?
Hello Archie's Campings* offers a pretty thorough list of campsites in Europe. Problem is, files are only country-size, so the number of waypoints is overwhelming (Here's the UK for instance**). To plan bike tours, I'd like to… 1) import a trace from a GPX file, 2) import Archie's list for a given country, 3) filter that list to only keep campsites that are 5 kms from the route, and 4) export the output to a GPX file. Since a "gpxpy" Python module is available, I assume this can be done just with a script instead of an expert application like QGIS… but I know nothing about GIS. Can the above be done with a Python script? Thank you. * http://www.archiescampings.eu/ ** https://s7.postimg.org/4mck58dbf/Archie.s.Campings.UK.png -- https://mail.python.org/mailman/listinfo/python-list
Re: [GIS] Keeping only POIs X kms from a trace?
Problem is, files are only country-size, so the number of waypoints is overwhelming (Here's the UK for instance**). How many is 'overwhelming'? Lutz -- https://mail.python.org/mailman/listinfo/python-list
Re: [GIS] Keeping only POIs X kms from a trace?
On Monday, May 8, 2017 at 3:06:44 PM UTC+2, Lutz Horn wrote: > > Problem is, files are only country-size, so the number of waypoints is > > overwhelming (Here's the UK for instance**). > > How many is 'overwhelming'? If you click on the screenshot I posted, it looks like thousands of POIs, while I only need to see one campsite every 80-100km along a 400km track. Can Python do this? -- https://mail.python.org/mailman/listinfo/python-list
Re: [GIS] Keeping only POIs X kms from a trace?
On 05/08/2017 02:34 PM, Heck Lennon wrote: To plan bike tours, I'd like to… 1) import a trace from a GPX file, 2) import Archie's list for a given country, 3) filter that list to only keep campsites that are 5 kms from the route, and 4) export the output to a GPX file. Since a "gpxpy" Python module is available, I assume this can be done just with a script instead of an expert application like QGIS… but I know nothing about GIS. Can the above be done with a Python script? Yes, you could also have a look at the excellent libraries: - Geopandas: http://geopandas.org/ - Shapely: http://toblerity.org/shapely/manual.html Cheers, Fabien -- https://mail.python.org/mailman/listinfo/python-list
Re: [GIS] Keeping only POIs X kms from a trace?
On Monday, May 8, 2017 at 3:45:43 PM UTC+2, Fabien wrote: > Yes, you could also have a look at the excellent libraries: > - Geopandas: http://geopandas.org/ > - Shapely: http://toblerity.org/shapely/manual.html Thank you. I'll see if I can figure out how to do this. -- https://mail.python.org/mailman/listinfo/python-list
Re: packaging python code
OK. I did that but it fails! Please see the stack D:\ThinkPad\Documents\NetBeansProjects\ExcelTest>pyinstaller exread.py 96 INFO: PyInstaller: 3.2.1 96 INFO: Python: 3.6.1 98 INFO: Platform: Windows-10-10.0.14393-SP0 103 INFO: wrote D:\ThinkPad\Documents\NetBeansProjects\ExcelTest\exread.spec 109 INFO: UPX is not available. 111 INFO: Extending PYTHONPATH with paths ['D:\\ThinkPad\\Documents\\NetBeansProjects\\ExcelTest', 'D:\\ThinkPad\\Documents\\NetBeansProjects\\ExcelTest'] 112 INFO: checking Analysis 113 INFO: Building Analysis because out00-Analysis.toc is non existent 113 INFO: Initializing module dependency graph... 117 INFO: Initializing module graph hooks... 119 INFO: Analyzing base_library.zip ... Traceback (most recent call last): File "C:\Users\ThinkPad\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller-script.py", line 11, in load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')() File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 90, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build exec(text, spec_namespace) File "", line 16, in File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__ self.__postinit__() File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__ self.assemble() File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble excludes=self.excludes, user_hook_dirs=self.hookspath) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph graph.import_hook(m) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook source_package, target_module_partname, level) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package target_module_headname, target_package_name, source_package) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module module_basename, module_name, parent_package) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module module_name, file_handle, pathname, metadata) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module self._scan_code(m, co, co_ast) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code module, module_code_object, is_scanning_imports=False) File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode global_attr_name = get_operation_arg_name() File "c:\users\thinkpad\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operation_arg_name return module_code_object.co_names[co_names_index] IndexError: tuple index out of range D:\ThinkPad\Documents\NetBeansProjects\ExcelTest> Regards, Mahmood On Monday, May 8, 2017 5:07 PM, Lutz Horn wrote: > Is there any way to pack my .py with all required libraries and create a self > running package? Take a look at PyInstaller: * http://www.pyinstaller.org/ * https://pyinstaller.readthedocs.io/en/stable/ Lutz -- https://mail.python.org/mailman/listinfo/python-list
EuroPython 2017 Keynote: Jan Willem Tulp
We are pleased to announce our next keynote speaker for EuroPython 2017: * Jan Willem Tulp * About Jan Willem Tulp - Jan Willem Tulp is an award winning data experience designer from The Netherlands. With his one-man company TULP interactive he creates custom data visualizations. Jan Willem has created visualizations for organizations such as Google, Scientific American, Nature, Popular Science, World Economic Forum, Unicef, Unesco, ESA and Philips. He speaks regularly at international conferences, and teaches a workshop on data visualization design. His work has been published in books and magazines and has been exhibited internationally. He has been a judge on visualization contests, such as National Science Foundation vizzies (USA) and Malofiej (Spain). The Keynote: How to create inspiring data visualizations? - Many times data visualizations need to communicate insights clearly and effectively. But sometimes the goals of a visualization go beyond that: they need to inspire and engage people. But how do you draw them in? What is the process behind creating a creative data visualization? During this talk, I will show some of my projects, and explain a little about the process behind it. Enjoy, -- EuroPython 2017 Team http://ep2017.europython.eu/ http://www.europython-society.org/ PS: Please forward or retweet to help us reach all interested parties: https://twitter.com/europython/status/861595625938460673 Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
Overall a nice preso. I disagree with the slides on a few points. Slide 8: I don't see why I would want to refactor def f(a, b, *args): stuff into def f(*args): a, b, *args = args stuff The first one has a cleaner signature and is also shorter. Slide 55: What makes the "Better" example better than the "Good" example? Creating a 2-element list just to yield from it seems wasteful, and for readability I prefer the version with two yields. Slide 56: "If you need a list (e.g., for slicing), just call list() on the generator." No, if you need to slice an iterator, use islice, Then call list() only if you still need a list for some other reason. Slide 58: "Not going to lie to you. I still don't get this." Uh, sure, great sales pitch there. If the author doesn't understand asyncio, then why include it in the list? On Mon, May 8, 2017 at 1:17 AM, Steven D'Aprano wrote: > > http://www.asmeurer.com/python3-presentation/slides.html#1 > > > (The web UI is a bit ~~crap~~ minimialist. Use the left and right arrow > keys to advance backwards and forwards among the slides.) > > > > -- > Steve > Emoji: a small, fuzzy, indistinct picture used to replace a clear and > perfectly comprehensible word. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Refactoring tool to create Python functions
Googling "refactoring python code to create functions" I came to https://wingware.com/doc/intro/tutorial-refactoring where the "Extract Function/Method" does what I want. Is there a free Python tool that does this? -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On Tue, May 9, 2017 at 1:02 AM, Ian Kelly wrote: > Slide 58: "Not going to lie to you. I still don't get this." Uh, sure, > great sales pitch there. If the author doesn't understand asyncio, then why > include it in the list? IMO he doesn't understand it because he's aiming at Python 3.4. Aim at 3.5 minimum and use "async def". Much easier. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On Mon, May 8, 2017 at 9:07 AM, Chris Angelico wrote: > On Tue, May 9, 2017 at 1:02 AM, Ian Kelly wrote: > > Slide 58: "Not going to lie to you. I still don't get this." Uh, sure, > > great sales pitch there. If the author doesn't understand asyncio, then > why > > include it in the list? > > IMO he doesn't understand it because he's aiming at Python 3.4. Aim at > 3.5 minimum and use "async def". Much easier. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > Agreed `async` and `await` in Py3.5 made it so much easier for me to understand the new async stuff. I've been toying around with aiohttp a bit and I can say it's actually fairly enjoyable. Doesn't have all the creature comforts I've enjoyed while working with Django in my day job, but I can see some fairly robust applications being created with aiohttp. -- https://mail.python.org/mailman/listinfo/python-list
Re: I want to learn Python and how to benefit from the great Data Science packages - have some questions.
On Sunday, May 7, 2017 at 1:03:57 AM UTC+5:30, Rahim Shamsy wrote: > Hi, > > Hope you are well. I am currently in the process of learning the basics of > programming in Python, and was just checking if I am in the right direction. The tutorial https://docs.python.org/3/tutorial/ is short and good. Generally recommended [You can adjust the version in left top corner] > I have experience programming in C++ and Java, and want to learn Python for > research work that I am doing. The research is regarding application of > Machine Learning as a Data Analysis tool for application in the domain of > smart infrastructure. You will be fastest if you put aside ML and Analytics until you get through the tutorial. Because python has the same core across a wide range of applications And being comfortable with that core will reward you with less time wasted later with minor confusions -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
Slide 15: > def sum(a, b, biteme=False): > if biteme: > shutil.rmtree('/') > else: > return a + b Now that's just evil. :^) -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On Mon, May 8, 2017 at 3:40 PM, wrote: > Slide 15: > > > def sum(a, b, biteme=False): > > if biteme: > > shutil.rmtree('/') > > else: > > return a + b > > Now that's just evil. :^) > -- > https://mail.python.org/mailman/listinfo/python-list > I sincerely hope no-one is trying to run this example as root. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On 2017-05-08 07:17, Steven D'Aprano wrote: > http://www.asmeurer.com/python3-presentation/slides.html#1 Just adding my regular beef about #5, the "everything is an iterator" in regards to the new tuple-unpacking when the wild-card is in the last position: >>> a,b, *c = range(10) >>> a 0 >>> b 1 >>> c [2, 3, 4, 5, 6, 7, 8, 9] >>> type(c) I've had multiple occasions where I don't care about the rest, yet don't want to consume them. Take for example a, b, *c = itertools.count() It would be perfectly sensible to have it result in >>> a 0 >>> b 1 >>> c count(2) >>> type(c) However, because it attempts to consume the iterator before assigning it to `c`, the code will hang until it has completely exhausted memory. As it says further on in #5, "If you want a list, just wrap the result with list." Just a personal pet peeve here. :-) > (The web UI is a bit ~~crap~~ minimialist. Use the left and right > arrow keys to advance backwards and forwards among the slides.) Additionally, classic vi keys of j/k work nicely, as do page-up/page-down, and works to advance a page at a time as well. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On Monday, May 8, 2017 at 5:09:33 PM UTC-7, justin walters wrote: > On Mon, May 8, 2017 at 3:40 PM, wrote: > > > Slide 15: > > > > > def sum(a, b, biteme=False): > > > if biteme: > > > shutil.rmtree('/') > > > else: > > > return a + b > > > > Now that's just evil. :^) > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > I sincerely hope no-one is trying to run this example as root. To be fair, the import statement that would make this code truly evil was thoughtfully left off. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ten awesome things you are missing out on if you're still using Python 2
On Monday, May 8, 2017 at 12:48:03 PM UTC+5:30, Steven D'Aprano wrote: > http://www.asmeurer.com/python3-presentation/slides.html#1 Nice list thanks! Do you have a similar list of 10 awesome features of Python that you can't use because you refuse to upgrade from Java/C++ ? [Context: Ive to take a couple of classes for senior such developers and wondering what features would give them) the most value] -- https://mail.python.org/mailman/listinfo/python-list