« first day (1410 days earlier)      last day (3541 days later) » 
04:00 - 17:0017:00 - 00:00

4:37 AM
Heyy I'm working with datetime and pandas right now and seem to figure out how to create a new column with the difference between today and a series of dates
 
 
3 hours later…
7:25 AM
Cbg
 
7:38 AM
C to the B to the G
 
Can I get the file extension from the mime type string in python
expecting = image/jpeg = > .jpg
 
@gowri given that exact example, how would that work? Should it return .jpeg or .jpg?
 
any one may be .jpeg
Now I am doing stupid code
`
                    if mime_type == "image/jpeg":
                        ext = ".jpg"
                    elif mime_type == "image/png":
                        ext = ".png"
                    elif mime_type == "image/pdf":
                        ext = ".pdf" `
 
7:55 AM
In [5]: mimetypes.guess_all_extensions('image/jpeg')
Out[5]: ['.jpe', '.jpg', '.jpeg']
 
Hi
 
@vaultah: great! that's what I want, thanks!!!
 
Hi devs... I'm iOS dev
and need help in python
Just trying to write a script for chat for ios app.
I'm facing problem in indentation in python ..
 
Indentation in python follows the rule n * m, where n is a fixed number of spaces and m is an indentation level
 
Yes reading doc ... now
@vaultah - Can you please have a look into my code ?
I have one query ...
 
8:15 AM
I advise you to use either tabs or spaces (better) for indentation but not both. I fixed your indentation, now it should work
 
Thank you .... Actually it is working as it is.... I want to add few lines of code into it and then it gives me indent error....
it is giving error..... while with single line it runs
I just added self.factory.userids.append('123') extra
 
You're mixing tabs with spaces
 
ok try to check
Thank you once again
Yes ..... I removed all the white spaces and used tabs ... and its working :)
 
8:40 AM
heya!cbg all
 
8:54 AM
cbg()
@TheTiger Best practice is to use spaces only.
as using tabs can easily hide spaces on the same line, causing all sorts of problems.
 
9:13 AM
cbg
 
9:35 AM
@MartijnPieters - Ok .... Will keep it in mind :)
 
Morning all
 
@IntrepidBrit cbg... I quite enjoyed watching Eyebrows & "The Other Strange Looking Man" talk over each other last night :)
 
I didn't see them. Was stuck in the office. Now looking to rerun what sounds like a bloody farce of a debate...
 
It started off okay, started to go downhill, then really went downhill after the cross-examing
 
Always tends to with Salmond to be honest
 
9:42 AM
I cracked open a beer and a bag of popcorn... it was good entertainment value...
 
He's an excellent tubthumper
Entertainment for you maybe ;)
 
Well, apparently 79% (or 71% - whichever poll you choose) seem to think that the tubthumper came off better
 
Wheee, a double Mojibake with question-mark substitution.
 
Well, we'll I'll see. His last performance was a bit gash
 
e.g. a fun puzzle to guess the original intended character after it went through several runs in the UTF-8-as-Latin-1 washer.
 
9:45 AM
@Martijn Mojibake sounds like a pokemon
 
Urgh, this iPlayer video is buggered
 
Microsoft rejected my resume, again... Sigh
 
@thefourtheye how desperate are you if you want to work with M$!!!
 
I used to be a MS fan boy, before the Linux bad boys beaten me up :(
still secretly loves Microsoft
 
Ah yes. Let the strawmanning begin!
 
9:55 AM
@JonClements same Japanese cultural background, so I can imagine.
To repair, run one of the two variants through CP1252, then decode as UTF-8, encode again as Latin-1, then decode again as UTF-8 to get the original character. Pfwew.
u'\xc3\u201a\xc2\xa0'.encode('cp1252').decode('utf8').encode('latin1').decode('utf8')
Oh, after substituting the   HTML entity with \x0a first, of course.
 
@Martijn ooo... have you seen the new Admin page (sopython)
Very nice to see who's on the approved list
 
Not until you mentioned it, no!
 
How to see that puppy?
 
\o/ I am now part of the in-crowd!
 
@thefourtheye go to sopython and login, then you'll get an Admin link
 
10:05 AM
Cool
 
YAM OFF. Scotland's NHS is ALREADY being privatised in Scotland! OPEN YOUR YAMMING EYES
coughs
 
cbg @Daniel
 
cbg()
Done.
 
cbg()
@MartijnPieters sounds like some kind of magic incantation
 
10:31 AM
@Martijn kinda getting a feeling they're after something like print(format('5.5', '0>20'))
 
@JonClements Which is what str.zfill() does..
 
@Martijn hopefully they'll reply to a comment - be nice to know what they're actually trying to do :)
 
I can use format() with '0>3' too if you really like.
 
@Amogh please don't link your newly asked questions into the room, please see sopython.com/pages/chatroom (same link I gave you yesterday...) for the chatroom rules.
 
@Martijn I'm not aware of any sorting software these days that isn't able to sort on a numerical value anywhere... so not convinced it's a practical exercise
 
10:35 AM
1 message moved to Trash
 
@Ffisegydd: Ok.
Is there anyone who know if there is a way to configure Django Rest Framework to store token information in Redis rather than the Database?
@Ffisegydd this looks better ?
 
Okay... so what happens if I attempt to remove myself from the approved group?
 
@Ffisegydd : Have you seen the rule no 1 ? it says "Be nice."
 
@Amogh what's your point? Have I been "not nice" at all to you? I've told you the rules and nothing more.
 
@JonClements I managed to remove myself from approved group :D
 
10:42 AM
@vaultah ahhh okies
 
So, this works
 
okay... better see if adding back works...
 
I added @IntrepidBrit so it should do
 
That was a mistake
What power do I have?
 
Yup... it does
 
10:43 AM
You can add/edit/delete wikis
And can add/edit/delete canonical questions
Don't delete anything unless you're really sure as we don't have version control yet
 
@IntrepidBrit it means that when England buys back Scotland after its completely failure for something like a fiver, we'll let you run it
 
@Ffisegydd Roger that. Knowing me, I'll probably nitpick at everyone's grammar
 
@MartijnPieters Regarding the 5000 times doing the string concat answer, Strings are not supposed show any difference, right?
 
@JonClements If Scotland goes Independent, it won't go bankrupt and even if it did, it wouldn't come back to the rUK for help
 
I ran a quick timeit test and the result is almost the same
 
10:45 AM
It's just a matter of how well we do Independent
 
@thefourtheye I think there were some optimisations, I asked the OP for the Python version.
 
(Appreciate the quasi-dictator support though)
 
@IntrepidBrit nit-picking at grammar, any other obvious mistakes, or enhancements to canonical posts and taglines... please feel more than free to do so!
 
This ice thing is ridiculous.
 
10:56 AM
If you're going to choose a name... hardly the best choice...
 
@Ffisegydd Hey, it's actually working. Can't fault it
 
Just cause I can't doesn't mean I won't.
 
@Ffisegydd it'd be awesome if I could share a mate of mine's FB post - he did it in style... made me laugh
He's locked it to direct friends only
 
@JonClements Urgh. And so we see British political debate sliding into the same sort of pish as American political debate.
 
I want that bloke...
 
11:12 AM
I prefer the "Rent is Too Damn High" guy
I take that back.
The last 10 seconds won me over
He now ranks above the Penguin who beat the Lib Dems
 
11:30 AM
Did I ever mention that I hate moving house.
 
@Ffisegydd once or twice - would you like to mention it again?
 
@JonClements That's a punalicious speech!
 
Yes @Jon. Yes I would.
I hate moving house.
 
@Ffisegydd are you trying to make a point or something? It almost seems like you're saying you hate moving house? Is that correct?
 
Funnily enough that is exactly my point. I hate moving house. Good question, now next question in The Great Moving House Debate?
 
11:39 AM
You haven't answered my question Mr @Ffisegydd. Do you hate moving house, or just idly detest it?
 
What an excellent question! I hate the process of packing all of my worldly belongings into suitcases then having to move them and then unpack them.
 
Why do you AVOID my question?!
 
@IntrepidBrit what question were you asking... about whatever @Ffisegydd what stating?
It was something to do moving and a house or something
I imagine it's quite hard to put a house on the back of a vehicle and transport it...
 
depends on the house...
 
Well, my Kennel's quite easy to move to be honest :)
cbg @Paolo - how ya doing?
 
11:46 AM
inflatable houses are easy too.. :D
cbg @jon :) all fine thanks! :)
@jon this morning i read about nidaba.. cool! :)
 
@IntrepidBrit Because you are the enemy.
 
@Paolo well... it's been a long time in the talking about... but we finally have a team that's bothering to do something about it -so...
 
See! Mr @Ffisegydd is a FASCIST and he hates me, he hates you, and by God, he hates 'Merica.
 
12:02 PM
@thefourtheye: Bingo!
I coaxed the real change out of the OP.
 
@martijn ?
 
12:18 PM
2
A: Why is variable1 += variable2 much faster than variable1 = variable1 + variable2?

Martijn PietersThis isn't about using inplace += versus + binary add. You didn't tell us the whole story. Your original version concatenated 3 strings, not just two: sTable = sTable + '\n' + sRow # simplified, sRow is a function call Python tries to help out and optimises string concatenation; both when usi...

Rewritten to explain what is going on.
The OP claimed a 50% increase in speed when replacing str1 = str1 + str2 with str1 += str2.
But it was really str1 = str1 + str2 + str3.
 
Final closing statement on the Scottish Independence Debate: "What a waste of everyone's time. Again."
(And I'll shut up about for 3 weeks unless someone wants to talk to me about it ;) )
 
1 message moved to Trash can
1 message moved to Trash can
Can't even move them to the trashcan..
4
Q: Feeds user has gone crazy

ProgramFOXIf we post any message (both in Tavern on the Meta and Shadow's Den, and also the chat.SE Sandbox, probably more rooms), the Feeds user replies "this is why we can't have nice things". Can this please be fixed?

translate: rot op feed bot
 
12:40 PM
@MartijnPieters should retag that rather than some of the useless tags that are there now
cool answer
 
@davidism done.
Even if that costs me my 16-votes-per-answer average.
:-P
 
I'm not a fan of brownnosing, but that's the sort of answer I came to SO for Martijn
GJ
 
@Martijn don't we have a dupe for this
wb @rlemon
 
@JonClements sorry, lunch.
rbrb
 
@Martijn no worries - nice of you to offer - I'll have a tuna and cucumber sandwich thanks :)
 
1:15 PM
"An invitation to participate in a Google Apps survey". Lucky me.
 
"Can I remove myself from the approved group?" Should have expected that... :-]
 
:P
I tried to add IntrepidBrit twice to see if he got super super powers but he did not.
 
@MartijnPieters looks like neither of us made the AirConf "highlight reel" :-(
 
@Ffisegydd Hey! I already HAVE super powers
 
Yeah but don't you want SUPER SUPER powers?
 
1:24 PM
... yes. Yes I do
 
@MartijnPieters Awesome, now you got my +1 ;)
 
1:39 PM
why are questions wrongly marked duplicate sometimes? the solution was already tried. think it should be reopened? stackoverflow.com/questions/25497198/php-time-is-1-hour-off
 
That's a php question
 
why good morning friends
 
ah jeez, sorry hah
 
:P
 
i normally program python, but stepped into php for a small script :D
 
1:42 PM
Ewwww
 
@corvid your changes are now live it would appear
 
oh cool, apparently I'm an approved user
 
Yes @corvid cheers for that
You are.
 
@macdonjo I can't answer the question, because php, but did you consider that a) it's daylight savings time right now, and b) your timezone info may not be up to date with the latest politics?
 
Oh, davidism your interface HTML is WAY better
 
1:44 PM
@corvid it's truly appreciated you put the effort in (never mind @davidism had to do a couple of bits, point stuff out) - but hopefully you've learned a lot... and it's all cool now... so thank you very much
 
thank you, it was a good learning experience
 
@Jon he was already asking what ticket he should aim for next :P
 
Oh yeah, it's definitely appreciated. I'm just a stickler for consistency, and already know the code, so it's easy for me to see that stuff.
 
Well... I haven't raised one, but I'd quite like to see our little python/stackoverflow cross logo next to "sopython" on the header bar
 
I was thinking -- is there logging on the site? It might be good, if a user was added or removed, that it logged who did it and when. like 9:23AM corvid added blah to approved group
 
1:46 PM
@corvid I imagine that'd be a greater part of a revision control
 
Yep, if I ever get history implemented...
 
history? Is this something different than a plain python-based logger?
 
@davidism simplest solution is to put a trigger on the DB itself...
But like I said, I'll be writing something up this week regarding what approaches we can take regarding moving forward with the database etc... (but mostly on the nidaba side)
 
Add MyTableHistory for each table, a foreign key to the real record, a timestamp, and a user. View revisions, rollback. Lots to do, probably will also tie into a python logger as well.
one step at a time though
 
@DanielRoseman Meep!
Ah well.
 
1:53 PM
@davidism also other ways to do such things... let's hold off on that until you review what I've written and we collaborate from there
Any particular reason we're sorting by user ID instead of lower cased name or something for the groups page? It all fits on one screen... but seems a little bit of a weird sorting order for scrolling up/down and checking if someone's there
 
The name can change, the id stays the same. I can change it.
 
@IntrepidBrit here's one you can work at changing: sopython.com/canon/16
@davidism indeed... if I'm going through my phone book to find someone, I don't look by number, I look by name...
it's a pedant thing, and since it all fits in one screen anyway, it doesn't matter, as it's perfectly possible to use the avatar pictures to immediately identify
 
I like that explanation. I'll make the change.
gotta fix this bug first:
In Progress on sopython-site
This commit changed how the app context is set up. https://github.com/mitsuhiko/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8 Update flask and click and get this working again.
 
Huh, when you change the sorting method, my position in the list will remain the same :P
 
@davidism it's not important - put it down under "nice to have"... :)
(the sorting thing - not the bug)
 
2:08 PM
Table everything, Jon wants sorting!
 
@davidism I had that same problem yesterday
I think you can use load_app() or something. There was something in the documentation about it
 
you can install the archive before that commit for now
 
@JonClements Hmmmmmmm?
 
@IntrepidBrit both 2.x and 3.x compatible as the example?
The example provided also will break on a StopIteration on a 0-len iterable
The answer it links to is perfectly fine but the example demonstrated on our site isn't great
 
2:19 PM
Gonna add the ability to get answers by tag(s) on sopython.com/canon/?
 
Yeah it's on the list
And a search function
 
that's what I'm doing after this bug
 
I feel like there must be a flask extension for making searching a db column reeeeally easy
 
@vaultah what am I supposed to be looking at?
 
2:26 PM
Those docs are awesome, cheers @davidism
 
@Jon, got it wrong, forget it :)
 
CLIENT PROJECT DEPLOYED! WOOT WOOT!
appears to be working
hopefully 6 months of hell interesting constantly shifting requirement changes over
Do we not have a @Kevin today?
 
2:46 PM
He's hiding.
 
Well done @JonClements
 
Back. I need to stop closing the tab
@JonClements Will knuckle down to it this evening after family meal and mini-deadline is done
 
3:11 PM
@JonClements There is another type of requirements than constantly shape-shifting beasts?
 
@JonClements Only for a short while. Busy day today.
 
2 answers. Why would anyone answer this?
 
This PDF rendering task keeps revealing new facets of complexity. I thought I'd be able to query the database once and slot in the data without additional processing, but now I see a GroupSelectionFormula field, which filters out rows based on some complex criteria.
So I guess I need to reverse-engineer this field's mini language and write a parser for it? Auuuugh
Or I could go through the dozen input files and modify each one by hand so it has no group selection formula, instead incorporating that logic into the main SQL query. Should only take thirty minutes each. Also auuuuuugh
 
@vaultah Because it is easy to help someone that obviously needs the pointer.
 
3:24 PM
Sure thing
 
For simple typo questions I always both vote to close and provide a quick answer pointing out the error.
 
These questions get downvotes. Posting an answer with a positive score won't let asker to delete the downvoted question. Downvotes stay with person forever.
Easy rep, yeah. I'll definitely start answering questions like this.
Or maybe I should start answering give-me-code questions as well? They're easy.
 
3:40 PM
@Kevin wow... just played a hand of magic with almost perfect cards again
2 "you may play an additional land", 2 rampant growth, and 3 lands
followed by a titan and an anhillator
that was a quick game
finished portal 2 in both single and multi player
New civ in 6 weeks it is then
 
Civ 6 is gonna be immense.
 
4:08 PM
Blech. Looks like Blade Runner II is actually going to happen :-(
 
translate: dit werkt nu weer, toch?
Obviously not.
Ah, indeed, it's been disabled for now, perhaps forever.
@ZeroPiraeus I'll reserve judgement until it is out.
@Ffisegydd Wait, that cat is winning?
 
@MartijnPieters 1. Deckard will be 35 years older, which makes no sense whatsoever in the context of the original. 2. Prometheus.
 
@ZeroPiraeus point 1 is only relevant if Dekard actually was a replicant, which is purposely left unresolved.
 
It really isn't :-P
 
@ZeroPiraeus as long as Ford is not going to try and look just the same, just 35 years on, I'm looking forward to it.
That already didn't work in the last Indiana Jones film.
 
4:24 PM
Well, the other way of dealing with it is to set the film only a couple of years later, with Dekard looking 35 years older because he's a replicant nearing the end of his life. Might be quite a good hook for the story.
 
Maybe ... Batty just sort of conks out, but you could pull some handwavy "different model" explanation I suppose.
 
Dutch is a weird language. It kind of sounds like German with an accent over it
 
4:39 PM
cabbage all
 
And, I've just discovered that my flatmate has never seen Blade Runner :-)
 
I've never seen Blade Runner
 
Oof ... it's a bit late for spoiler warnings now, sorry :-/
 
wasn't it based on a Phillip K. Dick novel?
 
@corvid very loosely, yeah.
 
4:41 PM
@Zero I'll live :P
 
user559633
It turns out that Indiana Jones was dead the whole time.
 
When a film is a certain age you are absolved of all spoiler issues.
 
Darth Vader is a sledge.
 
Got a design question for you all. In java, when designing an object, the best practice is to create getter and setter methods, and make the attributes private. What is the correct way to do this in python, since there is no "private"?
 
user559633
Really anything. "ugh shut up don't ruin the ending of WW2 for me"
 
4:42 PM
Or in other words, how would seasoned python programmers typically access member attributes/variables?
 
@Humdinger depends on whether you need to do some crazy stuff behind the scenes
 
user559633
@Humdinger we are all adults here. if you want to pretend that shit is magic, use descriptors
 
If you do then use descriptors
 
user559633
implement them as properties if you want things to look more pretty
 
And assume that the user won't be stupid enough to play with something that has been noted as private with a _
 
4:43 PM
no. I just want simple "getters" and "setters" no magic
 
(Fact: they will play with it, but it's their own damn fault)
 
@Humdinger we don't use accessors, on the whole.
It's the responsibility of the API user not to mess it up.
 
@Humdinger then why do you need getters and setters at all? Just have them access the object directly.
 
Getter: my_instance.my_attribute
 
class Foo(object):
    def __init__(self):
        self.bar = 'baz'
 
4:44 PM
Setter: my_instance.my_attribute = my_value
 
Then just set bar if you need to set it.
 
So what your saying is that is is acceptable (not considered bad practice) to just access them directly
 
user559633
@Humdinger getters and setters in a language that allows for monkey patching is the magic. the advantage of using properties/descriptors/access methods is that you can make the API a little more clean or change the behavior for existing child classes.
 
spam = Foo()
spam.bar = 'Monty Python'
@Humdinger Absolutely.
 
user559633
4:45 PM
@Humdinger How do you think that "myclass.attribute" works?
 
ok
Just making sure. Thanks
 
You use setters and getters in Java because you cannot change your mind afterwards.
 
@MartijnPieters how do you mean that?
 
So you can give something a public attribute, but then you cannot later change that to use a getter and setter instead.
In Python you can.
I can now update Foo and the API doesn't change:
 
user559633
@Humdinger that doesn't mean that using descriptors is verboten, it's just that you don't need to
 
4:47 PM
cbg
 
user559633
cbg
 
class Foo(object):
    _bar = 'baz'
    @property
    def bar(self): return self._bar
    @bar.setter
    def bar(self, val): self._bar = val
 
user559633
@ZeroPiraeus ugh. self-proclaimed 'great script' and deckard being human
 
If "name" is a value at first, but is later composed of "first_name" and "last_name", you can't transistion in Java, but in Python you could turn "name" into a property and still access it like an attribute
 
Foo().bar = 'Monty Python' will still work, but the implementation has changed and a setter is called, magically.
 
4:48 PM
ah ok. Awesome. Thanks very much :)
 
in java you cannot change an attribute into getter/setter without refactoring
in python you can
 
user559633
I think the horse is dead, guys
 
But is it horse.dead or horse.get_dead()?
 
user559633
Nice edit. Makes me want to add linking descriptors to calls with similar names as part of my python troll-repo
 
I need to start writing complete sentences to begin with.
 
4:51 PM
@davidism Well seeing as how it is a boolean, the correct "getter" would actually be is_dead() as opposed to get_dead()
 
Nah, in Horse-2, get_dead() returns "yes" or "not yet".
 
ah.. good to know
 
user559633
schrodingers dead horse
 
he did it with horses?
That was a man with some serious issues about putting animals in boxes
 
and radioactivity
 
04:00 - 17:0017:00 - 00:00

« first day (1410 days earlier)      last day (3541 days later) »