« first day (3895 days earlier)      last day (1047 days later) » 

12:43 AM
How can I translate this: "Cookie:sid=token:${access_token}:${uuid};user=${user_id};version=${version} into the cookies parameter in requests.get()
 
 
5 hours later…
5:35 AM
Hi guys, do any of you know any good python functions to check for the smoothness of a a parabolic curve?
detect*
 
6:01 AM
Hi everyone, for me to apply SVD or PCA is it necessary that my train data be in n * n shape?
 
6:40 AM
Hi everyone, I'm stuck with the problem. Anyone can help me on it.
The tuple at 0 has common elements with 1 and the tuple at 1 has common elements tuple at 3 and hence all these are connected/linked. So the first list in my list of lists should consist of all the linked tuple's indices. The second list is the tuple that is left out. — Deepak L 26 mins ago
1
Q: How to get the index of tuples in a 2D list?

Deepak LI need to get the tuple positions which are linked to each other with at least one element within it. [('1','1','1'), ('X,'1','X'), ('Z,'Z','Z'), ('Y,'Y','X')] Here, in 1st tuple value '1' present in 2nd tuple. And, now in 2nd tuple value 'X' present in last tuple. So, I need to combin...

 
6:54 AM
@nirmalnk Be careful about questions in which the OP misses to make it clear what they are even asking about. This one leaves it open whether they care about fixing the code or finding any solution; there also seems to be some holes in the specification, e.g. what happens when multiple elements are linked at once.
 
7:05 AM
apologies for repeating my question.. which was if there are any specific python functions than can detect if a curve is smooth.. So far I am using the standard deviation of the differences in the curve :
std(abs(x_i+1 - x_i))
if you guys know of any better method, I'm all ears
 
Looks like a solid approach. In the end, you will have to define for yourself what you still consider "good enough", so if your current approach works for you there's no problem sticking with it.
 
sure, I was just hoping if there were a python prebuilt function, that would have been more reliable way of doing it
 
@MisterMiyagi he gave explanation to your question in comments section
 
 
1 hour later…
8:18 AM
cbg
çquestion guys if you are passing a function to another to be called within it and at the same time want to be able to parse arguments for said function, however some points could be 1 or more arguments how would you call said arguments within the parsed function?
how would i call the callback with the variables... trying to make this reusable throughout the code as have to use the same load of waits many times
 
Is there any -- thing in python?
lst=[1,2,3,4,5,6,7]
print(any([i for i in lst if i%7--0]))
I am getting the output "True " after running this
Why is this happening?
 
a--b is a - (-b).
 
@MisterMiyagi Oh , thanks!
 
8:41 AM
@Kwsswart callback(variable)? you can get the args as a dict and then callback(**variable) would also work, or I understood this wrong
 
I guesss could work, but then all the functions sent through to it would have to work from an argument as dictionary no'
 
are you asking should my callback accept parameter as a dict?
 
No essentially if parsing it a dictionary instead of the args directly then wouldn't every function being called within the function (any function set as callback) would need to work from a dictionary instead of args directly?
 
this is what I understood, do ignore if this is not what you asked
def wait_elem(callback=None, variables=None):
    if callback is not None and variables is not None:
        callback(**variables)

callback_1 = lambda x, y:x + y
callback_2 = lambda x, y, z:x * y * z

wait_elem(callback_1, {'x':1, 'y':2})
wait_elem(callback_2, {'x':1, 'y':2, 'z':3})
you can still call callback_1 as callback_1(1, 2) to get 3
 
9:08 AM
will give this a try
@python_user cheers for this mate works well
 
no problem
 
9:53 AM
@Kwsswart Also take a look at functools.partial, which seems quite close to your desired goal.
>>> import functools
>>> x = functools.partial(print, "Hello world!", "I hope you're ready for me :-)", sep=" -- ")
>>> x()
Hello world! -- I hope you're ready for me :-)
>>> x()
Hello world! -- I hope you're ready for me :-)
 
hmmm interesting may work using dpaste.org/JpQK to make those two the same
 
The second one isn't quite what I had in mind. I was proposing that you create the partial before calling wait_elem, and you pass it in as the argument for callback. And you rewrite wait_elem so it doesn't have a variables parameter.
Rule of thumb: there's no point in creating a partial and then calling it on the very next line.
 
10:13 AM
Here is more what I had in mind, plus a bonus version that makes use of argument packing/unpacking.
If you've ever used Tkinter, then the way version A is called should look familiar to you -- that's how button click callbacks, etc, are registered. I don't recall if any popular module uses syntax like version B, but threading comes pretty close -- you can do t = threading.Thread(target=print, args=("Hello", "World!"))
Quite like python_user's proposal, come to think of it, so one quatloo to him
 
10:35 AM
hmmm thanks for that definitely going to take a look into all the options
 
Ah, that's the secret code phrase for "I'll use whichever one works first" -- say no more. [I tap my nose conspiratorially]
 
lol actually no I am wanting to look into the option b to understand it more XD
 
 
1 hour later…
11:44 AM
@Kevin with exchange rate that will get me by one month
 
 
1 hour later…
1:06 PM
Now entering hour 3 of "getting file A to acknowledge the presence of file B in this convoluted project structure"
If you're thinking "well, you could always mess with sys.path or the cwd", think convoluteder. Think networks and sandboxes and venvs
 
1:41 PM
Ok, I did it. Only took me 17 tabs' worth of documentation. Not an exaggeration.
 
1:54 PM
Another one of those "I really want to know why that's so complicated, but I also really don't want to know" scenarios. You seem to have these fairly regularly :P
 
It's my curse
The end result didn't turn out to be too complicated, I just had to solve a 4x-nested XY problem with two possible approaches for each subproblem
I had to discard approaches AAAA, AAAB, AABA, AABB, ABAA, ABAB, ABBA, ABBB, BAAA, BAAB, BABA, BABB, BBAA, BBAB, and BBBA before I found correct approach BBBB
 
On 2nd thought, it's probably better not to post that because it could be misunderstood
 
hehe
 
 
2 hours later…
3:58 PM
Hi guys I need some help. How I can get results in table by some condition. I want to get combination of all names. From my example I have one table with names. But I want to have 27 possible combination. This is code for simple table with names pastebin.com/jeDKSxdq Is there a way if I wrote 1 to get one combination of names in table, when 2 another and so one till 27. Can someone give me some instruction what to do?
 
I don't totally understand the exact goal, but I bet itertools.product would be helpful
 
REST API question, what would be the HTTP status code for if want to add/post a record that is already there in the database?
 
@Pijes Quick prototype:
table = [[ 'alex', 'smith', 'john'], ['sharlote', 'oliver', 'liam'], ['jasper', 'aria', 'luna']]
def get(x):
    x, c = divmod(x, 3)
    b, a = divmod(x, 3)
    return [table[0][a], table[1][b], table[2][c]]

for i in range(27):
    print(get(i))
 
@Kevin Thank you Kevin. I will try that
 
Of course, this only works for tables with a size of exactly 3x3.
 
4:11 PM
@JoeSaad depends how you want the client to react or know about?
 
def get(table, x):
    result = []
    for subseq in table:
        x, i = divmod(x, len(subseq))
        result.append(subseq[i])
    return result

table = [[ 'A', 'B', 'C'], ['D', 'E'], ['F', 'G', 'H', 'I'], ['J']]
total_possibilities = 1
for subseq in table:
    total_possibilities *= len(subseq)

for i in range(total_possibilities):
    print(get(table, i))
This one's more general.
But all of this work is only necessary if you're dead-set on having out-of-order access to arbitrary rows by specifying their index. If you only need to iterate through all products in strict order, then you can replace all this code with for seq in itertools.product(*table): print(seq)
 
Sorry Kevin I didn't explain you what I need. Maybe this can help you. I need only one table in time pastebin.com/WnHBkPcS
 
4:27 PM
Ok, I can see why my suggestion wouldn't be helpful there. I'll write up a new prototype.
 
@Kevin Thank you for helping me
 
Combination problems are fun :-)
 
looks like I missed something interesting
 
Well I haven't written a single line of code that's productive towards the actual goal, so plenty of time to jump in ;-)
 
