Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Feb 27, 2016 22:27
Both great movies, I'm just more of a shawshank fan if I had to choose.
Feb 27, 2016 22:26
Not better than shawshank, come on the plot alone takes it.
Feb 27, 2016 22:18
tell me about it. I've tried and tried to make that "always" not 100%. I argued once with mine..... once...
Feb 27, 2016 22:17
@idjaw you went for a walk, that's your first mistake ;)
Feb 27, 2016 22:09
Any of you awesome people have suggestions for app hosting? heroku/webfaction/digitalocean/etc. ? python 3.5 and postgres really all I need.
Feb 26, 2016 15:38
trying to get this thing up in the world for some coworkers to test, etc.
Feb 26, 2016 15:38
@corvid it's ok :D TY for looking at least. I appreciate it
Feb 26, 2016 15:12
@corvid I've used it with running an app in the root. but I've restructured my app int a sub folder. so TestApp/main/__init__.py has my "app" initialization. I tried doing "web: gunicorn main.__init__:app" but that failes. wasn't sure if it doesn't like subfolder?
Feb 26, 2016 15:04
Anyone familiar with heroku Procfile syntax?
Feb 26, 2016 14:45
lol
Feb 26, 2016 14:41
This is the same stupid json api crap I've been dealing with all week. I think it's more just my lack of understanding json/dictionaries/nested information. I've basically given up on actually making use of the json and just feel like dumping the entire request into a DB and just talking to it instead lol.
Feb 26, 2016 14:38
My flask view has 2 nested loops inside a main loop, and then AFTER rendering, the template has 3 loops nested inside another loop. LOL I'm a super coder apparently
Feb 26, 2016 14:36
@idjaw you would cry if you saw my code lol
Feb 26, 2016 02:27
Has anyone had experience with API requests and dealing with separate requests based on the initial one? Like you request something, get JSON back and then while looping through that JSON you make another request during each loop? Suggestions on alternative, or maybe more efficient structure.
Feb 24, 2016 22:30
makes way more sense now, the defaultdict sets the key if it's missing initially.
Feb 24, 2016 22:28
I'm very new to working with data especially from an API in JSON.
Feb 24, 2016 22:25
this is why I need to actually learn pandas I think. I'm trying to deal with complex data and using a spoon to build from it.
Feb 24, 2016 22:24
ohhhhh wait yeah I see what you're saying now. use Counter as the default.
Feb 24, 2016 22:23
@DSM but that's only dealing with single nests. I'm having to build down into {'Fred':{'S':0,'M':4,'L':0}} so and so forth
Feb 24, 2016 22:22
would I even need to use counter at all though. it's the only solution I've seen to keep adding values while creating the keys initially.
Feb 24, 2016 22:19
I've tried, Counter(), and defaultdict() and apparently butchered both into the ground
Feb 24, 2016 22:19
@JGreenwell fill a dictionary with key:value pairs as the 'first_name'{story_size: minutes_spent} and continue to increase the minutes_spent value each time as it loops through the data.
Feb 24, 2016 22:10
@Arden yeah TK was my first thought. :(
Feb 24, 2016 22:04
@Arden Would that not be just using a python gui library and just load the program inside the window
Feb 24, 2016 21:57
@Kevin I think I've managed to take your suggestion and literally butcher it into the ground lol
Feb 24, 2016 21:57
nested = defaultdict(int)
developers = Counter(nested())
developers[y['user']['first_name']][story_size] += y['minutes_spent']
Feb 24, 2016 21:51
ugh, defaultdict is going to be the death of me. It refuses to work with Count() lol
Feb 24, 2016 18:39
Anyone else notice that recently every day there's some new random.js library that's trending for Python web front end use lol
Feb 24, 2016 14:42
JSON: [{'project_slug': 'test', 'project_id': 19855, 'date': '2016-02-11', 'task_name': None, 'iteration_name': 'test', 'notes': '', 'user_id': 81946, 'story_id': 392435, 'iteration_id': 76693, 'story_name': 'test', 'user': {'id': 81946, 'last_name': 'test', 'first_name': 'user1', 'email': 'test', 'username': 'test'}, 'project_name': 'Development', 'id': 38231, 'minutes_spent': 240}]

As you can see the json will get looped through and the 'first_name' will get pulled. the static variable is set outside of JSON as whatever we can call it variable = "foo".
Feb 24, 2016 14:36
@InbarRose sure let me get some test data for you.
Feb 24, 2016 14:32
whoops *not allowed
Feb 24, 2016 14:32
Can a nested dictionary be created from multiple variables? ie: mydict[json['var']['info']][variable] = "foo" , end result [{'info':{'variable':foo}}]. I'm thinking that it's now allowed since you are trying to combine an iterable object with a static object, I could be wrong.
 
Apr 13, 2015 13:51
@PadraicCunningham I moved from koding.com to a local OSX box and it works fine. So it has to be something specific to the linux system that runs on the site. I'll stick to a local unix system for now so I can get testing done.
Apr 13, 2015 13:51
pastebin.com/6xmtCVEU , this is the code that spits out - Kйкаs Т Yazuki
Apr 13, 2015 13:51
Correct, I printed the json data out before pulling the data and printing specifics. that was the output right before (Kйкаs, Т, Yazuki).
Apr 13, 2015 13:51
{u'rankings': [{u'name': u'Kecks'}, {u'name': u'\u0422\u044d\u0439\u043a\u0430\u0445\u0445}, {u'name': u'Yazuki'}] Total: 508 Kйкаs Т Yazuki
Apr 13, 2015 13:51
after the export, I now get a print output of (Kйкаs, Т, Yazuki) instead of (Kecks, Тэйкахх, Yazuki)
Apr 13, 2015 13:51
same error as before with the above print statement.
Apr 13, 2015 13:51
>>> import locale;locale.getpreferredencoding() 'ANSI_X3.4-1968'
Apr 13, 2015 13:51
Linux Ubuntu 14.x, this is on the cloud IDE at Koding.com
Apr 13, 2015 13:51
print u"\u0421\u0432\u0435\u0436\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0414\u0443\u0448" UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
Apr 13, 2015 13:51
doing a print rank_name.decode('utf8') fails, along with decode('utf-8'). Wouldn't it already be unicode so I'd need to re-encode?
Apr 13, 2015 13:51
It's in the source above, "name": "\u0422\u044d\u0439\u043a\u0430\u0445\u0445". I set these a variable in the code above for example rank_name. and then print them out to test that it's working. I just need a way to see what the value actually is when it is printed / returned instead of the raw unicode.
Apr 13, 2015 13:51
that's a good idea for processing, but still not sure how to get it to print afterwards.