« first day (1767 days earlier)      last day (3404 days later) » 

01:46
Hey!!
@AaronHall You!!
I've been gleaning the minimal leftover questions. Very difficult following cyphase around...
At least some of the leftovers make me think.
What's the correct thing to do with questions that have been answered in the comments, anyway?
Ooh, just noticed I have to collect my car from the charger. I try not to fill it completely full of electrons unless I need to. Back in a bit...
02:36
Apparently I have to get up at 3:00AM my time if I want to be on this group when it's happenin'
02:52
Ha!
:)
@PatrickMaupin Summarize and correct where needed in an answer, and do not give any attribution. That'll teach 'em.
Alternatively, we could pick out some relevant questions, summarize and attribute, and then vote each others' answers up. Immediate rep they're missing might teach them faster :-)
When I see that happening but I don't feel like answering, I comment "Please answer with an answer, not a comment." No, actually I say, "don't answer in the comments." Or some such phrase.
I agree in principle, but in practice it might be called a voting ring and get us kicked out.
Yeah, but some of them were maybe-kind-of-sorta answers, and you're really only sure after you see the "Thanks! That worked!"
Apparently they're big on the competitive part of the coopetition around here.
Oh, that kind. Well, I don't like uncertainty in my answers. If they don't provide enough info to diagnose with 100% certainty, I don't usually touch it. Vote to close?
Yeah, I suppose if it was a tentative answer in the comments it pretty means the question was unclear.
03:54
ok, good night everybody!!!
G'nite John Boy & Mary Ellen!
 
2 hours later…
06:16
morning
Cabbage
nah, it's 23:15, I should really go to sleep :)
morning all
06:19
hi Jon
@vaultah thanks for re-pin :)
cbg @Antti
@VigneshKalai dv'd
Wow... how'd that even end up getting asked? :p
06:41
Hey up
yo fizzy
07:11
Cbg :)
cbg @Ian
It's quite chilly this morning
Its hotter than usual here :(
07:27
Umm.... wanna share a little bit of that over here? :p
We can actually exchange ;-)
That's fine - just send over a few degrees - that'll be great. Thanks pups!
07:45
Cbg you beautiful pythonicas
Cabbage!
cbg Bobby G and poke
Cabbagio
Ugh, just heard on the radio "supermarket shoppers are shopping vertically". As opposed to what? Those going round waitrose on all fours?
I assume the aisles run into the sky, to save space. The real question is: where did they get their magnetic boots?
@JRichardSnape what's wrong with going around waitrose on all fours? Seems perfectly natural to me...
07:57
(Basically unrelated) - in SA, the trolleys at the airport work on the escalators, so you don't need to use a lift to move lots of heavy bags around
Umm... slight tangent indeed. It's not exactly weird for supermarkets to have travelators that whack a trolley on while going around the floors, then down into the car park etc...
Ah okay, haven't seen that
Are you thinking of tenuous reasons not to leave SA, Bobby?
@JRichard 'cos if he is... I can think of way better ones :)
Although, paradoxically, you will only use that feature if you have left SA
08:01
No, that's something that makes it easier to l...yeah :)
@JonClements yeah, agreed
What are the reasons? :)
Primarily, sun (yes, it's another grey day in the East Midlands)
08:16
cbg Steve
08:50
cbg @PM2Ring
cbg Jon
09:14
Hi @pm2
Cabbage
09:26
Ah guys should I take this job? It's actually freaking me out.
@IntrepidBrit and cbg
Pro/con snapshot?
Morning all. I'm one of the minor devs of SE-Chatbot, which python_bot is built off. I'll be around for the meeting tomorrow.
Pro: more money; bit of career advancement; new, possibly quite exciting and high-profile project; living in UK
Con: lots of upheaval with an ill pregnant wife; visa stresses; current role going well; leaving SA
@Kevin I feel as though we could take your current starred items and write you into a script that needs a cynical army techie
Chances of the same / similar offer being made in the future?
cbg @ArtOfCode :)
09:32
@IntrepidBrit probably decent, as I've had similar ones this year, but possibly not for as much money
Not a huge difference in terms of money, but it was a bit more
Say 10%
@ArtOfCode A stranger. From the outside. Oooooooooooooooh!
points at @ArtOfCode and shrieks
@IntrepidBrit I know - what do we do? What do we do! runs around panicking...
Hi all I have a data like thisa=[('', '', 'CA 95928', '', ''), ('', '', '', '', 'on 229')] and I used ` [[b for b in c if b]for c in a]` now it looks like list of list how to make it a list of strings
[['CA 95928'], ['on 229']] the output I get
@RobertGrant - having been in visa hell before, that's the one that's really causing me to pause.
09:36
[[el for el in lst if el] for lst in your_list]
@IntrepidBrit it'd be my wife's visa, not mine, this time. Already had visa hell over here :)
So that's something - I wouldn't have to extend my SA visa
@JonClements same list of lists I want list of strings
Aye, and from what I've heard from others - the UK is getting harder to get into if you're outside of the EU.
@VigneshKalai okay... so the desired output is? A single list of non-empty strings?
cbg all
09:38
Yes the output I want is ['CA 95928', 'on 229']
Yeah it's gonna cost a nice amount
Basically 1500 quid for a two year visa with healthcare
So you want: [el for sub in your_list for el in sub if el]
cbg @jonrsharpe
@VigneshKalai [s for t in thisa for s in t if s]
@JonClements just saw this. Genuine lol
[b for c in a for b in c if b], to use your (terrible!) variable names...
09:40
Yes why did not I think of that
Nested list comprehensions always look backwards to me, though I understand the logic
@jonrsharpe bah! what's the problem - no one reads code once it's written, right? :p
My names are almost as bad, but at least they're mnemonic: s for string, t for tuple. :)
And sorry for the variable name using it for just checking
@JonClements only if it stops working, as a rule!
which obviously never happens
09:41
Exactly!
Thanks all :)
@RobertGrant What does the SO make of it? (if you don't my asking)
She's excited to go
Which is very good of her :)
What about her opportunities/prospects?
Decent, but she's basically got a great job (in terms of opportunity; rubbish in terms of pay) right now, although that opportunity is probably coming to an end at the end of the year.
09:45
@jonrsharpe When you have 2 or more loops inside the one set of brackets then the order of the for loops is exactly the same as what it'd be with plain old for loops. OTOH, when you have a list comp in a list comp, then the order is reversed, eg [[inner for inner in range(outer)] for outer in range(n)]
We'd have to pay a few thousand quid towards a UK certification, basically
And she'd have to work for a year there
When she's only a few months from registering in SA
@PM2Ring yes, as I say I do get the logic, but every time I write one it looks wrong somehow!
Although even if she registered here, she'd still need to complete the registration process over there if we ever moved in the future
@jonrsharpe Fair enough. :)
09:53
There's just not much building in the UK, so architects seem to do lots of extensions (not fun) and restoration work (she would like this), so as long as she could do the latter, that'd be really good we think
@jonrsharpe I've been known to think "oh sod this - let's go with [el for el in chain.from_iterable(some_iterable) if el] :p
Do we have a sensible duplicate for "my SQL query concatenation isn't working", preferably with the answer "well don't do it, then"? (ref: stackoverflow.com/q/32069071/3001761)
@jonrsharpe I guess, the root cause is somewhere else, but indeed someone has to stop him.
@JRichardSnape Hi. Sorry I didn't reply earlier - I was having dinner. Here's another tune for you: my all-time favourite example of blues violin: Frank Zappa and the Mothers of Invention - Directly from my Heart to You, featuring Don "Sugarcane" Harris on violin and vocals. Composed by Richard Penniman, aka Little Richard. [Audio only]
So far the only answer is to use % formatting instead of concatenation, which is less than ideal...
10:01
"When i use it on postgres it work fine i don't know why it produce an error when using on eclipse."
oh
10:20
@RobertGrant Sorry about that mate. Flurry of client calls. Move to Edinburgh! I'm sure there's loads of restoration work up here for all our beautiful old buildings ;)
Side note - if she moves to the UK and gets certified over here - would there be scope for her to work on the continent. Might as well make use of the free travel of movement whilst the UK is definitely in the EU
Yeah that's true :)
Tart up the Vatican
I'm using fuzzywuzzy module
@VigneshKalai: A answer consisting of "Try this:" plus a code dump risks attracting down-votes. See Reduce “try this” answers by giving a helpful message for the reasons why. Similarly, "Have you tried" + code dump, can also be a down-vote magnet since it sounds more like a question than an answer.
I was wondering if I also can customize the threshold for the ratio.
Uh. There is a troll irritating people in GitHub right now..
10:27
@PatrickMaupin can I use your pdfrw library to extract images from PDFs?
@thefourtheye what?
There is one guy who randomly creates issues in repositories and when people close them, he abuses them
@AnttiHaapala : I'm using your python-Lev module.
:)
@d-coder not mine :P I am just collecting the shit
heya @d-coder
10:28
@PM2Ring yes I agree was going toimprove it but then jonsharpe link it self had all the required things
That seems like a really strange way to behave!
Ya, and he randomly comments in PRs as well.
@JonClements Hello there!
@AnttiHaapala : You aren't the other huh ?
author ?
nope
I am just maintainer
but PyPI is so shit one can only register 1
Cool!
I want to know if I can customize the ratio value before replacing the string
10:32
@IntrepidBrit looks as though there's an EU-wide arrangement, in that EU architects get short-term free membership of the registration board (although UK architects have to pay)
Steep fee?
"You should ORM methods. Try something like this:" what kind of answer is that?
Hm not huge I think when you're registered, but to register it'll basically cost about 6k
So, not a small sum of money.
Okay, what about your future kid's education? UK or SA?
@VigneshKalai jonsharpe's info is only in a comment, though, so it doesn't have the same weight as a proper answer. Comments are like Post-It notes: they can disappear at any time, whereas answers are much more permanent.
I think your answer is ok, apart from the sloppy grammar & the typo ("buils" instead of "build"). I just thought you ought to know that some people on SO react badly when they see the word "try" introducing a code block, especially if there's not much other non-code text in the answer. That answer should be safe, though, since there is other text.
@bereal Verbs don't grow on trees, you know. :)
10:46
One does not simply ORM methods
I mean, ORM is irrelevant to the question. Same as if he answered "use Mongo instead".
@PM2Ring No problem. Gotta love a bit of Zappa - I like that more earthy sound. We're going round a tour of fiddle tones. Amazing to see the variety you can get even under the broad umbrella of blues style. I didn't know this one, but again it's a goodie :))
I guess he's using a fairly primitive electric violin on that tune, but the tone really suits the tune. I was surprised when I learned it was a Little Richard tune - i knew he was a great writer of early Rock 'n' Roll tunes, but I didn't realise that he was also a gifted bluesman.
@RobertGrant Got a mate who's a UK architect if you need an inside track. I know that the indemnity insurance rules are very strict and potentially quite a barrier to setting up on your own initially.
@PM2Ring yeah - you get a lot of bow noise on the early pickups (frequency response wasn't quite so well developed). Also people tended to mod cheapo violins because they didn't want to mess up good ones by drilling holes for wires. I made one myself when I was about 15. Painted it white, used a piezzo earpiece for a pickup and painted a celtic knot on it. Hippy chic, I like to tell myself ;)
Nice.
11:00
yeah, it worked. Actually - the poor high frequency response of the earpiece gave it a lucky not-too-scratchy tone. more good luck than judgement. Makes me wonder if I should plug it into my raspberry pi today and get back into a bit of signal analysis. drags subject back to Python with some effort ;)
@PM2Ring really thanks mate and about the grammar it need a lot of work :)
Another Zappa tune Peaches en Regalia played on acoustic mandolin & guitar!
@JRichardSnape yes please that'd be awesome. More contacts the better!
Actually, I was wrong about ORM, the whole question is about OpenERP, which is on top of Odoo.
11:16
@direprobs hello
11:31
Meh. I hate this kind of test deployment. Change two characters in an XML file, and wait 3 minutes for the deployment to finish… >_<
Insert compulsory xkcd about "it's compiling!"
That's true - we just say "It's building"
“It’s deploying”
I’m so bored.
Anyone want to do a swordfight with me?
Sure... I'll grab the katana... one sec
I'll grab popcorn
11:43
How's that going to help in a swordfight? :p
I can throw that in opponent's face and run away :D
good morning
@RobertGrant Psh, Irish accents are the most attractive accents world-wide. German is the funniest accent
hi to all
@MoorthiMuthu hi
hi @VigneshKalai
i am new to this chat room and stackoverflow
11:57
You may want to start with this
hi there @MoorthiMuthu
Is it common for Python functions to use more arguments that declared? I would expect, to keep things tidy, to use specify all used arguments in the function "head" instead of taking it from the "pool" of environments around it.
@RomanLuštrik huh?
12:08
I think he's asking "how often are global and nonlocal variables used?"
environments == scopes
head == parameter list
/me is pointing with a finger and saying "uh uuh uuuh uuh"
Wasn't sure what the terminology is in Python so I used barbershop level words.
global constants are fine. If you find yourself writing a lot of functions that modify global values, that may be an indication that you need to redesign.
@Kevin That's the thing, the examples I was looking at didn't modify the global variables at all. Perhaps the authors were just a bit lazy?
nonlocal values are more rare, but there's nothing wrong with them - they just aren't useful very often.
The way I understand functions is that they should be a self contained system that spits out something.
Which is why I was asking if this is not the norm in Python.
12:11
That's one philosophy, sure
In general that makes them easier to reason about, but e.g. closures can be useful too
It can be convenient to write a function in a strict manner so that calling it with particular arguments will always result in the same return value.
It's easier to remember "frob(23) always returns 42" compared to "frob(23) returns 42 when global value phase_of_moon equals "GIBBOUS", and 99 otherwise"
4
@jonrsharpe and easy to test as well
Hi
Ack, I give up - how does one Python in chat?
12:15
You have to indent every line in your message.
Type/Copy/Paste - Select - Ctrl + K
Yes, this means it's impossible to intermix code and text in a multiline message.
@Kevin ah, there it is
def memoize(func):
    cache = {}
    def wrapper(*args):
        if args not in cache:
            cache[args] = func(*args)
        return cache[args]
    return wrapper
...a common memoization decorator using a closure. Of course, it won't work well on functions that themselves retain state!
does this seam right? annual_spend = Lead.objects.filter(assign_to=User).exclude(lead_status='CV').aggregate(Sum('ann‌​ual_spend'))
@nope what do you mean "right"? Does it work?
12:17
It seems syntactically correct, certainly.
Whether it will actually produce the output you want, or even run, is another matter entirely though
I take it this is Django? Or something else?
Yes
...to which question?
Why would you want to assign something to someone who doesn't have a CV/resume? Seems a bit sketchy to me...
Only a programmer replies "yes" to the question "is this X or Y?"
Yes, it certainly is one of those.
12:19
@IntrepidBrit no not resume this('cv', 'converted'),
Sorry, just winding you up with a terrible, unfunny joke.
@nope I don't think not resume this('cv', 'converted'), is going to create a valid tuple
@RobertGrant Hi do you remember me
This conversation fills me with [untranslatable]
you mean Cabbage?
12:24
Jan 5 at 12:35, by Ffisegydd
@Aniket yes, yes I remember you.
@thefourtheye all is cabbage, and cabbages for all!
Cabbage is the cabbage of all.
I don't understand how can get each user with the objects that they are associated with? :s
I'm not convinced that's a question! Have you tried breaking it up into smaller steps?
okay, so I have assign_to function which allows user/staff to be assigned to a customer I want to get that user and all customers that they are associated / assigned to.
It's unlikely that you're going to be able to provide an appropriate amount of information here. How about you create an MCVE, show what you're trying and precisely how it's failing, and ask on SO proper?
12:32
I just got an error that just says "huh?"
@RobertGrant cool - I'll see if I can get in touch with him this evening.
Today I learned about the commands module. I also learned that it's deprecated.
I feel a tinge of regret, since its interface seems slightly easier than subprocess.
No fiddling with shell=True flags and you don't need to pass in a list of strings
LOL @ "This function is nonobvious and useless. The name is also misleading"
But it has to stay in to maintain the symmetry! getstatus, getoutput, getstatusoutput.
12:41
:)
getoutput = lambda cmd: subprocess.check_output(shlex.split(cmd)) ? :p
Can't be bothered. slides out of chair onto the floor in a boneless heap
CBG!
Here lies Kevin Kevinson. In the end, it was the subprocess that killed him
@RomanLuštrik That's a nice ideal, but sometimes it leads to more efficient code if you deviate from that ideal. A fairly common example that Kevin mentioned is the use of global constants.
Python makes it easy to read global objects in a function, but you have to use the global keyword if you want to write to them, and Python tutorials warn you to use the global keyword sparingly. OTOH, you can call the methods of a mutable global object to modify its contents, eg you can append to a global list.
I want to display the time taken by query on my website
12:45
In Soviet Russia, subprocess kills you.
@d-coder like on SEDE, you mean?
Cabbage.
wb @Morgan
Either "recommendation request" if he wants a ready-made solution, or "too broad" if he wants to write the program himself
Thanks guys, as always, very insightful.
RomanLuštrik: Here's an example I often use. Say I need a function to use a constant compiled regex. I don't want to pass the regex to the function or to re-compile it every time I call the function, so I compile it in the global scope just before the function definition. That way it's easy for someone reading the code to see what's going on.
@PM2Ring how about def func(reg=re.compile(...)): ?
@bereal I'll pay that. And it allows the caller to use an alternative regex if they want to. OTOH, if the regex is truly constant then you get the opposite problem of what Roman was originally complaining about: a function that has a formal parameter that the caller isn't supposed to touch. FWIW, in awk that's the only way you can create local variables in a function.
@jonrsharpe SEDE means what ?
I just want it to be like how google displays it :P
@d-coder “Stack Exchange Data Explorer”
13:12
People searching for a cuddly bedtime snake companion will be disappointed when they Google "python pillow"
@poke Oh! I don't know that but how google shows for example About 6,89,000 results (0.45 seconds)
Something similar to that
@d-coder, start_time = time.time(); do_thing_you_want_to_time(); print "completed in {} seconds".format(time.time() - start_time)
start = get_time()
do_stuff
time_taken = get_time() - start
print('Took', time_taken)
@Kevin Nice.
Great minds etc
yeah
13:18
I did something like this
for q in connection.queries:
time += float(q['time'])
print time
Is that wrong ?
Thanks! I didn't know it was that simple :P
@poke thank you!
@Kevin Thank you!
slowly, but surely I approach 10k.
is there life after 10k?
If you can call it living.
I see.
I have one doubt They say it is best to ask forgiveness then permission in python but I also heard try catch are expensive to use
I frequently say "if you care about marginal differences in efficiency, don't use Python in the first place"
13:29
@bereal I heard they remove your sleep function.
@JRichardSnape what sleep function?
ah
that one
overrated
@VigneshKalai It depends. If the exception is only raised a small percentage of the time then try:...except is much faster on average than the equivalent if:...else: code
deprecated
yeah, measured that once, if it's not raised, it's times faster. But, anyway, we're opening the freaking file, comparing to it, any exception delays are nothing.
13:30
I am concerned about efficiency the both statement clashes against each other so which is more better for knowledge basis
@VigneshKalai In other languages (eg Java), try: is expensive, but in Python the bytecode for try: is lightweight & fast.
Given a choice between code that is easy to maintain, and fast code, choose the former. At least until your boss tells you otherwise.
then slap the boss with a large trout and choose the former.
4
Ho that explains
(Incidentally, I hope "former" and "latter" are well understood terms by truth-seekers who have English as a non-native language. I worry that they just smile and nod and think "I'll just pick one of these options at random")
13:34
I do understand former[first] and latter [second]
@bereal Very True. However, in that question the OP isn't actually reading the file, they're only testing for readability. Sure, it's reasonable to assume that they do want to actually read the file eventually, OTOH, who knows? :)
One possible misinterpretation: "Former. Adjective. 1. having previously filled a particular role or been a particular thing." Ah, so you're telling me to just keep doing what I was doing before. Cheers.
@VigneshKalai latter = last
I have only give two cases so only I said second
I thought, latter was some coffee.
13:35
I'm not grading you, just making sure you knew :)
Luckily "last" and "second" point to the same element, since I only use it in the context of lists of length two
latter = x[-1]
Thanks @RobertGrant
I don't think you can ever use "latter" in any situation other than exactly two choices, so this is pretty academic
:) programmatically speaking latter = x[-1] makes a lot of sense
13:36
Sure you can
I wish I could make wordplay jokes in another language. It is to my shame that I can haltingly decode one or two languages other than English and thus limit my pun making ability :)
Now I'm not sure
When you're at home depot and your life partner says "Which should we choose: red, green, or blue?", which word would you use to specify each color?
Yeah I was always impressed with a guy I know from Nigeria who loved (and loved making) English puns
Yeah you can, but it's unusual. e.g. I had three options : death by starvation, death by drowning or build a raft. I chose the latter
13:37
@Kevin I think latter can be used for blue, but former can't for red
So I don't think you'd use former with a list longer than 2, but you can use latter
I don't know where my morbid tendencies come from today.
And that's my latter word
former would be confusing for n > 2
sorry, the answer is "trick question. I can't step foot in a Home Depot, due to a family curse stretching back ten generations"
@RobertGrant A Norwegian friend of mine solves cryptic crosswords in the times. I stare in slack jawed amazement still.
13:40
That's awesome
@JonClements pdfrw won't create the necessary file headers to save the images standalone, but it can easily save images as PDFs. E.g. this example will save all the images from a file one-per-page. If you read the source, you can figure out how to save images in separate PDFs, and even how to only get images from particular pages (pass single page to page_per_xobj).
@PatrickMaupin ta... yeah... I've tried isolating the image streams, but yeah... noticed it didn't have suitable headers
Well this will put suitable headers on to create a PDF. Then you can use image magick or inkscape.
I was hoping there was a simple way to extract images as actual image files...
I have a 900 page brochure with about 40 images per page :)
Would it be a problem if each image was a separate PDF?
13:44
Well, as long as I can easily then turn them into actual image files, no... but that seems potentially an unnecessary iterim step
@PM2Ring so then try catch is more light weighted then if else ? just checking
I vaguely remember that someone wrote a wrapper around PyPDF2 to do this -- I think it might be on PyPI, but that's a 30 minute searching exercise. Honestly, headless inkscape works great for me -- it has command line options you can call from subprocess to convert file formats.
That's cool
But if there is something to generate the headers directly, then that might give you smaller pictures, as well as reducing the amount of work. There's a nice package called img2pdf that goes the other way simply because most methods of getting images into PDFs decompress and recompress them with disastrous results.
@PatrickMaupin okay... I'll look to see if your tips work... as long as I can associate the image back to the original page it was on in the end...
13:48
That association is easy if you call page_per_xobj on each source page, rather than on the whole file. But then for each page you get back, you will want to create a new PdfWriter object and add the page to it, and then dump it out to the filesystem.
@VigneshKalai When I said it's lightweight I meant that using try:..except instead of if:...else won't bloat the bytecode. In terms of execution speed it is slower than if:...else if the exception is raised, but it's faster than if:...else if the exception is not raised.
So if you expect the exception to be exceptional, then use except. :)
Thanks @PM2Ring and @jonrsharpe
@JonClements You might also want to look into minecart.
@Patrick cheers... was aware of slate and pdfminer... minecart just makes me think of Minecraft though :p
13:55
Also, fwiw, my example won't extract images embedded in streams. This is a somewhat deprecated practice, but it happens.
I would just run the example as-is to see if it will work for you, and then it's easy to modify to get page info and split outputs into separate files if so.
Okay - thanks - knew you'd be the man to ask :p

« first day (1767 days earlier)      last day (3404 days later) »