« first day (3281 days earlier)      last day (1671 days later) » 
01:00 - 17:0017:00 - 00:00

1:00 AM
haha, that's funny @AndrasDeak
As long as my vpn works, I can access all I need. It is mostly around some important festivals that the government ramps up TGFW, and it becomes a little bit inconvenient.
 
 
2 hours later…
2:56 AM
0
Q: What to do with all the similar question about hash collisions, Birthday Paradox, "How random is random sampling/RNG?"

smciThe following questions are all essentially about the same underlying concept, albeit in different wordings; we get new variants every month. How to handle them? Re hashing collisions, some questions are simply about calculating/estimating the collision probability; others are about tweaking the...

 
3:11 AM
Is this one Is there a Python equivalent of Perl's x operator? sufficiently distinct?
This one is distinct, it calls for replicating each element N times, rather than replicating the list. replicating elements in list
There was one very almost-impossible-to-find mention of replication in one answer in Hidden features of Python ; deserves to more visible but that question is closed.
And whichever of those you agree to be dupe targets, deserve to be canonicals. Sound good?
 
 
3 hours later…
5:54 AM
Quick question for people who use pre-commit hooks: Is there a standard on how to bind them? I've found a python lib that uses a config and apparently supports a million languages, and just dumping a shell script in the toplevel with instructions in the docu how to properly symlink to it.
 
Hello, there is matrix kinda like this:
[
["ABC", "DEF"],
["ADE", "CBF"]]
Any hint on how I can ensure that any particular letter comes with any other letter exactly once? For example, in this case, B and C come together twice. How can I check whether they do come in machine mode? Only way, I came up with is brute force.
Like collect all the string where a particular letter is, for example for A, collect, "ABC", "ADE", and check the number of occurrences of letters other than A, via Counter. Are there any other efficient methods?
 
6:41 AM
@AjayMishra I think the best thing you can do is iter over it and use a regex to find the specific occurences
 
Yeah. I am doing exactly that, but don't you think that pretty ineffecient?
 
@AjayMishra Hi. It looks like each row of your matrix contains all of the letters in "ABCDEF", partitioned into a pair of strings of length 3. And you want the whole matrix to contain every pair of letters exactly once. Do you just want to test a given matrix? Or are you more interested in generating matrices that fulfill those conditions?
 
I want to test whether a given matrix satisfy the said conditions or not.
 
This is a very fascinating and useful branch of mathematics called Block design. Also see en.wikipedia.org/wiki/Kirkman%27s_schoolgirl_problem
 
melon.
 
6:49 AM
@AjayMishra Ok. I was investigating this stuff 2 years ago, and wrote several programs related to generating such matrices. Some of those programs use semi-brute force techniques, which use fairly efficient ways of testing if the solutions are valid.
I'll post a link to my code shortly. But it has been 2 years since I thought about this stuff, and my memory is a bit fuzzy. ;)
 
I passed the kata by using brute force. I used the following algorithm:1) Collect all blobs where a particle letter occurs 2) append the length of the dict returned by Counter into a list 3) Convert that list into a set, now check the cardinality of the set, if it is greater than 1, return False. (i.e. two players are playing together more than one time)
 
I think using Counter is probably a good idea. You should only need to loop over the collection of blobs once.
The code I wrote is mostly focused on creating decks of cards for a game called "Spot-It" or "Dobble". You might find it helpful, or at least interesting. :) gist.github.com/PM2Ring/c758d5ba782f3e6b5eeddb49432dc71b It's probably not that relevant for the kata you just solved, but it may help you in future.
 
What do you do? It is hard to read 100+ lines code in python for me. Density of thoughts in python is pretty high.
 
My tests generally test the possible solutions row by row, rejecting a matrix as soon as a pair of letters is detected. That's usually faster than scanning over the whole matrix.
 
7:04 AM
Yeah, I see. Your worst time for computation is my usual time for the computation.
 
@AjayMishra Yes, that's a lot of code. I wrote it over the course of a few weeks. Some of it isn't easy to understand. But you should be able to follow most of the smaller programs. One main thing they use is a technique called recursive backtracking. That will be very useful in the coding challenges that you do.
There are lots of articles about Spot-It & Block Design on the net. Some are highly technical, but many are aimed at general readers, eg smithsonianmag.com/science-nature/… Of course, the general ones don't give much details about algorithms. ;)
 
7:26 AM
@Arne I don't use it myself, but multiple people have recommended pre-commit to me already
 
7:48 AM
hey is there a way to open a matplotlib figure in the background?
 
user10984358
hey guys, regarding "call by value vs call by reference" in python, python-course.eu/passing_arguments.php, whatever this link says is credible? I have been seeing various justifications on various websites
 
Looks about right
Coming from C/C++ python only knows call by reference, just that some objs are mutable vs not, so it looks like it has both call by reference and value while it doesn't. Which might confuse ppl because you will still be able to change a nonmutable object inside a function, it just won't be visible on the outside. But the article probably explains it better than my short explanation
 
they're not doing a good job of being explicit about whether they're talking about "the contents of the variable" or "the object referenced by the variable" IMO
 
Sometimes it's hard to tell how good an explanation is if you already know the things. It might make sense if you already know how it works behind the scenes. This is why writing good explanations is so hard, you become blind after a while
 
according to the definition there I would've said python is call-by-value - because if I pass a variable x to a function f, f can't assign a new value to x
 
7:59 AM
depens on what scope you are talking. Inside f can happily assign a value to x
lol, I love how we are just playing out what the article is saying
 
user10984358
that is what puzzles me, you can pretty much assign anything inside a function cant you?
 
user10984358
its going to change scope
 
yes, no
there are mutables and immutables so if you change a passed list, it will be changed outside the f, if you change a string it wont be changed outside
two examples of mutable/immutable
and you need to know what types are what. But you get a feel for it fast
 
user10984358
the point of me asking was not to debate the credibility of the article, I have been preparing for interviews lately so this was a question I was asked in one of my earlier ones
 
@TheNamesAlc the entire vocabulary depends on strongly on what your background is. there isn't much need for lengthy explanations if you know what call-by-value and pointers are
 
8:01 AM
function call semantics don't differ based on the mutability of the arguments, that's bs
python always passes the exact same object to the function, never a copy
 
user10984358
@Aran-Fey this has been my head canon
 
python is call by value, and that value is a pointer to an object
 
user10984358
"python is call by value, and that value is a pointer to an object" I saw this in an SO answer
 
def x(a):
    a = 5

z = 3
x(z)
z
3
b = [4]
def y(a):
    a[0] = 5

y(b)
b
[5]
 
user10984358
 
8:04 AM
lol calling call by value when passing a pointer is stupid
 
@Hakaishin Right, but a = 5 is semantically different from a[0] = 5. The former rebinds the value of the variable a to 5, while the latter mutates the list referenced by a
The result is different because you do 2 different things, not because function call semantics are different with mutable types
 
looks pretty much what I was saying above no? How does your sentence differ from mine? Can you show a practical example?
 
you cannot change an immutable value
 
^
 
user10984358
I believe this example shows how variable assignments work and not the whole value/reference?
 
8:07 AM
might be worth reading if you are familiar with C langs: stackoverflow.com/questions/13530998/…
 
> if you change a string it wont be changed outside
^ you can't change a string
 
change = rebind
it's just sematics no?
 
no
if you rebind a mutable object, that won't be visible outside either
 
> if you change a passed list, it will be changed outside the f
^ and that "change" means "mutate" rather than "rebind"?
 
but = does not rebind a list it mutates? So = does rebind sometimes and mutate other times?
 
8:08 AM
x = ... rebinds. x[0] = ... mutates
 
a = b always rebinds, no matter the type of a or b
Python has four different types of target, though
a, a.b, a[b] and a[b:c]
 
are 3 and 4 really different?
 
grammatically, yes
 
They both go into __setitem__, so I'd consider them the same tbh
 
but I see what you mean now. This makes more sense
 
8:10 AM
num_angels = sum(angel for angel on pinhead)
 
@Aran-Fey there were the good old days of __getsclice__.
alas, [] is one of these things that are fundamentally broken once you work with it properly.
 
those days are over :P
 
@MisterMiyagi example?
 
it is not a proper function call, even though it mimics it and there is no reason not to. Contrast a[b,] versus a(b,) and a(foo=b) versus a[foo=b].
that brings a whole range of headaches, for example signatures are difficult to describe with a type system; creating a fast __getitem__ with something like Cython is basically impossible.
various proposals to change this have failed hard: python.org/dev/peps/pep-0472
 
8:25 AM
To me, asking if Python is "really" call by reference or call by value isn't productive. It's trying to force Python's data model into terminology that's appropriate to the C family of languages, but Python doesn't work like that. Sure, CPython is implemented in C, but that's not really relevant.
 
Why should slicing be similar to a function call?
that's hardly its intended purpose
 
Sure, understanding how C works van be helpful in understanding what's going on under the hood. But it can also be misleading. Try to embrace Python's datamodel on its own terms. Forget about variables and pointers, and think in terms of names & objects.
 
@Aran-Fey because it effectively is one. there isn't a reason for it to be different other than historical reasons.
having things be different just because is a huge headache for composibility.
 
while we're at things being different just because
why can I do
a
array([[1570696058,          2],
       [1570696058,          4]])
a[:, 0] = a[:, 0]*3
 
@PM2Ring I find it a valid question from people that really are familiar with C langs. Many people asking aren't, though...
 
8:29 AM
but not
a[:, 0] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(a[:, 0]))
I guess somebody implement * for numpy arrays, but how do I transform a whole column in numpy?
 
time.locatime has no idea what an array is. same as str.join has no idea what a Process is.
 
good point
 
@MisterMiyagi Agreed. I was writing C for a couple of decades before I started on Python. And I was writing IBM 360 assembler 5 years before I even heard of C. So I know (or at least knew) a fair bit about low level stuff. ;)
It's like the old joke. One Irish man asks another: "Are you a Catholic or a Protestant?" The 2nd guy replies: "Actually, I'm an atheist." The 1st guy says: "Yeah, but are you a Catholic atheist, or a Protestant atheist?"
 
8:54 AM
man pandas dataframes are so much handier than numpy arrays
 
@MisterMiyagi the python package?
 
>>> s = super(bool, True)
>>> inspect.isroutine(s)
True
?????????
 
9:11 AM
'super' object is not callable
???????????
 
@MisterMiyagi thanks
 
Need some help with a CNN LSTM model
 
Where do you guys but stuff that you want to be global in your whole application, like datetime formats?
display_date_format = "%d.%m.%Y"
date_format = "%d.%m.%Y"
datetime_format = "%Y.%m.%d %H:%M:%S"
Do you put it in a global file, which gets included everywhere or what's the best way to handle this?
put*
 
Depends on the scale of the project, for me. If it's a small-scale script, I put that kind of stuff in a config.py. But if I want to write proper code, I write a UserInterface class and make those constants attributes of that class
 
(assuming those formats are for formatting dates, not parsing dates)
 
that's it for now; and don't believe the -1 score on the questions
 
I see, sounds like a good idea, they are both. Right now just global vars, but yeah having userinterface class sounds better
 
9:42 AM
@AndrasDeak I decided to be a nice guy & hammer it with a question I answered. Hopefully he'll learn something & not just feed his cargo cult addiction.
 
meh
guess I can delvote now
 
Feel free.
 
as a teacher I'd hate to point a student as lazy as that to an actual answer
 
That is a great answer of yours there @PM2Ring
 
I did feel ambivalent, especially after my comments on this MSE post about copy-cat coders: meta.stackexchange.com/q/334811/334566 But I am rather proud of that answer. And maybe, just maybe, some of the info in my answer and the rest of that page will rub off.
 
9:49 AM
@PM2Ring can you link it here? I am curious now and the question got deleted =D
 
@ReblochonMasque Thanks! :) Someone suggested that I should create some graphs to illustrate the times better, but I haven't gotten around to it...
 
