« first day (2685 days earlier)      last day (2488 days later) » 
00:00 - 18:0018:00 - 00:00

00:12
I stumbled on something that puzzled me today: a=[[[3]]]
I can print this via print(a[0][0][0]), is there a more elegant way to do this?
"this" being the innermost element of a nested structure?
"this" being 3 yes
I don't think there is one unless you write/use something that flattens/walks arbitrary nested structures recursively
@Simon you can print 3 as print(3), hence my question about "this"
Wow. I did not know that. :-/
>>> np.ravel([[[3]]])
array([3])
Needless to say, this is not what you'd generally do. This will create an array under the hood which will often fail for generic input, and it might squish your data in a way you don't expect it, and using numpy for just this is plain wrong.
in practice you have a specific model of your data and you need to work with that accordingly
00:16
Wait a second I have to check that function out.
I don't think I can think of a practical use case where you say "yeah I have this weird triply-nested structure and I don't care about any internals just give me something from the inside thanks"
That function you just showed me looks like it might be fatal!
>>> a = [[[3]]]
>>> try:
...     b = a
...     while True:
...         b, = b
... except TypeError:
...     res = b
...
>>> res
3
worst recursive walker ever ^
@Simon fatal how?
Debatable. It's not even recursive.
@AndrasDeak * horror * \O/
00:20
@Aran-Fey it is recursive semantically, just not in a function call sense :)
@Simon okay?
I feel feint.
Are you sure you looked up the docs of numpy rather than the Necronomicon?
@Simon more snow today
@AndrasDeak Yes np is almost a life saver. My question was not only np related (although you seem to have guessed I would be expecting something on that module) but just if there was something inbuilt some might call "hidden" that would allow easier access to that value in the list.
@Code-Apprentice Got enough for a snowman yet?
as I said, "that value in the list" is really vague for this problem
00:24
3 then
What if it's [[[3,4]]]? What if it's [[[3],[4]]]? It's not about the three...
what if it's [[[3,4,[5]]]]?
@Simon not really. Just a light dusting
and I know your question wasn't numpy-related, hence my hopefully-obvious warning that using np.ravel is not a typical solution to your problem, whatever "your problem" might actually be
It is really dry snow, too. Just brushes right of the windshield
That's snow fun :-(
@AndrasDeak It was more about making my code more elegant. If I need more information on flat packing my furniture with np.ravel() I will ask. :p
00:30
But why does your code contain [[[3]]] to begin with?
smells like an XY problem, especially if it comes from numpy
>>> np.squeeze([[[3]]])
array(3)
that is more idiomatic to turn your list of shape (1,1,1) to shape ()
but you shouldn't have that list in the first place
import numpy as np

a = [[3, 2], [1, 4], 3, 4]
b = np.array(a).reshape(2, 2)

print(b[0][0][0])
I'm messing around with reshape()
that's not an adequate input to np.array because it's not rectangular
>>> b
array([[list([3, 2]), list([1, 4])],
       [3, 4]], dtype=object)
you should always try to use homogeneous (non-object-dtype) arrays
And ensure they are regular. Ok thank you.
In [14]: A = np.random.rand(1000,1000)

In [15]: B = A.astype(object)

In [16]: (A**2 == B**2).all()
Out[16]: True

In [17]: %timeit A**2
1.26 ms ± 6.78 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [18]: %timeit B**2
29 ms ± 691 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
@Simon if they are non-rectangular then non-object dtypes won't work
In [19]: a = [[3, 2], [1, 4], 3, 4]

In [20]: np.array(a)
Out[20]: array([list([3, 2]), list([1, 4]), 3, 4], dtype=object)

In [21]: np.array(a,dtype=int)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-21-7fbf08ab72c8> in <module>()
----> 1 np.array(a,dtype=int)

ValueError: setting an array element with a sequence.
00:46
I see. This will work:
import numpy as np

a = [[3, 2], [1, 4], [3, 4]]
np.array(a)

