« first day (109 days earlier)      last day (450 days later) » 

11:17 AM
@AaronHall hey there!!
 
12:09 PM
@Sword hi, what's up?
 
12:29 PM
why is this place spammed with feeds?
this will keep away the crowds
:)
 
Isn't it nice?
I've gotten some rep from questions in these feeds. One of my top answers.
 
hmmm , justified then but this isn't a good place to chat then
Do you know me?
 
I don't think that makes it a bad place to chat.
 
these are similar to pop up adverts
which stay forever -_-
 
really? How big is your screen?
 
12:37 PM
my office laptop is a 14 inch (approx) screen with a 1366*768 standard crap resolution
 
Well, there's another Python room, but the downside is they greet you as if they were lost in the produce aisle.
 
which brings me back to:
2 mins ago, by Sword
Do you know me?
In case you don't , I was a newbie last year with the name 'Sword' -- 'Swordy' - 'Flappy Bird' etc etc
And you helped me a lot ..
 
In the python chatroom
 
Afternoon :)
Or - hello - to be less UK-centric!
 
12:41 PM
@JRichardSnape Good afternoon Richard
 
Cool.
 
damn , I had justin bieber's baby playing on my phone.. I should could have shot myself for it
 
I answered this question because of this room: stackoverflow.com/questions/32770762/…
May be my best answer to date.
 
nice ,
well formatted!
 
It leads with a proper warning about premature optimization, it's organized correctly, and best of all it flowed organically from my interaction with the asker.
So, I try to hang out here.
 
12:52 PM
nice , I landed up here because I had a question and I was reluctant to ask it in sopython room for reasons you know of.
 
Do you mean you have a question now? or previously? because if you have one now - shoot. I certainly won't jump up and down about it :)
 
yeah thanks , it was about args parse
I searched SO questions but did not get any
so I have need to execute something like
 
0
Q: Project Euler #42 - Triangle Numbers

mburke05Here is the Euler problem referenced, it says: The n\$^{th}\$ term of the sequence of triangle numbers is given by, t\$_n\$ = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... By converting each letter in a word to a number corresponding to i...

 
python file_name.py -r arg1 arg2 arg3
I need to have another keyword "-k"
 
python file_name.py -r -- -k arg1 arg2 arg3
 
12:57 PM
so
python file_name.py -k
should display a message
but when i do this, it expects args1,2 and 3
 
see the double dash?
 
I tried with a different instance of argsparse but it dint work
 
You left that out
 
@AaronHall that is not the problem
I want to execute -k separately to get a message containing keys
I'll put up the snippet
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    subParser = argparse.ArgumentParser()
    subParser.add_argument('-k', help = 'displays keywords for similarity check')
    parser.add_argument('-r', action='store_true', default=True, help = 'input <space> output <space> similarity')
    parser.add_argument('input')
    parser.add_argument('output')
    parser.add_argument('similarity')

    args2 = subParser.parse_args(['-k'])
    args = parser.parse_args()

    files_dir = args.input
 
ok, just be precise in your examples, I'm not a super expert on argparse, but if I see something wrong, I'll say it, and it may distract from the real problem.
 
1:00 PM
@AaronHall check out "subParser" above
 
So you want it to require the three args if and only if the first argument is -r?
 
@JRichardSnape exactly
 
Snape, you help, I gotta head in to work.
 
its not so urgent, you guys can answer anytime you are comfortable
I need to deliver by friday
I have workarounds to it though :)
 
:D I'll insert an implicit can between "Snape" and "you" there Aaron ;)
Well - I can think of a few options @Sword - depending how you like to work. I think the "cleanest" would be to have mutually exclusive groups
The docs on that are here - my lunch time is over, so I can't write you out a full example - but basically you want to have -r and -k in a mutually exclusive group (if they truly are mutually exclusive)
and then add a subparser for input, output and similarity that only parses if the first arg is -r, I think. Like Aaron, I'm not an expert on argparse, so it would take me a little while to get to a full listing.
Thinking about it - the mutually exclusive group bit might not be necessary - you might just want two sub-parsers.
 
1:22 PM
Yeah, I meant if you can. :)
 
@JRichardSnape great , I was thinking about the same , and I guess I'm nearly close to it. what I'm thinking of as a workaround is the use of epilog mentioned in the docs. It will display along with -h and will cut it for us.
 
1:55 PM
that -r needs to be on the other side of the --
 
here's an example using subparsers.
import argparse

def i_got_r(args):
    print('I got in here with options')
    print(args)
    print('Input file',args.input)
    print('Output file',args.output)
    print('Similarity',args.similarity)


def i_got_k(args):
    print('Here with a lonely k - I\'ll print my keywords')
    print('this should be empty',args)

#Option 1
if __name__ == '__main__':
    # create the top-level parser
    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()

    # create the parser for the "foo" command
However...
For some reason, the subparsers don't work if they're named -<letter>
I don't know if that's a bug or a feature. They're designed for sub commands, rather than dependent options. However, the options I had for mutually exclusive groups didn't work
I'll have another think another time, but that example enforces your rules, albeit using {r|k} instead of {-r|-k}
(The cunning mis-use of foo and bar will point you to the example I hacked around to get to this - bottom of this section docs.python.org/3/library/argparse.html#sub-commands)
 
gets up to make tea and get some doughnuts.
 
2:28 PM
@JRichardSnape so nice of you to take so much trouble. I am not a help vampire and I wouldn't want to waste the time of you guys.. But I'll check with this.. Thnks a ton, mate..
 
MMMmmmm, Boston cream....
 
@AaronHall we're not even jealous :D
 
I'm sure you're aghast at my gluttony.
 
googles gluttony
habitual greed or excess in eating.
@AaronHall no I'm not , even we eat a lot when we feel like. After all, it takes all of these to generate brilliant code ;)
 
well it's probably my first doughnut that I got for myself in a year.
 
2:37 PM
Enjoy it :)
@Sword no problem. Don't worry either, you can't waste my time - I decide where to deploy it :) Only I can waste my time really.
 
:)
@AaronHall dude , the pop-up feeds!! they're so annoying.. -_-
 
Get a bigger monitor.
I click dismiss and they go away.
Also, you might read the popups and see a question you know the answer to, and thus go answer it...
 
2:56 PM
uhmmm
 
0
Q: python write and open temporary csv

deseosuhoUsing Python 3 on a windows machine: I have a function to take a list of lists and open it as a csv file using my default application (excel). Despite closing the file after writing, I get a 'locked for editing' message when excel starts. def opencsv(data): """saves a list of lists as ...

@vaultah I almost didn't see you there!
 
3:14 PM
benefits of having white avatar
 
hiding in plain sight :)
 
who loves a good argument?
"Pre" means "before". Defining a mature point for optimization as the point that is the bottleneck, until the Python process becomes that bottleneck, adding complexity to optimize it is premature. — Aaron Hall 5 mins ago
 
screen camouflage, you can't escape the SO dark theme extension @vaultah
leaving for home. rhubarb, errrr byee
 
3:34 PM
@vaultah you need one with an all alpha.
 
4:13 PM
hmm...
 
@AaronHall are you actually going to keep this room active apart from having feeds coming in?
 
Jon Clements has frozen this room.
 

« first day (109 days earlier)      last day (450 days later) »