The answer would indeed gain from graphs; however, it would already help a lot if you would emphasize your recommendation. Maybe using some bold formatting?
This would be a lot less work than graphs, and quite good too!
 
bold is distracting
 
@ReblochonMasque Maybe, but I'd prefer people to actually study the algorithms to see how they work, and to run the tests themselves and make their own decisions.
 
just read that page of text, it isn't that much
 
9:57 AM
In other news, I have the top answer on a HNQ Astronomy question about global warming (or lack thereof) on Mars. astronomy.stackexchange.com/q/33628/16685 :) I'm not fishing for votes, it'll probably hit repcap anyway.
Astronomy is a Beta site, so many privileges kick in at lower rep levels. I just hit 2k a few days ago, and I can now delvote, which is rather nice, although I haven't exercised that right yet.
 
Does somebody know why matplotlib uses their own datetype object, instead of datetime objects?
 
10:26 AM
Nov 15 '16 at 13:51, by Antti Haapala
Python datetime is the worst datetime module I've ever used, and I've used quite a many
 
It just feels like it's all a giant mess...
 
Also see chat.stackoverflow.com/… I don't exactly agree with Antti, but I do admit that datetime has problems. A few things have improved, but it's still unpleasant and confusing.
At least the documentation is a little easier to search these days. It used to be broken up into a bunch of separate pages. But it still has lots of potential for confusion.
Measuring time is one of the oldest parts of science. You'd think we'd be able to get it right by now. Partly the problem is we have legacy issues that literally go back thousands of years to the ancient Babylonians.
 
talk about technical debt
 
LOL
 
It's really hard to make changes to time systems. You can't exactly turn it off & turn it back on again. :) A while ago I read about the technical & political issues connected with UTC. Seriously, it's amazing that nobody turned up to one of the numerous conferences and meetings with automatic weapons. ;)
Sep 15 '18 at 19:25, by PM 2Ring
Cabbage @AnttiHaapala If you think datetime is a mess, you ain't seen nuthin'. Take a look at the insane history of UTC, summarised by astronomer Steve Allen of the Lick Observatory. Be warned, even the summary is rather large... http://www.ucolick.org/~sla/leapsecs/timescales.html He briefly discusses some of the key issues here http://www.ucolick.org/~sla/leapsecs/
 
 
2 hours later…
12:17 PM
20tabs later and a few hours and I have solved my datetime mess. Man this is so unnecessary complicated. We need a dictator who forbits all computersystems to have any other datatype than 1, idc which one and the format is UTC. 1 global time
 
UTC is 1 global time :P
it's more than global, because it's universal
 
general question on preference: if you have a function that takes a variadic number of tasks, do you prefer it to always return a tuple even if just one task was given? or something like itemgetter that only provides a tuple for multiple tasks?
 
the first intergalactic war will be fought either over UTC or Miss Universe contests
@MisterMiyagi very much the former
 
I was afraid of the answer being "yes" :P
 
I like my functions to consistently return the same type
 
12:19 PM
@Hakaishin Einstein probably objects
 
Failing that, the same type or None
 