good to see you fine folks again!
PSA: quantum computing for computer scientists. Interesting talk at Microsoft. I feel ready to try some examples after watching this
 
4:53 PM
@Pijes How about this: pastebin.com/r9Gm0nbZ Not totally confident it's what you're asking for either, since there are 216 results, not 27. Just throwing this out there: if you manually type up exactly the 27 results you expect, I can probably figure out how to generate them.
Or perhaps you could go through my 216 tables and pick out, say, ten of them. And say "tables 23, 42, and 99 aren't valid, for reasons X Y and Z"
 
5:30 PM
@Kevin You are a wizard. Yes I am bad in math. And yes this is what I wanted with some correction. I need only one table at once. You helped me a lot. Thank you again
How to print for example only table 116? Or 89?
 
rearranged_table = nth_product_of_combinations(table, 116), then plug it into tabulate
 
5:46 PM
I do something wrong. I get this print(tabulate(rearranged_table = nth_product_of_combinations(table, 116), headers=["A","B", "C"], showindex=range(1,len(table)+1), tablefmt='grid',))
TypeError: tabulate() got an unexpected keyword argument 'rearranged_table'
 
6:09 PM
@Pijes Ummm then try removing the keyword? print(tabulate(nth_product_of_combinations(table, 116)....)
 
6:20 PM
With that I get this error print(tabulate(nth_product_of_combinations(table, 116),rearranged_table, headers=["A","B", "C"], showindex=range(1,len(table)+1), tablefmt='grid'))
TypeError: tabulate() got multiple values for argument 'headers'
 
Shouldnt you be knowing what all the arguments that tabulate takes and you need? pypi.org/project/tabulate
 
@CoolCloud Kevin never make a mistake. But I make mistakes all the time.
 
I disagree, if I haven't made three mistakes before breakfast, then I'm not trying hard enough
 
@Kevin I speak from my experience with you. You helped me a few times a couple of years ago and you never made a mistake.
print(tabulate(rearranged_table = nth_product_of_combinations(table, 116), headers=["A","B", "C"], showindex=range(1,len(table)+1), tablefmt='grid'))
Did you think like this?
 
6:40 PM
Well, you said earlier that you got a TypeError when you tried that, so I'm guessing that's not the right syntax.
 
@Kevin yes but I wasn't sure if you meant it. I often make mistakes.
I have some kind of autism.
 
I suspect you interpreted my message, "rearranged_table = nth_product_of_combinations(table, 116), then plug it into tabulate", to mean "take the exact code rearranged_table = nth_product_of_combinations(table, 116) and put it inside a tabulate call". But rather, I want you to execute the assignment statement rearranged_table = nth_product_of_combinations(table, 116) on its own line, and then call tabulate on a later line.
 
7:01 PM
@Kevin I can not understand. I'll try tonight to figure out what needs to be done. Thank you again.
 
rearranged_table = nth_product_of_combinations(table, 116)
tabulated_table = tabulate(rearranged_table, ...)
I think that's what Kevin is trying to say
 
But that is what I already suggested and it did not work I guess
 
rearranged_table = nth_product_of_combinations(table, 116)
tabulated_table = tabulate(rearranged_table, headers=["A", "B", "C"], showindex=range(1,len(table)+1), tablefmt='grid')
print(tabulated_table)
Just to make it all explicit.
If that doesn't work, I'm not sure what will...
 
7:21 PM
I'm being a little evasive about what I really meant because I think it would be a fun exercise to come up with a couple plausible interpretations and see which of them fail :-)
 
@MattDMo I do this and I get one table but 216 times
 
Other users are welcome to say "I'm pretty sure he meant X, because I ran it and it produces the expected output", because nobody has to participate in my weird experiments on the educational merits of the socratic method
 
TBH, I have no idea what the code does, I was just trying to interpret the Kevinic method.
 
@MattDMo Sure. I got this result pastebin.com/QdyynvbJ
I need only one
 
Now this is an interesting spin on an old problem -- most help seekers ask "my code does this thing once, but I want it to happen many times", but here we have "my code happens many times, but I only want it to happen once"
Consider: these problems may have related solutions!
 
7:34 PM
hello everyone
 
Welcome
 
i'm working on a python assignment right now. but my problem isn't even python related yet because i struggle grasping the idea. would it be okay to ask for advice which is more computer science related? i guess i have follow up implemntation questions xD
 
I'll allow it
 
hahah thanks :)
so i was asked to come up with a new model of computation. it can be an extension to eg a turing machine, lamda calculus or a string rewriting system. but it can also be entirely new. and i should make a show case in python.