np.array(a,dtype=int)
wim
wim
>>> print(*(*(*a)))
SyntaxError: can't use starred expression here
T_T
>>> for [[val]] in a:
...     print(val)
...
3
>>> for [val] in a:
...     print(*val)
...
3
Erm I'm lost now.
wim
wim
>>> import compiler.ast
/home/wglenn/.local/bin/ipython:1: DeprecationWarning: The compiler package is deprecated and removed in Python 3.x.
>>> getattr(__builtin__, 'print')(*compiler.ast.flatten([[[3]]]))
3
I've been lost the whole time
@wim This works: print(*[*[*a]])
@MichaelHCameron My question has been pretty crappy so don't worry.
00:53
Oh no, I just meant in life.
@wim So somehow [val] is going inside the list.
Most interesting:
a=[[[3, 2, 1]]]


for [[val, i, j]] in a:
     print(val)
     print(i)
     print(j)
Returns 3, 2, 1.
@wim: You need a comma in a tuple display: (*a,) instead of (*a). It doesn't look at the * and decide you want a tuple.
It's similar to how *b, = a is an unpacking and *b = a is a syntax error.
wim
wim
01:12
hmm, still can't get a triple unpack working though
@wim I was sad to see that b,,, = a didn't work
print(*list(*list(*a)))
In [41]: ((b,),), = a

In [42]: b
Out[42]: 3
hehe
but the triple nested list assignment version is much cleaner (I just didn't realize I could do that)
rhubarb
Nor did I
@AndrasDeak Rhubarb. Thank you for your help :)
01:40
Rhubarb all
02:05
Hello, any one here?
I have a code I am try to execute but I am getting a syntax error
 
3 hours later…
04:37
@fsfh60 You won't get any help if you don't post the code :P
this guy's attempt to align his ascii art though :I
cabbage
@Aran-Fey How's it going? Today was an awesome day :)
Sounds like your day is going better than mine. I slept 4 hours :D
My sleep schedule has been completely b0rked the last 2 weeks
Oh :( Well, I'll be joining the party soon. Got a quiz on friday
Got a lot to study?
05:10
Machine Learning :D
Yes, a hell of a lot :(
Ooh, I can imagine. That's a pretty wide topic (as far as I know, at least) o.o
Yeah... we've a few supervised learning techniques for the quiz: Linear/Logistic Regression, Perceptron, KNN, Neural Nets, and SVMs
Thus far I've covered like 2 topics. My attention was diverted somewhere else
The next quiz will cover Unsupervised techniques
A quick google search and a glance at a wikipedia article have told me that ML is a difficult topic, so I wish you good luck :D
@Aran-Fey Haha thanks!
05:44
<3 SOM
05:59
@AnttiHaapala What is SOM?
self-organizing map
 
1 hour later…
07:07
Hey! I initially had a print() here gist.github.com/taljaards/…, but I now want to use proper logging. I changed the print to logger.info(). Now checking my console output, it is as if the logger is taking longer to show the outputs in the console. Check the order of outputs in my link - the order seems a bit messed up to me. What would cause that?
 
1 hour later…
08:11
cabbage
cabbage
cbg
Julia Silge on November 13, 2017

Life as a developer (or data scientist, in my case) involves being comfortable with changing technologies. I don’t use the same programming languages that I did at the beginning of my career, and I fully expect to be using different technologies several years from now. Here on the Stack Overflow blog, we’ve talked recently about technologies that are shrinking in popularity and those that are growing, but sometimes a programming language, framework, or technology comes out of nowhere and bursts on to the scene, or falls off a cliff. Sometimes there are dramatic shifts in a technolo …

08:35
@AndyK Nice to see pandas and tensorflow!
@Mierzen How are you initializing the logger?
That basicConfig line? @noumenal
I don't have that. I followed this part here docs.python.org/3.6/howto/logging.html#configuring-logging. Maybe I understood them wrong (they don't have it - I thought it's not needed then)
@noumenal yep
@Mierzen I am guessing that the cause is the repeated STDIN polling. I am not sure what the consequences for the logger is though.
I guess I should then rather give the initial feedback to the user using print() again, instead of logging(). That's not really a fix, but at least I'll be able to continue
08:50
I'm going to do it like this now, @noumenal:
if print_:
    # logger.info has delayed output to the console
    # this is confusing, so rather use print
    print(answer)
    logger.debug(answer)
Note to self: Solve a problem with recursion once in a while. Instant peace of mind.
09:26
Is there a place in the pandas documentation where all the possible functions to use like `sum` here, is listed? `df.resample('1D').sum()`
(i.e. all aggregator functions)
09:38
How can I do something like this? I want to have the agg_func "end-user-definable" via console input
resolution = '1D'
agg_func = 'mean'
df = df.resample(resolution).aggfunc # resample a pandas dataframe
10:01
cbg.
@fsfh60 Welcome to room 6. You might want to read our room rules
I have UnitTest code where I test a very long fixture file full of requests->expected responses. The code is more or less def test_fixture: for fixture in open(..): self.assert(api(fixture.request), fixture.response). The problem is that when any one of them fails, I get no useful information from the UnitTest output, and I have to add print statements in the general test_fixtures function to know what exactly failed.
I am not sure what would be best: 1) Accept this 2) Write a UnitTest for each fixture 3) keep it as it is with print statements and all 4) dynamically add more descriptive functions to the UnitTest object (I favor this one) 5) something entirely different
The only problem I see with 4 is that it makes the unit test code itself non-linear and you have to look into another file to see what code will actually get executed, and I think there is somewhat of a convention to not do stuff like that.
@Arne You could try dynamically generated unit tests! Create appropriate class and add setup and teardown functions, then the ones that are repetitive (key / value pairs) can be defined right after the class in a for loop
But yeah, there might be better approaches
@AshishNitinPatil Alright, thanks for the input =) I'll go for that then
This seems to be on the same lines stackoverflow.com/a/12362144/2689986
The comments on that are quite nice & funny
10:31
@Aran-Fey you pinged dynamically import snippet on dpaste couple of days back...it involves writing new implementation for __builtins__.__import__()