Though I guess it could also depend on the semantics. I don't mind that pyplot.subplots returns either an axes or an array of axes objects in its second returned element.
but I (and probably others) usually use the single-output version, so it would be a drag to have to unpack that all the time
(technically the function always returns a 2-tuple but I don't think this makes a difference)
 
@AndrasDeak that's what I'm wondering. Is "you have to unpack" tricky to teach/use?
 
Hey, I have a question about django urls, if you can get all URL parameters within the request.GET dictionary, why would you need to use regex to specify the parameters in urls.py? Like if I have a url: something/values?param1=1&param2=2, I can access param1 and param2 from request.GET. So what's the benefit of declaring regex in urls.py such as 'values/{regex for parameters}'?
 
@MisterMiyagi no, just possibly a nuisance
it's a trade-off between practicality and purity I guess
you could even have a kwarg like return_scalar=False with which you can opt-in to type inconsistent output
 
12:25 PM
Half serious suggestion: frobnicate_tasks takes a list of tasks and returns a list of... Promises?, and frobnicate_task takes one task and returns one Promise.
Everybody's happy, except you, who has to write two functions
 
at that point, I don't mind writing another function ^^
but long-term exposure to typing is beginning to show side-effects :/
 
the go-to cure for exposure to harmful environments is to remove yourself from it :P
 
This is assuming that there's a good reason to write frobnicate_tasks instead of just forcing your users to do promises = [frobnicate_task(t) for t in tasks]. Perhaps you can frobnicate tasks faster if you do them in batches, since there's less setup/teardown. I don't know, I'm not the frobnicate expert.
 
since the tasks are eventlooped when frobnicated, doing separate frobnication seems impractical
 
Justification established
 
12:29 PM
Is 1 == 1.0 guaranteed to always be true?
 
nice
 
as long as it's really 1.0
 
>>> 1 == 1.00000000000000009
True
 
>>> (0.1 * 3) / 3 * 10 == 1
False
 
12:32 PM
I guess 1 will always be read to 1.0 by the configparser
 
Hard mode: find documentation that guarantees that 1 = 1.0
 
haha
 
@Kevin it's mentioned on the dict documentation
 
well it works on my system and so chat said so, good enough for me :P
 
That's a funny place to specify the interaction of int and float objects
> Numeric types used for keys obey the normal rules for numeric comparison: if two numbers compare equal (such as 1 and 1.0) then they can be used interchangeably to index the same dictionary entry.
 
12:34 PM
Thanks kevin your comment motivated me to do it right
 
In KPython, 1 and 1.0 is the only int&float pair you can use == on. all others evaluate to False, because nobody told me I couldn't do that.
Clearly 2 != 2.0, there's a difference of ".0", that's like two thirds of the literal
 
How would documentation for this look like? "Int and float objects compare equal if they are equal."?
 
There probably is documentation for that, but it's in the C spec or the IEEE double spec
 
@Kevin interestingly, I didn't find anything about it in the numerical section
 
>>> x = 489124829192421849284281482492849821982198429812
... x == float(x)
False
guess it can get complicated to formulate it exactly
 
12:37 PM
"Hashing of numeric types" vaguely implies it
and based on coercion rules, I would have expected int(sys.float_info.max) + 1 == sys.float_info.max + 1 to be True
floats are weird :/
 
> The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects do not need to have the same type.
 
"When a finite value of real floating type is converted to an integer type other than _Bool ,the fractional part is discarded" -- from open-std.org/Jtc1/sc22/wg14/www/docs/n1124.pdf, page 43. So that's one piece of the puzzle -- we know that int(2.0) can't decide to return 3
Or, hmm, do we need the other way around -- that float(2) can't return 3.14159
 
That counts given that 1 and 1.0 have the same value
 
But what is a "value"
It's not "whatever data is held by the object not counting the header" because 1 and 1.0 definitely have different contents in that respect
 
10€? 20$?
 
12:46 PM
They represent the same quantity
 
Yes, but how does the computer know that?
 
someone told it
 
cbg
time to dive back into tkinter today....we'll see how this goes
 
totally partially unrelated side-note, the code for integer division is FRIGGING SCARY
 
The docs go on to day that: "default behavior for equality comparison (== and !=) is based on the identity of the objects" which, I find confusing
 
12:50 PM
@Dodge types without explicitly defined __eq__ do id(self) == id(other)
 
I suspect that the only built-in type that actually uses that default behavior is object
 
ahh, int has its own "explicitly defined" behavior
 
@Kevin range was identity compared for a while
 
Wacky
"When a value of integer type is converted to a real floating type, if the value beingconverted can be represented exactly in the new type, it is unchanged." -- same document, next bullet point. So anywhere that 2 gets coerced to a float, it becomes 2.0 guaranteed.
Now to find the specification for cross-type equality checks
"if the corresponding real type of either operand [of an operator that expects 'usual arithmetic' operands] is float, the other operand is converted, without change of type domain, to a type whose corresponding real type is float" -- page 44. "If both of the operands [of ==] have arithmetic type, the usual arithmetic conversions are performed." page 86
So in C, 2 == 2.0 is guaranteed to be equivalent to 2.0 == 2.0. Whether this expression has a well-defined result, I'm not sure yet
How presumptuous of the specification to assume that the reader knows what "equals" means
 
1:05 PM
in C, that should be bit equality for numeric types
wait a second, that does not work for floats...
 
Anyone here have experience with Pytorch?
 
Ah, so it's defined on a per-type basis... "The relational and equality operators [for float] provide IEC 60559 comparisons." - page 445
<sigh> hand me the IEC 65059 binder please
It's paywalled. Anybody got $455? I need to know whether (2.0 == 2.0) is True
Oops, that's 65059, not 60559
iso.org/standard/57469.html is only $178, that's much better
 
@Kevin time to open a kickstarter campaign, I guess
 
@MisterMiyagi I suppose there are some cases where you can't just do a bit comparison, for example -0.0 vs 0.0, or NaN vs itself. But for "ordinary" numbers, isn't a bit comparison OK?
 
but you don't know if bit comparison is okay unless you check for the unordinary cases
but otherwise bit comparison should be fine, yes
-but
 
1:22 PM
Props to floating point processors for implementing all this with just logical gates
 
>>> nan.hex()
'nan'
not what I expected
 
The secret hexadecimal digit, "n"
Equivalent to the decimal number "threeve"
 
1:40 PM
While I wait for my gofundme campaign to build momentum, I think I'll go back to solving geometry problems that were already figured out three hundred years ago
 
^^^ sopython is still doing fairly well :)
quite surprised by the percentage of "organic search" traffic though...
 