i'm thinking about it since last friday non stop but all my ideas are crap. there is nothing to add to a turing machine that makes it more intressting. and all of my own ideas are basically turing machines or FSM
i had for example the idea to take brainfuck and add a new character to it. would be rather simple to make an execution machine for it in python. but all my additions are redundant. there is no need for a goto command or a while loop.
 
quietly steps out at the mention of lambda calculus
 
7:49 PM
hahah i wish that would be an option xD. i thought about how one could add nonlinearities like ReLu for lambda calculus to make machine learning with it. but apparently that's already possible. you can use any function in lambda calculus.

how does one come up with new models of computation?
 
One operation I'd like to see in more toy languages is call/cc. To badly summarize, it creates a special function object that, when executed with some argument x, goes back in time to the point of its own creation, and replaces itself with the value of x.
Implementing such an operator in a serious language is quite memory intensive, since you basically have to save a complete snapshot of the entire program memory. For C-likes, that could be gigabytes of data. But if you have a wee little assembly emulator with six registers and 2kb of addressable memory... Then suddenly things are more tractable
 
holy shit. that's a genius idea! i guess that's exactly what the prof was looking for. but no way I can implement that in time
how do you came up with that? i have never heard of that concept. no wonder i'm having such a hard time to come up with ideas
 
I read about it on Wikipedia :-)
I think inventing a new model of computing is about as easy as inventing a color nobody has ever seen before. Especially if it has to be more interesting than a Turing machine, because by definition a Turing machine can do every interesting thing that all other Turing-complete systems can do.
Granted it might take a million billion times longer to print the result, compared to a modern zillion transistor cpu. But that's neither here nor there.
 
