Easiest Question Ever?

A forum for general discussion of the Python programming language.

Easiest Question Ever?

Postby jstuckhardt » Wed Apr 03, 2013 6:57 pm

I am totally new to python and trying to figure out some existing code that was written by another programmer. I have a function that is being passed two variables (uname, pword), however when the function is defined it looks like this:

def function(req, uname, pword)

Can somebody please explain to me what the 'req' is used for? Thank you in advance.
jstuckhardt
 
Posts: 4
Joined: Wed Apr 03, 2013 6:43 pm

Re: Easiest Question Ever?

Postby Yoriz » Wed Apr 03, 2013 7:15 pm

Hi.

From just the definition line 'req' could be for anything

req is used somewhere inside that function, you'll have to post the code inside the function.

Please read this for future posts.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 838
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Easiest Question Ever?

Postby jstuckhardt » Wed Apr 03, 2013 7:31 pm

Sorry, here are some lines of code where it is used within the function:

This is how code looks when code tags are used, please add them in future posts Thanks :)
Code: Select all
def login(req, uname, pword):
    sess = Session.Session(req)   
    sess['username'] = str(uname)
    sess['pword'] = str(pword)
    sess['ipaddress'] = req.connection.remote_addr[0]

Thanks again.
Last edited by Yoriz on Wed Apr 03, 2013 7:37 pm, edited 1 time in total.
Reason: Added code tags
jstuckhardt
 
Posts: 4
Joined: Wed Apr 03, 2013 6:43 pm

Re: Easiest Question Ever?

Postby Yoriz » Wed Apr 03, 2013 7:41 pm

Have a look at Session.Session to find out what it expects 'req' to be.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 838
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Easiest Question Ever?

Postby jstuckhardt » Wed Apr 03, 2013 7:47 pm

Yoriz,

Thank you for informing me about using the code tags. Will use them in the future. I would love to look at Session.Session if I could find it. I will continue to dig.
jstuckhardt
 
Posts: 4
Joined: Wed Apr 03, 2013 6:43 pm

Re: Easiest Question Ever?

Postby StormJedi » Wed Apr 03, 2013 9:02 pm

If on windows: Ctrl+F, type in 'Session'
Python 2.7
Python 3.3
Windows 7 x64
Ubuntu 12.10 x64
One day I hope to use one OS and 1 Python flavor, until that day, life goes on.
StormJedi
 
Posts: 27
Joined: Fri Feb 22, 2013 3:36 pm


Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot] and 2 guests