Thread: [pygccxml-development] need help with query
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-03-15 06:12:07
Attachments:
query.py
|
I saw Matthias filters ( Or, Not and And ) and liked the idea. But ( there is always some 'but' :-( ). I don't think they are useful in the form like this. People are to lazy to learn. So instead of composing queries using Matthias classes, they will right small lambda function that will do the job. May be I wrong, may be not. I propose an other implementation. Take a look on attached file. Right now it does not work. This is the area I need help. Can you see what I am doing wrong? Lets say I have query class, that has __call__ method, that takes 1 argument - some text qa =3D query_t( 'a' ) #returns true if 'a' in text qb =3D query_t( 'b' ) #returns true if 'b' in text qab =3D qa and qb print 'a and b in text ac?', qab( 'ac' ) #False print 'a and b in text ab?',qab( 'ab' ) #True qaqb =3D qa or qb print 'a or b in text a', qaqb('a') #True print 'a or b in text b', qaqb('b')#True print 'a or b in text c', qaqb('c')#False Do you like such approach? Matthias what do you think? Thanks for help. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <ba...@ir...> - 2006-03-15 09:27:39
|
Roman Yakovenko wrote: > I saw Matthias filters ( Or, Not and And ) and liked the idea. But ( > there is always some 'but' :-( ). > > I don't think they are useful in the form like this. People are to > lazy to learn. So instead > of composing queries using Matthias classes, they will right small > lambda function that will > do the job. May be I wrong, may be not. I propose an other > implementation. Take a look on attached file. Right now it does not > work. This is the area I need help. Can you see what I am doing wrong? > > Lets say I have query class, that has __call__ method, that takes 1 > argument - some text > > qa = query_t( 'a' ) #returns true if 'a' in text > qb = query_t( 'b' ) #returns true if 'b' in text > > qab = qa and qb > [...] > qaqb = qa or qb The above lines should read: qab = qa & qb ... qaqb = qa | qb "and", "or" is not the same as the &,| operators. > Do you like such approach? Matthias what do you think? I don't understand what problem you want to solve. Your query class just does the same than my filters, but above you say that this is too difficult to learn...? So in what respect is query_t easier to use than my filters? - Matthias - |
From: Roman Y. <rom...@gm...> - 2006-03-15 09:40:15
|
On 3/15/06, Matthias Baas <ba...@ir...> wrote: > Roman Yakovenko wrote: > > I saw Matthias filters ( Or, Not and And ) and liked the idea. But ( > > there is always some 'but' :-( ). > > > > I don't think they are useful in the form like this. People are to > > lazy to learn. So instead > > of composing queries using Matthias classes, they will right small > > lambda function that will > > do the job. May be I wrong, may be not. I propose an other > > implementation. Take a look on attached file. Right now it does not > > work. This is the area I need help. Can you see what I am doing wrong? > > > > Lets say I have query class, that has __call__ method, that takes 1 > > argument - some text > > > > qa =3D query_t( 'a' ) #returns true if 'a' in text > > qb =3D query_t( 'b' ) #returns true if 'b' in text > > > > qab =3D qa and qb > > [...] > > qaqb =3D qa or qb > > The above lines should read: > > qab =3D qa & qb > ... > qaqb =3D qa | qb > > "and", "or" is not the same as the &,| operators. > > > Do you like such approach? Matthias what do you think? > > I don't understand what problem you want to solve. Your query class just > does the same than my filters, but above you say that this is too > difficult to learn...? So in what respect is query_t easier to use than > my filters? By the way, I could be wrong. I just want a discuss this a little. OrFilter and AndFilter takes as argument list of filters right. I think that in most case an user does not have more then 2 or 3 filters. I could be wrong. So I think, user will not use next code f1 =3D filter(....) f2 =3D filter(...) mb =3D module_builder_t(...) mb.classes( OrFilter( [f1,f2] ) ) but rather: mb.classes( lambda decl: f1(decl) or f2(decl) ) I could be wrong, but in this case he will not learn OrFilter. If we implement your idea in a different way, then user can write next line mb.classes( f1 | f2 ) > - Matthias - I hope, I was clear. I do like your idea, but I think it should be improved a little. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <ba...@ir...> - 2006-03-15 12:38:30
|
Roman Yakovenko wrote: > f1 = filter(....) > f2 = filter(...) > > mb = module_builder_t(...) > mb.classes( OrFilter( [f1,f2] ) ) > > but rather: > > mb.classes( lambda decl: f1(decl) or f2(decl) ) > > I could be wrong, but in this case he will not learn OrFilter. If we > implement your idea > in a different way, then user can write next line > > mb.classes( f1 | f2 ) So you prefer this last line over the above two ways, right? I do agree with you and this is already how you can use my filter classes... :) (By the way, as I see it, using the filter classes directly is already an advanced feature anyway. The "normal" user would just use the convenience arguments of the query methods (which are converted into filter classes internally)) - Matthias - |
From: Roman Y. <rom...@gm...> - 2006-03-15 12:49:23
|
On 3/15/06, Matthias Baas <ba...@ir...> wrote: > > mb.classes( f1 | f2 ) > > So you prefer this last line over the above two ways, right? I do agree > with you and this is already how you can use my filter classes... :) Ooooooooooops. It seems that I did not paid enough attention to your classes (=3DFilterBase) I just took a look on Or|And|Not Filters and did not understand why do you need them. Shame on me. I will add your classes to pygccxml. Thank you very much. I am glad, that we talk. > (By the way, as I see it, using the filter classes directly is already > an advanced feature anyway. The "normal" user would just use the > convenience arguments of the query methods (which are converted into > filter classes internally)) Yes, but to write "mb.classes( f1 | f2 )" is cool. > - Matthias - > Thank you very much. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |