« first day (3750 days earlier)      last day (1188 days later) » 
00:00 - 20:0020:00 - 00:00

8:00 PM
@roganjosh well so due to running it with the wildcard sort of like % the only way I found this working with mongo is to transform the data with regex, and it is working well with querying the data as, except due to querying with multiple fields, some of which are empy obviously it calls all of them thats why I am trying to find a way to stop it querying that data if input is empty
when it is simply
'name' : re.compile('.*' + req['name'] + '.*', re.IGNORECASE)
 
flags should be an integer value, not None
you want re.IGNORECASE if ... else 0
 
Why does the code call sre given this answer?
 
the re module is combining your flags via the | operator (which is generally how you combine flags) so at some point it attempts to bitwise-or your None with a standard integer, yielding your error.
 
Or, maybe they just retained some of the module names, I guess.
 
Wait, let me read the code
 
I think I misunderstood again
Where's sre?
ah, traceback
 
Thanks for that explination alkasm
 
np
 
@alkasm arguably python should check whether isinstance(flags, int) or the EAFP variant
 
I agree None seems like an acceptable input at least
 
8:09 PM
It's been a long while since I used Mongo. In SQLAlchemy you can build queries up in stages, such as:
`if content_filter: query = query.filter_by(content_filter=content_filter)`
And just keep going like that. Can you do something similar in Mongo, or do you need to provide all the filters in one shot?
 
please see our code formatting guide :P
 
Oh, F grade to myself on formatting
 
@roganjosh that's more or less what this code is doing.
Q(filter=...) | Q(filter=...) | ... will return a query in the same way that q.filter(...).filter(...)... will do.
 
@AndrasDeak I really have nowhere to go from here. I can only apologise to my friends, family and fellow Room 6 members for my shameful performance :'(
 
Both are examples of "fluent interfaces"
(note the or operator thing is equivalent to Q().__or__(...).__or__(...)...)
 
8:18 PM
Ah, ok. Thanks
 
I thought fluentness was related to mutating methods returning the original object for the purposes of chaining. Q.filter(...).filter(...) fits the bill, but Q.filter(...) | Q.filter(...) does not
 
its not Q.filter() | Q.filter() but Q() | Q() and that inherently invokes the .__or__() method so it's basically equivalent.
 
@roganjosh I am playing with these to get accustomed with it incase i get a call-back for the programming challenge for the interview but its quite interesting how different they operate ^^ also with using react for first time its quite fun using flask differently
 
Both are a way of chaining expressions, each subexpression returning the same type.
 
you might have missed when I said "mutating methods"
but yeah, sorry for pulling the dot out
 
8:22 PM
you know what, i may have missed when you said "mutating methods"
 
@Kwsswart Can you get React playing nice with Flask? The {{}} syntax (IIRC) just made me run for the hills
 
@roganjosh yeah works quite nicely actually you have to return everything in json format for it and its taking a but to get used to it but its quite a fun experience
 
why is the fact that it's mutated important? that seems like an implementation detail
 
I don't know the correct terminology, but surely the fact that the object is mutated is foundational to the fact that it works in SQLA?
 
...why? each call returns an object, who cares if it was the first one but mutated N times, or a new object with all N mutations?
 
8:27 PM
My silence is telling. Ok, I need to think a bit more about this one.
 
@alkasm my 100% uneducated idea is that there's nothing "fluent" about methods returning objects. That's just how methods work. You only need a qualifier for something surprising. "Mutating method also returns the mutated object" is something surprising.
 
that's a fair take
 
but as I said 1. I might be wrong about the rationale, and 2. I might be wrong about the whole mutability deal
 
@roganjosh if you are curious heres the repo as it is now github.com/Kwsswart/flask-react-phonebook it is still really simply done no form verification or anything yet but plan to see if i can get it all to work together with flask wtf maybe and see how it all works
 
@Kwsswart woah. I've really gotta say; your coding and understanding has come on so much since we started discussions around your Flask app. I'm really impressed!
 
8:33 PM
Looks like SQL alchemy creates new statements on their method chaining interface (and the documentation states "Return a new ...")
>>> q = sa.select()
>>> q2 = q.limit(5)
>>> q is q2
False
 