I can find three things about import:
1. import statement
2. builtins.__import__
3. importlib.__import__

Reading this: https://stackoverflow.com/a/27307159/1317018
it feels as if importlib is at the core of everything import, be it import statement or builtins.__import__

Will that code on dpaste involve any changes?
Don't think so. The code only works if you override builtins.__import__
overriding builtins.__import__ also changes import statement behavior right?
The docs though: "[...] it is usually simpler to use import hooks [than to override __import__]" Pffft. Yeah, right.
That's the whole point, isn't it? You want to import modules from memory instead of from disk
yeah
Didnt get you. What was the point with import hooks stuff you quoted from doc?
The docs are lying. Ignore them :P
11:33
@Mierzen yes, the docs of the class that is returned by .resample. Odds are it's a DataFrame or a Series. The docs list every method
I ended up doing this, Andras:
temp = getattr(df.resample(resolution), aggfunc)
temp()
Okay?
You don't really need the temp there, though
The more you know.
That did the trick, allowing user-specifiable methods
getattr(df.resample(resolution), aggfunc)()?
because it returns a method
getattr(...)()
Yup
11:37
You could use a temp name there for clarity, but then it'd need a better name :P
Or to put a try-except around the getattr call vs the method call
Any thoughts on directly allowing if statements in loops in the same way they are in comprehensions? I find myself writing code like for elem in [elem for elem in bla.split(':') if elem]: .. every once in a while.
Nope
I'd define a separate generator for that
I prefer if not elem: continue. for elem in bla.split(':') if elem: looks kind of gross
Or that ^
Yours is unclear and overly verbose
If you're using a proper loop a separate if won't do much harm
I'm not sure why, but it looks out of place on a normal loop, even though I don't mind it at all in a list comprehension
11:53
Huh, that's quite decidedly
I guess if ..: continue will do.
hey guys
found a cool quirk of python
>>> 2 == True
False
>>> 2 == False
False
huh and i went overboard with complex examples
so what happens here?
does the bool get casted to an integer?
12:08
Booleans are actually numbers.
>>> 1 == True
True
>>> 0 == False
True
That doesn't prove much, considering that comparison can be customized with the __eq__ method :P
But yes, bool is a subclass of int
Compare bool(0), bool(1), bool(777)
(inb4 someone calls me out on the fact that __subclasscheck__ can also be overridden)
comparison between builtins only with curse though
rbrb, getting teeth pulled out =(
12:26
@Aran-Fey that's probably how collections.abc works, right?
I assume so, but I have exactly no evidence to back it up
@Arne take care
@Arne Be strong! D:
Hmm, what's the correct type annotation for an iterable that can be iterated more than once? There's collections.abc.Sequence, but that requires indexing support, so that would exclude sets
Something tells me I should just stick with typing.List
12:42
@Aran-Fey New __import__() had first line
__name__ = name if __name__ is None else __name__

was guessing when __name__ is none
When file1 does
import file2
__name__ is NoneType:None inside __import__ !!! Not getting why?
Are there categories for consumability?
@AndrasDeak Not that I know of
@Mahesha999 If I remember correctly, my __import__ function had a parameter named __name__?
Or anti-generator hint ;)
Is this even a type-related property?
No corresponding methods (maybe __len__?)
I could try something like Union[Sequence, not Iterator] ;D
(I know that doesn't make a whole lot of sense. Stop judging me.)
@Aran-Fey yess :| idiot me sorry...running it in debugging mode to understand how it is working...got confused for a while...
12:48
@AndrasDeak Well, it looks like it's not. But it should be :I
Even Iterator technically doesn't even correctly identify one-time iterables because the requirement is just "it must implement __iter__ and __next__"
I don't think it's supposed to do that. Reusability might be a semantic thing...
13:03
Let's agree that it should allow more fine-grained validation than just the type of the object. For example things like int > 0 or len(List[str]) <= 5
Is anyone familiar with scikit SGDClassifier.partial_fit() usage for online learning (or) perhaps time to read the last comment of the 1st answer from stackoverflow.com/questions/48902767/… ? Thank you,
@Aran-Fey now I feel I understand the code better now
but can you give some comment on how and WHY you have updating various stuffs like globals, module, MODULE, __name__

Or in other words, at various points in code, what values above variables should have, because of which you have updated them in particular order in code...?

I guess I understand that also a bit, but need more words, if possible
Ok, for starters, MODULES caches all modules that have already been imported, so that if you write import file2 twice, you get the same module object both times
Python does the same thing; imported modules are cached in sys.modules. So I had to emulate that.
module should be fairly obvious? It's an instance of ModuleType, the thing class as "normal" modules. I'm updating its __dict__ so that all the functions and classes and other variables that were defined in the code are reflected in the fake module. If you didn't update the __dict__, you'd get an AttributeError when you try to access file2.foo
Actually, I should probably get rid of that MODULES variable and just store the modules directly in sys.modules
The __name__ parameter in the __import__ function is used to identify the "main" file, the one that's executed first. The first file to start is assigned the special name "__main__", which is why the run function does that as well. It defaults to the name of the file if omitted, which is in line with how python assigns module names: if you import file1, it looks for a file named file1.py and executes it with the __name__ variable set to "file1"
Basically it comes down to
1) check if a cached module exists
2) if not, create a new module and set its `__name__` appropriately
3) execute the code in the module
4) put the module in the cache and return it
13:53
cbg all
I'm just writing a custom comparison for a class, and I'm wondering which of these is considered better:
def __eq__(self, other):
    return self.name == other.name