That "page value" column is awfully judgy. It's got sentimental value, and it's unlimited
 
love the page value column :D
 
It doesn't take into account the JavaScript bitcoin miners that I inject into every page, either
 
1:46 PM
Hey I wonder if my program design is bad. It generally goes like this:
import stuff


def usefull(bla):
    do_foo()


def do_foo():
    print("hi")


class SuperClass(object):
    def does_stuff(self):
        print("Awesome")


class Coordinator(object):
    run = False


def wow(coordinator):
    superclass = SuperClass()
    superclass.does_stuff()
    if something_happens():
        coordinator.run = False


def main():
    usefull(4)
    do_foo()
    coordinator = Coordinator()
    while coordinator.run:
        wow(coordinator)
    print("program finished")
some free floating methods, 1-2classes which I use in those methods, a main with a while loop or some threads that do things untill some condition happens and they should stop
Now I wonder if this is bad because I have lots of free floating functions and not too many classes. Is there a drawback with this kind of structure?
 
I think it's fine to have functions hanging around.
I'm not convinced of the value of the Coordinator class, since you can accomplish basically the same thing by doing return something_happens() inside wow, and while True: if wow(): break inside main
 
In this simple example yes, but in a more complex case I think it makes sense to have such a coordinator
 
There are justifiable situations, sure. I'd be inclined to first try an approach that doesn't use mutable state, and if that turns out to be hard or awkward, then go with something more like what you've got.
 
1:57 PM
Oh cmon, don't go in that direction SO pls
 
I'm a little wary of defining Coordinator.run as a class-level attribute, and then using coordinator.run as an instance-level attribute later on. I'd probably do self.run = False inside an __init__ instead. But I'm prepared to be convinced that it's fine the way it is and my way is pointlessly verbose
 
works fine for me dunno...
def seek_next_line(f):
    for c in iter(lambda: f.read(1),'\n'):
        pass
 
I don't think there's a situation where the mixed-level attribute approach would lead to unexpected behavior -- I just find it muddled on a conceptual level
 
this one is a gem, need to remember that
meh less code
 
@Hakaishin bit too obscure
 
2:00 PM
class Coordinator:
    run = True
@AndrasDeak I guess that's true
 
