« first day (1878 days earlier)      last day (3295 days later) » 
00:00 - 19:0019:00 - 00:00

19:00
So there's a Pavlonian association between anime and "well it's better than hearing what Carol said to Cheryl at last week's yoga class"
Haha. Davidism is who I was thinking of when I said "some of our members...".
I'm just going to leave this here in the most detailed way possible just in case someone picks this up. I have this code in my main py file that loads my instance/config.py shown like this app = Flask(name, instance_relative_config=True) / app.config.from_pyfile('config.py'). This file is gitignored so my secret keys cannot be public on github. The problem is that because it is ignored on github, when I git push heroku master, the file is not found and hence is not loaded.
Here's hoping your most recent edits will satisfy his desire for MCVEs.
well when you have a title like "Chief Executive Flask Answerer at Stack Overflow"....
Yep it's no joke.
The error I see is IOError: [Errno 2] Unable to load configuration file (No such file or directory): '/app/instance/config.py' which could be the gitignore or it could be the way my directory is structured with venv. This post gave me some clues stackoverflow.com/questions/2349991/… and this one as well which davidism helps someone who had a similar problem as me
3
Q: Unable to load configuration file from instance folder when deploying app

Pav SidhuI set up a new virtualenv for my app, to clean up the installed packages. I have a config.py file in the app's instance folder. There are two configs, one for dev in the 'instance' folder and one for production in the root folder. The app worked in the old env, but now I get an error that it c...

Its confusing because Explore Flask Configuration details how to lay it out, but some answers and comments on stackoverflow say something different
So there it is.
And if anyone is really having a slow day at work or bored heres the git repo [email protected]:drubio1989/blackduck_flock.git
19:27
can someone help me write a recursive lambda function? I'm trying to do a function that will put all possible rotations of a string into a list, the most pythonic way possible. What I am thinking right now is a recursive lambda, but I'm having trouble with nested lists that are resulting:

`ycle_transforms = lambda x: [x] if [x[-1] + x[:-1]] == text else [x]+[cycle_transforms(x[-1] + x[:-1])]`
can someone help me write a recursive lambda function? I'm trying to do a function that will put all possible rotations of a string into a list, the most pythonic way possible. What I am thinking right now is a recursive lambda, but I'm having trouble with nested lists that are resulting:

`cycle_transforms = lambda x: [x] if [x[-1] + x[:-1]] == text else [x]+[cycle_transforms(x[-1] + x[:-1])]`
DSM
DSM
Cramming everything into a recursive named lambda (?) is pretty unpythonic. Why do you want to do this?
I swear I'm noticing it (people butchering code by forcing it into lambdas rather than using a normal function) more lately.
@DSM Some people just want to watch the world burn.
Whether this is true, or bias, who knows?
Well I want the prettiest shortest most concise way. If there is a better way, please enlighten me. I am trying to learn functional programming and Python after using Java for a long time and am already pleased with some of the language features such as index slicing.
DSM
DSM
19:30
So you just want "abc" to become "abc", "bca", "cab"?
@AymonFournier that's not pretty at all. It's horrific.
Just use def foo(...):...
'the most pythonic way possible' in this case means 'learn itertools'.
DSM
DSM
>>> s = "abcde"
>>> [s[i:] + s[:i] for i in range(len(s))]
['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd'
19:31
one line != pretty.
thank you, i'm going to go slap myself
Unless you're golfing.
DSM
DSM
You could rotate a deque, I guess, but hardly seems worth the trouble.
Hard mode: write a function that only iterates through unique rotations. Ex. f("abab") yields "abab" and "baba" and then stops.
set(s[i:] + s[:i] for i in range(len(s)))?
19:34
I'm more prepared to blame overuse of recursion than overuse of lambda, myself
DSM, can you explain how you thought of that?
and what the slices mean in reference to the range of the len of the string
@Kevin That sounds almost exactly like that really great cycle-detection problem what ended up being solved by some be_clever(s + s) shenanegans a while ago.
@AymonFournier Simple application of the Feynman Algorithm ;-)
@DSM can you explain how you thought of that?
and what the slices mean in reference to the range of the len of the string

