« first day (3409 days earlier)      last day (1764 days later) » 

00:17
@Dodge - you inspired me
00:37
@PaulMcG Need that on a card in the supermarket. Probably the most romantic poem I've ever read ;) I notice you did not improperly use the equality operator to compare something to True as I did earlier.
AMC
AMC
I'm back
I've made the mistake of reading popular answers again: stackoverflow.com/a/12330535/11301900
Highlights: The second snippet of code, temp = [line[:-1] for line in file], risks chopping off a non-newline character from the list line of the file.
The solution? Easy:
with open(the_file, 'r+') as f:
    f.seek(-1, 2)  # go at the end of the file
    if f.read(1) != '\n':
        # add missing newline if not already present
        f.write('\n')
        f.flush()
        f.seek(0)
    lines = [line[:-1] for line in f]
Praise the lord, we finally get to the sensible solution: [line.rstrip('\n') for line in file]
Which is immediately followed up by [line[:-(line[-1] == '\n') or len(line)+1] for line in file]
 
3 hours later…
03:36
If anyone can help
I'd greatly appreciate it
 
4 hours later…
07:38
@Paul I love that verse from the bible
user10984358
already found one, but that one's not too bad good either (:
user10984358
08:51
Post it here, let me earn from the process of elimination :/
result = [x * y for x, y in zip(list1 + [1] * (len(list2) - len(list1)), list2 + [1] * (len(list1) - len(list2)))]
^ that's the one I went with
cbg guys o/
@Aran-Fey is that element-wise multiplication with padding?
09:18
Please help someone, I am about to go crazy ... All I want is to squash HEAD into origin/master
I have had no luck with "git rebase -i origin/master"
and then "pick" origin/master commit
doing "git rebase -i HEAD~2" and squashing the HEAD commit doesn't work either.
"doesn't work"?
I am saving my machine learning model using these codes.
filename = 'finalized_model.sav'
pickle.dump(model, open(filename, 'wb'))
But I am getting this error.
TypeError: can't pickle _thread.RLock objects
Can anyone help me to get rid of this error ?
09:34
What happens instead @SebastianNielsen
Literally nothing
take a look
(you can pause the gif if it goes too fast)
Try git fetch first
It looks like you don't have many commits locally to rebase onto origin
You only have one
My goal is to rewrite the content of one specific old commit: the commit at which the origin/master tag is placed at.
You need to change your branch too
The change is very minor:

- s"{val ${vals(0).x} = ${unparse(exp)}}"
+ s"{val ${vals(0).x} = ${unparse(vals(0).exp)}; ${unparse(exp)}}"
How exactly Samuel?
09:41
IF you want to rewrite a commit that you've already pushed
git checkout origin/master
git reset --soft
and re-commit
and force push
you kind of want to rebase 1b00fco onto 8f530f6
and then rebase origin/master
Oh god, now it looks like this
https://gyazo.com/ee9c31e7437bc30bf88d4854a45be223
I just checkout origin/master, altered the single line, and pushed to origin
You kind of have a branch off to the side
Yeah, that got there because I commited while being checkout out at origin/master
which wasn't the latest commit
I did just jump back and change the origin/master commit (this is how it looked before: gyazo.com/94b8293e66e3e4c3ac46159220f6f6db)
10:02
Ah well, I am just gonna resort to go cry in the corner hoping it magically fixes itself.
 
1 hour later…
11:16
I can try fix it for you if you do remote desktop
 
1 hour later…
12:28
@MisterMiyagi I came to the same conclusion, so yeah, it probably is
12:52
frankly, I have no idea how to write that any more readable ^^
Today i saw a very strange thing how can a person with only 3 medal is having more than 500 points and the irony is he never answered correctly and reached only 5 people😂
max_len = max(len(list1), len(list2))
padded_list1 = list1 + [1] * (max_len - len(list1))
padded_list2 = list2 + [1] * (max_len - len(list2))
result = [x * y for x, y in zip(padded_list1, padded_list2)]
like ^ that
zip_longest...
I know, but I can't make a point about readability by saying "you can replace this bad code with this function from the stdlib"
huh, just realised that [1] * -1 is actually a thing. TIL
13:04
hey guys
I've just learned about Golang , I'm new to python and i love it but too many articles have started dropping spots on golang and they say its WAY FASTER because it has Cucurrency feature unlike python , is that true ?
they say its better when it comes to webapp or operating system .
i mustly use python for web apps.
Every non-niche language is faster than Python, safe perhaps Ruby
then why everyone prefers to use python than any of them?
My experiences with Golang weren't pretty, though. If you want to write repetitive code for boring tasks, it's perfect though.
facebook , google , nasa .... etc
because often, speed doesn't matter.
if it does, many big shops use C++
13:07
but based on examples
python toke 280 secs in doing the same task as golang where golang took 20 seconds
ah, benchmarking games
that dropped my jar
yea maybe.
the reason is often in Python you don't have to do the same task as in Golang
what do u mean by that ?
Basically python is a hammer and Go is a screwdriver
13:10
Due to lack of Generics/Templates/Higher-Order-Types, Golang lacks a lot of abstractions. What you have to do manually in Golang, Python ships with fast, builtin blocks for important tasks.
oh that is the thing
Python is a toolbox, Golang is a Powerdrill with a size 10 bit welded in.
glang got a couple of few new libraries that coves it
that is why its standing out now to python
since 1 month ago i think
and almost everyone expects it to have more libraries since its google's
We're not responsible for people's expectations
well i can share couple of useful links but its not hard to find it

i'm just wondering if there is a way to make Python supports concurrency because that is the biggiest drop in python
like 280 seconds for a task that takes 20 seconds is crazy
13:17
280 seconds for a tasks that takes 20 seconds isn't concurrency
It's compilation, and there are much better contenders for that goal than Golang.
Anyways, Python ships with I/O focused threading, CPU focused multprocessing, and concurrency focused asyncio out of the box.
https://www.youtube.com/watch?v=I6f0g0xfuF8
just watch from 2:48
If you need plain speed, there are Cython, mypyc, numba, ...
oh cool that is what i wanted to hear
@diamond none of these tasks are concurrency focused.
then why its so much faster ?
13:21
because it's compiled
@MisterMiyagi Or write it in C, Rust, etc. and use an FFI
oh !
@Peilonrayz I'm still looking for an excuse to do Rust at work. :/
very nice language
ok i see now , and i was wrong its 280 sec its much worth :D
882 seconds ( python) ... 21 seconds ( golang)
so 1h with golang is like 42 in python :D
@MisterMiyagi I find it incredibly vexing to write, cause I normally write like 100 LOC then compile... I only have myself to blame. But I write something that actually works, it's rather nice
13:25
I found the tooling extremely good, it's probably the first compiler that I like shouting at me.
Then again, long-term exposure to C++ kinda made me biased...
@diamond How often do you have to solve an n-body problem?
I wouldn't say it's shouting, it's more like. "You dropped this, did you mean to drop it? Here's how to pick it up." Oh thanks Rust, I'll go fix that 😂
@MisterMiyagi have no idea what are they, i'm working on my second project in python. most of what i worked with was simple webapps
but i dont wanna be missing out a great tool
@diamond Then why do you care about the speed of n-body?
i dont know what is it
am i using it ?.
@Peilonrayz See? Can't even think about compilers without a lingering fear of gcc...
@diamond no.
13:29
then awesome i love python :D
but what are those functions for , games ?
like windows games and stuff ?
wow
dam
so all autocad , vray and any 3d game developers should look into it
because we often have problems with rendering process
thanks for the heads up
no. For these tasks, one uses a proper fast language such as C++, Java, Rust, Julia, ...
Use Golang if you want simple, concrete, high-concurrency messaging services.
the problem is autodesk , vray and 3d games are often use python
For configuration and orchestration. The number crunching are compiled libraries, usually written in C++.
13:34
all architecture programs,3d animations and 3d modeling uses it .
Python has lots of compiled libraries available, and it's relatively easy to write custom ones.
Python is very good if most of your computation is in a small portion of your code. In this case, implement that in a really fast, compiled language and wrap it as a Python library.
ok so if i have a python website would it be prefered to build the chatting system in golang instead ?
@diamond No
13:38
Is there anyway to master RegEx in python in one or two hour?
cool thanks alot @MisterMiyagi @Peilonrayz
I still remember the moment Golang died for me. I used defer to safely close a resource and my IDE immediately screamed at me that this is not safe. If a language's inbuilt means for safe cleanup doesn't provide safe cleanup, that's scary.
loool
i dont know much but based on what i'm hearing , companies have started using it again
last year it was 1% this year 7%
@AjayMishra bookmark regex101
i guess i'll keep my eyes on it
13:45
@diamond It's not "again", it's basically still in its initial hype phase. For most people, they use it because Google uses it.
yeah, i can see that , but they claimed that there'll be too many libraries for it this year which will make it strong aganist python in web dev, i'll just keep my eyes on it
its very easy ( not as readable as python ) but I don't wanna be late so i'll keep my eyes on it.
14:46
cbg
does anyone know the query execution sequence for postgres SQL
I took a look at this, but I wanted in-depth answer
15:23
What's a more in-depth answer to "what is the query execution sequence" than "this is the query execution sequence"?
 
2 hours later…
17:41
and I'm not sure where I have the issue
but let me explain
I'm trying to serialize the data
as you can see on line 21, the data are retrieved correctly
I've done a test with the data, un-serialized
and they are retrieved from the db. So far so good.
However, it is the model part that is giving me some headache (l1 to 5). As you can see, the model is here but as it is not a table per se (at least from my understanding of flask), it is not build
so it is code that is interpreted
How do I know that there is no table built for that model?
The error I'm having is the following AttributeError: 'list' object has no attribute 'data'
lemme know if I should raise a question on SO
@AndyK I'm assuming many=True means it take and returns a list, not the object you're expecting.
@Peilonrayz I'm not sure it is a returning a list actually
it it returning all the rows of the table
I don't see a list
"AttributeError: 'list'" makes me really doubt that
when I'm using an alternative method to show the results
@Peilonrayz so you think I should put the results into a list...?
or ...?
@AndyK No, I never said what you should do
17:53
Hello, so I have a question regarding matplotlib installed in windows 10 using pip command given on website. After I installed it on windows, it worked fine, and then i used IDLE to run a few lines. Then, plt.show() works one time, but second time it doesnt work
I used import matplotlib.pyplot as plt
@Peilonrayz oh ... you mean it is returning a list and yet the ModelsSchema is expecting something else, is it what you mean?
@AndyK "it is returning a list and yet [you are] expecting something else"
@Peilonrayz I need to figure out what I should be expecting...
thanks for the rubber ducking
18:05
I ask yesterday can I make Bitcoin address and private key from decimal number in pure Python without module and I get answer that I can do that. But when I search online I didn't find anything similar. Can someone give me some instructions how to do that?
@jeea please explain how it "doesn't work" and what your code is
Does table make sense to anyone?
That is related to maching character pattern by regex, but I can't understand what author wants to say.
I do not need full explanation here, just a small minimal hint would be suffcient.
It makes sense to me, so I'm not sure what part of it is giving you trouble
Although I guess the author skipped some steps between 1 and 2
how the step 1 is a? and step 2 is abcbd? and what is step 3 failure is referring to?
a is the first character in the regex, so step 1 is matching that a against the input string abcbd
18:15
Okay, fine, what about step 2?
The next part of the regex is [bcd]*, so step 2 is matching as many b, c and d characters as possible
And then the 3rd part of the regex is b, so step 3 is matching that b against the remaining input. This fails because there is no remaining input
then there is to-and-fro ?
yeah, then it starts backtracking
but then it goes forward again, would this forward and backward continue forever?
well, it ends when the entire regex matches or if no further backtracking is possible
18:19
"Try b again, but the current position is at the last character, which is a 'd'." what does this mean?
try b again , but the current position(?) ... which is d(?)
It means that the first 4 characters of the input were already matched, so only the last character d remains
the "current position" is the first unmatched character
then why it is trying b again?
uhhh, not sure how to answer that. Because it has to? There's no point in backtracking unless it tries to match b again
I can't get what you said, but thanks for clarification.
Maybe I didn't explain very well. From decimal number I want to get bitcoin private key and then address. With module that's easy. But I want without module.
18:29
@Peilonrayz Argh, sorry for sending that OOP question your way to CR. Is the [python] tag better over there than on SO?
@MisterMiyagi No problem, it looked fairly on-topic. I don't really SO, hence the ~700 rep, so I couldn't really say. I think CR's fairly ok, but we can get a lot of low quality questions at times.
Hm, guess I'll drop by a few times over the next weeks. Might need a break from wading through the current SO stew.
@AjayMishra You realise the last character of the pattern is b? So the final action of any match is to "try match the current input character against b".
Once the matcher has realised that the entire string (test[:]) matches a[bcd]* but not the final b, it then tries to use the shortened string (test[:-1]) for matching a[bcd]* and checks whether the remainder (test[-1]) matches b.
As long as that fails, it will keep in shortening the initial match (test[:-n]) until the following character (test[-n]) matches b.
18:45
@Pijes Yeah, it's not gonna be easy. At the end of the day, what you have to do is read the bitcoin specification and implement it. There's approximately a 0% chance of anyone here knowing how to do that, so you're on your own
19:08
Does someone know if there is a simple way to type hint "Callable with __get__"? The regular typing.Callable doesn't have __get__, and a Protocol needs an entire class declaration – kinda wasteful to annotate a five-line function.
@MisterMiyagi Don't think that possible. AFAIK Callable's pretty useless, it's normally best to use Protocols.
Unless it's something super basic
Seems like I want refinement types, which aren't a thing in Mypy/typing. :/
19:53
@Aran-Fey Thank you for explaining to me. Have a nice day
20:34
Does anyone know a high-level messaging system that could be used as a replacement for lame ol' sockets?
20:46
A remote procedure call lib would be nice, but I can't find any that are documented and not abandoned...
and not overcomplicated
user10984358
21:25
Does more processes mean faster runtime assuming my program is CPU bound? If so stackoverflow.com/a/18176257/10984358 suggests that the first scenario guarantees two process where as the second doesn't, so what should I go with say I want to share 10 cpu intensive tasks across 2 cpu cores?
@TheNamesAlc only if the problem lends itself to parallelisation.
Good: Fourier transforms. Bad: integration of differential equations.
user10984358
my aim is to run one single method with different input calls so they use all cores
user10984358
it just uses a lot of scikit to do some prediction so I have no idea how they have optimized that
user10984358
so I run one method with a 100 row dataset and the same method with a 200 row dataset, I just want them to be running on different processes (lets assume 100 and 200 is taxing on a single cpu core)
you should run one and monitor your CPU usage
scikit sounds like something that leverages multiple cores already to do linear algebra
user10984358
21:37
if this medium.com/@messiest/… is to be believed I have to manually override it to anything other than 1
for instance this will utilise all your cores by default:
import numpy as np
arr = np.random.rand(1000, 1000)
while True:
    arr @ arr
