« first day (3199 days earlier)      last day (1740 days later) » 

Tim
12:21 AM
@smci it's all "Agile Working" in my workplace.
 
1:14 AM
cbg
 
1:46 AM
@AndrasDeak Isn't that an implementation-dependent detail, and could the cPython implementation special-case the fairly common [::-1] idiom on a string to be O(1) if they really wanted to?
 
2:03 AM
cabbage
 
 
2 hours later…
4:04 AM
@Tim Oh God, unfortunately that's accurate. I thought the only (ab)use of the term was "Agile seating". But then I googled and I found various cargo-cultist forms of "Agile working" being used. Sigh.
 
Tim
@smci is a little more encompassing than just hot-desking, includes working from home etc. Beyond software, most other teams don't really use the term Agile.
Well in the same context as software engineering does. Although I have encountered it in a newspaper newsroom when working with them on a project.
 
@Tim Right, the cargo-cultistry is going in the same trajectory as "Seven Habits..." back in the 1990s: "Seven Habits of Coaches/Teenagers/Lovers..."
 
Tim
4:33 AM
@smci except companies do see benefits in terms of the reduced cost of office space. Still doesn't make it better for workers, but I think it's a little more than just a cargo cult or a bunch of pointless slogans.
 
5:16 AM
@AndrasDeak @Kevin @DeveshKumarSingh Thanks for pitching in yesterday. :) Works now.
cbg
@roganjosh used np.where() with Kevin's logic
def color(x):
    c1='background-color: red'
    c2 = ''
    df1 = pd.DataFrame(np.where(s,c1,c2),columns=x.columns,index=x.index)
    return df1
df.style.apply(color,axis=None)
 
5:36 AM
@Tim You're misunderstanding me: I merely objected to the ongoing abuse of the word 'agile' ever-further outside its domain. I didn't say those office practices didn't make sense.
 
Tim
6:06 AM
@smci I'm not following you, Agile is an adjective for "move quickly and easily", can technically be applied to anything that exhibits those behaviours.
Anyway, boring semantics. Back on topic!
 
 
2 hours later…
Tim
8:36 AM
How do you handle questions like this one stackoverflow.com/questions/57121703/… issue is with the developers of the package only doing a single build and not providing a source package.
I couldn't find an appropriate flag to use
 
9:03 AM
@smci no, not for strings nor lists nor tuples. Python says lists slicing copies, and strings/tuples are immutable so again you have to copy unless the string/tuple has length 0 or 1.
@Tim I suggested a dupe
 
9:38 AM
And your "output" you show cannot be valid python, so consider posting an actual MCVE
 
10:13 AM
@Tim There's a whole "agile management" paradigm that's sprung up and, like most newly-introduced techniques (in this case mostly borrowed from the world of XP/agile programming), people are jumping on the bandwagon, using it to justify changes made for other reasons, and so on. There really is no end to human folly.
 
 
1 hour later…
11:38 AM
recbg
 
12:11 PM
cbg folks. I'm looking for some insights / thoughts on my recent (>2 days) Django question. Edits / question-only suggestions are also welcome :)
1
Q: Unique together involving multiple foreign keys & a many to many field

shad0w_wa1k3rOur business' pricing is dependent on multiple parameters, and now we want to introduce another possible M2M parameter to the existing setup in Django. For this, we have an existing table for pricing, which has a unique_together constraint on all fields except the price_field. Apologies for the ...

 
1:05 PM
@Tim instead of hacking around with requirements and sources, I recommend telling the developers the distribution is missing. often enough missing distributions are just an oversight.
 
Hmm, is this normal? My program can't see its command line arguments unless I invoke the python executable directly.
C:\Users\kevin\Desktop>type test.py
import sys
print(sys.argv)
C:\Users\kevin\Desktop>python test.py -a -b --help "coconut pie"
['test.py', '-a', '-b', '--help', 'coconut pie']

C:\Users\kevin\Desktop>test.py -a -b --help "coconut pie"
['C:\\Users\\kevin\\Desktop\\test.py']
 
Sounds abnormal. But with windows you never know.
 
My first theory was "the arguments are getting sent to python.exe, not test.py" but if that was the case, I'd expect test.py --version to display my Python version number. But it doesn't.
 
$ python foo.py -a -b --help "coconut pie"
['foo.py', '-a', '-b', '--help', 'coconut pie']
$ ./foo.py -a -b --help "coconut pie"
['./foo.py', '-a', '-b', '--help', 'coconut pie']
linux with a #!/usr/bin/env python shebang
 
Tim
1:21 PM
What is the .py extension mapped to in windows?
Is usually pythonw.exe I think
 
On a completely fresh windows install, it's not mapped to anything. Python's installer might map it to something.
 
shebangs don't work on windows, do they?
 
Or maybe I had to map it myself with "open with..." followed by "always use this program"
@AndrasDeak The answer is either "no" or "yes, but every single time I tried using them, I messed it up somehow"
 
Tim
I'd have thought the installer would, but like I said I think it maps to pythonw.exe rather than python.exe. I don't recall what the difference is.
 
1:25 PM
If it is mapped to pythonw, that puts the "arguments are getting sent to the executable" option back on the table, since pythonw doesn't support --version or AFAICT any options at all
Currently researching how to determine the current default program for a file extension... I know how to change it, which is extremely easy. Finding what's being used now is another can of worms.
pythonw is off the table again because pythonw test.py displays nothing, which doesn't match the usual behavior of just test.py
 
7
Q: Executable Python Script not take sys.argv in Windows

Zewei SongI have two computers with Windows, and I just found that on one of them, if I ran python code directly, like: test_args.py input1 input2 Python will not recognized the input I gave, but this works: python test_args.py input1 input2 I tried the code: import sys print 'Number of arguments:'...

probably needs a better answer, incorporating the SOLVED from the question
but then stackoverflow.com/questions/30981750/…, which might or might not be no MCVE
 
superuser.com/questions/963464/… says I can find the full pathname of a default program by checking my registry. I'm looking, and my registry says that Python can be found at c:\windows\py.exe. This is a lie.
 
@Kevin that's probably the issue
(unless that's exactly what you meant too)
 
I haven't looked at your links yet so we're in different branches of the conversation right now
 
1:33 PM
It can't just be that the default action for me running .py files is to try to run py.exe in a directory where it doesn't exist. I would expect the command test.py to fail spectacularly in that case
Ok, now that I have vented about Windows' cryptic and terrible design, I will read these links.
 
@Kevin what you wrote is probably correlated with my first link
 
I'm reading it now. It's somewhat related - both posts suggest poking around the registry. But mine advises looking in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\<program name>, and yours in Computer\HKEY_CLASSES_ROOT
 
I can't comment on that
Since you see surprising behaviour you should go with the one that has Wow in the path
 
Tim
Don't miss dealing with the registry, also watch out it's not stored in HKEY_CURRENT_USER
 
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\python in general looks... Stale. I see subdirectories for 2.7 and 3.4, but nothing for 3.6, which is what I use daily.
I can confirm that sys.version prints 3.6.3 no matter how I try to run the file.
HKEY_CURRENT_USER\Software\Python\PythonCore\3.6-32\InstallPath has my most up-to-date Python install, at least.
 
Tim
1:42 PM
I think those keys are there so the python installer (or other software) can find the location of any existing install.
 
Yeah.
 
Tim
I predict a lot of similar cursing as I'm going to have to be working with windows over the next couple months... not looking forward to it, first goal get a VM with linux onto the corporate PC.
 
Ok, I'm going to edit my registry as suggested by Andras' first link. Pray for me.
C:\Users\kevin\Desktop>test.py -a -b --help "coconut pie"
['C:\\Users\\kevin\\Desktop\\test.py', '-a', '-b', '--help', 'coconut pie']
Looking good B-)
 
phew :)
 
@AndrasDeak Nice find. I award you ten quatloos and one "Great Job!" sticker.
I'll mail it to you. I have faith that the US Postal Service can deliver this letter if I put down "Andras" as the address. They'll know who I mean.
 
1:52 PM
 
I guess my own google searches on the topic didn't turn up anything because I was being too abstract -- instead of searching for python-specific solutions, I was trying to basically reverse-engineer the windows default file association system.
Next I must determine why I can run my test.py file as just test when I use a regular command prompt, but it fails to guess the extension if I use a command prompt that was opened from explorer using the "open command window here" option.
Current guess: "Because %pathext% is getting overwritten???"
Only three more metaproblems to solve and I can go back to doing productive work
 
2:54 PM
Does anyone have a preference on displaying Python code on, let's say, a HTML-based blog post? I'm kinda looking for something like this but I really don't like the full-width part. I could probably fix that with fixing the <div>. I've also found Pygments but it doesn't, on the surface, seem to fit the style I want
 
As long as code is obviously separated from text in its own box and rendered with a fix width font, I'm happy
 
The outcome is obviously always going to be open to personal preference, so there's not a definitive answer. I'm just curious to crowd-source potential approaches
 
SOPython satisfies my requirements, for instance
 
Normally I couldn't give a yam about appearance; I'm more for functionality. But in this one case, I really do care about having a "dark theme" to display the code. I can't argue you on your requirements because I agree, but I'm really focusing on the options for modifying the display aspects here
 
Mm hmm. Nothing wrong with putting more effort into styling than what my bare minimum requirements prescribe. I don't think a fancy dark theme with cool syntax highlighting etc etc has ever harmed my reading experience or anything. It's a strict improvement, just not one I find essential.
 
3:14 PM
The "bare minimum" is "what will sell me well?". I've been hammering together an interactive personal profile for a few weeks now for my projects. It's becoming pretty exhausting but I'm still holding to the principle of being uncompromising on the front-end.
 
If it's for a portfolio, definitely juice it up. Impress those recruiters with your bright colorful plumage.
 
So it goes back to my initial question :P ; Does anyone have a preference on libraries to embed Python code in HTML templates?
 
I don't, but I personally like the way code is naturally formatted on SO. I don't like dark themed code blocks on light themed sites. If I could add anything to the SO code formatting it would be line numbers
 
That's pretty interesting, thanks @Dodge
A "dark theme" has been long-requested for Spyder, for example
 
3:32 PM
Yeah dark-themes are popular. I use one in Pycharm. I know how to use <code> and some in line styling to make custom code blocks but I don't know to perform syntax highlighting like what we see in a code block in SO flavored markdown. That is why you are looking for a library I guess...
 
it is :)
 
But for the do-it-yourselfer we have this :)
 
Oh man, I'm really not gonna try to implement from scratch! I already have 3 servers running, in addition to the app server, just to power my examples. I want something a little more simple here :P
 
Sympy has interactive blocks where you can toggle output I think
 
@roganjosh No joke!
 
3:38 PM
Good day to all..
 
Or maybe they have the online interpreter
 
@Dodge There has to be a simpler way. For sure.
 
Oh, it's docs.python.org that toggles output!
 
Uh, wordpress? :)
 
get out :P
 
3:40 PM
I know nothing of wordpress but have read enough memes to know that is is extremely simple and well-liked
 
It won't do what I'm trying to make
 
@Dodge also vulnerable I think
 
Did you say your back end stuff is Flask? @roganjosh
 
I have a C++ routing engine, a Java-based routing solver, stand-alone scripts
 
Allow me to ask a quick question, no code, just about class.
Disclaimer - I just asked about it on SO, but it's Saturday, might not get an answer today
 
3:43 PM
Wait
 
@AndrasDeak really? That's interesting. Hadn't heard that about WP
 
@Mr.President that's exactly what we ask users not to do sopython.com/chatroom
@Dodge perhaps it was just one incident, not sure
 
@AndrasDeak Yeah, I read that, that's why I did not post anything
 
@Dodge The framework is Flask
 
3:46 PM
:), Would you make me wait for full 48 hours?
 
Yes, please
 
ok, thanks
 
@roganjosh take the code block in the first result from Andras' query for example, it's ugly, don't do that.
 
i'm not following
 
@roganjosh quora.com/Why-is-WordPress-so-vulnerable second result from the link, the message he just posted that starts with OK
 
3:48 PM
Nothing I have done touches wordpress at all
 
@roganjosh my terminology is not great. So Flask is the "framework" got it
 
click button --> flask route --> call some process --> process responds --> flask receives data --> flask passes results to front-end
That's a really simplified version of things, because I have a Java server waiting for problems to solve, so flask passes that data to my Java server via ZMQ in a set format. I also have a self-hosted version of OSRM that both generates distance/time matrices for vehicle routing problems, and also powers a JS library to map out the route
 
Cool. Is the site up? Can I take a look
 
No, it isn't up (yet) as I'm now trying to fix the second example. However, I have a really rushed example that I screen-grabbed for my best mate
... it's failing to upload
 
Reading about the WordPress vulnerabilities I found this: 74 different versions of WordPress were identified. 11 of these versions are invalid. For example version 6.6.6. version 6.6.6 just sounds like trouble
 
4:00 PM
I bet you can use the tokenize module to get quick-n-dirty syntax highlighting. As an example, pastebin.com/36Tzz238 colors all keywords blue and all string literals red.
... And it also deletes all whitespace that isn't part of indentation. Making it not do that is left as an exercise to the reader ;-)
 
@Kevin the coloring syntax that has been inserted in the output string... what is that. Not HTML, right?
 
@Kevin That's way more effort than I expected. Please don't go out of your way for me!
 
maybe that is just some dummy syntax to show how coloring could be inserted and could be changed to the needs of the user
 
Knowing Kevin, he will have tested that to make it correct. It won't be dummy syntax.
 
4:17 PM
[color=blue]import[/color]os in what context will this syntax produce a colored output? It's probably an obvious answer I just don't recognize it.
 
@Dodge It's a common convention on many sites to convert HTML tags to a form that uses square brackets instead of angle brackets. That makes it easy to support a restricted set of tags while preventing undesirable HTML injection. phpBBS sites like the xkcd forums use that strategy.
 
Ahhh, thanks @PM2Ring
 
4:44 PM
@Dodge No worries. I just checked an old xkcd post of mine, and it definitely uses that exact syntax. Eg, I used this: 0=black, [color=brown]1=brown,[/color] [color=orange]2=orange,[/color] [color=green]3=green,[/color] [color=blue]4=blue,[/color] [color=purple]5=purple.[/color]
 
weekend cabbage
 
I wanted an advise on the below,

I have a Django form and there is certain criteria for a record to fall in a database probably some validation. I have written the validation in forms.py file and now I would expose the same functionality but via REST API so I will have the trouble to rewrite the same logic again. What can I do ?

My Proposed Solution
Write a common business logic function in some place(lets name it BusLogic.py) and pass the objects to that function so that the business logic written once can be resued ?
 
5:02 PM
other way around perhaps?
the function in one place, and all objects that need it use it?
to me, that seems like a more traditional way to use a function. call where needed
or well, if you meant what i said, then ignore. :P but yes, common function lying around somewhere sounds fine
 
So if you write a common function you could just pass the object and that function would validate and add the record to the database.

If you are exposing the same functionality via REST, I will take inputs from the request create the object that the business function needs and then pass the prepared object to that function which will do the same job hence reusing the function
At a higher level this is what I mean, creating an object that is recognized by the business function so that it can do its job.
Writing a code for an enterprise is a no joke takes so much time to understand and architect that's what I learnt..
 
5:38 PM
@Dodge It's BBCode, or at least what I think BBCode is after not using it for five years
I didn't test it. I considered emitting ANSI escape codes instead, since that is testable in the console. But then it was time for lunch.
 
6:25 PM
HI guys
I want to get the details of the first dataframe which has common address values with the second, how do I do that?
 
give us an expected output for unambiguity, that's also part of an MCVE
 
Ok should I create a new one? or should I say the output here?@AndrasDeak
 
update your pastebin, or if that's not possible post a new one
 
Is there any shortcut for aligning things there? I always find it hard to align the columns above the values
 
it's fixed font, I imagine it shows what you type/copy there
 
6:39 PM
>>> d1['address'].isin(d2['address'])
0     True
1    False
Name: address, dtype: bool
>>> mask = d1['address'].isin(d2['address'])
>>> d1[mask]
                       address BLD
0  wienerstr. 30 wienerstr. 3ß  30
 
Ok
I tried that for my original dataframe and it is returning 0 rows, I guess I failed to create a replica MCVE @Dodge
Thanks for the prompt help though, I will see how I can improve the MCVE @Dodge
 
it will do exact matches, not substring matches
 
For substring matches, I will use str.contains right@AndrasDeak
 
could be, I don't know pandas
 
6:59 PM
Is there any way I can pass a whole column to the str.contains function of pandas?
It seems that when I compare the values directly, its not being returned but when I use str.contains for a common value, its getting returned
 
What search expression did you try to google?
 
how to pass a series to pandas contains function
 
That won't do
Try something like "pandas match substrings"
 
7:17 PM
Thanks @AndrasDeak
 
cbg
@piRSquared bit late to the party, but I've finally gotten around to playing around with GIMP. Here's a proof of concept for creating a gif from the command line, using GIMP's python-fu. There are some inevitable hacks involved (for instance, python 2). Might be useful in the future (cc @Kevin)
it could easily be turned into a proper python-fu plugin, but that's mostly useful for running it from inside a fully fledged GIMP window I think
 
7:51 PM
Hi team, I am looking for a python library or framework for getting complete search results of a successful search engine (like: google, bing, yahoo or duckduckgo). Most of search engines have restrictions and I don't want to waste time with restrictions. I want to query specific keywords like: inurl:wordpress
 
8:03 PM
<shameless promotion> I ran into a question I need answered and put up a 500 point bounty </shameless promotion>
1
Q: Deploy Semantic Segmentation Network (U-Net) with TensorRT (no upsampling support)

YayuchenI am trying to deploy a trained U-Net with TensorRT. The model was trained using Keras (with Tensorflow as backend). The code is very similar to this one: https://github.com/zhixuhao/unet/blob/master/model.py When I converted the model to UFF format, using some code like this: import uff impor...

 
8:37 PM
@AliOkanYĆ¼ksel I'm a layman when it comes to web stuff but my impression is that free search engines have restrictions for a reason. I wouldn't be surprised if there were paying API customer options
@Mikhail small world that both of you have to solve the same specific problem within 2 days :)
 
Perhaps its the ML feeding frenzy
Did they add any new features past python 3.7? Last cool thing I saw was python static checking, letting PyCharm provide more relevant code hints.
 
8:53 PM
Well 3.8 is not released yet. But it has positional-only parameters, and some syntax warnings are raised in common typo or dumb situations. But 3.8 will also have assignment expressions, ew. See docs.python.org/3.8/whatsnew/3.8.html for current list
 
@AliOkanYĆ¼ksel Elasticsearch?
 
Also doesn't even look like a walrus
 
>>> '\e'
<stdin>:1: SyntaxWarning: invalid escape sequence \e
'\\e'
 
@RaphX .str.contains operates on a full Series. That's the whole point of pandas methods; if they can't be properly vectorized, they'll implicitly iterate through rows of a dataframe or, in this case, items in a Series.
 
neat
@roganjosh they wanted to compare two Series based on substring matches
>>> def foo():
...     return *'bar',
...
>>> foo()
('b', 'a', 'r')
also interesting
code golfers rejoice
 
9:02 PM
@AndrasDeak it's still an answer to that particular question but, on re-reading, I don't suppose it's going to get them anywhere
 
could be
 
Eh, replace "answer" with "response". I don't suppose there's much in way or an answer with no MCVE
 
there was an MCVE
 
 
1 hour later…
10:25 PM
@Arne It might just be that I got to "grow up" with SO, but I've never found it to be difficult to ask a good question. I mean, sometimes I've asked non-SO questions
or other poor-quality questions
but I think the challenge is that asking a good SO question is an entirely different skillset from the one required for writing reasonable software
I'm not surprised that industry vets have a bad time asking on SO because it's an entirely different paradigm than any other community that they've previously been a part of
 
Is it really? Writing good bug reports requires writing MCVEs for example
And can you spent years in sw industry without ever learning that? Apparently the answer is "yes", else there wouldn't be these kinds of post.
I'm mostly expressing my surprise here, I guess
 
 
1 hour later…
11:34 PM
I'm an industry vet. I get by. What was your point?
 

« first day (3199 days earlier)      last day (1740 days later) »