EuroPython 2021: Volume Discount for Company Teams

2021-06-29 Thread Marc-Andre Lemburg
EuroPython 2021 offers special discounts on business tickets for company
teams.

 * EuroPython Volume Discounts *

  https://ep2021.europython.eu/sponsor/packages/#Volume-Discount


If you are going to attend the conference as a team, we offer the
following volume discounts as a thank you:

- 5 business tickets for the price of 4
- 10 business tickets for the price of 8
- 15 business tickets for the price of 11

In addition to the above offer, we'll also send out a mention on Twitter
welcoming your team.

Your company should email [email protected] to apply. You will
then receive a coupon code and the welcome tweet will be handled by us.

You can also visit the ticket shop to view the different ticket types
and this year’s schedule to see the timetable for EuroPython 2021 in
your local time zone.

https://ep2021.europython.eu/registration/buy-tickets/
https://ep2021.europython.eu/schedule/


Quick Summary
-
EuroPython 2021 will be run online from July 26 - August 1:

- Two workshop/training days (July 26 - 27)
- Three conference days (July 28 - 30)
- Two sprint days (July 31 - August 1)

The sessions will be scheduled to ensure they are also accessible for
those in the Asian and Americas time zones.

More infos are available on our website at https://ep2021.europython.eu/


Help spread the word


Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/europython-2021-volume-discount-for-company-teams/

Tweet:

https://twitter.com/europython/status/1409886833085980686

Enjoy,
--
EuroPython 2021 Team
https://ep2021.europython.eu/
https://www.europython-society.org/

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


Re: python: server is not receiving input from client flask

2021-06-29 Thread Jerry Thefilmmaker
On Monday, June 28, 2021 at 3:59:54 PM UTC-4, Chris Angelico wrote:
> On Tue, Jun 29, 2021 at 5:43 AM Jerry Thefilmmaker 
>  wrote: 
> > 
> > Do you mind elaborating a bit more on making one function for any given 
> > request? 
> > 
> > As far as defining a bunch of functions that get called when particular 
> > requests come in I thought that's what I had going on in my codes. No? 
> > 
> > Also thank you, on making use of the print statement. Thought once I 
> > crossed over to the web side there was no more need for it. But what you 
> > said makes sense in terms of debugging, because sometimes I couldn't tell 
> > whether the client's variable was getting pass to my function which caused 
> > it not to be triggered. 
> > 
> > Thank you! 
> >
> Sure. I'll take a step back and look quickly at the way HTTP works and 
> how Flask figures out what function to call; you probably know all 
> this but it'll make the explanation easier. 
> 
> Every HTTP request has a method (GET, POST, PUT, DELETE, etc) and a 
> request URI. Some of the URI just figures out whether it goes to your 
> server or not, and the rest is which page within your server. So if 
> you're running on, say, port 5000 on the same computer the web browser 
> is on, then you can go to http://localhost:5000/any/path/here and 
> it'll be handled by your web app. Since the "http://localhost:5000"; 
> part is the way to find the whole server, Flask just looks at the rest 
> of it - "/any/path/here" - to do its routing. So we have two parts - a 
> path and a method - that define which function is called. 
> 
> When you point your browser at "http://localhost:5000/";, that's a GET 
> request (normal web page fetches are GET requests) with a path of "/". 
> 
> When you submit the form, that's a POST request (because the form's 
> method) with a path of "/" (because that's the form's action). I'm 
> assuming here that nothing is getting in the way of that, but that's 
> what printing stuff out can help with. 
> 
> So far, so good. I'm pretty sure none of what I just said is news to 
> you, but let's focus on those two requests: "GET /" and "POST /". 
> 
> The app.route decorator lets you associate a function with some 
> path/method combination. What you have in the code you shared is this:
> > @app.route("/", methods = ['POST', 'GET']) 
> > def play(): 
> > 
> > @app.route("/", methods = ['POST', 'GET']) 
> > def check_answer(ans, user):
> That tells Flask that the play function should be associated with 
> "POST /" and "GET /". And then it tells Flask that the check_answer 
> function should be associated with... the same two routes. 
> 
> I suspect that what you actually intend is for one of those functions 
> to just handle GET, and the other to just handle POST. But another way 
> you could fix this would be to change the URL used as the form's 
> action. It's up to you and what your plans are for the rest of this 
> app. 
> 
> (My recommendation is to start out with each function handling just 
> one route - say, "GET /" for play() and "POST /" for check_answer - 
> and only combine them (with multiple keywords in methods=[...]) once 
> you find that the two functions are duplicating a lot of code.) 
> 
> Once that's sorted out, you'll want to figure out exactly what 
> parameters your functions take. As a general rule, the function's 
> parameters will match the placeholders in the route, so if you're not 
> using placeholders, you'll probably just want them all to take no 
> parameters. Here are some examples from a project of mine: 
> 
> @app.route("/login") 
> def login(): 
> 
> @app.route("/force/") 
> def force_timer(id): 
> 
> @app.route("/") 
> @app.route("/editor/") 
> def mainpage(channelid=None): 
> 
> In the case of mainpage, it handles both "GET /" and "GET 
> /editor/12345", so the function might get a parameter and might not - 
> hence it takes a parameter with a default. For what you're doing here, 
> there are no placeholders in your routes, so all your routed functions 
> will take no args (like login in my example - it only ever handles 
> "GET /login", so it doesn't need anything else). 
> 
> Hope that helps! 
> 
> ChrisA

Thanks for taking the time to explained, Chris. Believe me, it helps. It had me 
thinking for a while. So, All the stuff about HTTP makes sense. I've been 
studying  and trying to wrap my head around the rest of your explanation and 
see how I can apply it to my codes.

So, if I separate my GET method which would be to get the web page from my POST 
method which would be assigned to returning value from my form, wouldn't I have 
to dedicate 2 functions for any given requests in that sense?

The only reason I have parameters in my functions is so I can pass value from 1 
function to another which is just stuff that happens in the background. Is it 
necessary to have them in my decorators as well, or is it that these values 
won't get passed around if they're not integrated in the decorators?
-- 
https://mail

Paramiko installation issue

2021-06-29 Thread Sourav Bose
Hello,
 I was using Python 3.8  32 bit ,but while trying to install the paramiko
there is some wheel issue I'm facing. definitely it is due to version
mismatching of the python and the paramiko.
I have uninstalled 3.8
Could you please help me by providing the exact paramiko files for 3.8 then
i will again try to install it other wise check the below paramiko files
and let me know which python version is compatible with this.
Paramiko files :-
pycparser-2.20-py2.py3-none-any.whl  -- Installed
six-1.16.0-py2.py3-none-any.whl -- Installed
PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl -- error
cryptography-3.4.7-cp36-abi3-win_amd64.whl --error
cffi-1.14.5-cp37-cp37m-win_amd64.whl -- error
bcrypt-3.2.0-cp36-abi3-win_amd64.whl -- error
paramiko-2.7.2-py2.py3-none-any.whl --error

Please help me to get the exact version.

Thanks,
Sourav
9836231860



-- 
Thanks & Regards,
Sourav Bose,
+919836231860
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python: server is not receiving input from client flask

2021-06-29 Thread Chris Angelico
On Wed, Jun 30, 2021 at 3:38 AM Jerry Thefilmmaker
 wrote:
> Thanks for taking the time to explained, Chris. Believe me, it helps. It had 
> me thinking for a while. So, All the stuff about HTTP makes sense. I've been 
> studying  and trying to wrap my head around the rest of your explanation and 
> see how I can apply it to my codes.
>

Glad to hear it :)

> So, if I separate my GET method which would be to get the web page from my 
> POST method which would be assigned to returning value from my form, wouldn't 
> I have to dedicate 2 functions for any given requests in that sense?
>

The web page and form response are two completely separate requests.
You can't think of them as a single request; in fact, it's entirely
possible for someone to send the POST request without first getting
the page at all.

> The only reason I have parameters in my functions is so I can pass value from 
> 1 function to another which is just stuff that happens in the background. Is 
> it necessary to have them in my decorators as well, or is it that these 
> values won't get passed around if they're not integrated in the decorators?
>

They won't get passed around. The only way to share that information
is via the page itself (or something along those lines, like a session
variable - which is some magic built on top of cookies). Think about
the two requests completely independently, and make sure that (a) the
GET request sends back the correct page, and (b) the POST request does
whatever it needs to, and sends back a new page.

Hopefully that should set you in the right direction!

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


Re: Paramiko installation issue

2021-06-29 Thread MRAB

On 2021-06-29 15:01, Sourav Bose wrote:

Hello,
  I was using Python 3.8  32 bit ,but while trying to install the paramiko
there is some wheel issue I'm facing. definitely it is due to version
mismatching of the python and the paramiko.
I have uninstalled 3.8
Could you please help me by providing the exact paramiko files for 3.8 then
i will again try to install it other wise check the below paramiko files
and let me know which python version is compatible with this.
Paramiko files :-
pycparser-2.20-py2.py3-none-any.whl  -- Installed
six-1.16.0-py2.py3-none-any.whl -- Installed
PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl -- error
cryptography-3.4.7-cp36-abi3-win_amd64.whl --error
cffi-1.14.5-cp37-cp37m-win_amd64.whl -- error
bcrypt-3.2.0-cp36-abi3-win_amd64.whl -- error
paramiko-2.7.2-py2.py3-none-any.whl --error

Please help me to get the exact version.


If the name contains "cp37" then it's for CPython 3.7, and so on.

Install the Python version (ideally the latest version) and then use the 
python launcher, "py".


For example, if you installed Python 3.9, typing:

py

on the Windows command line (in a Command Prompt window) should start it.

From the Windows command line, install the packages by calling the pip 
module via the Python launcher:


py -m pip install paramiko

and so on. That should pick up and install the correct version.
--
https://mail.python.org/mailman/listinfo/python-list


Re: python: server is not receiving input from client flask

