PyCon Israel 2018 CFP is Open

2018-03-11 Thread Miki Tebeka
Hi,

PyCon Israel 2018 call for papers is open, submit a talk today, another three 
tomorrow :)

See more at http://il.pycon.org/2018/

All the best,
--
Miki
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Mark Lawrence

On 11/03/18 04:09, Christopher Mullins wrote:

In the code you linked, I don't see where the *R*equest is used. The
request variable is setup by flask when you annotate the function with the
resource endpoint and POST method. It contains the content of the request
which can be converted to json if that content type was specified.



Could you please give some context when you reply, TIA.

--
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: Unnoticed traceback in a thread

2018-03-11 Thread Skip Montanaro
> Concretely: instead of "start_new_thread(my_thread_function, ...)",
> I use
>
> def wrapped_thread_function(*args, **kw):
>   try:
> my_thread_function(*args, **kw)
>   except:
> ... do whatever is necessary should "my_thread_function" fails ...
>
> start_new_thread(wrapped_thread_function, ...)
>
> Similar, should you use the "Thread" class (instead of "start_new_thread").

Thanks, that looks like an excellent suggestion.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
Sorry guys. i realized i was "mumbling" .

What is the difference between Request and request?  -   RTFM
, Andrew

Questions:
 a. when do i use Request?
 b. why can't I see any properties of the request?  For example, in
Michael's tutorial, there is a call for  request.json. PyCharm brings no
suggestions when i type in "request. "




On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence 
wrote:

> On 11/03/18 04:09, Christopher Mullins wrote:
>
>> In the code you linked, I don't see where the *R*equest is used. The
>> request variable is setup by flask when you annotate the function with the
>> resource endpoint and POST method. It contains the content of the request
>> which can be converted to json if that content type was specified.
>>
>>
> Could you please give some context when you reply, TIA.
>
> --
> 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
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip and command line

2018-03-11 Thread GISDude
On Saturday, March 10, 2018 at 10:28:00 AM UTC-8, Terry Reedy wrote:
> On 3/10/2018 12:23 PM, GISDude wrote:
> > Hi all,
> > I'm hoping someone could help a wannabe python coder out. I'm an aspiring 
> > Data/AI/ML coder/programmer/datafiend - that might help with my situation.
> > 
> > In my various fits of python downloads, I've managed to download Anaconda, 
> 
> Anaconda is a cpython distribution that comes with various 3rd party 
> modules pre-installed.
> 
> > Pyscripter,
> 
> I am not familiar with this.
> 
> > IDLE(3.6/32 AND 64bit), IDLE 2.7.
> 
> If you are on Windows, you did not download 'IDLE'.  You downloaded 
> various versions of CPython from PSF that include the corresponding 
> versions of IDLE, with its integrated shell and editor, but not the 3rd 
> party modules included with Anaconda.
> 
> If you are just starting with Python, and do not work somewhere that 
> uses 2.7, I would ignore 2.7.  Unless you absolutely need the 32 bit 
> version, I delete it.
> 
> > I'm having a problem using pip:
> > 1. Does one have to use pip in the commandline?
> 
> Yes, use command line programs in a command line console/window.
> 
> > Why can't I use pip while in IDLE
> 
> Would you expect to use pip in MS Excel?  If you type 'python' at a 
> command line, and get the '>>>' REPL prompt (google REPL), then your 
> input goes to the python interpreter, which only accepts python 
> statements.  The same is true in the IDLE Shell, and when you run python 
> code in the editor.
> 
> [Some 3rd party IDEs have a front end for PIP. I wanted to add this for 
> IDLE but the project was vetoed when partly done.]
> 
> > 2. For some unknown reason, I have "defaulted" to use IDLE python 3.6, 32 
> > bit version.
> 
> The order of installation, choices you made during installation, and how 
> you start python.  (With just one python installed, there would be no 
> problem.)  Read the first chapter of 
> https://docs.python.org/3/using/index.html and the chapter for your OS 
> (which you should have specified ;-)
> 
> -- 
> Terry Jan Reedy

Many thanks Terry. I'm back to the proverbial drawing board. On a side note, 
I'm uninstalling ANACONDA and re-installing. Seems like the whold 400mb of the 
win executable is missing a bunch of stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip and command line

2018-03-11 Thread Terry Reedy

On 3/11/2018 2:08 PM, GISDude wrote:

On Saturday, March 10, 2018 at 10:28:00 AM UTC-8, Terry Reedy wrote:



Why can't I use pip while in IDLE


