Re: New to Python - block grouping (spaces)
On 16/04/2015 05:07, Blake McBride wrote: Greetings, I am new to Python. I am sorry for beating what is probably a dead horse but I checked the net and couldn't find the answer to my question. I like a lot of what I've seen in Python, however, after 35 years and probably a dozen languages under my belt, I very strongly disagree with the notion of using white space to delimit blocks. Not wanting to beat what I believe is probably a dead horse, I have one question. Is there a utility that will allow me to write Python-like code that includes some block delimiter that I can see, that converts the code into runnable Python code? If so, where can I find it? Thanks! Blake McBride Interesting point of view. Likewise, I have used more than a dozen languages and I like Python a lot. Why? Because the use of indentation is (mostly) unambiguous and I find it a lot cleaner than having to check whether I need braces, parentheses or whatever delimiters are correct for a particular language. Plus I am relieved of the stylistic debates about whether the start-of-block marker starts after the 'IF' or on a new line and how the subsequent lines of code should be aligned. For me, Python is clean and easy to write and, more importantly, I find it easier to follow and understand code written by others. Steve Simmons -- https://mail.python.org/mailman/listinfo/python-list
Re: File Upload in Restful Flask
On 20/07/2015 11:13, subhabrata.bane...@gmail.com wrote: Dear Group, I am trying to learn Rest framework through Restful Flask. My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html Now I want to upload file through Restful Flask. I tried to check the web for reference. I got these urls, (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image (iii) http://blog.luisrei.com/articles/flaskrest.html But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. If any one of the esteemed members may kindly suggest. Regards, Subhabrata Banerjee. I'm no expert on Python or REST but the example >>> url = 'http://httpbin.org/post' >>> files = {'file': open('report.xls', 'rb')} >>> r = requests.post(url, files=files) >>> r.text ... seems quite straightforward so I would suggest substituting your URL for 'http://httpbin.org' and your file name (possibly with full pathname) for 'report.xls'. Give it a try and report back... Steve S -- https://mail.python.org/mailman/listinfo/python-list
Re: File Upload in Restful Flask
On 20/07/2015 12:57, subhabrata.bane...@gmail.com wrote: On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote: On 20/07/2015 11:13, wrote: Dear Group, I am trying to learn Rest framework through Restful Flask. My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html Now I want to upload file through Restful Flask. I tried to check the web for reference. I got these urls, (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image (iii) http://blog.luisrei.com/articles/flaskrest.html But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. If any one of the esteemed members may kindly suggest. Regards, Subhabrata Banerjee. I'm no expert on Python or REST but the example >>> url = 'http://httpbin.org/post' >>> files = {'file': open('report.xls', 'rb')} >>> r = requests.post(url, files=files) >>> r.text ... seems quite straightforward so I would suggest substituting your URL for 'http://httpbin.org' and your file name (possibly with full pathname) for 'report.xls'. Give it a try and report back... Steve S Dear Sir, Thanks. I could change the quickstart api.py slightly. I ran your suggestion on it. Some result seems coming but I may have to improve some portion, I am not getting. Please see the same. import requests url='http://127.0.0.1:5000/toworks/post' files = {'file': open('C:\Python27\NEWS.txt', 'rb')} r = requests.post(url, files=files) r.text u'{\n"message": "Method Not Allowed", \n"status": 405\n}\n' Regards, Subhabrata Banerji OK, so that message is telling you that whatever server is sitting behind 127.0.0.1 is not allowing you (your code) to POST to it. There are many reasons why this could be happening. Here are a couple for you to investigate... - port 5000 is not not 'open' for POSTs - your code may not have permission to POST to the server It would help if you could tell us what OS you are using (Windows or Linux or ...) and what server is sitting behind 127.0.0.1. I'n not going to be around for the next 24hrs but I'm sure someone else on the list will have some suggestions for you... Happy bug hunting Steve -- https://mail.python.org/mailman/listinfo/python-list
Python and sqlite versions
First off, this is my first attempt to post via Thunderbird newsgroup, so apologies (and please let me know) if it doesn't arrive in good shape. I'm just starting to get to grips with using a database (sqlite) and I've run into some confusion as to how Python 'ties in' to sqlite. First step in the tutorial is to import sqlite3 and display sqlite3.version and sqlite3.sqlite_version. Output below... >>> sqlite3.version '2.6.0' >>> sqlite3.sqlite_version '3.7.12' Next step is to run up sqlite. Output below... SQLite version 3.8.6 2014-08-15 11:46:33 Enter ".help" for usage hints. So, I have a disparity between installed sqlite and the Python sqlite library. Do I need to find a 3.7.12 version of sqlite and , if so, where might I find it or can I change the Python library for the later version? Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and sqlite versions
On 10/10/2014 20:02, Zachary Ware wrote: Hi Steve, On Fri, Oct 10, 2014 at 1:13 PM, Simmo wrote: First off, this is my first attempt to post via Thunderbird newsgroup, so apologies (and please let me know) if it doesn't arrive in good shape. Looks fine to me :) Thank you ;-) I'm just starting to get to grips with using a database (sqlite) and I've run into some confusion as to how Python 'ties in' to sqlite. How Python links with SQLite depends on several things, most importantly which platform you're on. First step in the tutorial is to import sqlite3 and display sqlite3.version and sqlite3.sqlite_version. Output below... sqlite3.version '2.6.0' sqlite3.sqlite_version '3.7.12' Next step is to run up sqlite. Output below... SQLite version 3.8.6 2014-08-15 11:46:33 Enter ".help" for usage hints. So, I have a disparity between installed sqlite and the Python sqlite library. Do I need to find a 3.7.12 version of sqlite and , if so, where might I find it or can I change the Python library for the later version? There aren't a huge number of differences between various versions of SQLite3 and fewer that you're likely to run into anyway, especially just starting out. You should be fine just using what you've got, just keep the fact that you're running different versions in the back of your mind if you come across differences that don't make any sense. It may be possible to change the version that Python uses, but again it depends on your platform and possibly your version of Python (sqlite3.version has been the same from Python 2.6 to 3.5). Thanks for this too. I'll plough on and deal with exceptions as they come. For the record, I'm on Windows 7 Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and sqlite versions
On 10/10/2014 20:31, Zachary Ware wrote: On Fri, Oct 10, 2014 at 2:18 PM, Simmo wrote: For the record, I'm on Windows 7 In that case (if I'm remembering correctly, I'm not on Windows at the moment), you could probably back up C:\Python33\DLLs\sqlite3.dll somewhere (just in case) and copy the sqlite3.dll you got with the sqlite3 distribution into that folder, and Python should be happy to use the newer version of sqlite3. That's got to be worth a punt. What's the worst that can happen... Thanks again Zach -- https://mail.python.org/mailman/listinfo/python-list