(sorry didn't tag your username last time)
god well the limiting factor is my IQ i guess damn it
Do pings even work in multiline messages? It's been a while since I tried.
DSM
DSM
19:37
@AymonFournier: you can figure out what the slices do by rewriting it as a loop, for i in range(len(s)): print(i, s[i:], s[:i]) and looking at the output.
I'm not sure
but I think they might do @Kevin
who knows?
That pinged me.
Thanks @JonClements
DSM
DSM
@Kevin: I was pinged, anyhow.
@Jon you could have turned that into a haiku so easily.
@AymonFournier this question is also a good reference for using slice notation
19:38
@Ffisegydd bah - long tiring day and all that ;(
DSM
DSM
The Python room officially approves of haiku.
The "how would you do it in real life?" approach seems useful here. You have a string of letters written down on a piece of paper. You have a xerox machine and scissors and tape. What physical actions do you take to get papers with all rotations of the string given to you?
Give it to the intern.
4
:27374019
>>> s = 'abab'
>>> s2 = s + s
>>> s3 = s2[1:]
>>> print(s)
abab
>>> for i in range(s3.find(s)):
...   print(s3[i: i + len(s)])
...
baba
"First I'd make N copies of the paper..." That's a for loop. "Then I'd cut each one between a different letter pair", slicing. "And I'd swap the pieces and tape them together." concatenation.
19:40
[You can surely ping](http://@Kevin)
on multiline messages.
This haiku has ping.
Hmm, can't remember how to secret ping.
Incidentally my computer is usually on mute so it doesn't bother me if you edit a message a bunch and ping me multiple times as a consequence
You need some text in the link I think
I don't think you can do links on multiline messages.
[test](http://www.example.com)
DSM
DSM
example.com was a good idea.
[](http://@Kevin)
I think they fixed it.
19:42
Oh, I see. They only fix the fun bugs.
;___;
Theoretically that's the right syntax.
Bah. Theory is for the weak.
DSM
DSM
;_;
Now if only they could fix the bug where people don't read the rules before they post.
DSM
DSM
19:50
@MorganThrapp: 2*(r>=d*c/2)-1 saves two bytes.
Unfortunately the source code for humans is pretty hard to modify. Insert obligatory xkcd link here.
@DSM I figured there was some fancy math I could do there, I just couldn't figure it out.
Thanks.
DSM
DSM
And I might be miscounting, but I think sum(map(random.randint,[1]*d,[6]*d)) is one tiny byte shorter..
I get one shorter, too. Thanks! I didn't realize you could use map like that.
i just scratched my contact lens out of my eye. my day is not going well.
19:59
This, too, shall pass.
How do you make a regex that can never be matched?
That last change breaks it.
How about "$^"
DSM
DSM
@MorganThrapp: oops, shouldn't it be c and not d?
Yeah. sum(map(random.randint,[1]*c,[d]*c)) works.
DSM
DSM
20:00
Yeah, I wasn't paying much attention to the contents. [1]*c,[d]*c, right? Ah, you beat me to it. :-)
random question, does anybody know if its bad to wear glasses while one contact is still in your eye....
DSM
DSM
I spent some time the other day trying to figure out ways to shave chars off on your imports, but when you only use it once unless the mod name is really long it's hard to win..
Moral of the story: don't put things on your eyeballs.
@DSM Yeah, something like collections might be worth it.
DSM
DSM
I wish you could autoimport a whole bunch of stuff but then you're halfway to Pyth. ;-)
@Kevin so, end before start?
20:02
Hahaha, yeah.
from x import* is worth it sometimes.
@corvid Yeah although I'm worried about multiline inputs.
Don't you have to put in a flag for multiline to be enabled?
How about you negate a regex that matches everything. Something like:
>>> import re
>>> pattern = re.compile("(?!.*?)")
>>> pattern.match("Hello") is None
True
>>> pattern.match("") is None
True
>>> pattern.match("Lorem ipsum dolor sit amet") is None
True
I'm not super proficient at lookaheads so I don't know if it truly matches nothing
Can we make it illegal to write code without a max timeout? I've been waiting for this report to run for an hour now. I know it threw an error, because it should only take 30 seconds, but it won't tell me what the error is, because it just keeps trying until I kill it.
And no, there is no logging.
@RNar I assume it's much like wearing someone else's glasses whose prescription doesn't match yours. Google suggests that doing that probably won't permanently injure you.
However I'm not sure how trustworthy the Fort Lauderdale Eye Institute is, since they couldn't spell "staring" correctly in the next FAQ entry.
DSM
DSM
20:15
One more day down! Three to go.
well according to Sam the optometrist, it will cause no harm
and I only have to stick it out for the next 6 hours so I'm just going to deal with it
If you wear glasses with the wrong vision, it does mess up your vision but only in the short term. (According to my eye doctor).
Context: My backup pair of glasses had the right and left lenses mixed up.
hey guys, I'm having some issues with class inheritance when dynamically creating a class with type('C', (MyBase,), {}) method. After creating my new C class it doesn't seem to have any __bases__ even though I've specified MyBase as its base class... I'm sure I'm missing something... can anyone help point me in the right direction?
Wild guess: try type('C', (MyBase,), {})
DSM
DSM
Two to go.
20:22
this is fun because now if I'm somehow blocking my left eye, I can see clearer
I think I shall take another crack at Advent of Code #6. or 5. Whichever one I was doing this morning.
@Kevin I removed the quote, sorry for the typo
I ended up with a run time of about 25s but I think I can do better if I get fancy.
I shoot I havent done the new ones yet
7 just looks like a language parser...
@sadmicrowave That's odd, it works on my machine.
>>> class MyBase:
...     pass
...
>>> C = type('C', (MyBase,), {})
>>> C.__bases__
(<class '__main__.MyBase'>,)
@RNar That's part of it, yes.
DSM
DSM
20:28
Day 6 is done. Only one to go!
Is there a word that's like "bisect", but for four pieces instead of two? I could use "quarter" but I don't like that it's also a noun.
DSM
DSM
quadrisect?
bibisect.
I wasn't sure quadrisect was an actual word, but on the other hand, when has that ever stopped me.
Descriptivism forever!
Hmmm, working on day 5 part 2 and I'm getting 9. This seems wrong. :/
20:32
@Kevin, true, my root cause must be wrong, but I'm running into the error `TypeError: super(type, obj): obj must be an instance or subtype of type` when I try to call `super().__init__(...)` within my new class:

def __constructor__(self, n, d, c, h):
	super().__init__(name=n, description=d, cost=c, hp=h)

item = type('C', (MyBase,), {'__init__':__constructor__})
user559633
Descriptivism forever or until it is no longer in fashion.
I was thinking it was because my __bases__ wasn't propagating, but it appears to be...
Is there a good way to do this? if (x = re_on.match(line)):? I want to assign-and-test x
Preferably in the if-statement.
I'm slightly embarrassed to admit I know virtually nothing about how super works.
I know I can x=... if(x)
20:36
lol darn
@QuestionC I don't think so. if conditions can only contain expressions, and assignment isn't an expression.
for advent of code 5, does having 3 vowels mean 3 distinct vowels or 3 of any vowels? like is aaa a valid string?
Maybe you could do something hacky with globals or locals but then you have to question if it's really worth it
Hey, Kevin (or anyone else). Do you still have your solution to day 5 part 2 around? I need more test cases to figure out what I'm doing wrong. :/
@RNar 3 of any vowels.
20:37
@RNar 3 of any vowel, so yes.
mkay thanks
@MorganThrapp Yeah here it is.
DSM
DSM
Ooh, I missed the two-letter aspect of day 7.
Bah, and now it's meeting time. :-/
Fortunately I started recording solutions on day 5. 4 and lower are lost to the sands of time.
Well, you could probably find a couple on pastebin while I was doing some light code golfing with Peter and Poke.
But I don't know where they are personally. They are lost to the sands of Kevin.
Ah, thanks. Found the bug in my implementation.
20:47
@Kevin, just incase you're interested in following or answering: stackoverflow.com/questions/34142895/…
@sadmicrowave Do you give a lot of bounties or something? You have 6k rep, but 22 gold badges.
no, I hardly give any bounties
user559633
@QuestionC questions
My time is short today, but I'll take a look when I can
no worries, just wanted to close the loop. Thanks for offering some insight
20:54
ok....... No java devs here; but if (a != null && b != null) does mean that a & b are both non null right? In like any language
yes
user559633
@paul23 depends on binding precedence, but typically
user559633
if you're using java, you probably want the nullfactory pattern fwiw
You could theoretically make a language where the operators have a different precedence than normal, but that seems very unlikely -- whoops tristan beat me to it
Well that's just weird:
user559633
20:57
bro no one wants to look at your java screenshot
This is during a debug run, where it stopped at a breakpoint (selected line). I'm really really wondering why the hell that line is now executed.
:P
To SO we shall go!
user559633
( ಠ_ಠ)
user559633
Whatever that was, keep it out of here.
I would really like a module that prints interesting factoids during long-running python methods.
user559633
21:04
dad_jokes.py
Could you do that? Like make a module that on import just starts a thread and it periodically checks to see if anything has been put out on stdout in the last 10 seconds, and if not, tells a little joke?

I'm mainly asking re: being able to see if stdout has been used in the last 10 seconds.
user559633
10%
...reticulating splines..
20%
>>> I used to have a shampoo addiction
30%
...flobbing bars....
40%
50%
60%
>>> ..but I'm clean now
70%
Traceback (most recent call last):
    you are bad at coding
I'm sure you could.
user559633
for feasibility, dad_jokeswould need to fork a different thread because of the gil, but sure
is len(set(list)) != len(list) the most efficient way to find if there is duplicates in a list or is there a better way
user559633
21:10
@RNar there has to be a better way!
user559633
depends on list depth and some other factors
I usually just do len(set(list)) != len(list). It's not too shabby, complexity wise.
IIRC Set construction is O(N) in the average case, so it's O(N) overall.
user559633
I typically just go sit next to whomever is making duplicate data and stare intensely until he makes it better
user559633
an any() approach will have to walk it, but it's a slower o(n) than set + cmp len
thats what i was thinking, something like any(x in list[index:] for i,x in enum(list)) would be slower wouldnt it?
21:14
@RNar are you looking to see if the list is unique or if any element occurs more than once?
if any element occurs more than once
I guess you need to profile to really know, but I'm a fan of...
seen = set()
for a in list:
  if a in seen:
    return false
  else
    seen.append(a)
return true
Maybe make it shorter/better if you can append-and-test-for-dupe simultaneously with python sets.
@Question "better" as in less readable/more unclear?
@QuestionC set doesnt have append (probably meant add) but yeah the non-greediness would be more efficient
last = -1
seen = set()
while last < len(seen):
    for thing in lst:
        seen.add(thing)
        last += 1
    return True
return False
21:21
@JonClements Better in the sense that a in seen and seen.add(a) are blatantly doing the same work twice. Test-and-insert is a common/normal set operation to me at least.
as close as I can make it
and ew
@RNar This is deep in should-profile land. I wouldn't be surprised if your original approach was ideal.
no wait
that doesn't work
argh and it's too late to delete, now my quick fingers and slow wit shall forever be a testament to my thoughtlessness
i think in terms of efficiency, yours is technically slightly better because of the possibility of the early return but on average, yeah my original would be the same ish
@Question well clearly, you want: any(filter(lambda L, s=set(): L in s or s.add(L), iterable)) for Python 3.x anyway :p
21:24
ouch
way to abuse set.add -> None
@JonClements I think we're talking different issues here. There's some redundancy in searching a set for an element and then conditionally inserting that element into the set. That's what I mean by 'better'.
user559633
depends on if the search is likely to find duplicates or not :)
we'd need set.setdefault
:)
Besides - I haven't written a one liner for a while - felt I was missing out :)
21:30
Grrrrrr, OP, why can't you just write your actual question in the post.
I think I may favor web approaches too much because they're so much easier to write
my co-worker asked me for some help on a non-work-related project
he's designing a database for a local non-profit and they're trying to get their volunteers to enter their data, rather than having hundreds or thousands of sheets of paper, etc.
Hi, I'm need a little help reordering this json data:

`[{"aName":{"name":"somename","vendor":"vendor1"}},{"bName":{"name":"somename","vendor":"vendor2"}},{"cName":{"name":"othername","vendor":"vendor1"}}]`

I need re order it like

`[{"vendor1":[{"name":"somename","id":"aName"},{"name":"othername","id":"cName"}]},{"vendor2":[{"name":"somename","id":"bName"}]}]`

it been a little hard to group all data with the same vendor name. I did in a way where isn't efficient because I use many loops.
stackoverflow.com/questions/34143444/… needs MCVE. They posted what looked like a valid question, only to reveal in comments that they need something completely different.
for i in old_format:
  if 'vendor' in i:
    new_format[vendor].append(i)
  else:
    new_format['novendor'].append(i)
@GEPD ???
TODO: Remove vendor from nodes added to new_format; deal with weird nesting cases on your input JSON, add JSON reading/dumping code.
the non-profit agreed to buy android tablets for kiosks. Co-worker wanted me to design an android app (if I was interested) while he built a database for it to connect to
but screw that, I don't wanna write an android app. Just build a web server that talks to a mysql database :P
DSM
DSM
21:39
@Kevin: you still around?
@QuestionC this line new_format['novendor'].append(i) is to add the data in a vendor already added?
@GEPD It's just to handle the edge case that you have a node which has no vendor. You could put an exception throw there or something.
Your output format is built on the assumption that each node has a vendor attribute, but your input format does not have that assumption.
DSM
DSM
@QuestionC: do you mean new_format[i["vendor"]]?
@DSM Yes. Thank you.
@QuestionC yes, each node in the input format has a vendor attribute
21:47
@GEPD Then you want an exception or some other noisy error to happen.
for i in old_format:
  new_format.get(i['vendor'], []).append(i)
  # TODO: Potentially remove vendor element from i before adding it to new_format
I think that works? It'll give you a keyerror if your input data doesn't have 'vendor' as an attribute.
You know about the JSON module too right?
@QuestionC not in deep, there is a special function I should read about it?
Just dump(s) and load(s), and understanding how python dictionary/lists map to the corresponding JSON objects.
@QuestionC Did you mean new_format.setdefault(i['vendor'], []).append(i) ?
Looks like store.steampowered.com/app/409160 might be worth 15/20 mins or whatever
Huh, looks like fun. I'll have to try it tonight.
I'll stop posting advice without actually running it in the interpreter.
22:07
Doing some quick test new_format.setdefault(i['vendor'], []).append(i) it seems to be the solution
22:18
it's the solution, now I've one more question, how should I add a new node in addition to the vendor? to have:

`[{"vendor1":"{...}","id":"id_vendor1"},{"vendor2":"{...}","id":"id_vendor2"}]`
it not seems to work new_format[i[vendor]].apped({"name":"somename"})
23:11
Hello
cbg
python 3 problem. I have a TemporaryFile(mode='w+t') but now I need to pass forward a binary file, what is the cleanest way? this is POSIX, anything better beyond dup + os.fdopen
the ref to the original will be dropped; so it is quite possible that the handle would be closed
What does pass forward mean?
returned from a function
stupid me, NamedTemporaryFile
Hmmm, looks like I need to buy a new hard drive soon. I'm running out of space. Anyone have brand recommendations for something in the 2TB area?
is python very popular lately in the development world? It seems like it's been less popular lately
23:25
It's the most popular language in schools so... probably?
Really? My school only had java and javascript
Java was the previous champ for a very long time.
It's very popular in my head.
@JonClements Stanley Parable remains the best example of a game I didn't want to play until I played it.
My school only had HTML and CSS (in one class), but I already knew those (and JavaScript) by the time I was allowed to take them. Online I only really talk to one other programmer on a regular basis, and we mostly use Python.
23:31
Web dev school?
@MorganThrapp isn't 2TB now small?
High school, sorry. I'm 18.
@AnttiHaapala Well, I have 2TB right now, and I only have about 300GB free, so I want to throw another 2TB at it.
It's my home media/game server.
@MorganThrapp 300GB free
my media disk is always like 3GB free
and stays at that :D
Actually, yeah, it's more like 200. It's over two drives.
@AnttiHaapala If that, it actually might be a little smaller. And that's because I just cleared a bunch of stuff out.
Yeah, I just deleted the installation media from a couple games and cleared plex's cache and cleared 100GB. So I guess it's not as urgent, but I still want one. :P
23:36
My bot really needs rebuilt, but I'm having trouble figuring out how I want to organize everything. haha
Maybe I should even go higher than 2TB.
I really want to just pick up a NAS at some point soon.
23:47
@MorganThrapp Trying to get a non-profit I consult for to pick up a low-end NAS. They're balking at the price tag
but they want to have an iTunes library that's synced between all their devices on-network (it's a performing arts theater / dance studio)
and that's not really doable without something there to sync it
Hmm.. How can I have a module, parent module, and the parent's parent all share one requests.Session()?
Wait.. I was confusing myself with something else. Never mind.
00:00 - 19:0019:00 - 00:00

« first day (1878 days earlier)      last day (3295 days later) »