Would you expect to use pip in MS Excel?  If you type 'python' at a
command line, and get the '>>>' REPL prompt (google REPL), then your
input goes to the python interpreter, which only accepts python
statements.  The same is true in the IDLE Shell, and when you run python
code in the editor.

[Some 3rd party IDEs have a front end for PIP. I wanted to add this for
IDLE but the project was vetoed when partly done.]


What one can do in any Python REPL or program is to use subprocess to 
call pip.  I used something like the following, recently, to prove it 
could be done, to install numpy from IDLE shell on Windows.


>>> import subprocess as sub
>>> sub.run("pip install numpy", stdout=sub.PIPE, stderr=sub.STDOUT).stdout

But since I have Command Prompt pinned to the taskbar and often open, 
there is no point to this extra typing for me.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
 after reading the docs and stackoverflow i got some rudimentary
understanding of Request vs request.
i still don't understand why i PyCharm won't show properties, but it is
tool centric question that hardly belongs to this group.

On Sun, Mar 11, 2018 at 10:02 AM, Andrew Z  wrote:

> Sorry guys. i realized i was "mumbling" .
>
> What is the difference between Request and request?  -   RTFM
> , Andrew
>
> Questions:
>  a. when do i use Request?
>  b. why can't I see any properties of the request?  For example, in
> Michael's tutorial, there is a call for  request.json. PyCharm brings no
> suggestions when i type in "request. "
>
>
>
>
> On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence 
> wrote:
>
>> On 11/03/18 04:09, Christopher Mullins wrote:
>>
>>> In the code you linked, I don't see where the *R*equest is used. The
>>> request variable is setup by flask when you annotate the function with
>>> the
>>> resource endpoint and POST method. It contains the content of the request
>>> which can be converted to json if that content type was specified.
>>>
>>>
>> Could you please give some context when you reply, TIA.
>>
>> --
>> 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
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: csv module and NULL data byte

2018-03-11 Thread Andrew McNamara
>Any idea why it might throw an exception on encountering a NULL in the 
>input stream? It accepts all other 255 byte values. Was this behaviour 
>intended? Perhaps a comment should be added to the docs.
>Thanks for your work on the module anyway.

The original module was like this - it comes about through the C convention
of null-terminated strings (the module is coded in C). It would have been
fairly involved to removed the restriction, and I would have run the risk
of introducing subtle breakage for a feature nobody had asked for in the
years we were maintaining the module outside the Python core... 8-)

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stock quote API ?

2018-03-11 Thread Irv Kalb

> On Mar 10, 2018, at 9:26 PM, Chris Angelico  wrote:
> 
> On Sun, Mar 11, 2018 at 4:18 PM, Irv Kalb  wrote:
>> Hi,
>> 
>> I teach courses on beginning Python (Python3).  In one of my topics, I 
>> explain how we can write simple programs that reach out to the internet and 
>> download data (request/response).
>> 
>> I show a number of examples using:   urllib.request.urlopen( 
>>  )  to get things like weather data, currency exchange 
>> rates, etc.
>> 
>> I just tried my examples again, and they are all working fine, except for 
>> one.  I had an example where I used the call above to get simple (American) 
>> stock quotes from Yahoo.  However, with this example, now I get a bunch 
>> errors.  In tracking it down, I found that Yahoo has shut down this public 
>> API, discontinued this service.
>> 
>> So ... I am looking for a replacement.  I have done quite a bit of 
>> searching, but I have not been able to find a simple way to get a stock 
>> quote (no need for historical data - most recent price is fine).  I have 
>> found many examples where people have built custom packages for doing this 
>> type of thing.  However, I am in a college environment, and I cannot install 
>> any new packages on the computers there.  I've also seen examples of people 
>> building SQL-style queries to get this type of information, but that's 
>> beyond what I am trying to teach.
>> 
>> Wondering if anyone has any example of an API where I could just make a call 
>> using Python Standard Library interfaces to get stock quotes?
>> 
> 
> Check out https://www.alphavantage.co/ for something you can query for
> free. Extensive and amazingly useful. One of my students did some
> second-tier analysis on the data they provide as a capstone project on
> stock trading analysis.
> 
> You may want to consider, though, modifying the "no new packages"
> rule. The 'requests' library is WAY better for teaching Python and web
> APIs than the raw urllib. Get just a small handful of pip-installable
> packages whitelisted and your life will be better.
> 
> ChrisA
> 

Hi Chris,

