« first day (2976 days earlier)      last day (1964 days later) » 

12:39 AM
Hey there, is there any way to flip a bool on a signal? I want to break a loop if there is an user interrupt.
Google just give me tons of articles where one wanna know how to just flip a bool...
and using the signal module ends up in no change. the variable just stays false :|
 
1:31 AM
you mean like not(a)
f(a==True): not(a)==False =>True
 
 
1 hour later…
2:40 AM
No, not exactly. Currently I'm doing this: signal.signal(cap_signal, lambda (sig,frame): interruptLoop = True. In a Loop I then check on interruptLoop and break --> if interruptLoop: break.
But this isn't working. The value of interruptLoop will be False even the signal is fired AND handled.
 
3:14 AM
solved: I forgot to refer interruptLoop by global
 
4:12 AM
I was going to say...
 
 
1 hour later…
5:41 AM
well, tonight doesn't seem amenable to brute force
 
5:57 AM
no, not so much
part 1 went fine... I guess I'm just going to go to bed and wake up and see if part 2 submitted fine (Thanks, Wim for aocd!)
burning up my cores, woohoo
 
I ran my code while I took a shower and it still didn't finish ;-(
 
6:14 AM
@Code-Apprentice @WayneWerner you both are doing it wrong.
the obvious solution is to use view spoiler for these marble tasks as was done in previous years.
@Code-Apprentice @WayneWerner I am bruteforcing,
1.51s user for all given assertions, and both parts 1 and 2
 
@Code-Apprentice my script has been going for over 700 hours and its still not done! (timelock crypto puzzle)
Can parallel computing be used to factor extremely large numbers? Can anyone explain how to do this with Python or tell me where I should start looking for answers?
 
6:30 AM
@XisUnknown of course it can.
you'd have each core test a different set of potential divisors.
 
My thoughts exactly.
How do I implement that? I've never done anything with AWS or parallel computing and I don't really know where to start.
My thought would be to write a program that writes the programs for each 'core'...
 
that's like
 
 
2 hours later…
8:13 AM
@XisUnknown you don't need aws. Check out the multi processing lib
@AnttiHaapala this is the furthest I've made it in any year
 
8:25 AM
@roganjosh need help to set the scroll of Spyder Ipython console to bottom by default. Just like a windows cmd will scroll to the bottom when its printing verbose.
 
 
2 hours later…
10:18 AM
Hi guys, can I ask a noob question?
When I type pip in the terminal (not python console) of PyCharm, I get <module 'pip' from 'C:\\Users\\Asus\\Google Drive\\Technicals\\Programming\\Python\\Python Scripts\\Web Scraping\\venv\\lib\\site-packages\\pip-10.0.1-py3.6.egg\\pip\_init_.py'>
 
slow brute force is slow
 
But whenever I try to do something like pip list
or pip install bs4
I get a syntax error
SyntaxError: invalid syntax
 
because you need to run that from outside python
from cmd
 
Yes I isntalled bs4 using the cmd
It is active in the list of packages
 
you said you get a syntax error
 
10:20 AM
But when I type in my python console
import bs4
It cannot detect it from my script I don't know why
 
now this is completely different from what you originally asked
 
Yes sorry I am confused atm lol
 
make sure you're using the right version of python
python3.6 -m pip install ... is the way to be sure
 
Alright thank you!
I asked a question about pip
in stackoverflow
It just got all the hate in the world
Asking the difference between pip installs
They say all versions are the same
 
10:35 AM
I did python3.6 -m pip install bs4 and I get a message: python3.6 is not recognized as an internal or external command, operable program or batch files
But python -m pip install bs4 --upgrade --force-reinstall works
But still cannot be detected by my PyCharm
 
yes, that was an example. You need to use the same python command that you'd use for execution
the point is that if you execute with python_whatever script.py then use python_whatever -m pip
odds are pycharm uses something other than python
 
Perhaps i'll just have to check everything out then lol. Thanks
 
you could start looking at python versions to try to guess what's going on but the real solution is to use the right python version without guessing
for instance, virtualenvs might also come into play, where python and pip are specific to the env
I've never used pycharm so I don't know how it handles these things
 
Right what I noticed sometimes is that the project folders I have in python
Have the library folders inside them
I am guessing bs4 was not placed inside the same project's folder
So when I press External Libraries on the project explorer of my pycharm I only have folders like python36, venv, DLLs, Lib,site-packages, pip-10.0.1py3.6.egg but no bs4
Anyway thanks for the help i'll just have to play around and figure it out :/
 
good luck
 
11:00 AM
@WantingtobeanAndroidDevelor Anaconda does not, in any way, force you to use Spyder. It's a python distribution that you can link to any IDE that you want
 
@AndrasDeak I fixed it already. There is indeed a site-packages folder inside the project folder of each project in PyCharm that contains all the installed libraries
Also using pip install in the cmd does not make the library detectable by PyCharm
There is a built in cmd for PyCharm called the terminal
I had to close PyCharm and run it as admin for it to accept pip commands
Then I was able to install bs4
 
@WantingtobeanAndroidDevelor Also, I have similar observations to you. Sometimes you can just crash the kernel and have no idea how or why, it just restarts. Add to that the weirdness of some features that Andras alluded to, and it's a good idea just to run your code periodically outside of Spyder to ensure it hasn't messed with imports etc
"eluded" instead of "alluded". This is how important my morning brew is.
@Aqua4 I'm not sure I exactly understand. You mean when printing giant blocks? If you print by line then the console will keep up. I don't think there's a feature as such that you can activate, I think on mega printouts the console just chokes and doesn't do what it's supposed to do but that's conjecture
It kinda half scrolls down through the block but doesn't always make it to the end
 
11:38 AM
How can I compare a NoneType and an integer?
int() don't work for NoneType
 
@taritgoswami no, it doesn't. But that's not relevant when "comparing". What is it you're actually trying to do?
 
Actually, I am computing Fibonacci numbers using the matrix multiplication..
 
Advent of the linked list...
 
and finally the function Fib(n) returns F[0][0]
But after getting the value, I need to check, if Fib(n) is > 4 million or not
@roganjosh But, as the return type is NoneType, I am not able to compare them
 
@taritgoswami I'm going to struggle without an MCVE. If it's more than, say, 12 lines, please post a link to a pastebin or likewise
 
11:43 AM
Ok
 
Perfect, thanks
LOL, "kernel died. Restarting...". Perfect demo of the earlier Spyder conversation.
 
since you're using matrix multiplication, how about adding numpy?
 
I haven't worked with NumPy
 
if (n==0):
    return
that returns None ^
 
You went and broke my machine: ibb.co/5ryFzWd You'll hear from my lawyers soon :P
 
11:47 AM
@taritgoswami it would make some of your work easier
ibb.co...
 
@roganjosh :p I have posted in Paste Bin also, please check here, if repl.it is not loading - pastebin.com/DmeGKd0Q
 
no, his point is that his spyder broke on your code
 
No, it loads fine, I tried to run it locally and Spyder had a fit
But that's not really your fault, I was joking about the lawyers :)
 
anyway, did you see my remark regarding your None?
 
11:49 AM
@roganjosh Got that :p
@AndrasDeak I haven't work on Numpy. How that will help?
 
It has nothing to do with numpy, that was just a general suggestion.
4 mins ago, by Andras Deak
if (n==0):
    return
 
Ooh, got it.. so, F[0][0] is not NoneType?
 
huh?
bah, I hate that I can't copy-paste from repl.it, piece of yam
for i in range(10000):
  if(Fib(i) > 4000000 ):
that will try Fib(0) > int(4e6), i.e. None > int(4e6), hence your error
 
How can you not copy? Are you on your shiny new phone?
 
Got it, thanks to both of you :)
 
11:54 AM
@roganjosh no, ctrl+c is disabled, have to right-click and fiddle with a yamming mouse
hmm, now it works
 
I literally did Ctrl + c
 
I swear it didn't work twice, and not for the first time
 
Well, you're an unreliable witness for when I take the Spyder crash to court...
I actually don't know how Repl.it works. In the past I've played with someone else's code to test; does that change affect everyone if I'm not the owner of the post?
 
@roganjosh Bill Gates did it
 
"I distinctly remember Bill Gates coding this crash into Windows, Your Honour"
@AndrasDeak This oddly reminded me of Randy dressing up as Princess Leia and stealing a magnet from the LHC in South Park
 
12:17 PM
stackoverflow.com/questions/53692128/… unclear/too broad. If anyone answers with an approach, they will make an invalid file format that would be a mega pain to fix.
Huh... a 1 rep user has surprised me on that!
Not 1 rep anymore :)
 
 
1 hour later…
1:52 PM
Had this on a phone tab. Should it be reopened?
 
 
1 hour later…
3:05 PM
Hi, can anyone tell me what will be best way to learn Python? (or a language in general) I am facing problem..
I'm learning by trial and error method :p , in this way most of the time I face errors
 
@taritgoswami I think that is perfectly acceptable for beginners. Not only will you learn what types of mistakes are associated with which error messages, you will become skilled at debugging your own code. That’s an important skill. My advice would be to continue to learn and be patient. And, of course, do not shy away from the official python documentation and related tutorials.
 
Yeah, read a tutorial first. Less frustration and higher chance of not learning anti-patterns.
 
3:20 PM
+1
@taritgoswami learning to start a fire by trial and error takes 5 billion years.
following an example not as much
 
@taritgoswami to the extent that I know python, you really just need a real-world problem to solve and just brute-force your way through errors, trying to actually understand them at each step. People learn differently, I couldn't follow a set tutorial
 
you need a real problem and supporting documentation
 
I followed LPTHW for a while, not knowing its drawbacks, and it got me up and running enough to just focus on the problem I actually had to solve
 
@taritgoswami try some puzzles, like adventofcode.com/2018/day/1
 
Basically, once you know loops, lists and functions, you have all you need for self-directed learning
Then it's just a case of "there must be a better way to do this" to expand your knowledge
 
3:27 PM
They’ve left… tutorials and trial-and-error are not mutually exclusive… that was the point I was trying to make.
 
3:38 PM
I got some advice yesterday on AoC problem one and Arne mentioned that I should build the dict with both prereqs and conditions. I have managed to do that but still, after much trial-and-error, cannot go from the dict I’ve built to my final order. If anyone could take a look… dpaste
 
Can't see the attempt
You need to formulate an algorithm, then figure out how to apply to your data model
 
Fair enough, ... I have written several but nothing worth sharing.
    for search_key in prereqs_conditions.keys():
        temp = [k for (k,v) in prereqs_conditions.items() if search_key in v[1]]
        print(temp, search_key)
 
20 hours ago, by Andras Deak
in your case you'll have to loop over all the keys and check "nobody depends on this", i.e. no value corresponding to another key contains that key
Something like that ^
And make sure you break ties alphabetically
 
Yes Andras, I knew that was coming. But in my actual data I have two keys without prereqs. So my initial attempt at that failed
 
@roganjosh Same issue for me also
 
3:47 PM
@AndrasDeak Ok, wait that means that I initially have a tie, that I need to break. Hmmm... ok
 
@AnttiHaapala Ok, I will try
 
By tie I mean cases where two or more letters can be used
 
@W.Dodge make a set of all tasks.
 
@AndrasDeak Right, so an initial state where two keys have no prerequisites means I have a tie that breaks alphabetically to begin with.
 
add everything you can see in prerequisites or the dependent positions
@W.Dodge not only that, at any given point, after each completion,
 
3:50 PM
@AnttiHaapala not necessary
 
you must check all remaining tasks in alphabetical order.
 
@taritgoswami It's not an "issue", it's just the way people learn
 
@AndrasDeak well, it is easier that way.
or, well, you can make a dictionary of all tasks to their dependencies
 
@roganjosh I mean, it is tough for me to follow tutorials throughly
How this works -

def problem6(r):
return sum(r)** 2- sum([x** 2 for x in r])

problem6(range(1,101))
 
My lecture attendance at uni hovered between 10-20%. I can't count the the threats I got by email of failing the course. Nobody rushed to apologise when I got a 1st in the exam.
People learn in different ways. A formal tutorial just doesn't work for me
 
3:55 PM
Cool cool, I'm going to go try again with this... @AnttiHaapala @AndrasDeak Thanks!
rhubarb
 
@roganjosh hem..
a formal tutorial says: "Please be careful to not hit your head here. Many people have done so and they know it hurts."
 
@AnttiHaapala Are we talking corner cases? I'll bash my head and learn :)
 
it will be ok if you hit your head right away :d
but if only later...
 
I'm not launching rockets or developing anything critical, so the hits are on me to fix, they don't impact others
I've painted a bit of a slapdash attitude, and that's not the case. But edge cases do occur and I learn from them.
In uni (noting that I did chemical engineering), the lecturers just basically regurgitated Coulson and Richardson.
I'm not waking up hung over to drag myself to a lecture theatre to have a book reading :P
 
4:14 PM
so like in chemistry, you don't actually go and try what will happen if you drop potassium cyanide in sulfuric acid.
 
I managed a lab and nobody was injured. Meanwhile I find we're being microwaved in the office above the lab because the microwaves leaked. Stuff like that is almost expected in that industry.
It's comparing apples to oranges. Honestly. The mentality is so different between the two professions
I once spilled methyl cyonide all over my leg. Just packed my jeans with bluerool and go sit in the sun for a cig while it evaporates off :P
Blueroll*
 
4:30 PM
@jpp, as per yours and Alex Riley's suggestion, I am planning to move some content from the merge canonical into separate posts. Specifically, I am going to make a separate canonical for index-based merging, and a third for computing the cartesian product. cc @piRSquared
I will not make the cartesian canonical a duplicate target because there are enough questions that serve that purpose already; mine will go into more detail with performance.
 
4:44 PM
Thing is, I'm also wondering whether the section on merging multiple DataFrames should be separate from the post on merging two frames. I don't really think it should, but I don't mind either way, and I'd like to hear some thoughts.
 
I think the main issue with questions is that askers aren't aware of the variety of ways to answer their question. Throwing a narrow dimension of answers at them may not expand their mind. Allowing for a more comprehensive bit of information is more useful.
It just can't be too much at once. I don't think your post is.
 
You can't expand the mind of people that don't want to learn. That's not an isolated issue.
 
@MartijnPieters view spoiler I'll be using your solution again to compare against mine when I discuss amongst colleagues.
 
4:59 PM
@piRSquared yup, original ran for half a minute for part2
Rewrote it after
 
bah, @AndrasDeak, @AnttiHaapala also thought to use the same thing @MartijnPieters did. I went and built it myself. Sometimes I'm so proud of myself up until I realize I just rebuilt an inferior wheel.
And, I'm now upset with myself because I should've remembered.
 
5:43 PM
@piRSquared very true. I do think it is good to put things into perspective when learning something. If someone asks a question about joining on a column, they are given an answer doing that and nothing more. Tomorrow, if they want to merge on the index, they will not know how and will end up asking another question. Really the only thing I feel should be in it's own post is the cross product section which was originally included here because it makes sense in the context of explaining SQL JOINs.
 
@piRSquared I knew at the start that I could use that but it was easier to roll my own
Probably typo eventually
 
6:11 PM
No repro now ^
 
6:39 PM
recbg
@AndrasDeak @piRSquared I knew the speed could be critical...
but I was struggling again with the CW-CCW so I think in case we're going to see these again, I am going to add some methods to help with it :D
 
Hello friends, I have a beginners question
can we name a file as main ?
i mean __main__
 
@jeea yes and no. mostly no.
__main__.py is a special file in packages.
 
ok so better not to name
 
and any initial script given on the command line will become __main__ despite its name, so, all in all it would be of dubious utility...
... neither can you ever import __main__ from other script and expect to get that.
so yeah, no, you don't want to do that
 
melon
also I have other question regarding working of reduce from functools pack. I have come to know from experimentation that:-
list1 = [2, 3, 4]
print(reduce(lambda a,b: a**b, list1))
 
6:54 PM
hello
 
This stores first 2 ** 3 in, say temp. now it computes temp ** 4 and so answer is 4096
 
What's the error:
`
foo = True
While foo:
foo,bar = doStuff(a,b,foo)
`
value of foo never changes
doStuff returns boolean, and a tuple
 
@AnttiHaapala the speed gain is less than what I'd have spent on writing it fast in the first place
 
really??!
 
@jeea you shouldn't use double-underscore ("dunder") names unless you're trying to use a specific one according to its purpose
@AnttiHaapala really
figuring out the lefts and rights would've taken too much time with too high a probability
 
6:57 PM
haha D
I did get to the global leaderboard in part 2
 
when I rewrote it after, I was like "OK, this order doesn't work, let's swap + and - -> it works". If I had done that the first time around there would've been trouble if neither worked :D
 
that's why I am going to write a wrapper now :F
 
my rewritten version is a wrapper, actually
 
I'd still need to figure out what rotateleft would mean w.r.t. current position :D
 
7:18 PM
@0x45 That's not enough information to figure out what the problem could be. Minimal, Complete, and Verifiable Example please.
 
7:29 PM
actually, the problem is a SyntaxError
 
two syntax errors
 
no :)
 
7:54 PM
recbg from 15,000 feet in the air!
 
8:17 PM
copycat-cbg
 
People seem to think Python room regulars are ‘too understanding’:
I lately started to hang around more in the python chat room, and I believe that between that one, php, javascript and the lounge, people in python chat are exceptionally understanding, sometimes too much, if I may. Some users are usual close votes casters, but generally the question need to be really bad for people to get involved. Maybe that also participates to what gnat describes... — Félix Gagnon-Grenier 16 mins ago
 
Felix is a regular enough guy in here. I wouldn't say we were accepting to a fault
 
yeah, Félix is not (just) "people" ;)
 
9:09 PM
That post by gnat has my back up a little. I've really been contemplating a meta post for the Python tag because, frankly, we're getting hammered by it being the new teaching language. I'd rather see his name on a few more close votes before he criticizes mods
 
they have 0 score in python
 
Python isn't half as bad as C :/
 
@AnttiHaapala what benchmark, though? I'm sure I could ask really stupid C questions after hours of research. Or are we talking people dumping requirements?
 
well, one paragraph questions with no code, backwards indentation in code, photos of screens with code in them, mentions of compilation errors but no sign of the messages, etc... and if I do not cv-pls them with a couple other souls, all them would be answered, upvoted and stay forever
my favourites are the kinds of "I am doing this stupid thing that shouldn't work... but why does it work nevertheless"
 
9:34 PM
cabbage
 
cbg
 
cbg
 
9:55 PM
@W.Dodge Since I set you on that road, I might also explain the loop logic I had in mind: spoiler
 
10:12 PM
@Arne I needed that, lol. I have been getting my butt whooped by this problem (probably will with the rest too). It's like the solution is right on the tip of my brain. I can see what exactly needs to happen but keep getting snagged in the implementation.
But I've got to give it a rest rest for now :) Thanks and rhubarb
 
rbrb!
 
11:08 PM
cabbage y'all
A cold and gray Monday morning, but the tea was hot and sweet. :)
 
@ReblochonMasque tea is the great fixer :)
 
indeed @roganjosh
 

« first day (2976 days earlier)      last day (1964 days later) »