I have to write a program such that seven(times(five()) would return 35. I've been checking the internet from last few hours, learn that this is business of higher-order functions and functional programming, I checked higher-order functions in 8 or 9 sites(first two pages of search results). In those sites, they basically told me that functions can be treated as argument, and given the need of doing so ~ Abstraction makes work easy and then show me some code, and then introduce some
functions like map, filter, reduce. but even then I have no idea, how to do that. Any suggestions or references to read about them? It seems this is a higher-higher-order functions business.
General goal: operand1(operator(operand2())) should return the desired result.
 
I'm thinking something like
import operator

def make_numbery_function(num):
    def numbery_func(*args):
        if not args:
            return num
        if len(args) != 1:
            raise ValueError("Expected exactly one argument")
        operator, right_side_number = args[0]
        return operator(num, right_side_number)
    return numbery_func

def make_operator_function(operator):
    def operator_func(num):
        return (operator, num)
    return operator_func

seven = make_numbery_function(7)
five = make_numbery_function(5)
 
isn't that just an exercise in writing awful code?
 
Those are my favorite exercises :>
 
@Aran-Fey Functional programming is not awful.
 
2:09 PM
that doesn't look very functional to me (in more than one sense)
 
Functional programming isn't awful, but you can employ functional programming to write awful code. Same as any other paradigm.
 
@Aran-Fey ha, was about to comment
 
@Aran-Fey I used 8+ functions to add two numbers, of course it's functional ;-)
 
@Kevin I asked about the sources, can you recall them?
 
The problem description sounds a little bit like church encoding, except a church-encoded addition would look more like result = plus(seven)(five)
 
2:14 PM
Kevin: guy here used to nest pre-op ifdefs....I about yelled.
 
@Kevin I can do that via lambda stuffs.
 
@AjayMishra Hmm, not much I can recommend, other than the official documentation for reduce and filter and map. The closure techniques I employed in my example code, I mostly figured out from experimentation
 
I'm re-reading the definition of "functional programming" for probably the dozenth time in my life and I still don't get it
 
Oh, I thought I am dumb. ;)
 
Important components of functional programming: no mutable state, lots of functions
 
2:17 PM
so it has no features, just restrictions?
 
For bonus points, never re-bind a name to a new value
 
insert obligatory xkcd
 
@Aran-Fey Kind of, yeah. I'd say its selling point is that you can more easily deduce/verify/prove things about the behavior of the program.
 
that's true I guess
 
@Kevin Were you too "shocked" when you learned about this for the first time, assuming you have followed the imperative programming paradigm and OOPS before learning this.
 
2:21 PM
I think I understood the appeal of the paradigm, since a lot of mathematics is also functional
When a proof says that a = [1,1,2,3,5,8,13...], you can be confident that the third value of a won't suddenly become 23 later on
 
mathematics tends to assign the same name to a whole bunch of different values though >_>
 
At the same time, I decided that functional programming isn't a one-size-fits-all paradigm. You probably wouldn't use it for very stateful projects, for example CRUD apps or video games
 
Also websites
 
OOP wants to be the paradigm that eats all other paradigms, but functional programming knows its niche
 
So like most of cs :D
I don't have to prove that 99.9% of customer will see this random span at pixel height 15. It's good enough if it works most of the times reasonably well, functional just isn't worth the hassle for many things. Whereas for physics simulation and engineering solutions it might be usefull
I heard(I think on the website of a functional language) that it was used successfully to plan some process related to a oil platform
 
2:32 PM
If the website considered such a feat noteworthy, that may imply that stateful simulations are very hard to implement functionally, and the oil platform is a triumph of ingenuity and hard work
"Look, we did this, and it only took 10,000 man hours and five PhDs"
 
lol^^
 
Kevin, the control flow of your code seems pretty alien.
 
I suppose. A function that defines and returns a function isn't something you see every day.
 
@AjayMishra There's nothing wrong with that exercise, in principle. It's just that it doesn't fit well with the way we normally do things in Python. To really get into the spirit of that exercise, you could alter Kevin's code so you could call make_numbery_function('seven', 7) and it would automatically add a function named seven to the globals() dict. But we normally yell at people who do stuff like that. ;)
@Kevin Well, you do. But we mostly restrict that to @decorators.
 