Thank you very much for this.  It is very close to what I am looking for.  I 
had seen this early in my searches but I didn't go into it in detail because it 
looked like it was designed to give way more information than I was looking for 
- for example, the first example is about time series data.  

I did look into it today, and I got a free API key to check it out.  It does 
have the ability to give just a stock quote for a symbol, but it looks like the 
minimum I can get back is a csv:

symbol,price,volume,timestamp
MSFT,96.1800,--,2018-03-09 16:01:30

which is easy enough for me to break apart.  I just wish there was a way to 
eliminate the header line so I wouldn't have to go through an explanation about 
that.  

Thanks very much.  If I can't find another one that just give back a price, 
I'll probably use this one.

Irv

PS:  The "no new packages" rule is not mine.  It's the rule imposed by the 
college.  They are the administrators of the computers and I don't have an 
admin password. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stock quote API ?

2018-03-11 Thread Chris Angelico
On Mon, Mar 12, 2018 at 3:19 PM, Irv Kalb  wrote:
>
>> On Mar 10, 2018, at 9:26 PM, Chris Angelico  wrote:
>>
>> On Sun, Mar 11, 2018 at 4:18 PM, Irv Kalb  wrote:
>>> Hi,
>>>
>>> I teach courses on beginning Python (Python3).  In one of my topics, I 
>>> explain how we can write simple programs that reach out to the internet and 
>>> download data (request/response).
>>>
>>> I show a number of examples using:   urllib.request.urlopen( 
>>>  )  to get things like weather data, currency exchange 
>>> rates, etc.
>>>
>>> I just tried my examples again, and they are all working fine, except for 
>>> one.  I had an example where I used the call above to get simple (American) 
>>> stock quotes from Yahoo.  However, with this example, now I get a bunch 
>>> errors.  In tracking it down, I found that Yahoo has shut down this public 
>>> API, discontinued this service.
>>>
>>> So ... I am looking for a replacement.  I have done quite a bit of 
>>> searching, but I have not been able to find a simple way to get a stock 
>>> quote (no need for historical data - most recent price is fine).  I have 
>>> found many examples where people have built custom packages for doing this 
>>> type of thing.  However, I am in a college environment, and I cannot 
>>> install any new packages on the computers there.  I've also seen examples 
>>> of people building SQL-style queries to get this type of information, but 
>>> that's beyond what I am trying to teach.
>>>
>>> Wondering if anyone has any example of an API where I could just make a 
>>> call using Python Standard Library interfaces to get stock quotes?
>>>
>>
>> Check out https://www.alphavantage.co/ for something you can query for
>> free. Extensive and amazingly useful. One of my students did some
>> second-tier analysis on the data they provide as a capstone project on
>> stock trading analysis.
>>
>> You may want to consider, though, modifying the "no new packages"
>> rule. The 'requests' library is WAY better for teaching Python and web
>> APIs than the raw urllib. Get just a small handful of pip-installable
>> packages whitelisted and your life will be better.
>>
>> ChrisA
>>
>
> Hi Chris,
>
> Thank you very much for this.  It is very close to what I am looking for.  I 
> had seen this early in my searches but I didn't go into it in detail because 
> it looked like it was designed to give way more information than I was 
> looking for - for example, the first example is about time series data.
>
> I did look into it today, and I got a free API key to check it out.  It does 
> have the ability to give just a stock quote for a symbol, but it looks like 
> the minimum I can get back is a csv:
>
> symbol,price,volume,timestamp
> MSFT,96.1800,--,2018-03-09 16:01:30
>
> which is easy enough for me to break apart.  I just wish there was a way to 
> eliminate the header line so I wouldn't have to go through an explanation 
> about that.
>
> Thanks very much.  If I can't find another one that just give back a price, 
> I'll probably use this one.

It's usually easier to find a decent API that gives too much info than
to find something that gives exactly what you want - because "what you
want" usually isn't the same as "what someone else wants", and the
easiest way to give both is to give lots of info.

> PS:  The "no new packages" rule is not mine.  It's the rule imposed by the 
> college.  They are the administrators of the computers and I don't have an 
> admin password.
>

Oh, I'm sure. But talk to the college about getting a small number of
packages whitelisted. You don't have to ask for arbitrary package
installation, just for a tiny handful of really REALLY useful
packages. If you were teaching data science with Python, would you
restrict yourself to the standard library, or would you use numpy,
pandas, etc? Web development is the same - while you CAN do everything
with just the stdlib, it's way better to pick up a few well-known
packages that tie in well with that.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list