Thak you mate I appreciate it ^^ I am trying to improve each day
 
Just don't dabble with the frontend dark arts too much :P
Flask leads to JavaScript. JavaScript leads to React. React leads to Frontend
 
haha I enjoy the backend more tbh but will be nice when I feel confident enough to say I know react and in my last interview it seemed like they wanted someone who know a bit of both so thought why learn
Once I know this i was thinking of learning some more python libraries like numpy, pandas and matlib
 
@alkasm OK, I looked up en.wikipedia.org/wiki/Fluent_interface and it says "having each method return the object to which it is attached, often referred to as this or self" so it seems I had the right idea
 
AFAIK "fluent interfaces" come from the static typing world where it makes almost no sense to not mutate the original (e.g. the builder pattern), so I think most contexts probably will be that to be fair.
 
8:39 PM
Not sure I see the connection between static typing and mutation
Can't you have OtherType ThisType::foo();?
 
I just don't think it's common in the static typing world to have successive chains of partially constructed objects, and each time making a copy and then adding to it.
 
OK, but that's not really about static typing, that's about the builder pattern in specific, right?
implementing the same pattern in a dynamic language would be similar
 
umm yeah that's a good point
lol his example is broken, calling lower() on a str.split() result.
related, how do you guys read mailing lists?
 
through tears
I only follow the ones that land in my inbox
 
8:55 PM
Can someone recommend a tutorial on how to implement two factor authentication on the template?
 
Also the python asq library constructs a new query on each method call as well.
i cant actually find a method chaining API in python that does mutate the starting object (sample size of...3)
 
That's not too surprising because python is almost completely consistent about returning None in mutating methods
fluent APIs look a bit ruby or something
 
yeah
 
@AndrasDeak But why? What was the purpose of your question?
 
@Marco I was expecting the code to break inside function(), which would have been the anticipated education vis-a-vis chat.stackoverflow.com/transcript/6?m=51418660#51418660. If the code doesn't break there then either 1. the code breaks earlier, or 2. function() was naturally vectorized to begin with. In any case you cannot vectorize the enclosing code without vectorizing that function. Asking for help and then thinking you know better doesn't really spark altruism.
 
9:10 PM
The whole "Should Python do fluent interface/method chaining?" debate ended 17 years ago with a 'no', AFAIK (other than SQLAlchemy). We don't want to be PHP or C#, and if you want FP, there's Scala. If you chain N expressions, control flow becomes a pain: consider each possible permutation of exceptions that the previous (N-1) method calls might generate. Are you just asking about SQLAlchemy, or proposing doing this in mainline Python?
 
@smci I don't think anyone's asking anything per se, we just went on an aside about fluent APIs. At least I think so.
 
9:39 PM
For puzzling.SE afficionados, also fun to do via programming Table of mathematical expressions - fill in 1-9
 
10:38 PM
@smci other than sqlalchemy, many other database libraries, python-linq attempts (e.g. asq), fluentpy (FP-style), pandas, hell even some aspects of numpy.....and probably many other things.
But yeah as Andras said, this wasn't a proposal. It was just a discussion about them.
 
FWIW I found it an interesting discussion because I don't actually think I've thought about any of this. Each library is siloed in my brain and I just use it as I know how... "It is known..."
 
10:56 PM
An IRL analogy that this brings up in my mind, and which I try my best to remember when working with newbies, is when I moved to Nottingham for uni. I got to a point where I could get to anywhere I wanted to in the city, but each path was completely disconnected. Had I watched myself with a bird's-eye view, it was totally dumb in some of the roads I took; I walked in some giant circles, unable to comprehend where a potential side road would land me - nothing fitted together
London's even worse for that because you just spring from the ground. But that's a different story :P
 
@alkasm numpy? you must be kidding. which functions?
 
All of the methods which return arrays?
np.arange(10).reshape(2, 5).sum(axis=1).mean()
@roganjosh i love talking about stuff like this for that reason! it's really cool when you learn a specific pattern and then realize all the usages of that pattern.
 