2021-06-29 Thread Jerry Thefilmmaker
On Tuesday, June 29, 2021 at 2:03:58 PM UTC-4, Chris Angelico wrote:
> On Wed, Jun 30, 2021 at 3:38 AM Jerry Thefilmmaker 
>  wrote: 
> > Thanks for taking the time to explained, Chris. Believe me, it helps. It 
> > had me thinking for a while. So, All the stuff about HTTP makes sense. I've 
> > been studying and trying to wrap my head around the rest of your 
> > explanation and see how I can apply it to my codes. 
> >
> Glad to hear it :)
> > So, if I separate my GET method which would be to get the web page from my 
> > POST method which would be assigned to returning value from my form, 
> > wouldn't I have to dedicate 2 functions for any given requests in that 
> > sense? 
> >
> The web page and form response are two completely separate requests. 
> You can't think of them as a single request; in fact, it's entirely 
> possible for someone to send the POST request without first getting 
> the page at all.
> > The only reason I have parameters in my functions is so I can pass value 
> > from 1 function to another which is just stuff that happens in the 
> > background. Is it necessary to have them in my decorators as well, or is it 
> > that these values won't get passed around if they're not integrated in the 
> > decorators? 
> >
> They won't get passed around. The only way to share that information 
> is via the page itself (or something along those lines, like a session 
> variable - which is some magic built on top of cookies). Think about 
> the two requests completely independently, and make sure that (a) the 
> GET request sends back the correct page, and (b) the POST request does 
> whatever it needs to, and sends back a new page. 
> 
> Hopefully that should set you in the right direction! 
> 
> ChrisA

Got it. It all makes sense. It feels like I'm doing all the right things, 
accounting for all functions but somehow it's not working.

I changed my methods. Adjusted my routes. Still the same thing. Now I get this 
error:
  i3 = ans.get(answers, '')
AttributeError: 'str' object has no attribute 'get'

Which doesn't make sense because my object ans is a dictionary and get method 
here is supposed to get another value within the dictionary based on the key 
value of answers which is passed from the client. Does that make sense?

--

Here's my modified code by the way:

@app.route("/")
def main():
return render_template('app.html')

@app.route("/play", methods = ['GET']) 
def play():

qa = questions.qa #list of dict with questions
#user1, user2 = [], [] #containers for each player's answers

if request.method == 'GET':
answers = request.form.get('answers')
random.shuffle(questions.qa)
response = quiz(qa)
print(answers)
return response 

def quiz(qa):
for rand_q in qa:
i = rand_q['question']
i2 = check_answer(i)
   
return render_template('app.html') + i, i2 

@app.route("/check_answer/", methods = ['POST'])
def check_answer(ans):
user1 = []
if request.method == 'POST':
answers = request.form.get('answers')
if 'yes' in answers:
print(ans)
user1.append('yes')
i3 = ans.get(answers, '')
return i3
--
Here's my form from the html file:


Enter your answer: 
 


Also, where do I see my print statement in this case? Mind you the codes worked 
fine before I attempted to use flask.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python: server is not receiving input from client flask

2021-06-29 Thread Chris Angelico
On Wed, Jun 30, 2021 at 6:21 AM Jerry Thefilmmaker
 wrote:
> @app.route("/check_answer/", methods = ['POST'])
> def check_answer(ans):
>
> 
> Enter your answer: 
>  
> 

What you're creating here is a route with a placeholder. The
check_answer function will handle POST requests to /check_answer/foo,
/check_answer/spam, /check_answer/barney, /check_answer/whatever. In
each case, the variable "ans" will be given the part of the URL that
 represents - the string "foo" or "spam" or "barney" or whatever.
It's never going to carry a dictionary around.

I'll stress this again: *Your requests must be independently handled*.
You can't think of passing information from one request to another,
because there might not have been a previous request. Moving to the
web means thinking differently about things; you no longer have
control flow from one part of the program to another, you instead have
independent handlers that have to think exclusively about their own
requests.

This might mean carrying some extra information through the form. For
instance, you could include a question ID of some sort (using  for that purpose), and then you could have a global
constant with all of your prewritten questions. There are other ways
to carry information around, but they have to go via the request
itself; you can't keep variables from one function to another.

> Also, where do I see my print statement in this case? Mind you the codes 
> worked fine before I attempted to use flask.

Hmm, that depends on how you're running your code. Ideally, you should
have a server running somewhere - a terminal window or equivalent -
and if you're using Flask's default server (werkzeug), it will be
reporting every request as it goes through. It might look something
like this:

INFO:geventwebsocket.handler:127.0.0.1 - - [2021-06-30 06:30:51] "GET
/ HTTP/1.1" 200 10267 1.569960
INFO:geventwebsocket.handler:127.0.0.1 - - [2021-06-30 06:30:52] "GET
/api/twitch_schedule?channelid=49497888 HTTP/1.1" 200 593 1.403456
INFO:geventwebsocket.handler:127.0.0.1 - - [2021-06-30 06:31:06] "GET
/ HTTP/1.1" 200 10267 1.724949
INFO:geventwebsocket.handler:127.0.0.1 - - [2021-06-30 06:31:07] "GET
/api/twitch_schedule?channelid=49497888 HTTP/1.1" 200 593 1.277206

Your print calls will insert messages into that log, prior to their
corresponding summary lines (the summary is written when you return a
response, so that's at the very end of your function).

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