@Mr.Sh4nnon Please don't use expletives here. You can use "yam" in future as we try to avoid them
 
If the class is being graded on a curve, I have a feeling that most of your classmates will turn in fairly lukewarm ideas that don't revolutionize technology forever. So if you submit something tame like "brainf--k except with a new operator '!' that makes the data pointer jump a number of spaces equal to the byte at the current data pointer", then you can still comfortably score an A- even though you haven't technically made the language objectively more powerful
 
8:06 PM
I think my imagination went overboard... the first thing that came to mind was an N-dimensional version of Langton's Ant. Traditionally, it moves on a 2D grid with 2 colors. Add a 3rd dimension and a 3rd color, and boom, suddenly your ant can not only turn left and right, but also up and down. Add a 4th dimension and a 4th color, and boom, suddenly your head hurts
 
(disclaimer: I have not thought very hard about the "!" operator in terms of difficulty of implementation, or revolutionaryness. Standards of "tame" may vary.)
@Aran-Fey Ooh, N dimensional computing, fun. I've seen 2d languages like befunge, but never 3 or higher
I see that befunge has been generalized into an N-funge family of N-dimensional languages. But I wonder, if NFunge has the monopoly on all of euclidean space, has anyone tried... Noneuclidean languages?
 
@roganjosh sorry about the yam :S
 
No, I do not know what that means and I cannot elaborate further
 
No worries :)
 
@Kevin you are probably completely right. i think most students handed in something completely useless or existing. i guess my expectations to myself are just too high.
i had an idea with brainfuck that you coudl add integers eg before the increment to make multiples of it. ++++ is 4+. but that's just synthactic sugar. no way that would count. i think your idea with the ! is similar. do you think thats "novel" enough?
 
8:13 PM
Gonna write me a language, Mobius, which executes its source code normally, and then again with each line read backwards
And no cheating by putting #)(tixe at the end of your first line
 
