« first day (2241 days earlier)      last day (2933 days later) » 

@AnttiHaapala hah yeah I luckily just searched for "north" :P
I bounce between "dirty one line solutions" and "doing it "properly""
Updated my day 4 to be a little more pythonic
off to bed -- night all!
night Marcus
wim
wim
09:31
str.translate has a wacky interface
and it's very hard to make it cross-compat py2 / py3
was looking for a way to do the shift without using a "magic number" 26 anywhere, and found one like this
09:46
@wim str.translate is 2-3 compliant
if you use unicode
but [str, unicode].translate is what is broken on Python 2
cbg :)
10:32
i just did aoc3 and come in an issue:
why
print (x.sort())
is none, but
x.sort()
print (x)
works?
€: found it: https://mail.python.org/pipermail/python-dev/2003-October/038855.html
i think thats the answer (even its from 2k3) :D
10:56
@manuzi1 closing as a duplicate of...
@AndrasDeak oh shit
 
1 hour later…
12:04
@wim exactly:)
@AnttiHaapala right?
stupid aoc sniped me real bad
and I had to stop with part 2, 5 minutes after getting it to work, due to Real Life Stuff
@wim I sense a Markov chain
I decided to spoiler
@AndrasDeak s/after/before/ #duh
13:03
cbg
@AndrasDeak, so I edited that function so it returns qstat, which shouldn't change.
13:48
cannot convert pixels values to image :

from PIL import Image as img

def imgFromPixel(pixel,type,width,height):
im= img.new(type, (width, height))
im.putdata(tuple(pixel))
im.save('test.png')

imgFromPixel(X[0],'LA',20,20)

here, X[0] is an array which stores the value of 400 pixels. But on running this code, I'm getting this error :
self.im.putdata(data, scale, offset)
SystemError: new style getargs format but argument is not a tuple
Grr... why does fetch always cause an Uncaught (in promise) SyntaxError: Unexpected end of input(…)
cbg btw
cabbage
14:08
things like this annoy the crap out of me:
in PyCharm there is a nice refactoring tool to move a thing into another module
except when you use it it doesn't work at all. First you need to choose the file where it needs to go, not a module. (well of course, python doesn't have modules...). Second, it doesn't move any of the pycharm linter instructions associated to it. Third... the resulting file has one warning: "PEP 8 requires that the file end in a new-line"
seriously?!
everything is so half-assed that it hurts
@Code-Apprentice the stack exchange
I feel that this question could be allowed to be open. Any reopeners?
@thefourtheye ahhh just the puppy!
Yay, nuppy :-)
  componentDidMount()
  {
    fetch('http://localhost:8000/test/', {mode: 'no-cors'})
      .then(r => r.json())
      .then(json => this.setState({preferences: json}));
  }
Why does that always give me the error above ^^^ ?
14:21
Does it say which line?
I am guessing its either fetch or the preferences line
@thefourtheye negative
@thefourtheye that is really POB question
Response is not JSON?
@thefourtheye the hoisting question
it is one of those stupid "why this not that" questions
even the answer doesn't answer the question
ROT-whatever decryption is so easy in Python.
I'd hate to have to re-implement the str.translate() method in any other language.
@MartijnPieters but str.translate interface is awful
14:25
@AnttiHaapala Honestly, I had the same question... But nobody can provide definite answer I guess.
@thefourtheye actually I came up with an answer:
the reason is that var affects the scoping of a variable.
if that wasn't hoisted, the meaning of a variable would change in between a scope...
@thefourtheye It is json... - that's the thing! :(
@JonClements Okay, try adding catch to the Promise object and try to print the stacktract of the error
@AnttiHaapala Meaning of a variable? What do you mean by that?
@thefourtheye meaning of a name, its binding
or then, you would allow it at the top of the scope only.
which is what JSLint does, and people complain that that is stupid
@thefourtheye The error doesn't appear to be much more than I posted above...
14:29
anyway, it's turtles all the way down, there is no way that does get anything other than POB
@JonClements Even this doesn't help?
fetch('http://localhost:8000/test/', {mode: 'no-cors'})
  .then(r => r.json())
  .then(json => this.setState({preferences: json}))
  .catch(e => console.log(e.stack));
@AnttiHaapala Hmmm, still not clear. Can you give an example?
say, you did:
function bar() {
    while (true) {
    if (!foo) {
        var foo = 10;
    }
    alert(foo);
   }
}
@thefourtheye Just adds "line 46" which is the r.json() line... which is a fairly obvious guess given it's a json syntax error :)
Hello there.

Can I join in with a quick question?
@thefourtheye if there was no hoisting, then the first time the if was run, foo were a global variable, and then local afterwards.
the question is more of "why is the var statement allowed everywhere and not just at the beginning of a fucntion"
which is POB.
14:34
@HighOnMeat, what's the question?
I am facing some really weird issues getting stuff to run on a windows machine using windows exe files while driving it frm a Linux machine from where the python code is run
@HighOnMeat cbg, chatroom rules; just ask your question...
@HighOnMeat, what are the issues...
is this fairly common? I mean I am basically trying to run a few exes simulatenaously so I popen a few SSH connections to the machine and then wait for them to finish. One of them is a bat file that does some longish SQL Server related things
@HighOnMeat, it is generally hard to tell whether or not it is common without knowing what the issues are =P
14:38
ok
@JonClements Try logging r.text() before running r.json(). Response might have some extra characters?
I create a few Popen procs which talk to that windows machine over SSH
to quote the hbar chatroom, "'Gave errors' is about as useful as 'potato'"
@thefourtheye Ahh - that's an idea... not sure the best way of approaching debugging this but that makes sense
and I basically want to log the output of those processes as they progress.
user6568562
14:40
Cbg, everyone
since one of the Popen connections deals with SQL DB related issues which can take some time to complete
@randomhopeful, cbg
@thefourtheye ah hah! A hint Syntax error: Unexpected token, expected ; (15:57)
user6568562
hey @heather. How's the marketing world doing ?
@randomhopeful, the marketing world? I'm not in marketing...=)
14:41
@heather I will be back soon with some more info
@AnttiHaapala unicode.translate or (Python 2) str.translate?
@AnttiHaapala Perfectly makes sense. Bad design :-) Thanks
user6568562
@heather Oh I'm sorry, I mistook you for someone else, then
@MartijnPieters when I talk about str, I talk about str:D
They tried to fix it with let and const in ES2015
14:42
python 3 naturally
But the most important thing is, get this, let and const also hoist, but accessing them before the declaration is reached will raise an Exception
@JonClements :-) :-)
@randomhopeful, no problem =) fyi, I'm in 8th grade, can't exactly get a marketing job yet =P
meh, I find the interface clear enough. "Give me something I can pass unicode codepoints to" and what such a lookup should return.
user6568562
@heather Eyyy, that's cool
from xxx.business import IFileBusiness
from xxx.business.iface.file import IFileBusiness
this is crap produced by pycharm refactoring. It didn't even notice anything wrong with this...
even though this is in the package xxx.business
hmm
@MartijnPieters yea, I mean I use it so seldom that I need to relearn that a) it gets unicode codepoints in, and b) it nonetheless can return either unicode codepoints or strings.
14:54
cbg
>>> 'abc'.translate({97: '123'})
'123bc'
>>> 'abc'.translate({'a': '123'})
'abc'
@Code-Apprentice, cbg
@AnttiHaapala well, do you expect Python to try both 97 and 'a' every time?
and I use str.translate to build the map anyway.
14:57
just saying, it is not very pythonic to use codepoints in there, though it naturally has better performance
or at least had in Python 2
time to learn some Python regex
You want to use str.translate() because of the performance.
So asking Python to then box all unicode codepoints into a length-1 str object is rather counter to that.
>>> class Foo:
...     def __getitem__(self, bar):
...         return random.choice('abc')
...
>>> 'aaa'.translate(Foo())
'bbb'
>>> 'aaa'.translate(Foo())
'bbb'
>>> 'aaa'.translate(Foo())
'ccc'
interesting, the mapping is still cached.
that I didn't know
@MartijnPieters since the mappings are cached, it should've been string -> string only.
it was again retained for the unfortunate Python 2 compatibility.
AoC day 4 is kind of fun
15:15
Which of the following is correct?

> A Lexical Environment consists of an Environment Record and *a possibly* null reference to an outer Lexical Environment.

Or

> A Lexical Environment consists of an Environment Record and *possibly a* null reference to an outer Lexical Environment.
I think it should atleast be ... Record and *a possible* null reference
nvm. After reading it again and again, a possibly also makes sense.
15:30
reading comprehension FTL, note to self, when doing programming challenges actually read the prompt and look for the right thing, lol
@heather I wish I was as motivated as you when I was a kid
I was listening to Martin's talk to me python and realizing how many programmers have 5-10+ years of experience compared to me, at my age... :/
So, my motivation for AoC now is to just do it, knowing I will get the lowest number of points for it because I have no time to finish it the day of 😛
How long will this motivation run for :D
on the python leaderboard I think it just shows points for completion
or rather, stars
I'll never get "points" since they release the new one in the middle of my night
But what do the stars correspond to
like, I have one grey one, and a bunch of people have gold stars
15:43
@enderland, I'm really not that motivated though - I just kind of mess around with things.
but thank you.
@idjaw silver means you did 1/2 of the days challenges, gold is 2/2
@heather more than I was doing in middle school
@enderland oh man...I just noticed that my day 1 problem just got extended to a second part
haha
looks like I still have day1 to finish :D
and my current solution is like 55 lines of code
I feel like that is really long
for something that seems can be done in shorter
I'm missing something critical I feel, in my solution
but it works
@idjaw my sol'n for AoC1 is about 60 lines long
Wouldn't sweat it.
We still love you, even if you are a terrible programmer.
It's true.
@Ffisegydd I don't know what I would do without you.
15:49
I watched your talk up to the point I realised it wasn't going to involve cats and then gave up, what I saw was good though.
@Ffisegydd Then you didn't watch long enough and stopped it only 1 minute 35 seconds
because at 1 minute 40, the cats showed up. and never stopped
Ah yeah, I got to 1 minute 5 seconds.
My bad.
it's all good. I don't blame you
Maybe lead with the cats next time.
That was actually a comment in the QA
I made note of it
15:50
No one cares about CI, unless it stands for Cat Integration
That was the twist
jeeeeez Fizzy...it's like you don't care about me at all
You twisted the cats?
That was the punchline
It was about Cat Integration.
But Fizzy just couldn't last more than two minutes.
ugh....
Don't even get me started over the fact that you're not made of lego.
Your shirt is the right color though, so I can forgive the lack of blockyness.
15:55
@idjaw, what video is this? I like cat jokes =)
There's no cat jokes, he is the son of lies.
@idjaw cool that your talk was recorded!
Fire-driven development is a fantastic term.
@enderland yeah! Someone had a camera and recorded some of the talks.
@Ffisegydd :)
I'm on mobile right now and about to head out with my daughter, can't link it now.
Yeah, I'm going to start using that term at work.
16:02
@heather sadly no cat jokes. Just good ol' boring tech talk :D
which is why fizzy bailed :p
Oh thanks @MorganThrapp
oh, no cat jokes =P sad
Haha yeah
I'm currently watching it, so I had the link up already.
Did you want that linking publicly Idjaw or did Morgie just pull an e-faux pas?
Also: Good old Gerrit
Nono it's fine. I posted it everywhere else :p
don't know why I didn't just post it here. Maybe I was ashamed of my non-Lego appearance
16:06
omg...
Russian trolls in action
A wacko shot 3 in the town of Imatra yesterday,
now Russian trolls are telling in twitter that the 3 shot were Russian women and the shooter a Finnish nationalist army officer...
Go world go
they weren't
so this wasn't mentioned in the Finnish language news, but only in Yle Russian news broadcast
I forgot how many times I overrode Jenkins in my Gerrit workflow.
i'm trying to import a file with a bunch of functions in it into another file (this is python 3) by using import function (function is the file name) but it gives the error "hadop undefined" (hadop is a function) when I try to run it. What am I doing wrong? The code can be found here.
16:15
@AnttiHaapala, was that in reference to my problem? (Sorry if it wasn't)
@AnttiHaapala Eevee had a nifty idea to make __tablename__ a metaclass argument with Py3.6, I've been meaning to try it with Flask-SQLAlchemy.
@davidism I am not sure if I should say "eww" :D
Yeah, lol. I just wanted to see if it would work. :-)
I'd rather have a policy for __tablename__
all my tables are just the class name lowercased :P
16:18
Flask-SQLAlchemy kinda does that, but it's missing a bunch of cases.
I just realized this recently, have a 20+ line test suite for it to work on at some point.
DSM
DSM
Unexpectedly early Sunday cabbage for all.
stupid idiotic PyCharm!!
class BaseService(object):
    def __init__(self, **kw):
         super(BaseService, self).__init__(**kw)
the **kw passed in to super.__init__ gives warning "unexpected argument"
DSM
DSM
@heather: works for me (that is, I get to the "How many qubits" question.)
16:20
same
I am so divided
perhaps I should pay the license again to get a newer pycharm
but I am sure they haven't fixed any of these and I'd be just as frustrated
I just renewed my license. 40% off first year and free second year since I had one of the old licenses.
They're fixing the flask.ext issue in the next version, finally.
@AnttiHaapala you could try the community edition to see if the syntax is fixed
16:35
@DSM, if you type 1, then 0, then Hadamard, X, Z, etc you should have problems
DSM
DSM
Well, yeah, but those aren't the "hadop undefined" etc. errors you were mentioning before. Those are errors because your function module doesn't import cmath, or math, or numpy as np, or random.randint, etc.
If I add the imports, I get results like
your result is [-0.70710678+0.j  0.70710678+0.j]
probability of |0> state is (0.5-0j)
probability of |1> state is (0.5+0j)
morning cbg
@MarcusS cbg
@DSM, really?
weird, but I'll try adding that.
DSM
DSM
Sorry, why is it weird?
16:45
When adding a comment to a question how do you add multiple lines of code to keep the python syntax? Ive tried the ` ` on each line and it didnt work out how I wanted
DSM
DSM
@ZackTarr: unfortunately you can't.
@dsm well thats a damn shame. Im trying to knock out some easy questions to get my rep up and I just feel my comments look ugly so they wont get upvotes haha
You don't get rep for comments.
DSM
DSM
.. aargh, Kevin'd by davidism.
Just answer if you have an answer.
16:48
aaaand if your answer is a comment, then it's not an answer.
And don't answer obvious duplicates. And don't answer with only code.
@BhargavRao I did not know that.
Do you have any comments posted as answers?
@davidism For sure. I will write code but like to only give reference to point the person into learning it on their own a bit.
Yeah, don't do that. If the question is looking for guidance instead of answers, it's a bad question.
Either answer the question or don't.
16:51
@davidism But we still should not write code for them. We need to give them the answer but not spoon feed them right?
@BhargavRao yeah, here is one I was going for. i should have used the answer feature but wanted to continue the comments.
-3
Q: For each word in line, add 1-3000 to the end of it in a new text file

aasI'm not a programmer and I need some help, I need a script that loads a text file with words (1 word in each line) and outputs the words with the numbers 1 to 3000 in the end of each word into a new text file. So if the words are: Okay Thanks It will output: Okay1 Okay2 Okay3 . . . Okay3000 ...

No. Answer the question or don't answer. You're trying to justify answering crap questions and doing people's homework for them. Don't do that.
This is not an answer: stackoverflow.com/a/40924692
@idjaw were you the one who recommended Emilie and Ogden?
@davidism Yeah, your not wrong on that one. I just want to be nicer than the high reps that answered my questions when I started using stack
Don't. You're making the problem worse.
I know it's strange - but we're not here to be nice. Being nice as a side is of course encouraged, but the content should be there first and foremost.
3
Really enjoying this album: madeinheights.bandcamp.com/album/…
16:59
@ZackTarr Those are meant to be comments. Use the "Post Answer" button for answers only. If you post a comment as an answer it takes 6 people to review it and delete it, or 1 mod, who has to go through 1000 posts per day. Don't you think that you're being bad to them? The SO model was made after considering all these.
When I started using stack I had to use 3 accounts because even if I searched for another question matching mine it still was hard for me to find as I didnt know the way to word my questions. Then when I figured Id just post a question my damn account would be blocked haha
So you're saying you're avoiding a question ban right now?
@ZackTarr Can you link those 3 accounts?
From 5 years ago yes. And I have no clue what they are under.
I didnt think there was a way to undo a ban, at least thats how it sounded back then
@BhargavRao thanks for deleting that comment
@ZackTarr you can do it yourself too
Okay so back to the account thing. What was I suppose to do? Just so I know for the future. Hopefully my questions are up to par now.
Well for starters, don't create multiple accounts to avoid a ban.
Okay so how do you get unbanned in the first place?
Edit your posts and make them better.
Provide good content, increase the value of your existing content.
17:07
And especially, do not be a help vampire :D
answer some questions instead.
If you're question-banned, you can answer, edit...
I see. Well I was young and had way less knowledge so I couldnt make it too much better. And I can finally start answering questions but now I feel bad for answering easy ones haha
But I now know to only answer the question, dont try to teach only answer. ;)
You can do both. Explain what was wrong, add some code, explain what your code does / how it fixes the problem.
Now you've both answered the question directly and given insight into the code and problem solving process.
@ZackTarr that's how you get 500k rep :D
Right, I do that now. I probably wasnt the best at it as a freshman in college though. But your right I was just half assing my answes from the looks of it.
@AnttiHaapala Life goals right there. Im on my with my solid 77. :D
@ZackTarr for example the question that you just answered, the question isn't any good - it lacks specifics - what is the OP having problems with, etc...
@ZackTarr you've got 50 rep, so you can comment everywhere... you should ask for clarification in comments instead before jumping into answering
` if (l.find(userstring)>-1):`
instead of this abomination, you should use if userstring in l
and one doesn't even need to use readlines...
17:22
I did that once. But my comment was deleted. I said this question is too broad. Didnt know that was better. And yeah Im sure a lot of what I put out there isnt the best code to high rep standards.
cbg! if I am opening file with this code: with open(file, 'r') as f:, do I need to close it with f.close()?
But that being said Im always happy to see when someone else can post better code. Because then I get to see whats good/bad.
@Grimlock No, it will close once you leave the with block.
@MorganThrapp Great, thanks! :)
No problem.
wim
wim
17:33
@AnttiHaapala I don't understand what it does or why it would be useful. Can you add a description/usage example like pyramid's reify has ?
will do later. reify can only used as a decorator on a class method. this can be used for example for
class Foo():
     attr = something_lazily_calculated()
reify doesn't work there because it doesn't know the name attr.
@davidism yeah. Still listening?
@idjaw I was listening to madeinheights.bandcamp.com/album/…, which is nothing like it but I thought you might enjoy.
For some reason I associated the two even though the styles are completely different.
@davidism thanks! Will definitely check it out when I get back home
Something about the lyrics maybe, I associate Purity Ring with them too.
OK, after getting distracted repeatedly, done with day 4: bitbucket.org/davidism/advent2016/src/…
wim
wim
17:41
@AnttiHaapala on class method? reify works on instance methods
@wim :P reify doc says: "class method decorator"
(of course it is wrong)
wim
wim
@AnttiHaapala something_lazily_calculated will be called at class definition/ import time here
maybe it returns a descriptor , which has a __get__/__set__, but there's nothing lazy about that ...
of course, but it can return a reify_attr-decorated function, say
there is nothing special in what this does, only, that this approach now benefits from __set_name__ in Python 3.6; in previous versions it needs to autodetect the names on the class dictionary (and perhaps fail... hmhmh...)
ah I noticed that it needs to actually go through the mro chain... pfft
wim
wim
ok so is it a descriptor that replaces itself the first time when you access it on an instance ?
replaces itself with what is returned by __get__ ?
yes
and no.
it doesn't replace itself, just shadows on the instance
wim
wim
17:50
what has precedence, instance variable or descriptor protocol
instance variable
that's why it works
wim
wim
try with __repr__ = your_thing()
it will probably do weird shit
probably :D
actually it doesn't do weird shit.
foo.__repr__ will be looked up on the instance.
repr(foo) would use the class attribute always
wim
wim
I don't understand what you expect to pass in wrapped
@Grimlock "It is good practice to use the with keyword when dealing with file objects. This has the advantage that the file is properly closed after its suite finishes, even if an exception is raised on the way." From docs.python.org/2/tutorial/inputoutput.html
17:56
@wim the object instance
perhaps I should call it by some other name
because... this is not a decorator-only... Don't ask anything too difficult, I am battling some other problems ATM :d
wim
wim
it needs a usage example ... it's only clear in your own head what the code is for :P
I tried to use it and got TypeError all over the place
ok
>>> def foo(*args, **kwargs):
...     print('foo called')
...     print(args)
...     print(kwargs)
...     return 'hello world'
...
>>> class A:
...     blah = reify_attr(foo)
...
>>>
>>> a = A()
>>> a.blah
foo called
(<__main__.A object at 0x10868a048>,)
{}
['blah']
'hello world'
>>> a.blah
'hello world'
>>> A.blah
<__main__.reify_attr at 0x108686080>
>>> del a.blah
>>> a.blah
foo called
(<__main__.A object at 0x10868a048>,)
{}
'hello world'
>>> a = A()
>>> vars(a)
{}
>>> a.blah
foo called
(<__main__.A object at 0x108689208>,)
{}
'hello world'
>>> vars(a)
{'blah': 'hello world'}
ok, I think I understand what you're trying to do now
yeah
I should find a better name for it, lazy_attr or something
wim
wim
found a bug
wim
wim
it used the wrong name
18:08
really :? :D
ah :D
it is possible if you assign the same instance in multiple places.
wim
wim
yep
that's exactly what I did
perhaps it should remember the class, hmm
wim
wim
sounds like you are going to give the GC a very hard job
you should be ashamed of yourself! ;)
why don't you export __all__ in your helpers module, and just make the template import * from that
now your modules all has names that appear to come from nowhere, it's hiding the dependencies
@Code-Apprentice wow, TDD for the win !
Yah...for this one it seems better than verifying manually.
wim
wim
yes, I was verifying manually and it did my head in
18:22
and the test cases are simple enough that I just cranked them out really quick.
wim
wim
I lost loads of time by trying to use Counter.most_common
which doesn't work, because for example
>>> Counter('zzbbxxaa').most_common(2)
[('x', 2), ('a', 2)]
Total facepalm when I realised the issue
I wrote my own
not finished yet, though
got stuck on the sorting part. But I figured it out now. Next I'm stuck on string comparisons...
hmmm...had the wrong index for match.group()
wim
wim
18:44
I noticed you starred aocd, did you try using it? Was it working for you?
I haven't tried it yet.
@Wim I used most_common() but could have also used items() github.com/MarcusStuhr/Advent-Of-Code-2016/blob/master/Day%2004/… since it's just sorting the counter anyway
@wim nicee :D
@wim :D because I am super lazy :D
@wim this was the only thing that didn't trip me today :D
cbg @Łukasz!
19:18
Is it possible to run any code after calling unittest.main()?
Yes, if you call unittest.main(exit=False)
@wim so have you done auto submit yet :?
@AndrasDeak cbg
@wim I used most_common, but did the cut-off manually later
@heather OK, but the function I quoted only seemed to set two local variables. Those should be passed back to the caller, otherwise the function isn't doing anything.
19:48
Hi
@wim fixed. I needed the helpers import to also be able to use pycharm
@user312016 hi
ahha :D best aoc system now
pycharm, template file, my helpers, wim's data loader, tiling :D
@vaultah Tnx that is what I needed.
I hope tomorrow's challenge goes back to numpy

« first day (2241 days earlier)      last day (2933 days later) »