« first day (2771 days earlier)      last day (2402 days later) » 

14:01
My first abortive foray into coding was Amiga Basic in the early 90s. Python has been an on/off thing for the last 8 or so years
cbg all
(cbg Wayne and Olivier)
so annoyed -_-
I started coding for grad school financial engineering degree. I’d consider myself a person who could understand control flow and hack together things that ran. I got more serious about it 4 years ago when I picked up python.
)-: @WayneWerner
14:04
Someone had a year old gaming laptop on offerup that they agreed to sell me tomorrow AM. Then they marked it sold this morning, without so much as a BTW >_<
puts on some snake hide rimmed glasses and turns to Wayne "Please continue"
in other news, my UHK looks like it should end out shipping (being delivered?) right about time for my birthday, woo woo!
Could someone help me with a weird issue on some python code?
Why don't you open a question ?
Couldn't open a question because I got downvoted on some questions and I'm too new
14:07
or alternatively, ask about the issue in here, if you lack the skills to create an MCVE
so they banned me from asking a question
which, it sounds like it! :P
@AlB don't ask to ask, and if they banned you from asking a question, it was probably with good reason
oh hey, doesn't [mcve] work in chat now?
Guess not
write a better phrased question :P don't send us the exact same question because we are the people closing your questions
14:08
My day is full of disappointment \o/
It wasn't... The examples I asked had similar questions which I saw but they didn't answer my specific questions
@WayneWerner never has from my experience
unless they finally get around to implementing it...
and even if I rename or edit my questions I can't undo it or get unbanned it seems
I believe you should create a short code snippet, and send the link here, explaining very shortly what's it about.
I thought I remembered reading something recently, but apparently that was just in my dreams
14:09
Wait, let me see....
yup, still works @WayneWerner
@AlB one good choice: say "Here's my question that got closed: <link to question> can you help me understand why it got closed?"
@coldspeed gasp wha thappened to your name
6
So here's my latest code question
a = input("end of program")
MasterFolder = input("Paste MasterDoc Security Location")

a = input("end of program")
MasterFolder = 'C:\Users\Jahn\Desktop"
@coldspeed did you just link that?
My name has shed its skin (; ̄Д ̄)
14:11
If I run the top two lines in an idle doc, the program stays open in the cmd window
@WayneWerner never has. Userscript
If I run the bottom two lines with the C:\ my window immediately closes
and I can't enter input
@WayneWerner I have a open feature request on meta for magic links in chat.
I don't understand why python closes if I set something equal to this path string
14:12
Your syntax is wrong
Sorry, I copied part of my code wrong, its the same ' ' on both sides
@AlB What are you trying to do? What do you expect your code to do instead of what it is actually doing?
It's still wrong though, even with correct quotes
@AlB You open the string with a single quote and close it with a double quote
@coldspeed wouldn't it be bigger now, instead of smaller? ;)
14:12
and how are you running your code? Are you using the command line? Or are you using an IDE?
I'm using IDE
just saving the document and double clicking the program
@AlB also, Python should give you a helpful stack trace. Oh... but if you double click then cmd is probably closing on you without giving you time to see what you're doing.
yes, there's a common misconception that graduating from small caps implies your caps become big... but not true
I used to use dvorak keyboard layout until I got sick of nobody being able to use my keyboard... So I gave it up.
If you double click a Python program in Windows Explorer, it will run and close the window immediately after it ends.
14:14
You should open a prompt, and launch it with python <your_file> if you want to keep a log of the stack trace.
@piRSquared that sounds like a dream come true :)
others not being able to use your keyboard is step 1 towards sanity
It doesn't immediately close because of the input
Its justs only if I have the C:\ line in my code it closes
@AlB Yeah, it closes as soon as it hits an error
which makes no sense
but the first line is an input
14:14
try this code...
so how is it running the second line
@AlB That line:
MasterFolder = 'C:\Users\Jahn\Desktop" # you open with single quote and close with double
Lots of collaboration and passing a keyboard back and forth
input('type something')
x = 1 + 1
print('Hello!')
raise Exception('This will crash!')
input('You will never see me!')
I tried fixing it and it still has an issue
14:15
>>> 'C:\Users\Jahn\Desktop'
  File "<stdin>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Here's your error. MCVE: ✔
I didn't use the run check I see
This is pretty interesitng.
@AlB I'm sorry you got banned, but you really need to ask better questions
Not sure how that's a Unicode escape issue, never seen that one before
You guys might have an idea to answer the question.
14:17
@SeanFrancisN.Ballais and off-topic, too
probably better on math.SE?
@piRSquared you can set different layouts up in Windows so you can swap between them. Alternatively, find a... well, I can't find one, but I have a dvorty keyboard. I think that's what it's called
@AlB You need to escape your \, replace every \ with \\ and it will work
@AlB What is going on is that after a \U, Python expects a unicode code
14:18
or use r'C:\Users\Jahn\Desktop'
if that exists, sure
What's the difference between \ and \\? Not familiar with Unicode vs what this format is
or 'C:/Users/Jahn/Desktop', which also works
\\` escapes a \` in your string
Thanks, I'll try the r
@AlB I suggest you read that
14:19
ugh. And apparently in chat, lol
Thanks Olivier
nice cross-site dupe, @IMCoins
Thanks google for answering "big o origins". ;D
@IMCoins, nice catch!
jpp
jpp
What's the pythonic way to iterate lists of single-item dictionaries? I can see 3 options: (1) iterate as normal, i.e. {k: v for k, v in d.items()}, (2) access via list conversion: (list(d.keys())[0], list(d.values())[0]), (3) (next(iter(d.keys())), ...) ?
14:27
the first one is different from the rest
or you mean that inside a listcomp?
jpp
jpp
yes
What do you mean with single-item dictionnaries ?
jpp
jpp
if we have a list of dictionaries and you need to iterate them
definitely not the second
jpp
jpp
so [{k1: v1}, {k2: v2},...]
14:28
Do you need the original dicts? If not, how about popitem?
What should be the final result?
Hmmm, alright.
@vaultah A fused dict I think
jpp
jpp
final result: [(k1, v1), (k2, v2), (k3, v3), ...]
10 hours ago, by PM 2Ring
@AlB Firstly, SO isn't a forum, so trying to use it like one can lead to trouble. Yes, people can be a bit harsh to newbies, but we were recently asked to try to be more welcoming. However, newbies are expected to read the Help pages so they understand how SO works, and what's expected of them.
People don't downvote merely because you're a new coder, they downvote if they think you haven't done sufficient prior research.
jpp
jpp
14:28
this is actually a common sub-question.. with all the json data flying around
So if you ask a question that could be answered by reading a decent tutorial or the relevant section of the docs, then expect downvotes. SO can't be a substitute for an actual class or tutorial. We can't teach you stuff from scratch, but we can help to fill in the gaps in your knowledge, and try to fix misunderstandings you may have.
print( [next(iter(d.items())) for d in [{1: 'a'}, {2: 'b'}]] )
can't you just do dict(**d for d in x)? or something like that...
>>> l = [{'k1': 'v1'}, {'k2': 'v2'},]
>>> [x for d in l for x in d.items()]
[('k1', 'v1'), ('k2', 'v2')]
I think I tried that
14:30
[(k, v) for k, v in d.items() for d in my_array] ?
jpp
jpp
@WayneWerner, yeh but output isn't a dict
@WayneWerner You can't use splat unpacking in a comprehension / gen exp.
@IMCoins list, not array
plus reverse order
I like vaultah's
I quite like this alt
In [98]: from itertools import chain

In [99]: l = [{'k1': 'v1'}, {'k2': 'v2'},]

In [100]: list(chain.from_iterable(map(dict.items, l)))
Out[100]: [('k1', 'v1'), ('k2', 'v2')]
Though here you go: jfsasdvaav (some characters for those var names) ;D
14:31
How do I iterate through class attributes?
Something like this:
class Form():
fields = ['username', 'email', 'password']
. . .
form = Form()
for field in form.fields:
form.field.something()
100% functional
jpp
jpp
I like the chain too actually
very lazyt
In what cases would chain be useful?
Too many function calls and intermediate iterators
as are all functional approaches :D
jpp
jpp
14:33
but the function calls aren't in inner loops right..
@edsheeran attributes or methods?
@edsheeran for field in form.fields: and An illustrated guide to formatting code in chat
one of these things is not like the other
@vaultah If you don't already know, you'll be interested to know that chain outperforms list comps with flattening
methods, my bad
14:34
In [101]: l = [{'k1': 'v1'}, {'k2': 'v2'},] * 100000

In [102]: %timeit list(chain.from_iterable(map(dict.items, l)))
57.6 ms ± 705 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [103]: %timeit [x for d in l for x in d.items()]
59.1 ms ± 1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
etc
That's a lot
@SeanFrancisN.Ballais I call it Orbison notation. ;)
@edsheeran what is it that you're trying to accomplish? There may be a better way.
@AndrasDeak So it should be array([ (k, v) for d in my_array for k, v in d.items() ]) ?
14:34
@edsheeran replace form.field with getattr(form, field)
@IMCoins still not an array :P
I mean, the input
and I guess the output, while we're at it
it might not be a lot but it still proves my point that functional approaches aren't always worse
jpp
jpp
@edsheeran, why not use operator.attrgetter and specify multiple attributes?
besides I think the bottleneck here is map
In [3]: %timeit list(chain.from_iterable(map(dict.items, l)))
29.3 ms ± 95.4 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [4]: %timeit [x for d in l for x in d.items()]
29.7 ms ± 68.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
14:36
@WayneWerner you're probably right. I'm trying to generate forms with Jinja templates
Here you go
Well my laptop is quite old, even if it is i7 ... :-(
@edsheeran so.... you've got a bunch of functions that create forms?
@coldspeed Are you saying new CPUs are optimized for listcomps?
and vulnerabilities!
14:38
I'm just a little sad that my timeits are nearly twice as slow as vaultah's
I have i7, too
you don't even know what his d is
vaultah, give him the d
@WayneWerner yes, Jinja has functions to create form fields, labels, etc... I want to repeat as little code as necessary
I have i7 too
but they're getting old too
14:40
quite the model RO, aren't you
I've a 2013 mac, but it still works like a charm
oh, you used coldspeed's example d, nevermind
@edsheeran does it? That must be new!
Personally I've used flask-wtforms with some helper render functions
In [4]: %timeit list(chain.from_iterable(map(dict.items, l)))
39.8 ms ± 419 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [5]: %timeit [x for d in l for x in d.items()]
41.1 ms ± 463 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
What's currently in the market? i9? i11?
14:41
i9 I think
lol
disclaimer I know nothing of processors
@AndrasDeak yeah, to be fair, I don't get consistent results
i9's are pretty affordable right now
@WayneWerner I guess what I meant to say is render, I'm not really sure which module does what since I'm new to Flask, but that's good to know.
ios11 d-:
14:42
I've grown to realize that I'd be much better off with some low-power i5s than this i7 workhorse that eats all my battery
can you throttle it?
well there's speedstepping but it eats a lot anyway
@edsheeran do you have some sample code of how you're creating and rendering one form?
<pretends to understand what's being said> ahhh, yeah... should totally do that
i.e. probably a gist/pastebin because I'm expecting at least a couple dozen lines
@coldspeed Fake it til you make it!
omg @colds<tab> didn't choke!
https://pastebin.com/Ukcjz0wk
A lot of repeating code which I'm trying to reduce
YOU'RE WELCOME
Shouldn't that be Yᴏᴜ'ʀᴇ Wᴇʟᴄᴏᴍᴇ ?
14:54
@WayneWerner This looks promising, thanks
@PM2Ring I was thinking of Yᴏᴜ'ʀᴇ wEʟᴄᴏᴍᴇ for maximum eSport speed :D
@coldspeed here's a better test with a spoiler gist.github.com/vaultah/ff165ea95218fa3240ad1749b2c4ac50
g is always faster: 3.0065 vs 3.11
Why was that comment marked spam?
@vaultah That gist name though :-(
That's the spoiler
If that message gets removed, I'll repost it, because those flags are invalid
it doesn't say though, which function belongs to whom ;)
15:07
why all the high rep users seem to be banned now :?
@coldspeed do columns in pandas have homogenous types, so if you mix ints and strings will it always be object type?
@vaultah after 30 minutes?
@chrisz I think up/down coercion only happens with numpy to preserve performance. With pandas, they just become object columns and kill all performance
@AnttiHaapala I'd answer but it would get flagged
15:10
@AndrasDeak vlad from moscow, over 100k rep before, suspended for 1 year :D
Experimenting with musical accompaniment after reading an article. I figure 2Cellos counts as classical...but I generally wind up grabbing a guitar, so this may not be the best strategy for productivity...
@AndrasDeak 9 answers on the day that he received suspension...
@AndrasDeak it was Ashish's message that was flagged
@coldspeed So if you have an object dtype in pandas, it uses the python behaviour, and if it has a specific homogeneous dtype, it will use numpy ?
15:12
@vaultah oooooh, thanks
@AndrasDeak and to awful C++ questions :F
@AnttiHaapala I'm aware of his work
IIRC it still uses the numpy behaviour, but the numpy behaviour with object dtypes is slow python
TBH, I posted it because there are some regulars that are interested. (And I posted before about attending the summit)
Don't worry about it, it was appropriate
15:13
Every sane >10k user in this room has marked it invalid, I hope
@AndrasDeak I know, I was clarifying for whosoever flagged it.
No, I'm on mobile. Or insane. Or both
@AndrasDeak message was appropriate or vlad's suspension? :D
he'll say "both"?
15:15
@AnttiHaapala former
@shad0w_wa1k3r the kind users underlying today's flag culture on SO don't give a yam for context and merit
wait, so you're implying that the suspension was not justified?
I don't know details about the suspension so I can't form judgement
@AndrasDeak :/ Doesn't hurt to be hopeful of them changing for the better I guess.
I envy your optimism :)
rhubarb for now
Well, without hope, I would be very scared in 2018.
rbrb
15:17
Only 2018 ? ;)
Talking about the present :)
Why on earth would you want to reward people who post link-only answers by editing their answer to include the relevant offsite material, and thus increasing the answer's chance of getting upvotes? meta.stackoverflow.com/questions/368040/…
Isn't there a rule that forces you to explicitly write or quote the relevant information when you're using a link ?
But I think it can be ignored or there's a char limit to that. So, easily overcome.
Wow, I'm trying to write such a large image that pillow broke:
15:25
@IMCoins Link only answers are classed as Not An Answer so they automaticaly go to a review queue.
Traceback (most recent call last):
  File "merge.py", line 15, in <module>
  File "image_utils.py", line 44, in im_write
  File "site-packages/PIL/Image.py", line 1728, in save
  File "site-packages/PIL/BmpImagePlugin.py", line 257, in _save
  File "site-packages/PIL/_binary.py", line 84, in o32le
struct.error: 'I' format requires 0 <= number <= 4294967295
[10146] Failed to execute script merge
I have exceeded the size of a long long apparently
can you have an or mechanism in a glob pattern? glob('blah_{this|that}.csv')
@piRSquared No, I don't think glob supports pipes. only character classes
@OneRaynyDay Pillow didn't break, BMP did. And I don't blame it. :)
you'll have to do something like for f in chain.from_iterable(glob.iglob(f'blah{s}.csv') for s in {'this', 'that'}):
15:29
boo.. thx
did I say long long I meant uint32
@PM2Ring okay. Well... What file format is not so easily breakable?
@OneRaynyDay Give PNG a try. That way you'll get compression as well. But just how big is this image?
@PM2Ring more than 20 gigs
@OneRaynyDay I mean in pixels. And depth. Eg is it 24 bit?
@PM2Ring RGB, 8 bit, hundred thousands x hundred thousands width height
15:32
@OneRaynyDay I'm surprised nothing else broke before bmp
I am running on quite a beefy machine
(not that surprised if you say have 32GB+ RAM)
probably 10x that
@OneRaynyDay ah, that explains it then
@OneRaynyDay PNG should be fine. It uses 32 bit unsigned ints for width and height. But gee, do you really need images that big? :)
15:34
@OneRaynyDay Woah, where is this machine? Physical on-premise hardware I suppose?
@PM2Ring it's for a stress test on a system I'm working on
and the stress test worked! I'm also going to kinkos and printing an ANSI D poster of this ;)
Rightio. It'll certainly be pretty stressful. :)
@shad0w_wa1k3r on prem yes, sorta
OK I am more and more thinking that perhaps I should stop doing this SO.
Got a question : is there a better way to access an array with another array in numpy than...

numpy_arr[ tuple(numpy_arr_indexes) ] # outputs : 4

Where
numpy_arr_indexes = [1, 1]
numpy_arr = [[1, 2], [3, 4]]
15:40
@OneRaynyDay PNG has a variety of compression options that can be combined in various ways. The typical PNG savers will try a few variations to determine a good combination for a given image. That may take quite a while with such a large image. PNG optimizers can try a whole lot more combinations: if you're really keen you can force optipng to spend 10 minutes or more searching for the best compression on a mere 1024 x 768 image. ;)
@IMCoins Probably. Try to avoid mixing plain Python data structures with Numpy arrays. Tuples get converted pretty fast, but it'd be better to collect those indices in a Numpy array, using Numpy functions or methods.
DSM
DSM
Friday cabbage %
@PM2Ring dang that's so gcc -O4 stuff. I have enough hard disk :) and we got giant pipes on prem
15:43
One issue is if I'm sending this over to kinkos the file upload might throttle their upload servers and likely cause mayhem
(and yes I know the res is way over dpi)
Isn't -O3 the farthest the compiler can go?
@coldspeed yea, it was an attempt to make that optipng thing sound extreme
fun fact -O{n} where n > 3 will always go to -O3
@OneRaynyDay PNG was pretty advanced when it was first devised. But back then 32 bit CPUs were very new technology. If you don't want the PNG saver to futz around looking for good compression options then tell the saver to use a small optimize setting. Or whatever PIL calls it, I can't remember off-hand. Even at its best PIL's PNG saver isn't spectacular, so I generally use its default settings and then use optipng .
@OneRaynyDay And Clang will warn you the optimization level doesn't exist, while GCC doesn't :P
15:51
No hold on
I'm all in
I'm leaving, have a good weekend!! :)
yeah, what I wrote was right @IMCoins, you need to do what you did.
Unless arr[*indices] works, but it probably doesn't
@Neoares same to you!
Although my weekend is almost over, but at least I enjoy reduced work-hours (9-3) for a month :D
16:13
@miradulo even on my mac I have forced compilation to be on gcc
so I wouldn't know :P
DSM
DSM
16:26
@coldspeed: pivot_table's margins differ from the OP's expectations, and he says "apparently pivot_table cannot give correct results using mean", hence my question.
@DSM they probably didn't know about the margins... and it seems they've gone ahead and accepted
I'm guessing the expected result differed from whatever had calculation they'd done because of OP related typos
cbg all
DSM
DSM
(sigh) Serves me right for spotting an issue and waiting for an answer. I should know better by now.
Cabbage for Augusta.
How is DSM today?
@DSM something something early bird... :)
DSM
DSM
16:30
Drowning in work which absolutely has to be done because the process it controls goes live next Thursday, and if it goes wrong many bad things will happen. So of course I'm in SO chat complaining about gunners.
And two critical personnel are on vacation, and Monday's a holiday. Naturally.
FGITW well asked questions... I can forgive a typo
Anyway, good luck with your work!
mine starts monday :)
hi guys
i have a model like this
"When it rains, it snows."
-- Yogi Berra
@MilindAnantwar too much code, can you delete it and put it in a dpaste please?
im getting error at CoordPoint = CoordPoint(
geom=Point(1, 1)
TypeError: 'CoordPoint' object is not callable
@MilindAnantwar please have a look at our rules
You know, I have seen the name dozens of times in here, but I only now remembered what The Rotating Knives is a reference to. :v
It's one of my favourite Monty Python skits. But I must admit that it is a bit creepy.
cbg
16:43
And you know, after seeing "Live Organ Transplants" and "Mr. Creosote," I found I had no way to calibrate what I found 'creepy' in Monty Python? :v
Like, after those, What Even Is Weird Anymore?
It could just be me, though. :1
Hi everyone. i have model in django

class CoordPoint(models.Model):
name = models.CharField(max_length=200)
geom = models.PointField('longitude/latitude', blank=True, null=True)
objects = models.GeoManager()
@Augusta Not to mention the Lifeboat sketch
and im trying to itearate over list and create coordPoint like this

for idx, coord in coordList:
CoordPoint = CoordPoint(
name="coordlist" + idx,
geom=Point(1, 1)
)
CoordPoint.save();
@PM2Ring Just so.
getting error coordlist not callable
DSM
DSM
16:48
@MilindAnantwar: you have a class CoordPoint, but you're also naming your instance of it "CoordPoint". What will happen on the second iteration?
Also, you can directly use .objects.create instead of initializing them using .save.
e.g. CoordPoint.objects.create(<args>)
you don't need to save the output into a variable, so that should eliminate your current error.
@miradulo gcc is for people who want their amps to go to 11. clang is for people who want to make 10 louder instead, so it’ll be just as loud. But 11 is still one more. One louder. When you need that extra push over the cliff.
amazing, I found 28 upvotes to a comment that is total garbage, asking to check how the result of !0 might not be 1 in C on some compilers (guaranteed by any standards). Here
@AnttiHaapala Flag it as obsolete.
@PM2Ring I had to flag ~10 comments in total there :F
I mean did every 28 of those actually test that code and find out that it doesn't print 1 on their compiler, or... :D
16:53
I often upvote comments just because it might seem slightly clever even if I don't get it
At least Dale Hagglund's comment got more votes.
Maybe a lot of people are like me
@AnttiHaapala Didn’t the ANSI committee debate allowing -1 or other values of true before deciding YAGNI? So there could be some 70s or 80s compiler that does differently, and its developers just didn’t participate?
C was a mistake
@OlivierMelançon this isn't reddit :)
16:54
@shad0w_wa1k3r sorry about that
@OlivierMelançon sorry this isn't reddit?
@KevinMGranger Computers were a mistake. But we still have to live with them.
@abarnert I don't remember that, but I do remember -1 being the standard True value in numerous dialects of BASIC, and maybe some other languages.
Sorry about my out-of-tone comment-related behaviour
@PM2Ring me too
16:55
@OlivierMelançon Not all of SE is like that though, but you can't shouldn't be like that on SO.
@shad0w_wa1k3r: like this
CoordPoint.objects.create(name="coordlist" + idx, geom=Point(1, 1))
@shad0w_wa1k3r I'm more diligent on my question/answers votes though
Thanks shad)w_wa1k
16:56
yw
I just always upvote comments that are like: "what about [some corner case that will most likely never happen, but that the user surprisingly thought of]"
wim
wim
(removed) too late with this joke
@OlivierMelançon Comments can be a problem. They can get upvotes, but not downvotes. And that's one reason why we don't like answers being posted in comments, because they're insulated against downvotes. And so they aren't competing fairly with the proper answers on the page.
@OlivierMelançon I can understand. Sometimes it's okay, but sometimes you end up promoting something wrong.
@PM2Ring Yes, and -1 makes sense, if you assume everyone uses 2’s complement. Every bit is true. There is none more true. (Until you ask why every bit is 1, rather than -1. But the kind of people who ask that are knocking out hacks in a Bell Labs basement, not working at real OS companies like IBM.)
16:58
@OlivierMelançon I love cases like this but I am never sure what to do with them, more or less for the reason PM just gave.
About comments, is that really an issue? I mean, mature SO users know that and new users kind of overlook comments since they are just those tiny letters under what they are looking for (answers). Plus you do not get rep, so it looks pretty minor to me
% gcc -O9223372036854775806 foo.c
% gcc -O9223372036854775807 foo.c
cc1: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’ or ‘fast’
undefined behaviour in the C compiler! :D

« first day (2771 days earlier)      last day (2402 days later) »