Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7605081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:04:35+00:00 2026-05-31T00:04:35+00:00

So I understand here that python is assigning the render variable to web.template.render, but

  • 0

So I understand here that python is assigning the render variable to web.template.render, but I don’t really get what it’s doing in english. My templates directory is being “called” (is this the right word?) and the layout.html is used in some way. I’ve been trying to break the code and it still works without this line though. I’ve been instructed to use this and don’t understand it.

render = web.template.render('templates/', base="layout")

The following class makes sense to me to this extent: an object assigned to it will return hello_form.html and because of the second function (method?) it will allow a user to input things into a prompt and return those values. I don’t understand very deeply what the form variable line or the return line are doing though. Any help or quick translations will help me greatly, thanks!

class Index(object):
    def GET(self):
        return render.hello_form()

    def POST(self):
        form = web.input(name = "what", greet = "no response?")
        greeting = "%s, %s" % (form.greet, form.name)
        return render.index(greeting = greeting)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:04:36+00:00Added an answer on May 31, 2026 at 12:04 am

    Correct me if I’m wrong but your confusion is the name = "what" type syntax? This just says that the function, in this case web.input takes a parameter called name and you are assigning it directly to "what". Same with render.index(greeting = greeting), it takes a parameter greeting to which you assign the value of the local variable greeting which was evaluated in the line above the return statement.

    So without looking at the method, I would say there is no guarantee that return render.index(greeting) is the same as render.index(greeting = greeting). Take for example this snippet of code taken from here, but without the infinite loop I just noticed:

    # Default Values
    def multiprint(n=5, txt=""):
        i = 0
        while i < n:
            print txt
            i++
    

    You could then call this function this way:

    >>> multiprint()
    
    
    
    
    
    
    >>> multiprint(1)
    
    
    >>> multiprint(1,"hi")
    hi
    
    >>> multiprint(txt="hi")
    hi
    hi
    hi
    hi
    hi
    

    Where in the last line we did not specify n, the first parameter, but did specify txt. I also agree with you that greeting = greeting is confusing. It seems like a cute little trick, but I don’t much care for it. The parameter name is greeting, like txt in our example, and the local variable is greeting. Personally, I would have named the local variable something else and then had, render.index(greeting = myGreetingText) or something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that there's an nginx configuration file at http://www.friendfeed.com But i don't really
Here's a question that I don't quite understand: The command, system(pause); is taught to
I've come across an interesting behavior with Python 3 that I don't understand. I've
I am trying to learn python but don't quite understand the syntax. What is
I don't understand what happens here : use PAR { file => 'foo.par', fallback
I don't understand what's happening here. If someone could explain, I would appreciate it.
I don't understand why async as described here http://www.rebol.com/article/0050.html is no more available in
Here is code from MSDN . I don't understand why the work isn't just
I have a program that runs in Python 2 and Python 3, but there
There are multiple posts on here that capture value , but I'm just looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.