« first day (2525 days earlier)      last day (2648 days later) » 

15:10
GNAAA
Stupid backwards APIs
foo.replaceChild(a, b) – what you would you assume this does?
I'd assume it replaces child a with b yet it replaces b with a?
recbg
100 points for Andras. >_<
It’s Node.replaceChild(newNode, oldNode)
I hope these points are worth more than quatloos
15:11
Might be less
Poll: del seq[x] or seq.pop(x)?
latter for me
usual caveat for listening to my opinion in programming
or seq[:x] + seq[x+1:]? :P
honestly I have a superstitious aversion to deleting from lists
seq = [y for y, i in enumerate(seq) if i != x] # No lists were harmed during this "removal"
Just to throw in other ideas
Kevinson Senior is asking for my advice, so the results of this poll will influence literally dozens of new users that we'll probably have to interact with some day
I’d go the del route since it’s a keyword and we use that already so rarely.
15:16
perhaps the one that is more broadly applicable to containers? (assuming there is one)
del then
DSM
DSM
Syntax should match semantics. Use del if you just want to remove it. Use pop if you want to use the removed.
del myDict['foo'] vs myDict.pop('foo') #derp
I told him "pop if you need to use the value, del otherwise"
He actually worded the question like "del: statement or method?" so I had better follow-up and make sure he wasn't asking whether it's ever a good idea to call seq.__delitem__ manually
I think what I actually usually do is seq = seq[1:]
But that creates a copy
15:23
@Kevin aren't you Kevinson Senior?
DSM
DSM
I actually spent time with the intern this summer talking about my "syntax ~ semantics" position and how it guided my evaluation of his code.
@RobertGrant Thanks for bringing that up, this was confusing me too
No, he's my dad. I try to use that name only in contexts where it's obvious I'm not talking about myself.
For real?
I would not ask myself for my advice, for instance. because I already know it.
Speaking in the third person is not one of my many eccentricities.
DSM
DSM
15:25
That Kevinson Senior is also a programmer is a fact which is known.
it is.
I didn't know that
Speaking in the second person is a sometimes-eccentricity, but only for internal debates
"Chicken or turkey for lunch today?"
"Chicken is superior and you know it"
"Ok, but how do you know I know it?"
"I know everything you know and I also know that you know this, so I know that question is rhetorical but I'm answering it anyway, because I have no problem answering rhetorical questions, as you know"
@Kevin Are you sure though?
Kevin comes from a long line of programming Kevins. An ancient race of Kevins
DSM
DSM
15:29
Now I feel weird about the fact I'm probably going to have turkey for lunch.
so will the turkey
My proclamations about the best lunch meat, only have authority in the space between my own ears. Ignore my opinions as your discretion dictates.
DSM
DSM
@AndrasDeak: genuine laughter was had.
Turkey isn't a great meat
I overcame my dictatorial discretion - we don't yet have a democracy yet, more of an anarchistic state, but we do often try things against some of our better judgement.
15:43
cabbage
@toonarmycaptain are you a benevolent dictator at least?
@Code-Apprentice I forced myself to come to work today, and I'm drinking coffee instead of rum, is that benevolent or tyrannical?
@Kevin is that an original Kevinson?
wim
wim
wow, pathlib.Path.glob is orders of magnitude faster than glob.iglob. I wonder what improvements they found in implementation?
Yeah
15:52
let me save that, it might come handy 30 years from now
plot twist: because by then turkeys will have been eradicated along with all the other farm animals
I have never seen a turkey in real life. They have only one wing and are only slightly larger than a slice of bread, I assume
test tube grown meat?
I already know this is a silly question but is shutil a built in python lib?
If it's on the main documentation it's built in, correct?
almost surely
wunderbar
15:55
tkinter is listed in the docs but it's not de jure built in
Sorry, de jure?
de jure vs de facto
tkinter is de facto built-in, but not entirely, and some installations are missing it
fancy foreigner with your fancier words
Mar 27 at 14:51, by Kevin
Unrelated. Today I learned that "de jure" and "du jour" are different concepts.
15:57
import openpyxl
wb = openpyxl.load_workbook(r'example.xlsx')
sheet = wb.active
sheet.columns[1]
> What is the *soup du jour*?
It's our soup of the day
That sounds great I'll have that
hehe
hey guyss i ke getting typeerroor
TypeError: 'generator' object is not subscriptable
so sheet.columns is probably a generator object
how doi fix that?
@Sterling tkinter's docs has a header about Tk's availability, and shutil doesn't
> The tkinter package (“Tk interface”) is the standard Python interface to the Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, as well as on Windows systems. (Tk itself is not part of Python; it is maintained at ActiveState.) You can check that tkinter is properly installed on your system by running python -m tkinter from the command line; this should open a window demonstrating a simple Tk interface.
I assume they'd note at the top if shutil wasn't a built-in
but my assumptions are just that, I don't actually know
16:00
This reminds me of how curses doesn't work on Windows ;_;
@faceless don't try to access its items using subscripts?
@AndrasDeak well, I gave it the old college try which I should have done in the first place (sorry for wasting time) and it was imported haha
you might or might not want to iterate over that generator, or consume it to get a sequence
Another de facto standard module. Or if not de facto de facto, then at least de jure de facto.
Asking noob questions is my plan to win @Kevin's heart
16:01
@SterlingArcher :P
My heart is made of stone, and not even stone with particularly high resale value
This is a no crap chat unlike JS (<3) so I actually have to try and be a contributing member when I come here
haha memer
Unlike those fat cats with hearts of gold
cbg!
code: https://pastebin.com/wySeeasa
in numpy 1.12.1(local machine), this code works perfectly, but in numpy 1.13(Jupyter Notebook) it doesnt and gives this error. "ValueError: cannot reshape array of size 50039824 into shape (60000,28,28)"
@Kevin even tungsten melts babe <3
16:02
Any obvious mistake I am making?
I'm more inclined to blame Jupyter than the numpy version. Not that my opinion is well-informed
Worth approximately two cents
okay, thank you @AndrasDeak
I dont like it either, but I have connected it to a powerful server and want to use it :|
wim
wim
@Code-Apprentice don't you love it when some n00b with 2.5% of yr rep tries to answer yr question .... 🙄
> The curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.
as de facto as it gets
16:04
@Grimlock if you became a medical examiner you'd be Grimlock, ME
unless this was your exact point
@RobertGrant Umm okay!
@Grimlock judging by the error that probably isn't numpy version specific
@AndrasDeak Cool. I hadn't looked at the docs so I wasn't sure if it was officially unofficial or not.
@Grimlock perhaps this will help explain: ME GRIMLOCK!
16:06
@Kevin that bit is unclear...
Course if you have to ask, then the joke wasn't great
My point was mostly to create a weird confusing sentence. Having any bearing on reality was a secondary concern.
@wim You saw that, huh? I appreciate him trying to help and with his newest answer I see that my question can be made more clear.
@Grimlock your file might be broken, or not in the format you expect it to be
or your shape is wrong
either of the two...
you need to figure out what's actually different between your two machines
for instance, the file
@wim I feel like I'm understanding pytest better than several weeks ago. Keep encountering situations where I don't know the pytesthonic solution, though.
and I don't like copy/paste coding ;-(
DSM
DSM
16:08
@RobertGrant: I just saw the "Grimlock, ME" joke and it's great. :-)
@Grimlock try printing the shapes and the length of the data read (without the reshape) on both systems
wim
wim
your question was perfectly clear, just the guy is clueless
what are the fixtures foo and bar actually setting it up?
@wim that doesn't necessarily imply that the answerer is wrong. Of course if your rep is question-tag-related, then there is some correlation to be expected ;)
I am transferring my script on server just to check if I get the same error. If not, then its the problem with Jupyter.
OK
I'll be away for a while but feel free to ping me if others aren't around to help in the mean time
16:11
Also, do explain what was the Grimlock, ME joke?
wim
wim
because if they are just setting up data, it will be better to parametrize the data than to try and parametrize the fixtures
@wim They are selenium-based fixtures which take the browser to two different pages.
wim
wim
ok so the data is just the url then
parametrize that
errmm
I'm clicking on links and/or buttons to get to the pages.
those are already parameterized.
hey, i need to build a scraper to scrape data from an excel spreadsheet, does anyone have any good tutorials for these types of scrapers?
16:13
I have a set of pages that I navigate to with a link and another set where I navigate from a button click on one of the pages from teh first set.
So, I tried uploading and running script on server, but no luck. Same error as Jupyter.
@wim Let me back up a little: I have a fixture login() which navigates to the login page and enters username/password. foo() and bar() both depend on login() and the resulting session data that carries around the authentication. This is why I am clicking on links and buttons rather than navigating to the URL directly.
wim
wim
I would try this approach docs.pytest.org/en/latest/example/…
If you figure it out, self-answer. I'd be interested in the feature too.
16:24
will do
I wish to register a complaint:
The docs.python.org/3/howto/curses.html contains absolutely no information on how to curse my enemies!
12
@wim I will have to read that doc in more detail later. Again, thanks for the links.
def move_subs_files(path, rmv_dir):
	sub_dirs = next(os.walk("%s/%s" % (path, rmv_dir)))[1]
	destination_path = path
	rmv_path = "%s/%s" % (path, rmv_dir)
	for child in sub_dirs:
		child_path = "%s/%s" % (rmv_path, child)
		try:
			print "copying directory from %s to %s" % (child_path, destination_path)
			shutil.copytree(child_path, "%s/%s" % (destination_path, child))
			print "removing directory tree %s" % rmv_path
		except shutil.Error as e:
			print('Directory not copied. Error: %s' % e)
			# Any error saying that the directory doesn't exist
@Kevin I did it!
This function moves a directories tree contents up a file level <3
that was fun to write
Nice work.
Style tip: you can use os.path.join to combine two strings into one path, rather than doing so manually with "/" and concatention and/or string formatting.
This is good design if your OS manufacturer might decide tomorrow that the path separator will be something other than "/"
Oh thank you! I didn't know that 😀 will use
16:30
On KevinOS, the path separator is the duck emoticon, but only on Tuesdays
Looking for a function to split a sequence into two, those which satisfy a predicate and those that don't. Have I reinvented the wheel here?
    In[7]: from itertools import groupby
    In[8]: split_by = lambda pred: lambda seq: tuple(list(items) for _,items in groupby(sorted(seq, key=pred), key=pred))

    In[10]: evens, odds = split_by(lambda x: x % 2)(range(10))
    In[11]: evens
    Out[11]: [0, 2, 4, 6, 8]
    In[12]: odds
    Out[12]: [1, 3, 5, 7, 9]
Hey guys, how do i look at what a certain module can do?
eg:
Hmm, I wonder if you could do something with takewhile there.
for cellObj in sheet["A"]:
    print(cellObj.value)
It's not what you need straight out of the box but it may be a useful component
16:32
@Kevin what about fridays
I want to know what value does or if i can put a parameter within the value module?
emoticons are just unicode, so that's a fine delimiter :O
KevinOS refuses to turn on on Fridays. Go outside and enjoy life.
> All stock prices plummet after production halts on fridays. Chaos erupts in Chicago..
@faceless Well, you can use dir to view the attributes of a class/object/module/whatever. And there's help. Those are the big two when it comes to exploring objects from within a python interactive session.
But the best way to learn about a module's capabilities is to read its documentation
dir(cellObj) will tell you that .value exists, but it won't tell you what it does or how you should interact with it. The documentation will, if it's any good.
16:35
ah wonderful, so will most modules have documentaiton?
Given that @faceless appears to be getting objects out of an Excel spreadsheet, and these may be win32/COM type objects, dir(obj) might not be that helpful.
Most modules have documentation. All of the standard modules do, and the majority of popular third party libraries do.
Yeah im trying to parse raw data using the openpyxl module
and boy, this is tough
win32 complicates matters somewhat.
Most of the Windows API documentation is designed for people that are comfortable with C
@SterlingArcher to add to what Kevin said: pathlib is magic (I'm not sure if it can help with your use case, but rootpath / childpath gives you the concatenated path and stuff. It just sounds great and if I ever had to do anything with files I'd try that first
16:38
@Kevin when will your OS ship?
that suggests there's no builter-in way (sorry English)
If I shipped I'd have to field a lot of angry troubleshooting calls, so I think I'll just not do that.
DSM
DSM
I've used openpyxl a fair bit. Worked well enough for me. @faceless: is the workbook you're playing with publicly accessible?
No it is not :( @DSM
DSM
DSM
Well, can you succeed and/or reproduce the problem with a workbook you made up yourself?
16:47
well, sort of, but the thing about this work book is that it is in column "A" and has 84000 rows of raw data and I need to parse a, 'Date: , To:, From:' and the data following after it and put it in chronological order and make sure that the 'Date:, To:, From:' fields are all relevant to each other but in their own separate columns
im reading through the documentation for openpyxl, but i might just use this to open and mess around with the file:
name = input('Enter file:')
handle = open(name, 'r')
DSM
DSM
Sounds like the real challenge isn't really openpyxl-related, then.
its having to filter certain fields from all these damn rows
DSM
DSM
Without concrete examples people can only give you general and/or motivational advice. In that spirit: you can do it! Don't give up!
hahaha
QQ
thanks DSM!
@DSM what module would help with finding a keyword within the data?
im just going to continue reading through these docs
17:02
That seems to be the way that every single question you ask in here ends.
lol @davidism why dont you like me?
TL;DR?
Is exactly what you should not ask about that article. Read it carefully.
that was priceless.
17:08
*whoosh
did you write this article?
lol
@davidism I fear the day they invent dragonscale armor
For all you math people:
Fun fact: Benoit Mandelbrot had a mole that looked exactly the same as Benoit Mandelbrot.
lol :D
that reminds me I haven't followed SMBC for a year or more
wim
wim
17:23
groan
recurse much?
17:34
huh, the new mobile chat interface looks surprisingly decent at first glance
wow, it even has useful features
dumb question; aspect ratio is always width / height?
@corvid Google it bb
<3
+10 pupper
DSM
DSM
@corvid: wouldn't bet my life on "always", but I've never seen it otherwise.
17:47
there has to be a crappy implementation of a library in a questionable language that does it the other way around
hey @DSM do you use public workbooks to practice with openpyxl?
I suggest buying a monitor with a rotate-able stand just in case the place you buy it from is the only store in the world that lists it as height:width
one of those fancy standing 9:16 monitors optimized for the new-fangled videos all over youtube
i use an abacus as my monitor
17:51
@vaultah OP is something there
yeah :[
wow, py-3.x gold badger
11 of those altogether
DSM
DSM
Over half of whom I net.know. \o/
the first reasonable one of its kind that I encounter
18:05
I keep feel like I'm doing this math wrong...
what math?
I can probably help with math
unless it's stochastic calculus, because that's hard
no it's like third grade math
I have an image that is width = 2576 and height = 1932. I want to resize the height to 200 and match the width to the same aspect ratio. 2576 / 1932 = x / 200, I get 266.6
that looks reasonable
In [31]: 2576 / 1932
Out[31]: 1.3333333333333333

In [32]: 266.66666/200
Out[32]: 1.3333332999999998
Why do they call it 16:10 and not 8:5? If the numbers don't have to be coprime why not call it 160:100 if they're so enamored with big numbers
probably to contrast with 16:9
18:08
"Introducing the new 16000000000:10000000000 monitor"
as in "you know the usual wide screen? Well, imagine 1/9 higher"
These go to 11
it's the next minor version after 16:9
yeah I am either getting 1.3 or 0.75 as the aspect ratio, they're from an iPhone so might be horizontal or vertical, I guess that seems right, my interface just looks wrong
looks suspiciously like 4/3 and 3/4
Photo is 4032x3024 with an aspect ratio of 1.3333333333333333
Adjusting to height 200, your image width will be 266.66666666666663
Might look funny to the eyeball because the numbers on the first line are width, height, ratio; and the numbers on the second line are height, width
"4032 is bigger than 3024 but 200 isn't bigger than 266, what gives?"
Does anyone know a good way to define a subset of enum.Enum? Something like...
class Colors(enum.Enum):
    red = 'red'
    green = 'green'
    blue = 'blue'
    chartreuse = 'chartreuse'
    puce = 'puce'

    primary_colors = [Color.red, Color.green, Color.blue]
Someone asked "why can't I post this flask question" on meta. It's an obvious typo. Maybe they'll take my warning and not post it.
18:27
one can only hope
hey
what's the best IDE to learn python ?
Notepad is sufficient.
Whichever one you like. IDEs aren't really related to learning Python.
more than just a notepad
I probably spent more time in a REPL than in an actual editor when I was still in my larval stage
18:30
is pycharm good ?
Yes. So are other IDEs.
Pycharm is also sufficient.
ok
is pycharm linux supported ?
what would you do if you were forced to try to answer that question?
If it doesn't mention it on the Pycharm website or Wikipedia, I would guess no
18:32
ok
I don't know whether it mentions it or not, that's just a hypothetical
actually, the only way we can be more efficient than their own googling is if we give definitive arbitrary answers
so "no" can work
[shake shake shake] ask again later
Interesting, the argparse docs has a note highlighting the tutorial (which is in another castle). I don't think I've seen that on other doc pages
I've seen the docs link to external pages every so often. Tkinter and super() in particular
Or are you saying that you don't see sidebar boxes on the right very often in the docs? That is indeed something you don't see often.
18:36
yup, that -----------------------------------^
@wim you'll be happy to hear that I'll be using argparse today. I'm already annoyed by the fact that its default usage printing starts with a lowercase "u"[sage]
argparse is great.
if it's so great why does it not let me print "Usage" >:(
I only googled for 3 minutes so far, so I haven't given up hope yet
argparse.ArgumentParser(usage=My_Help_Func)
12
Q: Custom 'usage' function in argparse?

devav2Is it possible to add a custom 'usage' function instead of default usage message provided by python argparse. Sample code: parser = argparse.ArgumentParser(description='Sample argparse py') parser.add_argument('-arg_1',type=int, custom_usage_funct('with_some_message')) output = parser.parse_arg...

oh wait no, it doesn't let you ovveride the word usage
lol
Perhaps you could replace stdout with a special file-like object that scans all write calls for the letter "u" and replaces it with "U"
pass argUment a
18:52
C:\Users\Kevin\Desktop>type test.py
import sys

class Upperizer:
    def __init__(self, actual_stdout):
        self.actual_stdout = actual_stdout
    def write(self, s):
        self.actual_stdout.write(s.replace("u", "U"))

sys.stdout = Upperizer(sys.stdout)
print("This is stupid")

C:\Users\Kevin\Desktop>test.py
This is stUpid
3
AttribUteError: 'Upperizer' object has no attribUte 'flUsh'
this is kind of hilarious
ha, that's terrific.
I get that error when I run it in 3.x, but with regular casing :-(
change stderr too
wim
wim
19:34
Why do you care what the usage capitalization is?
That sounds like a trivial distraction
yes, and it annoys me to no end
wim
wim
why don't you focus on something that matters?
I'm capable of focusing on important matters meanwhile being annoyed at minor nuisances
wim
wim
it does a gettext on the 'usage' string
that gives you a way to satisfy your OCD - define an AndrasLang which provides the translation 'usage: ' to 'Usage: '
surprisingly, I'm not even a bit OCD, I just hate ugly typesetting :P
wim
wim
19:44
lower u is standard
why should argparse differ from that?
$ git | head -1
usage: git [--version] [--help] [-C <path>] [-c name=value]
I never noticed that
wim
wim
maybe it's not standard, i dunno
that's your first reasonable argument, but I'll consider it
wim
wim
I'm used to everything being lowercase on unix
Now Andras can take a break from getting "Usage" to appear in his program, while he figures out how to get "Usage" to appear in git
19:46
hahaha :D
maybe I should
Might need to write a new shell for this one
Is git open source? I'm sure Linus would appreciate a pull request.
wim
wim
is the pope catholic?
$ gimp --help
Usage:
  gimp [OPTION...] [FILE|URI...]
@wim yeah I kind of figured by the time I finished the sentence
octave also has "Usage:"
so it might not be a gnu thing
it must be gnold
wim
wim
I think if you submitted a PR to change the capitalization of git's usage message, you would for sure get called a ****
19:48
I would probably have it coming :D
pie break, brief rhubarb
wim
wim
$ python --help | head -1
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
I think it would be a fun game to compose a pull request that maximizes the angriness of the reply while itself being totally innocent
So no, like, name calling, but you can get Linux Torvald's name wrong and stuff
wim
wim
we have to ask anti what innocent little things annoys finnish people most
But for intentionally getting a rise out of people you must achieve karmic balance by donating to the EFF, at a rate of 5$ per rage-hour generated
@wim yeah I tried that myself, but then I realized that I'd exactly expect argparse's behaviour there
@wim I see what you did there
20:08
I'm slowly decoding my own notes about Flask-SQLAlchemy tablename generation. I keep being incredibly confused until I rediscover why I wrote something down in the first place.
"defines pkey ^ + has decl name = forward decl" ???
I can imagine your expression when reading that
It's like we can almost see his facial expression :D
I just need to set up a mirror next to me to direct :-| at myself.
Past me was not making it easy.
will current you leave it up to future you to deal with it? It's basically two against one(?) will current you become past you once the moment passes?
past you knew that your life was too easy and some further obstacles in life would build character
past you thought that by now the flask tag would be a Canaan of knowledge and clarity
20:15
I think what it means is that if a model has a primary key but its parent acquired its tablename from a declared_attr, then we should copy the declared_attr to this model for sensible behavior.
But that doesn't quite make sense for a number of reasons.
that's not pkey^, that's "pkey", is it not?
Right, ^ is an arrow pointing at other notes. ;_;
not that this helps in decyphering
@davidism but there are opening quotes to the bottom left of pkey
and you were leaving other notes out?!?!?!!? =O
yesterday, by davidism
user image
20:18
that's what I'm looking at
Yeah, I have no idea what the " was for. I mean, notationally it means "copy line above", but it's on a line with no other changes.
then again you can probably read your own handwriting better
I just have a reflex of trying to read weird handwritings, I'm fairly good at it which is handy when trying to grade mid-terms
Luckily past me also wrote a couple key lines of code to get started, but it's only slightly more helpful.
those might be decoys to lead you on a wild goose chase
maybe the note is encrypted?
20:21
also that checkmark suggests that past you has already done this ;)
I don't remember deciding to be actively antagonistic to future me.
The checks and crosses are True and False.
Re: my enum question earlier
1
A: What's the most idiomatic way to make a collection of enum.Enum in Python?

Ethan FurmanOne of the things to keep in mind about enum.Enum is that any non-descriptor attribute is converted into an Enum member -- so property and functions/methods are not (converted). This means you can do something like: class Color(enum.Enum): red = 'red' blue = 'blue' yellow = 'yellow'...

Why Software Engineering instead of SO?
Also, that primary property is weird until you realize what Enums are doing. Cool.
wim
wim
Ethan Furman must get paged whenever there is a question tagged enum
he practically answers them all, and quickly
20:55
I'm looking into the source of scipy.ndimage.interpolation.rotate and am not clear about what happens when one has a 3D and above array. It seems that "affine_transformation" then comes into play? The code for affine is beyond me - I was hoping to find how to extract transformed coordinates (as opposed to transformed array values (intensities for an image)), but am now confused as to what "coordinates" list is (defined on line 662).
> The array is rotated in the plane defined by the two axes given by the axes parameter using spline interpolation of the requested order.
my naive understanding of that sentence is that you can think of your 3d array as a series of pancake-esque images, and all of them are rotated around a common axis
you can test that by stacking two 2d images, rotating with this hypothesis, and checking the two images in the result
Ah of course. Guess that's what line 670 is doing. Should be trivial to extract the coordinates then (unless I'm being naive), thanks!
I'd first check the hypothesis just to make sure
I think that's what I've done previously (loaded a numpy array of a zstack of images and then just passed that into .rotate as a whole and got something sensible)
but line 670 is part of a docstring
21:01
https://github.com/scipy/scipy/blob/v0.14.0/scipy/ndimage/interpolation.py#L670
commit ec4ee7a281aa062cd3994e83aa2ee027d59c8837
0.14 is ancient
I have 0.19 installed
> This release requires Python 2.6, 2.7 or 3.2-3.4 and NumPy 1.5.1 or greater.
Oh dear, just realized I never paid attention to volume of which the reference guide is referring to (follow the links from there usually)...
yup, I always make sure I use generic doc links
and when I'm interested in the source I just hit up github directly :)

« first day (2525 days earlier)      last day (2648 days later) »