Counting decorators, I probably see it every 1.5 days
 
2:49 PM
Any idea why results is empty?
conn, cursor = get_db_conn(global_log, database_password, "localhost")
        insert_message(global_log, conn, cursor, speed, distance, version, device_id)
        time.sleep(3)
        get_data = "SELECT velocity, distance, version, device_id FROM incoming WHERE device_id = 42"
        results = cursor.execute(get_data)
        print(results)
when I run the query get_data I get the 4 entries in the db
but somehow running this in python gives me None as results, not sure why
The weird thing is insert_message prints success, so the db connection is successfully established, also I see the test entries entered into the db, but I can't get them. Thus the sleep but to no avail
 
@Hakaishin did you commit the transaction at all?
 
Yes
I mean using pycharm db window I see the entries in the db
also when using this query alone I get the results back
 
Google tells me that cursor.execute returns None on a successful query, and you can find the results using "fetch*"
 
aaaah, thanks. My b, haven't used it in a while
 
YMMV for anything other than psycopg that also has a cursor class. I assume it's pretty common, since I see it all over the place.
 
2:53 PM
ahh yes... that should be cursor.execute(get_data)... you can then either use .fetch() or .fetchall() or iterate over cursor
 
nono this was it
yeah I use it all over the code, has just been a few weeks and I forgot^^
So easy unittests written, hard ones defered time for the weekend :D
 def test_refine(self):
        # TODO
        self.assertTrue(True)

    def test_match(self):
        # TODO
        self.assertTrue(True)
 
cursor.execute is very high up on the list of "SO questions that don't show their import statements", right below anything that uses "df"
 
damn it's thursday, cries :P
^^
have a nice evening ladies and lads
 
3:15 PM
in boto3, when sending a message to a queue via sqs, you can specify message attributes. so i can say something like Timestamp: "DataType": "Number", "StrinvValue": "abcd"
the problem is that i can say "abcd" for the DataType of Number
is that something that eventually gets error-checked in any way, or is "DataType" just a tag amazon uses for the sake of... i dunno, arbitrary record keeping?
 
Is there a term for this property? "If f(f(a,b),c) == d, then there is some value x such that f(a,x) == d"
All associative operators have this property, but I don't think the function has to be associative to have it
Subtraction isn't associative, but it has this property: if (a-b)-c == d, then a-x == d when x == b+c
 
it's funny. it's like all of the amazon tutorials specifically avoid using "Number" as a ValueType
so i can't see if they do anything different than "Stringvalue"
 
@AmagicalFishy docs.aws.amazon.com/AWSSimpleQueueService/latest/… says "if the type is Number, Amazon SQS validates numerical values", so I guess some validation occurs at some point
 
yeah, i just read that. i'm trying some stuff out using moto (mock amazon stuff) and nothing's happening
so i guess moto doesn't replicate that validation
 
3:32 PM
Maybe that sentence means "Amazon's implementation of SQS validates values, and any implementation of SQS that you write should do the same". In other words, it's your job to validate it
Confidence value: the same as an achaeologist trying to reverse-engineer a long dead language using the text inscribed on half of a broken urn
"SQS must have been... Some kind of religious ritual"
 
3:48 PM
The local deity "Amazon" often rejected offerings that were not prepared in the correct way
 
4:20 PM
8
Q: Official FAQ on gender pronouns and Code of Conduct changes

Cesar MWe expect today’s Code of Conduct changes to generate a lot of questions. We’ve tried to anticipate some of the most common questions people may have here, and we’ll be adding to this list as more questions come up. Q: What are personal pronouns, and why are they relevant to the Code of Conduct?...

 
That's about what I expected based on the speculation that's been floating around
90% of it prescribes that I do what I have already been doing, and the other 10% is subjective enough to be unenforcable
 
Pretty much. This writing has been on the wall for a while. It's going to lead to some weird discussions, none of which will involve me.
 
4:36 PM
that's stupid
 
01:00 - 17:0017:00 - 00:00

« first day (3281 days earlier)      last day (1671 days later) »