user10984358
~185%, thats all the "Activity Manager" on my Mac shows, need to google where I can see the core usage though
user10984358
it does, all the bar graphs for my 4 cores are 75% or above, so I need to see how it is for my code, thanks
23:09
hey i want to create a class that when initialized reads some data from a file and then at runtime creates class methods named based on the data in the file, how do i do this?
as in

class weird_class():
def __init__(self, items):
???
def generic_func(self, item):
print(f"specific {item}")

i am wanting to use this class in a notebook/repl where i would do something like:
`
>>> data = ["foo", "bar", "baz"]
>>> tool = weird_class(data)
>>> tool.foo()
out: "specific foo"
>>> tool.baz()
out: "specific baz"
`
@ch1rh0 This sounds like a really bad idea. I can help you out, but why do you want to do this?
"In a notebook/repl" so not as bad as could be
within a notebook i want interact with a database. i want to have class that i can use as a tool to insert logs/messages into a database. these messages also have a type associated with them
so instead of typing in the notebook/repl:
`tool.db_insert(msg_type="foo", msg="cool message")`
i just type:
`tool.foo("cool message")`
(apologies i am not familiar with how text fomating works here)
23:26
@ch1rh0 please see our code formatting guide to chat and practice in the sandbox if necessary
4
you could also use foo_command = functools.partial(tool.db_insert, msg_type="foo") and the like to get the short-hands you might need
@ch1rh0 I don't know enough about those, so I'll show you how to shoot yourself in the foot. I'd recommend not using it if possible.
>>> def generate_func(name):
	def inner(self):
		print(f'specific {name}')
	inner.__name__ = name
	return inner

>>> MyClass = type('MyClass', (object,), {item: generate_func(item) for item in ['foo', 'bar', 'baz']})
>>> MyClass().foo()
specific foo
I'd probably go for __getattr__ as far as footguns go
Yeah, that could be better, but I've never had a good experience with it. I've also had my first "I don't know what it does but it fix it" moment with it the other day...
it's to make a tool that i use in a repl more ergonomic.
the idea would be at object initialization a db query would return the top 10 most frequently used types and make short hand methods based on those
awesome thank you for these footguns, i know this is kinda wacko but for the sake of ergonomics i am gonna try it
23:57
@Peilonrayz are you sure your issues weren't with __getattribute__?
@AndrasDeak Yes

« first day (3409 days earlier)      last day (1764 days later) »