@alkasm Ok true, but I wouldn't call those manipulations "fluent", and there aren't potential issues with control-flow or invalid operation. Like not the stuff with determinants, inverses, solvers, linalg stuff.
 
Welcome to the discussion we were having.
:)
But also you said "fluent interface/method chaining" and it definitely is method chaining :P
 
@roganjosh The London Underground map distorts adjacency in favour of topology, so makes it impossible to visualize relative position, distance, adjacency and walking times between stations on different lines.
 
11:10 PM
Why aren't they fluent? I don't really have an opinion here, but that was part of the discussion. Is it the fact that it's the same object repeatedly mutated that makes it fluent? I think that seems somewhat of an implementation detail if the intended usage is via method chaining.
 
@alkasm Yeah sure, but only the routines that do simple manipulations... that runs out of steam before we get to higher-order functions. It's not like the whole library is fluent paradigm. (Analogy: pandas stack/unstack/melt/groupby/pivot/anything involving multi-indexing wouldn't be fluent paradigm, I think) What did you think of the Dave Glick blogpost? I thought it was pretty good.
 
I liked it, especially that it called out the "finalization" thing
also "casting operator" gave me a shudder
and tbf in Python I don't really feel like I get a lot out of a "fluent" interface
the most important usage of it AFAIK is the builder pattern which can be extremely nice for languages that don't have the concept of kwargs, also gives a good way to deal with defaults, etc.
 
I've seen at least one python code base where << was overloaded for this purpose...
 
and for something like query languages where the way you express a statement might not be the way you want the statement to be constructed (e.g. the combination sqlalchemy does for you could be viewed as a kind of predicate pushdown)
 
@roganjosh ... which is why I never got to Hyde Park, Kew Gardens etc. Mass-transit maps (London Underground, NYC Subway) that favour topology over adjacency are implicitly bad for tourists and multimodel travellers, and good for commuters.
 
11:20 PM
@AndrasDeak because you know, someone used C++ and actually thought the stream operators were...nice...?
somehow?
 
yes :'|
 
@smci interesting, never thought of the difference in audience.
i admit, I overloaded matmul for something that was indexed by time because I really thought state @ time was too cute to not do
 
you're the problem!
 
Was it a numerical object, or a custom class with no reasonable matmul of its own?
 
11:22 PM
@alkasm Consider how someone actually attempting to construct an itinerary visiting London(/NYC) by bikeshare, boat, Uber, etc.
 
class TimingDiagram:
then it's fine
you didn't "overload matmul", you implemented an @ operator
 
oh, that's fair.
 
calling it __matmul__ was the original design mistake
then again perhaps the same could be said about the << case, but that's just too icky
 
@smci I have been in this situation many times, I've actually cared more as a tourist knowing the # of stops or how many more stops till mine, which these types of maps tend to show really well. since, well google maps exists
@AndrasDeak thats a good point, numpy definitely leaked straight into the stdlib there.
 
@alkasm well it was explicitly made for numpy, but still it should've been called something like __at__
 
11:24 PM
alkasm: My peeve is you can't write matrix exponentiation with M@@3 like you would with a scalar x**3. On this, R is more consistent. And of course, it's deeply unhelpful with matrixes for ^ to refer back to bitwise-xor, not to exponentiation; but we can't break backwards compatibility.
 
@alkasm also adjacency-based maps would often be difficult to impossible to construct and read
@smci I'd sooner want @= :P
 
@smci so in R, 3++5 is 3*5?
 
hehe
 
:P
 
@alkasm Go play with the tetration operator ↑ :P
Hey, there's boundless fun if we allowed Unicode operators...
 
11:27 PM
Is that a subtle "up yours"?
 
@AndrasDeak lol
 
@smci ugh no
 
@AndrasDeak Not at all. Fie upon thee, sir
 
@smci that's how you get swift
 
you can custom operator in swift right?
...
oh nvm thats what i was thinking
 
11:29 PM
operators seem intact though :P
 
@AndrasDeak Didn't know Swift allowed that. Why did the chicken crossproduct the road?
 
to get..to..the..orthogonal side..?
 
00:00 - 20:0020:00 - 00:00

« first day (3750 days earlier)      last day (1188 days later) »