i found a presentation of a former student. obviously only good and geniounly interested students put that online: nilsec.github.io/assets/integer_grad.pdf it's way to complicated
what aobut that. instead of ascii a brainfuck that outputs integers. also the commands are no longer <>+- etc but the integers themselves. now a program could execute itself. but i could never explain what monster i just have created^^
 
@Mr.Sh4nnon I agree that 4+ is essentially syntactic sugar. But I believe that "!" could not be replicated just by swapping characters out in your program before you run it. There's a little splash of dynamicness you can't get rid of.
@Mr.Sh4nnon Ooh, executing oneself... More toy languages should implement eval().
 
i just realised i shouldnt write brainyum either.... sorry about that^^
 
True, if you write "brainyum" too much we'll start suspecting you might be a zombie :P
 
hm i starting to like the !-idea. now i just have to find out what the implications are
@Aran-Fey hahah :D
do you know the scene from family guy where peter "speaks" italian?
 
8:20 PM
I usually don't mind people typing out Brainf---'s True Name uncensored, because 99.9% of the time, they're not doing it to be edgy or puerile or whatever. That's just what it's called.
But we may a well try to be PG-13 if it's not an obstacle to clear communication
 
agreed. mentioning brainyum by it's real name once is sufficient for communication
 
I think I've got confused. "so i was asked to come up with a new model of computation." and I got totally sidetracked by the following mention of a Turing Machine, sorry
On a purely CS-side, there wasn't much for me to add. You can come up with a new biologically-inspired heuristic? It's all the rage
Whale Optimisation, Ant Colony Optimisation, Barnacle Mating Optimisation,... pick an animal
 
the prof actually mentioned coming up with new biology inspired models of computation
 
In a good or a bad way? :P
 
i just checked out langtons ant. it's beautiful. i just have no clue how i could show what it can do. no clue how to show if it can create binary patterns, multiply numbers or whatsover. same for the ! brainfuck operator. it's simple, it's neat, i just spend 10 minutes to check how i could eg improve something like creating fibonacchi numbers with it
hahah i guess in a good way? he also teaches neuro stuff. like how edge detection in the brain works. i guess the guy who came up with spiking neural networks would have gotten an A for that :D
 
8:36 PM
For an optimisation approach in that sense, you just need a function to minimise that has plenty of minima
 
how is optimization a model of computation?
okay in the keynote i sent the guy basically had a model of computation using gradient decent. but that's a coincidence, right?
 
In the same way as Newton-Raphson is?
This is where I don't think I know the strictness of the rules
 
how is newton raphson a model of computation?
me neither
 
What is computation to you?
 
we had eg wang tiles. i saw how they can create patterns. but not how you can compare that to a turing machine
 
8:39 PM
 
yeah and the prof writes literally "
What does it mean to compute? People have struggled with this question for a long time, and many models of computation have been invented. These models guide our thinking about what it means to compute" what the yum
 
Hi everyone! I have a little problem with pandas, anyone who can help?
 
maybe :) go for it. i can need the distraction. almost have a nervous breakdown due to lambda calculus
 
@Mr.Sh4nnon Then I think we're just at odds with the definition. This is why I was hesitant to say anything. I'm not sure whether your mental model of the task is too strict or I'm missing some obvious strictness
@isaac.af95 You'd be better just asking, as long as it's in line with our rules
Although not if it's your latest question, because that was an hour ago. We ask you wait 48 hours before posting here
 
@roganjosh i have the strong feeling my mental model is too strict. however, optimisation problems where never even mentioned. i think they are too far off. given from the lectures i think if i can show that my model can eg to a multiplication of two numbers, square a number, print fibonacchi, devide something by three or convert a binary number to a decimal one, its a valid model for him.
 
8:47 PM
@AndrasDeak neat, thanks :) I'll keep some of them in the bag for testing
 
@AndrasDeak uh those are nice
 
 
2 hours later…
10:37 PM
from num2words import num2words works because there's a folder called num2words inside num2words as shown here. Why can't I do from num2words import bin?
 
10:52 PM
Because bin is not a package, because there are no python files inside it
 
Thank you
 

« first day (3895 days earlier)      last day (1047 days later) »