def __eq__(self, other):
    return self is other or self.name == other.name
I have this nagging feeling that I don't understand the best practice here
@Aran-Fey but...that's not type hinting :|
you should push input validation further back, right back to the user
@shuttle87 if self is other then their .name is already the same, right?
so the longer version seems redundant to me
if self is other then yes they will be the same. Would it only make sense to check that if the equality check was expensive?
14:08
I don't understand
oh, you want to skip the .name lookup and comparison in case it's the same object for performance reasons?
Well say the 2 classes checked if some files were the same or something that was performance degrading. In the simple case where it's just a couple of comparisons I think the clear choice is the simpler one, but where should the line be drawn do you think?
Yeah, I don't know about that. I suspect that if comparison is a bottleneck you can win by short-circuiting identity, but I don't know anything about best practices. Perhaps others do.
I thought you had semantic concerns rather than performance ones
I'm sticking a lot of objects in a networkx graph, so I'm a little concerned about performance, but the more general situation I'd like to learn more about with this
if your rich equality comparison takes 10 seconds you're probably not going to lose by always making an additional identity check
Behold the ultimate best practice:
@functools.lru_cache()
def __eq__(self, other):
    return self is other or self.name == other.name
(P.S.: Don't do that)
14:20
\o cbg
bestest practice
@Aran-Fey :D
14:46
Recently I've been thinking that I'd like to improve my Python skills, are there any good resources for improving that aren't beginner focused?
define beginner ?
generally pick something you want to do and go do it. there's no set path on saying you should read this to improve your skills. you improve by doing things... go on github and find a project you want to learn about and see if there's issues you can tackle.
DSM
DSM
Last-work-day-of-the-week cabbage for all!
cabbage!
wait you took to days off Dsm ?
also did you wake up to watch this morning game against the Fins.... :D ?
DSM
DSM
15:02
@MooingRawr: I had days-in-lieu left over from last year and I promised to use them all up by the end of February. And no, I didn't get up, unfort.. but maybe fort. because there wasn't really a cushion so that would have been tense!
My god I was watching the first 2 periods at home, and I rushed to work to catch the last 5 mins. So freaking close :\
Also good on you for finishing your days off, hope you enjoy the weather (if it holds up)
Sometimes I worry that the "go find a project to contribute to on Github" is the kind of advice that's in the same category as "happiness finds you when you stop looking for it" and "just be yourself" that are actually only true for a small minority, most of whom are probably already self-driven enough to not require advice in the first place
The advice industry needs to be burnt to the ground and rebuilt on an evidence-based foundation. I want studies, I want censuses. How many people successfully migrated from Hello Worlds to pull requests?
how else would you suggest something that OP does not respond to what they want (that's only if they know what they want, most of the time they don't)?
I consider myself a capable person. I'm still struggling with git related things after several months of using it more properly.
DSM
DSM
@Kevin: since almost everyone who does PRs started with hello-world-level code, I think the number of migrants is closely approximated by the number of people making PRs.
15:11
I understand it's like replying to "I'm still single" with "there's plenty of fish in the sea" or "there's someone out there for you, you just have to believe". It's more or less useless objectively speaking, but it's comforting to a degree.
If you're saying "well he never replied to my 'define beginner?' question, so I feel justified in giving a general answer to a general question", I'm not trying to pick on you specifically. I get this same twinge of doubt when I see bloggers and high rep users and room owners say the same thing
unless they want to help us help themselves by saying something detailed such as "I think I'm having a hard time getting fit to attract someone", then we could offer them suggestion on diets, exercise, etc.
Would be nice to have legit training. Two parts, first: spin up a new project and walk through. Second: engage in existing project. Training would have both parts spoofed up and a class of individuals who have to coordinate (break them up into groups of 4 to coordinate).
I'm not trying to say you are picking on me or anything. I'm just genuinely curious on what you would have done in hopes of aiding the next person better.
@DSM Excellent, this is what the industry needs: rigor! Gotta define those terms. Does "from X to Y" imply that you can make intermediary stops A, B, and C? Find out in the second draft of my grant proposal.
15:16
@piRSquared That sounds perfect. Where do I sign up?
@MooingRawr I probably would have given no helpful advice at all because I don't think I can generalize anything from my personal experience that would apply to anyone not having my specific neurotype
(whatever that is)
fair points, but then the question comes down to, is it better to "ignore" (or not respond to OP) and let them think we are ignoring them, or maybe try to engage them in more details by giving vague answers to their vague question
That's a question I don't know the answer too, I would like to guess, engaging them would make them feel more welcome, but can we do it to everyone, is it something we want to do in teh room ?
@ZackTarr seriously right? That's hard work to do. Devs at my firm give git related talks but nothing along those lines. Definitely gets me thinking though. Kevin's comment may end up having done nothing more than add one more person to the advice industry.
If you're thinking "well, isn't off-the-mark advice better than no advice at all?", sometimes it is, sometimes it isn't. Depends on how off-the-mark it is. If you're thinking "I don't think you should criticize something if you're not prepared to replace it with something better", that line of thinking would put every movie critic and business review website out of business ;-)
but, OK, I agree that "it would make them feel more welcome" is an important goal because we're not all here just to win the title of Most Correct Person.
Yeah but, did you follow up with that just to make sure you covered your bases and remained correct?
15:26
True Correctness is timeless and immutable
@piRSquared True. But I would be interested in just a KT from a dev team on git hub. If I taught CS as a professor I would have a project where the class goes out and gets a PR and attempts to create a feature for a project.
true_correctness = 'Timeless'
true_correctness[:] = 'With Time'

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-6f103d9df92b> in <module>()
      1 true_correctness = 'Timeless'
----> 2 true_correctness[:] = 'With Time'

TypeError: 'str' object does not support item assignment
Sorry had a phone call, in this context I'm making a distinction between the materials that are made with a target audience of people who are unfamiliar with Python or development. In this sense a beginner is someone who hasn't had multiple years of professional experience with Python. I've been using Python fairly regularly since around 2.4 came out, I feel as though I have proficiency but I'm certainly not at the level of many of the regulars in this room.
@Kevin would like your thoughts on my attempt at defining "beginner" materials in this context
@MooingRawr as for the "generally pick something you want to do and go do it." this is basically my approach so far. I've been spending a fair bit of time learning about CPython internals and expanding my horizons. I have a nagging suspicion I'm not prioritizing the best I could though, something I feel a more experienced Python developer would have more insight into
One part of what makes this question difficult is that, since there are so many sub-categories of things you can learn, any attempt to measure expertise along any single axis will give you only a partial understanding of the state of a person
Totally agree. What would you need to know in order to actually attempt a good answer to this question?
15:41
You need a complex assessment; ask Pluralsight. Oh, no, maybe don't
lol
I'd much rather pay someone in here than pluralsight :)
FWIW the pluralsight test via SO is for free, but looking at that meta (and my "expert" rating) suggests that you can't really trust the results anyway
Perhaps you could talk a little more about your goals/aspirations. "I want to become a Data Science Master" requires different prerequisites than "I want 100k reputation" which requires different prerequisites than "I want to publish an O'Reilly Python book"
Honestly I just want to be better at Python so that the juniors I work with can get better mentoring/advice/etc
or "I want to be a professor"
15:45
But what kind of advice would best suit those juniors? Perhaps we could ask them about their goals... Oops, we're recursing :-P
But thats not a bad idea Kevin. Asking them what they want to get out of a class might be worth while!
polymorphism
@Kevin Yes I know that's vague, more specifically I'd like to be more productive as well as an individual contributor which is much easier to define. Which means I'd need to know about techniques that can be used to increase productivity, especially on a more API and team enhancing level. In that manner I was looking into metaclasses lately.
They likely don't know or will spout off they want to code a video game like the majority of beginners I have spoken with.
I'd like to know more techniques that can enhance a teams/projects efficiency in an overall sense
A bit like in the way that say it's really good for people to test packages installing via Tox, someone less experienced doesn't need to know exactly how all of it works in order to benefit. I'd like to expand my horizons with things that roughly match that pattern.
15:49
Cabbage, all
And of course anything else that is similarly useful
@AndrasDeak So learning more about implementation detail things like MRO, or when/how to use polymorphism?
sorry, I was just joking about "what they want to get out of a class"
my motto is "if you can't be helpful at least be distracting"
Duplicate. See the answer as it has a link to the original question stackoverflow.com/questions/48901304/pyuic4-in-python-27
@AndrasDeak oh lol thats actually quite funny
Well in the specific case of team projects, communication is the bottleneck that worsens exponentially proportional to the number of contributors. So the questions one ought to be asking should be subsets of "how can we make this code base understandable just by reading it?"
15:56
That makes sense.
Subtopics:
high level design - separating code logically into directories and modules
Documentation
Automated testing
Adherence to style & idiom standards
Achieving concision but not at the expense of readability
Each one of these you could probably fill a whole book on
documentation should probably be twice in that list
Among these, documentation has the highest possible payoff in terms of explanatory power, but you only get out of it what you put into it
@ZackTarr I agree with that dupe, although the actual answer is not the top one that the answerer copied, but the second one that addresses the path problem...
I left a comment for the answerer
I hadnt gotten that far yet. Got side tracked after posting the cv. And I saw your edit on the other one, I thought about adding it but figured the question will likely be closed so didnt add it.
16:04
Personally I most enjoy lecturing newbies about style and idioms. Probably not because it's most useful, but because it's easiest
@ZackTarr If someone suggested an edit later when the question was closed, it could lead to complications. So for 2k+ users it's better to pre-emptively edit
I'm working on a style guide for my work project. any boilerplate stuff you have available for me to pilfer off of?
I figured you could edit then just go in and accept it. Or do your all's edits just skip the queue and post?
the latter
@piRSquared Lazy solution: just say "we're following PEP-8" and make edits on the fly as corner cases pop up
16:09
@Kevin I'm off to a good start then (-:
Half of the fun of being god-emperor of your project is getting to adjudicate disputes and lay down the law based on your mere whims
And you get to pretend to be a sand worm
So I have this idea on a feature to add to my project but need some direction so I can do research on it. I have a tool that stores queries written by experts with a description of what they do. Id like to be able to implement a search feature in the tool to help find queries based on both the text in the query and the description. All the data is stored in a MySQL database (likely switching to MsSQL soon). But should I solve the search by querying many columns for a LIKE word? Or what?
@ZackTarr That seems like a fine approach for version 1. I suspect that there are much fancier approaches, but they probably require more development time.
I do not like to think about the existence of the Orange Man for too long
3
As requested.
It was funny for like a minute and then got really uncomfortable
16:20
@Kevin I figured that would be the answer to my question but wanted to see. Thanks!
I regret that I don't know enough about the field to give any advice on researching more advanced approaches. I googled "implementing search" and that brought up two or three interesting pages, but that's the extent of my insight
morning cabbage!
cbg & rbrb!
@piRSquared is beating @Kevin on the starboard. Is that reason to celebrate?
Sure. ~Take any available opportunity to find joy in life~
16:29
is return [list comp] preferable to
return_value = [list comp]
return return_value ?
I think I should get royalties for pi's message that executes a sick burn on my message though
@Code-Apprentice no!!!! It doesn't count!!! my stars are @Kevin related
Let's say 5%
^^ @Kevin'd
If you reach twenty stars you owe me one star
@toonarmycaptain I almost always prefer the first one
And not just for list comps; I think foo = <expression>; return foo is an antipattern that could almost always be replaced with just return <expression>
16:32
Thanks :) I didn't feel it was necessary either.
"almost always" here being code for "always, except I don't want to say 'always' because someone might say 'what about this one corner case you didn't consider?' and I don't want to back pedal, even if right now I don't think there are any corner cases"
like a three-line-long expression as return value
@Kevin So essentially where I'm thinking some of those intermediate steps to get my iterable for the list comp could just be within the listcomp?
Within reason, yeah. x = x.strip(); y = x.split(); z = [int(s) for s in y] could easily become z = [int(s) for s in x.strip().split()]
Certainly there's a tipping point where you don't want to chain too many expressions together on one line.
The two-headed beast of "Achieving concision but not at the expense of readability" reveals itself once more
@Kevin That is such a programmer way of thinking...it creeps into my non-technical conversations, too. I almost always cannot bring myself to use absolutes like "always" and "never".
16:42
return [x[1] for x in sorted(histo_tuples, reverse=True)[:20]]
is fine and clear, right?
16:57
@Code-Apprentice it's not a bad habit if you don't need to worry about [citation needed] signs all the time
@AndrasDeak I just assume citations are needed for all claims during cocktail conversations.
I harp on the "Well Actually" brigade a lot but there's objective value in being diligent in your thinking before putting ink to paper.
Metaphorical ink and paper or otherwise
When did "I calculated that by hand" become equivalent to doing the calculation in Excel?
I missed the memo
If I forwarded it to you, I'd be admitting that I know exactly when (-:
17:05
@toonarmycaptain Yeah. For me, it's not so much length as depth that matters; approximately 3+ nested parens is when I think about refactoring.
You only have one paren so you're good
In theory I'd have no problem with [int(s) for s in line.lower().strip().partition("{")[-1].rpartition("}")[0].split(",")] because nothing's nested
17:23
@Kevin I cringe at that chaining.
Let me rephrase. My problem with the code I just wrote is not that it's long.
Its sins are myriad but that's not one of them
at least it doesn't parse html
I forgive you
@AndrasDeak you never know...what is line?
we know it has curly brackets and commas, so... JSON?
reminded me of a set repr
also, .lower is redundant there
17:28
I'll try harder next time ;-)
cbg. I'm struggling with representing the range [-3.14, 3.14] using only two bytes. As this is a hardware communication problem I think XDR is suitable for the task, provided some validation of the input. I need to choose a suitable degree of accuracy. It seems to me that binary angular measurement (BAM) outperforms degrees and radians, but I have not found an implementation of BAM in python - maybe it's too simple. Any thoughts?
Asking as an utter layman: is the problem specification of "representing a [float] range using two bytes" really complete? Is this an unambiguous specification of your task?
I'm already wondering about "represent"
17:44
Perhaps you could assign a unique identifier to each possible range. If the client receives a "0" from you, they know that means [-3.14, 3.14]. If the client receives "1", that means [23, 42]. And so on for whichever ranges you need to transmit.
@Kevin It's a single number in the range that I need to transmitm e.g. 2.7 ... Sorry if that wasn't clear.
Oh, I misread.
@AndrasDeak In terms of encoding and decoding, the system-wide optimal solution is to use as few 2-byte representations as possible. It is possible to use 4 bytes or even 6, but at the risk of "cluttering" the byte stream as well as filling valuable "clock" time with packets.

The minimum required accuracy is 1 degree, but 0.01 degrees would not be bad.
Ok, so assign "0" to 2.7, and so on
"Yeah but it's a pain in the butt assigning arbitrary identifiers to every possible degree value, isn't there a formula or something that could calculate them all in one shot?" you think. Perhaps there is.
I guess I could achieve a resolution of 0.02462745... if I choose (2 x 3.14)/255 with 128[127] as 0.
@AndrasDeak Your questions were very useful! Thanks!
17:49
no problem
Maybe something like: to encode, multiply by 2^7 and convert to integer. To decode, convert to float and divide by 2^7.
DSM
DSM
Unless there's some unmentioned constraint or relaxation of constraints (e.g. you don't actually need to encode both -pi and pi, you're happy for pi and -pi+epsilon), or you need to make sure you hit 0 exactly (which is the sort of thing I'd want), why wouldn't you just map 0 to -pi and then have every increment be 2*pi / (65536-1)?
@Kevin You're right. It's simpler than I thought. That scaling is exactly how BAMS work
and BAM---it's solved
:?) Thanks!
17:52
Or, I'm not sure if 2^7 is the right thing to multiply by - whichever 2^N value doesn't give you any integers larger than 2^(16)
I have a feeling I'm going to think about this for a while and just agree with DSM at the end
@Kevin Thanks for your effort!
I guess the only problem is if I wish to have an absolute zero.
numbers are data so we should listen to DSM
DSM?
oh I see
@noumenal the third law of thermodynamics tells you you needn't worry about absolute zero
(running computations)
@DSM That's actually a 3-byte representation: b'8\xc8\xf6\x8c'
DSM
DSM
17:56
I have no idea what you're talking about.
plus the number in the increment can be adjusted for the required bandwidth
Now we're talking...
DSM
DSM
Both in the sense that I don't know what the "that" is, and that what you showed after the colon looks to have four bytes.
My mistake
4 bytes, 2 bytes, let's just wait until network speeds double again and it won't matter any more
DSM
DSM
17:59
If you have two bytes, you have (2^8) *(2^8) = 2^16 = 65536 values to play with.
I'm stuck with a parallel port due to an outdated real time system.
@DSM So max would be b'Ii\xf3\xa9'
00:00 - 18:0018:00 - 00:00

« first day (2685 days earlier)      last day (2488 days later) »