Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread Chris “Kwpolska” Warrick
On Mon, Oct 14, 2013 at 3:27 PM, Kush Goyal wrote: > Also, db is an sqlalchemy engine and db.Model is a class. > > db.Model is I think a sqlalchemy declarative base class which has all > the needed methods and classes for database handling. > > So, did I get the above things right? Not quite. db

Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread ALAN GAULD
I tried experimenting with classes and objects on python interpretor >and learned that in python functions, classes, method, objects and >modules all can be passed around and returned.That's correct, they are all >objects in Python From what I understood from your answers: > >user = User.query

Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread Kush Goyal
Hi, Thanks a lot Bob and Allan for the help. I tried experimenting with classes and objects on python interpretor and learned that in python functions, classes, method, objects and modules all can be passed around and returned. >From what I understood from your answers: user = User.query.filter

Re: [Tutor] Cannot understand object initiation

2013-10-12 Thread bob gailer
On 10/12/2013 11:01 AM, Kush Goyal wrote: [[snip] "user = User.query.filter_by ( username = self.username.data ).first()" now this I do not understand. Can a object be create by using a method of a class instead of the class consturctor? I Without seeing the code you reference (User module) I

Re: [Tutor] Cannot understand object initiation

2013-10-12 Thread Alan Gauld
On 12/10/13 16:01, Kush Goyal wrote: Hi, I am learning web development by using flask framework. The below code is used to create a class LoginForm which inherits from the class Form. In the method 'validate' of class 'LoginForm' the variable 'user' is initialized by using: "user = User.query.

[Tutor] Cannot understand object initiation

2013-10-12 Thread Kush Goyal
Hi, I am learning web development by using flask framework. The below code is used to create a class LoginForm which inherits from the class Form. In the method 'validate' of class 'LoginForm' the variable 'user' is initialized by using: "user = User.query.filter_by ( username = self.username.da

Re: [Tutor] Cannot understand what this means

2013-07-22 Thread ALAN GAULD
ect: RE: [Tutor] Cannot understand what this means > > >Hi >I have doubts only on the arguments part.  > >OK, But what about them? Do you understand what command line arguments are? > def main(): > >>    # This command-line parsing code is provided. >>    # Mak

Re: [Tutor] Cannot understand what this means

2013-07-18 Thread Alan Gauld
On 15/07/13 09:53, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: websites. But now, there is a program from Google's Python Exercises whose main() part is already given to you. def main(): # This command-line parsing code is provided. # Make a list of command line arguments, omitting the [0

[Tutor] Cannot understand what this means

2013-07-18 Thread #PATHANGI JANARDHANAN JATINSHRAVAN#
Hello All, I have just started out with python and was feeling pretty comfortable and confident to the point of solving problems from websites. But now, there is a program from Google's Python Exercises whose main() part is already given to you. def main(): # This command-line parsing cod

Re: [Tutor] Cannot Understand

2006-03-11 Thread Alan Gauld
> we don't all agree on everything, but that we can disagree politely and > still be helpful. One of the truly great things about Python is the user community, by far the most civilised that I've encountered in my 20 years or so of internet use. Long may it continue, Alan G. __

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Alan Gauld <[EMAIL PROTECTED]> wrote: >> Could you please explain this code?. f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1>> This is why lambdas are evil.It's not the lambda thats evil its the need in Python to limit them to a single _expression_.If we writedef f(n):   return n-1

Re: [Tutor] Cannot Understand

2006-03-10 Thread Liam Clarke
On 3/11/06, Pawel Kraszewski <[EMAIL PROTECTED]> wrote: > Dnia piątek, 10 marca 2006 19:31, Edgar Antonio Rodriguez Velazco napisał: > > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > Oh God! This smells lispish! Haven't seen a jevel like this before, but I LOVE > it! Haha, hey, I've been le

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Alan Gauld <[EMAIL PROTECTED]> wrote: >> Could you please explain this code?. f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1>>>This is why lambdas are evil.I meant to add to my last post that even using lambdas this is a weird attempt at a factorial fiunction.Here's the equivalent f

Re: [Tutor] Cannot Understand

2006-03-10 Thread Alan Gauld
>> Could you please explain this code?. >> >> f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > >This is why lambdas are evil. I meant to add to my last post that even using lambdas this is a weird attempt at a factorial fiunction. Here's the equivalent from my web tutor on functional program

Re: [Tutor] Cannot Understand

2006-03-10 Thread Alan Gauld
>> Could you please explain this code?. >> >> f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > This is why lambdas are evil. It's not the lambda thats evil its the need in Python to limit them to a single expression. If we write def f(n): return n-1 + abs(n-1) and f(n-1)*n or 1 its just

Re: [Tutor] Cannot Understand

2006-03-10 Thread Bob Gailer
Edgar Antonio Rodriguez Velazco wrote: > Hi, > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 You've had 2 replies that dissect the "expression". I fear they might not make lambda itself clear, so I will add my explanation. lambda is a Python operator that

Re: [Tutor] Cannot Understand

2006-03-10 Thread Pawel Kraszewski
Dnia piątek, 10 marca 2006 19:31, Edgar Antonio Rodriguez Velazco napisał: > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 Oh God! This smells lispish! Haven't seen a jevel like this before, but I LOVE it! - First, let's cut that into pieces: R1 n-

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Danny Yoo wrote: > > The expression n-1 + abs(n-1) is always a true value... except in the > > case where n is zero. > > Sorry, that's wrong of me, but you know what I mean. *grin* Ugh, the other thing I screwed up wrong was misreading: X and Y or Z and forgetting my

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
> The expression n-1 + abs(n-1) is always a true value... except in the > case where n is zero. Sorry, that's wrong of me, but you know what I mean. *grin* It zeros out when n-1 <= 0, that is, when n <= 1. ## >>> def test(n): ... return n-1 + abs(n-1) ... >>> for x in range(-5, 5): ...

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Edgar Antonio Rodriguez Velazco wrote: > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 Hi Edgar, This is terrible code. *grin* I know that this is the factorial function in disguise, but this is just Wrong. I don't think we sho

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Edgar Antonio Rodriguez Velazco <[EMAIL PROTECTED]> wrote: Hi,Could you please explain this code?.f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 This is why lambdas are evil. Officially, they are for creating "anonymous functions"; usually they only succeed in creating obscure unreadabl

[Tutor] Cannot Understand

2006-03-10 Thread Edgar Antonio Rodriguez Velazco
Hi,Could you please explain this code?.f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1Thanks,-- Edgar A. Rodriguez V. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor