« first day (3062 days earlier)      last day (2111 days later) » 

03:01
@roganjosh I had to reset a laptop last week because Windows update screwed up a bunch of file permissions...had most things I should own and had write access to owned by TrustedInstaller.
03:36
how can i run a generator twice?
 
2 hours later…
05:44
cbg
 
2 hours later…
07:54
@AlexBollbach itertools.tee
well, that lets you iterate over the thing twice. It won't execute it twice, though.
08:41
Pet peeve of the day: Moderator candidates answering all questions with "appropriate action needs to be taken"
09:12
Hello All, I am iOS Developer and I started learning python. Python have many libraries and functions. I tried some open tutorials and but I am not sure from where to start properly. Currently my study is not in order that's why I am unable to track my progress and not getting good confidence.
I just wanted some suggested topics for learning and practice. I asked many ppls but does not got any proper response and It is not a proper question so I couldn't post it. Any help that you can do will be grateful. Thanks.
I'd recommend reading through the python tutorial and then familiarizing yourself with the itertools module
Since you already know how to code the tutorial might be a bit boring, but I think it's still a good way to learn how to write pythonic code
 
2 hours later…
11:44
@Aran-Fey Yeah I have done basics and now doing numPy through this. For better examples I will further search on google and practice them. Do you know any open source demos/projects for learner so that I could practice them for more hands on?
You should learn native python well first. Further frameworks (numpy, scipy, keras, django, whatever) should come later.
my point being that numpy is a third-party library with somewhat specific use cases, and being good at python and being good at numpy are mostly independent things
@AndrasDeak I though numPy is the part of python. Ohh it my bad. That's why I need some experts suggestion so that I can make myself on right track.
I am doing practice on hackerrank too. Their some easy questions are also tough for me as it belongs for any library. Do you have ref for basics with seq. I can study myself if I got a ref topics.
The official tutorial Aran-Fey mentioned teaches the standard library
You can't learn from this link directly but for the record this is the stdlib docs.python.org/3/library
(Contains docs rather than tutorials, not meant for early learning)
12:00
I have done some basics from dataquests. It helps alot no doubt. I know List, dict, for-loop , list comprehension and few more basics.
I do not wanted to jump higher with having good commands on basics as it is always dangerous for developer.
Yup. So tutorial.
I am familiar with some topics of the standard library. I think i need to stick with this and start digging it topics wise.
Learning in patches means the risk of missing basic things and picking up bad patterns instead.
Also learn how names and mutability work nedbatchelder.com/text/names.html
Yeah I am facing this issue. In the standard library they mentioned whatever this library includes but if I look carefully there is topic file management which cant be studied out if you dont have good hands basics then this is going to tough.
That's why I am facing trouble on learning python.
My study always be irregular with the topics so I have less confidence on topics.
Sam
Sam
12:18
Any of you guys work on Mac? I'm unsure if I've specified multiple libraries correctly in my PYTHONPATH variable:
....
PYTHONPATH="/path/to/projectone":"/path/to/projecttwo"
export PYTHONPATH
I think it needs to be PYTHONPATH="/path/to/projectone:/path/to/projecttwo"
Sam
Sam
Yeah I actually just found a blog which mentioned that
PYTHONPATH="${PYTHONPATH}:/path/to/some/cool/python/package/:/path/to/another/c‌​ool/python/package/"
what's with the leading ${PYTHONPATH} ?
that's how it should work in linux
@Sam append, don't overwrite
Sam
Sam
So I should use this yes?
yeah
12:29
for linux $PATHs that's what you'd do, yes
don't interfere with system stuff, extend with your own last (things get searched from left to right)
Sam
Sam
Makes sense. I'll set that now
cbg
What is the recommended utility for virtual envs now? virtualenv? pyenv? pyvenv? pipenv? In order to make proper suggestion to @Sam, who could probably use something like this
Dunno about recommended, but venv is the new built-in I think docs.python.org/3/library/venv.html
Sam
Sam
I use virtualenv
But in work I just use my Conda environment
ah, apparently that's pyvenv
> Note: The pyvenv script has been deprecated as of Python 3.6 in favor of using python3 -m venv to help prevent any potential confusion as to which Python interpreter a virtual environment will be based on.
so only the -m venv part is "new"
12:40
@Sam Can you then just isolate your work in a virtual env, pip install whatever cool packages you want to mess with, and then not have to do the PYTHONPATH dance?
Sam
Sam
@PaulMcG I would usually just use virtual env.. but I've been instructed by work to use Conda
I thought Conda had its own form of environment virtualization
Yes, the Google turns up a number of articles on doing this
Sam
Sam
12:59
Cool i'll take a look
thanks
13:24
@PaulMcG Pretty soon PEP582 may mitigate the need for any of them! It'ld be nice to have "...one-- and preferably only one --obvious way to do it."
4
jjj
jjj
^ for gems like these I like lurking in this channel, thanks
Oh, that PEP sounds great. Having a builtin mechanism would make virtualenvs much more approachable than they currently are (because you have to choose and learn how to use one of the many programs that create virtualenvs)
I just hope "drop it into __pypackages__" won't become the new "append to sys.path"
13:38
Still seems more flexible than having a bunch of copies of (I assume frequently, at least for beginners) of one or two versions of the complete Python interpreter floating around your system. I understand legacy code, but having one copy of 3.7, 3.6, maybe 3.5/2.7 on a machine rather than increasing copies of the same interpreter. It'ld be nice to somehow keep multiple versions of packages with each version of the interpreter also, Python giving the latest if none is specified.
Before I reset my machine I removed nearly 2GB of what were essentially a dozen or so copies of the same files (e
Honestly, I don't really know how virtualenvs work (because I've never used them). Do they really create copies of the whole interpreter and stdlib? That sounds... suboptimal
quick question: if I have a dataframe X with columns {a, c, e, f} and another dataframe Y with columns {a, b, c, d, e}, what's the appropriate pandas function to append rows of Y into X? I want the resulting dataframe to keep X's columns, i.e., {a,c,e,f}, where for rows of Y, the 'f' column values are N.A.?
X = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'],
'C': ['C0', 'C1', 'C2', 'C3'],
'E': ['E0', 'E1', 'E2', 'E3'],
'F': ['F0', 'F1', 'F2', 'F3'],
})
Y = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'],
'B': ['B0', 'B1', 'B2', 'B3'],
'C': ['C0', 'C1', 'C2', 'C3'],
'D': ['D0', 'D1', 'D2', 'D3'],
'E': ['E0', 'E1', 'E2', 'E3'],
})

pd.concat([X, Y], sort=False, ignore_index=True) # this doesn't work, obviously
13:55
@Aran-Fey they just create symlinks unless requested otherwise
14:14
@ksgj1 what do you mean "obviously"? Apart from the additional columns if Y being present the result sounds exactly like what you're trying to achieve. What am I missing?
@Aran-Fey as far as I can tell they do. They have a bin/include/lib tree of their own, with copies of the interpreter in bin/ and the usual site-packages fluff and whatnot in lib
cbg, all.
sounds messy
@Aran-Fey I thought they did. Maybe they don't and that's just what Pycharm does. I assume(d) that's what was happening because I could activate those environments with the same commands and with the same (my_env) C:\Users\toon\ commandline visual.
@Aran-Fey I wouldn't call it messy, but it is redundant
if you have five virtualenvs and all of them have numpy you'll have five copies of numpy in each, I think
@Sam By now you have probably already discovered conda create -n env_name and conda activate env_name. Note that you can create a conda environment in a specific place using the -p /path/to/environment/ option instead. Then you'd use conda activate /path/to/environment.`
14:25
$ ls numpy-dev/numpy-devenv/lib/python3.5/site-packages/numpy-1.14.0.dev0+892cee1-py3.5-linux-x86_64.egg/
EGG-INFO  numpy
@toonarmycaptain At some point Python did have the concept of multi-versioning. Ref: stackoverflow.com/a/6445404/211827 — though since most developers might not even realize this is a possibility, no guarantees, either.
(And it's fragile to import order. E.g. if some package has a .pth file hack, you might not have any control over the version being imported later.)
\o cbg
14:44
@amcgregor I don't know a whole lot about how the installing of packages with the interpreter works, but I presume it mostly just extracts the files into a directory.
So in my naiive presumption, we could have a mypackage marked v7, also marked latest, alongside mypackage versions marks v5, v6.2, v3.3.6. Then the unspecified import would get the latest version, but importing a specific version would get you what you need.
I don't know how you'd handle one part of your code relying on an older version while another uses a newer in the cases where they might interact, or interact with objects returned by the different versions, but I presume if numpy is using an older version of pickle than the one I'm using to load stuff, that it's entirely wrapping functionality it's farming out to the older version anyway?
IIRC wxPython used to allow multi-versioning, but that was mostly a hack because the project hadn't adapted to virtual environments. The last time I installed it it seemed to drop into a virtualenv pretty easily, so I don't know whether the capability is still there.
_"how you'd handle one part of your code relying on an older version while another uses a newer"_

Key point: it doesn't handle that. The `sys.modules` cache stores singletons for import references, first imported version "wins", subsequent attempts to `pkg_resources.require` another version will explode gloriously.
Similarly, wxPython didn't allow version-switching within a single executable.
15:34
cbg everyone
@amcgregor Seems that expressly needed myminorpackage could install into a directory inside mymajorpackage if it's completely wrapped by majorpackage, naming it and importing it by relative imports in whatever manner it likes. Of course that means packaging together with imports into larger wheels rather than at install time..
@toonarmycaptain Vendoring is always an option. Often a terrible option, but an option.
I remember, not fondly, Django entirely encapsulating a dozen or so library dependencies that are actually very useful independently, such as simplejson.
You end up with multiple simultaneous copies of the byte code in memory, multiple module global states, … it's ugly in almost every way. ;)
(Version differences between vendored and package-installed copies…)
16:02
@amcgregor I imagine, besides the duplicated code, that distinctively named simplejsonDjango if named like that in contrast to simplejson would eliminate some of those issues? Feels like apart from a resource duplication issue, it's a namespace problem, unless I'm not comprehending something.
Which, hey, wouldn't be unusual.
16:22
Who do I have to kill to get contextlib.contextmanager ported to C#
They've got using which is roughly equivalent to with, but instead of __enter__ and __exit__ I need to implement iDisposable which apparently involves manipulating raw pointer data
I'm not sure how killing people will help with design decisions unless you're planning to wear a core dev's skin as clothing
Silence of the Kevins ...
he can't talk until he gets the area around the mouth in the right position
I have a choice between trusting myself to correctly do pointer arithmetic after having neglected the practice for fifteen years, or I can make fifteen trips to the database instead of one
do what any decent person would do and choose the one that's less work
16:42
'It's a bit fanciful to imply that SafeHandle handle = new SafeFileHandle(IntPtr.Zero, true); requires "pointer arithmetic" or that it's unsafe. It's got "Safe" right there in the title' says the rational corner of my brain. But I can't hear its objections thanks to the corner that houses a monkey playing the cymbals.
But consider: If a thing has to reassure you that it's safe, maybe it isn't
Feb 25 at 22:06, by Andras Deak
anything that calls itself TrustedInstaller sounds like a shady guy in a trench coat
luring innocent developers into vans since '69
16:59
@toonarmycaptain Namespace conflicts aren't a problem at all, interestingly. From django.vendor.simplejson import loads
@AndrasDeak And starts foundations pushing vaccines... Drat I lift my tin hat at home.
@amcgregor If they're pretty self contained and don't pollute/interfere with other namespaces, how does having multiple module global states present much of an issue, apart from being confusing when you see django.simplejson, myuseragent.simplejson, someloader.simplejson, databaseside.simplejson which presumably you don't see all at once except when debugging?
@Kevin Or, if a protection happens to be flawed, patch that protection, don't just make a fixed copy and slap real_ on it as a prefix. ;^P
@toonarmycaptain Because you might use the non-vendored copy, expecting some state from the vendored copy to be in place. In simplejson's case, that'd be additional serializers/deserializers for serializing custom data.
(Or vice-versa.)
@amcgregor Oh, you mean if i use simplejson to serialise some data and then pass that to Django, where Django.simplejson would give a different(custom) output?
The usual problem with x_safe() methods is that they are introduced after the unsafety of a first implementation is recognised, and they SHOULD be the default, but aren't. YAML has that exact problem right now.
@toonarmycaptain Yes, inconsistencies like that are the deepest concern, since they represent "errors passing silently". Serialization of custom objects would simply explode if there were no handler for that type.
Whereas deserialization would likely not fail, it'd just return unexpected objects or structures. MongoDB Extended JSON being an example custom format that is still valid JSON. You just have to "know" how to process things like { "$date" : { "$numberLong" : "<dateAsMilliseconds>" } }. ;P
17:27
@holdenweb but that's mostly (always?) due to backwards-compatibility and deprecation cycles, right?
`S'pose so. Safe should always be the default, but it's tricky if people are already something to process unsafe inputs when it's discovered not to be safe, for example.
In this particular case I assume SafeHandle delegates the actual work to some kind of more primitive Handle while installing guardrails so that you don't faceplant into a segfault. The Handle isn't buggy or poorly designed, it's just closer to the metal and thus has many more ways to shoot you in the foot.
That iDisposable interface looks like a bit of a pain.
I think that's a requirement for java interfaces tbh
one time I tried to implement a Collection so I could use the .map method
I gave up 3 hours later
oh wait, we're talking about C#
I'll pretend this never happened
bye
"I had a problem and thought to use Java… now I have an AbstractProblemFactoryObserverSingleton… and a problem."
17:35
The documentation has (what I assume is) a fully functional example of an iDisposable implementation which I can modify to suit my needs, but I rankle at the idea of writing code without knowing what it does.
I need to understand both Windows resource allocation and .NET garbage collection before I can use using
cargo cult is best cult, embrace it
@amcgregor I'd assume some of those concerns are really user responsibilities, much like I can't expect table data to cut and paste into various spreadsheeting software (even from the same vendor :|) exactly the same way. But I do comprehend the wisdom of preventing cases of "expected American-English but was provided correct spelling instead" errors.
that's not the same kick as the other one though
I just flashbacked to CS 101 when they said "don't worry about what public static void (int args[])` means, we'll tell you later"
@toonarmycaptain Heh, that copying tabular data issue cropped up on Freenode's ##webdev a short while back. With correct application of display:table-row and display:table-cell (or use of semantic tables), copy/paste behaviour there can be wrangled to be sensible. It's just… well…
17:43
I don't blame teachers for not starting out the first lesson with an introduction to command line arguments, arrays, static functions and classes tbh
can confirm, that's css.
that probably wouldn't end well in a room full of kids who pretend they want to learn programming but in reality want to browse the internet during class
@amcgregor I don't see that image at work, but I comprehend.
Basically I'm slamming all languages where Hello World is more complicated than print("Hello, World!")
i.e. most of them
@toonarmycaptain Heh, wish I could [closed caption] these things. (No alt tag on the upload modal? Really, SO? ;) [Peter Griffin in a jury deliberation room attempting to wrangle Venetian window covering, and failing, excessively.]
17:46
oh, he's wrangling just fine
You can alt tag hyperlinks but I don't know if the same can be said for embedded images
require io
require lang.functional:function

hello = function(['name'])
    io.stdout.puts("Hello", name)

hello("Dave")
no, oneboxes only get extra features for special cases such as xkcd
@Kevin <3
@amcgregor What language is that?
17:49
@Aran-Fey Clueless, an esolang in RPython I'm working on.
"A metaprogramming programming language that uses itself to define itself whose only native loop construct is forever."
Interesting idea
reminds me of Lisp, but with a nicer syntax
Heavily Python-inspired, or, at least, that's the first syntax style I targeted for implementation. XP (JS seems to have beaten me to the punch on the . vs. .. syntax, with their Symbol namespace for object attributes. Same idea.)
((mean (what do you))(nicer))?
@coldspeed good luck with your mod. We be rooting for you
we be?
17:55
i heard mentions of lisp
then one day, i took the brave step
i went and saw its source code.
I am a changed man now. i can never go back.
And you realized the stunning truth? That code is data?
I cannot unsee what i have seen. oh, and ))))))))))))
@AndrasDeak Fine I be. since my rubber ducky doesn't get a vote does it :(
@ParitoshSingh I often look over my sister's shoulder as she hacks away on some Lisp, or MUSHcode (where newlines don't exist), and joke about needing to plug the modem back in. She… doesn't appreciate it after this many years of constant ribbing. XD
17:59
@MooingRawr not unless it has 150 rep... ;)
listening to people's problems doesn't award any rep, unfortunately
ducky should get credit for indirectly solving them though, unless.... I think i just had an epiphany. Ducky was the Community wiki user all along!!!
I made sure to create a GitHub account for my bot (not enough free time in the world for all of the projects I want to get done, including Mr. Ed, here). There does seem to be an animal trend…
The idea being it'd open issues for linting issues and such, PRs for automatically correctable failures (such as import ordering), etc.
18:15
A horse is a horse, of course of course...
wim
wim
@PaulMcG venv
Oct 19 '18 at 18:05, by wim
virtualenv: **avoid**
pyenv: **avoid**
pyenv-virtualenv: **avoid**
virtualenvwrapper: **avoid**
pyenv-virtualenvwrapper: **avoid**
pipenv: **avoid**
pyvenv: **avoid**
py2venv: **avoid**
venv: useful.
I heard that guy has strong opinions
Sounds about right, on both counts. With ~20 lines of Zsh, 95% of the extended virtualenv utilities (wrapper, pipenv, etc.) are made absolutely pointless anti-tools. (E.g. do you really want to install a complete secondary package for every other package that installs an executable CLI script, a la pipenv? I think not… see: s.webcore.io/30cf6d28fc7f/zsh-venv-love.svg)
The main thing(s) I like about pipenv are the Pipfile/Pipfile.lock
If you don't need or want those things then Pipenv is probably not worthwhile
is conda's environment * management good?
18:24
If you use conda, probably
@WayneWerner For that I have setup.py install_requires and friends, with range or explicit version pinning there. Or, worst-case, a requirements.txt file generated not by Pip, but by a separate tool that graphs the packages first. (Damn I suck with nouns… what the heck was that called?!)
wim
wim
@toonarmycaptain you are doing your venv wrong, somehow. stdlib and interpreter should be symlinks, a venv will be < 10 MB and most of that is pip + setuptools.
hmm, true, the env I looked at earlier was an old virtualenv env
@wim Some of them are around that, the others seem to be bigger because of installed packages.
wim
wim
@AndrasDeak it should not be a copy of the interpreter.
18:33
Indeed; in the SVG animation I linked at the end there, you can see ls -al invocations examining a few different virtualenv configurations; $VIRTUAL_ENV/.Python is a symlink.
@wim see my previous message :P
Long ago virtualenv itself used to copy the interpreter in, and actually patch the copy. AFIK venv never has.
wim
wim
which one?
wim
wim
ah.
18:35
@AndrasDeak I strongly approve of being helpful in the least helpful way possible. Bonus whuffie. XD
wim
wim
I thought you meant previous to the one I was replying to.
yeah, I realized eventually
18:54
@wim I did note that that might be just the way Pycharm does it. I have a project_env folder in one project with python 3.7.2 coming in at 112MB, including several installed packages (matplotlib, Pillow, setuptools, pexpect, pytest, codacy-coverage, codecov, coverage, coveralls, pytest-cov) and their dependencies.
matplotlib is probably a biggie
matplotlib 20MB, numpy 50MB on disk.
wim
wim
you let pycharm create your venvs?
I don't trust PyCharm to do anything important like using venv or git or pip, I don't like all their weird wrapper scripts.
git? Now that sounds scary.
brief cbg
Good luck with the election @coldspeed :)
> situation escalated into a mess (ref 1, ref 2)
that brought back some mixed memories @AndrasDeak,didn't know it had a long drawn out meta post too.
19:07
yup
it went on for a while, some of it not visible unless you paid attention
I'm glad to not have paid further attention :)
you didn't miss much, what's relevant is already in my comment there
Also, your comments on several candidatures are quite nice constructive appropriate word, thanks.
How long does one's moderator status last?
lifetime, (unless some rare scenario takes place)
19:09
Then why more every year?
Well when they get old, they become less moderate, and turn into conservators.
more work every year, plus oldies kinda slack a bit, I think (not opinion, just guessing)
hmm
I asked the same exact questions some years back :)
Great minds
19:10
yeah, few fall out, or more work comes up
I figure with the welcoming initiative they want to get those very evil toxic comments gone even fasterest
Andras why not you. You are a natural mod no? Room six probably keeps you busy
@wim Fair enough. I haven't bumped into any issues so far. Or leastways I haven't realised that an issue I've run into has been related to Pycharms implementation of virtualenv.
I just checked my mod candidate score and it would be 39/40. And I had 1337 active days on the start of nomination :D But I don't believe in signs :P
I don't enjoy janitorial work, so I never wanted to be a mod
@AndrasDeak Noting that fact on your candidate bio would probably itself garner some votes ;)
probably
19:13
@AndrasDeak your time is now or never :-p
mod3rat0r :D
Not open for debate :P
Hello, may I ask for a smaller help with regex in Python?
0
Q: Regular Expression - snake2camel case fix

Filip CZMy input strings are 'someWorkingTestingPhrase', 'shortMINEPasscode', defined substitution character (separator) is _. (see folowing screenshots: ). I need to fix my regex for conversion of this string from snake case to camel case, need to achieve this output: 'some_working_testing_phrase' ...

19:29
Hey thanks :) thanks, @Mooing!
I have never woken up to see this many notifications on my profile before
19:43
I'm not sure if you know what you're signing up for, @coldspeed, but if there's one person I trust to rise to the challenge and establish themselves in a new and unfamiliar position, that person is you :) Good luck!
Aran-Fey I'm sorry for confusions in my question, now the question should be ok. Do you have any idea how could I improve my regex to achieve the required output format? Thank you!
Not sure what the problem is. Wiktor linked you a working demo. You just need to copy/paste the regex from there.
If the substitution character has to be "_", then you definitely cannot change the case of any alphabetical characters.
when re.sub's repl argument is a literal string, then the only thing sub can do is 1) remove existing characters from the string; 2) insert the contents of the literal string. The output of sub(some_pattern, "MINE", "_") will never have lowercase letters no matter what pattern you supply
20:39
@coldspeed haha, nice try buttering me up in your nomination reply
20:50
hey guys
long time no see
cbg Andy
@Aran-Fey cbg
This error report from QA says the exception occurs on line 324. But the file is only 318 lines long.
Read the above message in the tone of voice of "Get the kids out of the house, we don't own a scary clown statue"
@Kevin Bane of my existence trying to debug import translation errors. :|
Because, well, just wow. (Spoiler: the module totally does exist. ;)
Huuuuh. There's something weird about 3.7…
Could you help me, how to read this regex please? Can it be written for simplicity in a sentence? Thank you
(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))
I can find out what each element mean, but I'd like to understand how to read the whole regex.
21:05
@FilipCZ That's a doozie. I often use this quick reference for looking up regular expression patterns and strftime formats (even though this is still for 2.7).
@amcgregor Thank you for a quick tip
"Match if proceeded by a lower-case letter [a-z] followed by an upper-case one, matching that initial pair of characters, OR matching upper-case [A-Z] followed by anything other than another upper-case letter or the end of the string." — I think.
rb folks
Dropping some unnecessary parentheses would probably make it easier to read
I will come back more often
21:08
Very much so. I also question how many of those groups (()) need to be capturing groups.
One or zero
@amcgregor thank you very much
Could be worse, though. Could be:

''.join((
('[\s%s]*' % (''.join(separators), )), # Trap possible leading space or separators.
'(',
('[%s]%s' % (''.join([i for i in list(groups) if i is not None]), '?' if None in groups else '')) if groups else '', # Pass groups=('+','-') to handle optional leading + or -.
''.join([(r'%s[^%s]+%s|' % (i, i, i)) for i in quotes]) if quotes else '', # Match any amount of text (that isn't a quote) inside quotes.
('[^%s]+' % (''.join(separators), )), # Match any amount of text that isn't whitespace.
Results in regular expressions like:

# "Search terms", a la: natural +forced -negated "quoted text"
r'[\s \t]*([+-]?"[^"]+"|\'[^\']+\'|[^ \t]+)[ \t]*'

# "Tags", a la: foo, bar "with space", baz diz
# (Cleans up extraneous separators.)
r'[\s \t,]*("[^"]+"|\'[^\']+\'|[^ \t,]+)[ \t,]*'
21:26
@FilipCZ regex101.com is your friend. Enter your regex, and get a verbose explanation in the right hand panel, plus a workspace where you can enter sample text to test for matches
21:41
cbg
anyone online that does a lot of unit testing?
<shines the amcgregor torch to the clouds>
I'm starting to seriously question my testing methodology. Specifically how do you decide what constitutes a "unit" and requires direct testing? For example, say I have a helper function bar() that is called by a function foo(). Do I need to test bar() or is testing foo() sufficient?
Maybe I should draft a question for Software Engineering...
@roganjosh wim's also a testing cultist
21:57
disclaimer, i dont write test code and stuff. However, i think its important to remember, testing is a tool for you to ensure you are able to check if your program behaves well, and stays that way.
Ah, true. Maybe a ground thumper will summon the badger?
So, specifically, if foo depends on bar, then you should ask yourself if bar is something that needs to be maintained (and the answer is most likely yes) to keep foo working normally
Testing purists will probably say the more tests the better and you can only know bar() works correctly if you test it
Also that if you're unsure that's a sign of bad design ;)
@Code-Apprentice Yes. I even test my logging messages and the text of exceptions, and have packages with more individual tests than statements to test. I test exhaustively, so each independently executable function (or invocation generally) I consider a unit. Testing of units operating together to enact a business requirement is an integration test, often accompanied by story tests.
rbrb
22:05
"the text of exceptions" I don't even know what that means. Like, that traceback.format_exc() gives a writeable string with formatting?
@roganjosh Specifically, if an exception is being raised due to a change, the exception should mention the old mechanism (what is currently wrong), and describe how to use the correct, newer mechanism (how to fix it).
And this is for an internal API?
No, for the public interface of library packages I develop.
Ahh ok. Still, this seems like mega work! I guess it's one of those that if I was on the user-side that it would be a appreciated, though
You think you know how to test? Here is how its done!
I'm curious whether there is an anecdote for all your testing, whether it was enforced by a previous role or whether you're just the type of person that needs to know this is all in order?
Alice's Law #53: If you didn't measure it, you didn't do it. (Also related: #62: If you deliver on time and there are defects, you haven’t delivered on time.)
Somewhere on SE I saw a post about mission-critical code (IIRC for NASA) and they had some really strict coding practices, like if statements always having an else even if it was a no-op, but commented that it was deliberate, so I imagine their test suite is even more rigorous
Most software engineers can't grasp the level of validation and assurance code such as NASA's goes through.
SE being Stack Exchange here
It was a HNQ on one of the software sites, but I don't remember which
22:19
It's a heck of a thing to have a mathematically proven codebase.
One of the big reasons I'm a fan of the seL4 L4 kernel variant. It also has formal proof.
Rhubarb.
rbrb amcgregor
22:35
@amcgregor So say I have functions B1 and B2 with their own unit tests. Then function A calls B1 and B2 as well as additional logic. Would you call a test for A a "integration test" rather than a unit test?
layman's hunch: in A's unit test you'd mock B1 and B2
that's more or less the current state of the tests in my current project, I am mocking B1 and B2
but then what happens if A's implementation changes to call B1prime instead? Now the test breaks because of a change in implementation detail.
Even though A's output doesn't change at all
the new test for A should mock B1prime, yes?
ideally, the test for A shouldn't need changed at all, I would think
but that's just the "ideal" in my head...
But this is becoming chicken and egg, either the code fails or the test fails, and both need updating. I think Code is concerned about how to approach that.
22:42
okay, I'll refrain from providing further uneducated insight :P
@AndrasDeak I was afraid that might be your response ;-( I do appreciate your comments.
but my guesswork is as good as anyone's
lol, true
software engineering is so much messier than I would like...
I really don't have any insight either, but surely TDD has at least some answer for this and I guess that's where it drops into a subjective realm. Happy to be corrected on that, though.
it's hard to do things both Right and in a way that works in practice
good point
its only messy if you make it so
@roganjosh that probably gets to the heart of the issue here...I'm not really doing TDD. I often implement things first then go back and write tests later.
Even without TDD as a strict principle, this kinda thing must come up during refactoring
So I would assume they have some kind of formal process, otherwise it seems too rigid a framework to have been adopted anywhere
well, thanks for everyone's input...gotta get back to work and finish fixing these tests.
22:46
good luck
@Code-Apprentice If you get directed to a resource, I would be interested in a ping to have a read if you remember :) To clarify my point, even if you're not doing TDD, there should be some principle from that to pinch for these situations. Have fun with your tests :)
@roganjosh sure, I'll try to remember to share it here if I find anything
23:30
@amcgregor What are these tests written in? I mean what testing framework is this?
knowing her it's a custom-made framework written in a language designed just for it ;)
23:46
@Code-Apprentice From the link, from unittest import TestCase
23:56
@Code-Apprentice My korcu story testing DSL, derived from the methodology I developed writing cinje. (That is: import-time "unicode" codec transformation potentially allowing production deployment of pure byte code without the need to install the DSL package—a template engine you can use without it even installed. ;)

« first day (3062 days earlier)      last day (2111 days later) »