« first day (3348 days earlier)      last day (1592 days later) » 
00:00 - 20:0020:00 - 00:00

12:00 AM
you're lucky I'm on Windoze, because on linux I went to the trouble of removing all the stuff I don't use from the context menu
well, most of it. It's poorly documented trial-and-error
 
:) I use that all the time
 
oh, that's how you made that full-page screenshot of that super long question
 
indeed
then again I used to have an add-on for the same thing before it was built in, but still it's nice
 
How should I document helper functions which call a longer more complicated function which has proper docstrings?
I don't really want to copy-paste everything, the helper function does something fairly simple, but is the outward facing function.
 
if it's thin enough as a wrapper you might be able to use functools.wraps or similar
 
12:15 AM
ah yes that could work, thanks
 
wim
@roganjosh Hard to say, because tag itself will probably show similar uptick
 
If I write a lot of mixins and it's not obvious whether they're supposed to go to the left or right of the base class, am I doing something wrong?
 
wim
although flask is a notorious "n00b" tag so you could be right
@Aran-Fey they would normally go on the left. I don't think I've ever needed to use mixin pattern on the right side ..
 
12:34 AM
It was a stupid question without more context. And I'm too confused about the whole affair to know exactly what context is required. So let's just forget I asked
 
wim
@AndrasDeak I live in Illinois. There is a Wauconda, IL, also presumably with superheroes.
 
@Aran-Fey I know that in which room I'm in. also my question were about UUID in Python.
 
ok, then I don't understand the question
 
 
3 hours later…
3:36 AM
def get_child_pages(id, session):
    response = session.get()
    children = response['results']
    for child in children:
        children.extend(get_child_pages(session, child['id'])
    return children
I need some help converting this function into a generator
some of it is psuedocode
 
 
1 hour later…
4:53 AM
Hello Folks i am first timer in Python ..great to be hear
 
@NabiShaikh Cabbage!
 
@NabiShaikh - in this room "cabbage" = "hello", "welcome", "aloha", etc.
 
 
2 hours later…
7:22 AM
cbg guys o/
@jigglypuff function into generator? What does that mean?
 
user10984358
9:04 AM
@jigglypuff a week or two ago I had to convert my function to generator and Kevin told me to substitute the return with yield and do the recursive call using yield from
 
@wim That one is reasonably self-evident. There are tonnes of pandas questions and most of them just rehashing the same issue :/
Vectorizing definitely is faster. I have managed to work it out and there is a more than 3x improvement in speed. — user9853666 6 hours ago
Well, I guess 13 months is better than never :P
 
9:33 AM
I have accidentally implemented depth first search in a problem but it is just going along one path like from root to leaf.
is anyone there?
 
Yes, people are here
 
I have a problem of shortest knight path, i.e. two coordinates are given I have to find the shortest path length a knight would travel in order to reach from coordinate 1 to 2. Chess board is usual 8 by 8.
Which algorithm would be most efficient? In terms of speed possibly.
 
A* I guess
>>> len(AES_CBC.Encryptor.mro())
22
I may have overdone this multiple inheritance thing...
 
9:50 AM
Were the last two messages for me?
 
nope, just rambling
actually, I'm not sure if A* is a good choice for knight pathing. Might be difficult to find a suitable heuristic, since the knight might have to increase the distance to the goal before it's able to reach it
 
hi, is there any advantage on using microsoft windows visual studio community for python programming? while we have idle or other tools for python itself...
 
@AjayMishra There's plenty about that here
 
@Aran-Fey I cannot recall that algorithm, I am reading it, so I cannot discuss anything regarding that.
@roganjosh Thanks!
 
10:17 AM
@EnthusiasticEngineer IDLE may be included with Python, but there are a number of free development options that are far better. VSCode from Microsoft, MS Visual Studio, and JetBrains PyCharm all have community editions that have much better developer support (most notably integration with GiT, Mercurial, et al.)
 
Hi. I put a bounty on this, in case someone is interested: stackoverflow.com/questions/59333807/…
 
10:35 AM
Hi all any recommendation for a course to start to understand ML, I am java developer and so eager to start ML but there is too many and I am kind os lost
 
@Fateh There's the one from Stanford that I see mentioned frequently
 
I am calling a function recursively , if one getting some condition satisified if I just want to end the further recursion or calling, what should I do?
For example:
If I have this function, if any of those if condition get satisfied I just want to leave the function, what should I do?
 
@roganjosh I was planning to start this one coursera.org/specializations/data-science-python what do you think ?
 
If I try using return under if, it justs terminates the call for that particular level.
 
Change finder(i,p2,cnt+1) to result = finder(i,p2,cnt+1); if result is not None: return result?
that has the additional advantage of actually returning its result rather than None
 
10:46 AM
@Fateh That one looks like you'll learn more Python along the way but I'm always dubious about these courses so I can't really comment on whether it's good or bad
 
It did not worked. Wait, I am giving the output.
 
@roganjosh thanks for the help I will check the course you send me
 
And by that I mean, you'll certainly learn stuff along the way but they often seem to overstate how proficient you'll be at the end
 
@Aran-Fey Please check this, if you want I can provide the full code..
 
Ok, I have absolutely no idea what you're trying to do with that code, but you should get the correct output if you change return cnt and return 0 to just return.
 
10:55 AM
i am working web scraping and i am getting a error max retries is exceeded , after few web search i get to know proxy setting need to be called when one is scraping on a particular websites repeatedly . can anybody guide me on this
 
That if cnt > 3 .... statement was for stopping the program to reach maximum recursion depth, I used the because I couldn't figure the answer of the question that I am asking here.
 
11:23 AM
@MikaelKen That question is at risk of being closed as unclear, or needs more focus. You need to respond to the comments, eg how do you decide that a is the start of a cycle? You're more likely to get help if you post your own code attempt. BTW, the "Code Snippet" feature is for HTML / JavaScript, it's pointless for Python, so you should change those snippets to plain code blocks.
@jigglypuff I'm glad you said it's pseudocode. That recursive call looks like it's got the args the wrong way around. Also, you need to be extra careful when modifying a list that you're iterating over.
 
11:42 AM
@PM2Ring apparently, one cannot close-vote if a question has an open bounty. :/
 
Cbg
I thought pythons variable scope is the function no?
try:
    try:
        raise AssertionError
    except AssertionError as e:
        pass
    raise AssertionError
except AssertionError:
    print(e)
This throws NameError: name 'e' is not defined strangely enough
 
@jigglypuff What parts do you need help with exactly? Have you ever written a basic generator using yield, and chained them using yield from?
@Hakaishin That's not a function and the issue isn't naming scope either. An except clause deletes the exception variable at its end to break reference cycles.
Other, you have a cycle from the exception to the frame handling the exception.
The exception handler name binding is tailored specifically for this
see the linked grammar definition for the except clause as well
 
11:59 AM
@MisterMiyagi Ah, good point.
 
I see, so there is not problem in simple doing exc = e, if I want to use it later right?
 
yep. The docs recommend this:
> This means the exception must be assigned to a different name to be able to refer to it after the except clause.
 
Cool, thanks
 
@MisterMiyagi Reference cycles? In what situation would an exception cause a ref cycle?
nvm, found it
god the python docs are so hard to search
> Exceptions are cleared because with the traceback attached to them, they form a reference cycle with the stack frame, keeping all locals in that frame alive until the next garbage collection occurs.
 
Yep, that's it. Frame cycles are pretty evil. In Py2, they made generators uncollictible in somewhat common situations.
 
 
1 hour later…
1:28 PM
Hi guys, I created a virtual environment and installed a module called 'gspread' within that
Now if I need to call that module from within a jupyter notebook what are the prerequisites?
 
Is that for reading gsp's?
 
yeah@PaulMcG
Basically I am trying to read google sheets and create a mysql table from that
 
If I have a virtualenv, I activate that first, then start Jupyter notebook so that it is running in that environment. Then in your notebook pages, just import gspread like you would in a regular script.
 
Ok got it thanks!@PaulMcG@roganjosh
 
1:32 PM
Oh that is much cleverer - makes your virtualenv a type of kernel that you can start from the main notebook page
 
Wow I'm cringing hard right now, I just found some code I wrote a while ago with this function argument: testing=False)
I'm happy my mocking voodoo improved, time to refactor :P
 
Dec 13 '18 at 21:07, by Wayne Werner
@Code-Apprentice The definition of bad code is anything you wrote more than a week ago
 
Where is Weyne these days? :/
 
1:57 PM
Guys I need some help again , any idea how I can solve this error?
ERROR: Could not find a version that satisfies the requirement MySQLCredentials (from versions: none)
ERROR: No matching distribution found for MySQLCredentials
This is after I type 'pip install MySQLCredentials' in my virtual environment
 
Did you install MySQL itself?
 
IIRC That error usually occurs when there's no module with that name on pypi. Are you sure there's a module with that name on pypi?
 
No, I was trying to write data to a table in an existing mysql db
This is the site I am following to do this
 
pypi.org/search/?q=MySQLCredentials returns zero hits for me. Can you provide a link to this module's homepage?
 
Yeah I shared it above your comment
 
1:59 PM
That wasn't what I asked. I asked whether you downloaded MySQL to the system (forget about python for a minute)
 
No @roganjosh
 
Then you'll probably want to do that
 
Its in the #import libraries section @Kevin
Ok I will try that @roganjosh
 
Let's see if I can find installation instructions for that module on that page... No, but I did find "Open your IDE and create a file called “MySQLCredentials.py”". Sounds like you're supposed to write it yourself.
 
For MySQL specifically, it's been a long time since I used it, but psycopg2 throws all sorts of errors if you don't have the drivers installed first
@Kevin I think that's unlikely. Maybe, but normally you can just specify them in a connection string
 
2:13 PM
Hmm, you lost me. What's unlikely? If you're saying "you won't find a credentials file on pypi that has the username and password of the database you're using locally", I agree. If you're saying "it's unlikely that this tutorial expects you to write your own credentials file", I disagree, because I'm quoting the tutorial directly. If you're saying "it's unlikely that you'll have to write your own logic for communicating with the database and negotiating access rights on a low level", I agree.
MySQLCredentials.py contains only four string literals for username/password/host/schema, so there's no real logic in there
 
Oh, if you're talking about the tutorial specifically then we're agreeing sorry.
I've not followed the convo very well, it seems. Apologies
 
I routinely make it through conversations while only understanding half of what is being discussed, so I can't blame you :-P
 
:P
 
Unrelated topic - today I stumbled onto some implementation-specific behavior:
>>> import datetime
>>> datetime.datetime.now().strftime("%Y_%m_%D")
'2019_12_12/16/19'
 
@PaulMcG thank you...
 
2:20 PM
%D is not present in the standard format code table, but it still works because my platform's C happens to allow it
 
@PaulMcG now that i have python installed on my windows system, do i need to install it again when I want to shift to vs code or pycharm?
 
@EnthusiasticEngineer no
 
@Hakaishin co... how may i link it to the new editor? sorry I am basic in these topics...
 
I would expect most editors to work automatically if you already have Python installed
 
I have a generator that must be iterated until StopIteration to work correctly. This means something like zip(foo, my_gen()) is incorrect unless foo has more elements than the generator (which it usually won't). Is this bad design? If yes, how can I improve it?
 
2:31 PM
What happens if it doesn't get iterated all the way?
 
It's a bit hard to explain, but basically the generator opens and closes file objects as you iterate over it. Stopping the iteration midway would leave the last opened file unclosed. Here's a code sample if it helps
 
@Kevin wow it is linked easily and automatically by its extensions. IDE found python on my system
 
👍
 
(The idea is that if you have a series of functions that work on file objects/paths, the generator automagically creates suitable input/output files/paths for the functions, copying the data from one output file into the next input file whenever necessary)
 
now i understand the difference between IDLE and a good ide... it recognized many unused codes in my program which were never warned on idle...
 
2:38 PM
If you're using with blocks inside your generator, then you don't have to worry about the file objects staying open indefinitely. When a generator is garbage collected, the generator's code throws GeneratorExit, which will cause your with to end and close the file.
Since my_gen()'s refcount drops to zero after the zip statement, it should get closed before the next line runs.
Confidence that my last two messages are totally correct: 80%
 
Hmm, I'm not sure if generators (and context managers therein) are properly cleaned up if the interpreter shuts down
 
If you're not using with blocks, you can also catch GeneratorExit manually within the generator and perform your cleanup there; or make your design more class-oriented and override generator.close
 
But anyway, I'm not using with in the generator. Each iteration opens one file and closes another, which I can't do with with (because each file is closed one loop iteration after it was opened)
 
I'm 65% sure that generators always get cleaned up if the interpreter shuts down normally. I'll see if I can find a citation.
 
morning cgb o/ happy new week
 
2:42 PM
def f():
    try:
        for i in range(10):
            yield i
    except GeneratorExit:
        print("bye")

g = f()
next(g)
Here's an empirical test. This code prints "bye", desipte g staying alive right up until the interpreter shuts down
 
@EnthusiasticEngineer lol IDLE is not really an ide. May I ask how old you are? I would expect people who learn cs nowadays to expect the ide to be able to automatically find python
anybody got an idea how I create a mock function which returns an object which I can attach an empty function to?
 
@Kevin Huh, even though you haven't called next on it at all. Interesting. I'm blind
 
@Hakaishin 32
 
@Aran-Fey see PEP 533 for some background of the problem and the definitive answer that there is no answer (yet).
 
@Hakaishin <struggling to find any reference to them learning CS>
 
2:46 PM
If you're in here, you're learning CS, whether you like it or not
 
@roganjosh good point
@Kevin haha yeah
 
The room is filled to the ceiling with a goop comprised of 50% computer knowledge, 50% memes
 
@Aran-Fey It doesn't print 'bye' if next() is never called
 
I think not all the people here are advanced people who's major is computer related... so many thing very simple for CS people may be not as clear for others.
thanks guys, by the way and this will be my last time being here.
 
@EnthusiasticEngineer how come?
 
2:48 PM
@Kevin I'm 100% sure that there is no guarantee whatsoever that __del__ ever gets called.
 
Fortunately, if you haven't called next on your generator by the time the interpreter exits, you don't need to do any cleanup, because you haven't opened any resources yet.
 
@MisterMiyagi Hmm, shame
I mean, I could implement a context manager whose __enter__ returns an iterable, but that's... eww
 
@EnthusiasticEngineer I'm 32 also, and originally an engineer. I could see how the comment made would be slightly uncomfortable, but the people in the room generally help out a lot. It'd probably be to your benefit not to take it it heart and to continue visiting
 
@Hakaishin I would've expected IDEs nowadays to be quite good at finding current installs, but after how uncooperative a couple IDEs were with my C++ install, I wouldn't be so confident now.
 
I suppose this varies from platform to platform, but I think the consequences are basically nil if Python exits while you still have files open. Hopefully the OS is smart enough to reclaim the handles etc etc.
 
2:51 PM
@Aran-Fey if async programming is fine for you, I have a beta library which does exactly that, due to the exact same problem.
 
@KieranMoynihan haha yeah c++ I wouldn't expect anything, but python yeah. And sry @EnthusiasticEngineer in case I offended, I was curious to learn what expectations cs learners have nowadays of their ides
btw guys have you read coding machines: teamten.com/lawrence/writings/coding-machines? It's sooooo good :D
 
@MisterMiyagi True, as indicated by paragraph 3 of docs.python.org/3/reference/….
 
@MisterMiyagi Thanks, but my whole library is synchronous, so I'd rather not make this one function async
 
Or perhaps that paragraph is making a more specific claim. "__del__ might not get called if the object still exists when the program ends" is true. "__del__ might not get called for an object that is destroyed in the middle of the execution of a program" is not something I have confidence in
 
@Aran-Fey valid point. If you are looking at only a few builtins used by yourself, it's not that difficult to make them safe.
 
2:58 PM
On the other hand, "objects might get destroyed much later than you would expect" is true, so you can't easily point at a line and say "__del__ gets called here"
 
For now, I guess I'll just document it with a big fat "WARNING" label and then if it one day returns to bite me, I'll consider making it safer
 
AFAIK The timing of zero-refcount garbage collection is not strictly defined by the language specification, but I would expect most sane distributions to do it immediately
 
@Aran-Fey from my experience, it's only a problem if you have things like DB connections that need active cleanup. Files opened for reading are fine and handled by the OS.
 
anybody got an idea how I create a mock function which returns an object which I can attach an empty function to? sry for the repost
but my google foo and the docu leave me stranded
 
Well, it's not just regular files that might go unclosed. It could be any kind of file-like object, and the generator may also need to copy data from one file into another when it's exhausted. So the problem is that your files will be incomplete, and you'll probably have a very very very hard time figuring out why
 
3:02 PM
@Kevin the underlying problem is that The Interpreter might die an Unexpected Gruesome Death. In which case it just doesn't do any cleanup, including __exit__ and atexit.
@Aran-Fey in that case, welcome to the land of misery by generator cleanup.
 
Ok, nvm the docu is good, I just didn't get it. I could just return a MagicMock() object and all possible methods can be called on it
 
Current population: 2 plus all the people who haven't figured out yet that they have a problem
 
Hmm, I wonder if there's a way to check if a generator has ended
 
@Kevin there is only one implementation that even uses refcounting...
@Aran-Fey inspect is your friend
 
@Hakaishin I'm not completely sure I understand your requirements, but perhaps you want:
class MockThing:
    pass

def mock_function_that_returns_an_object_that_you_can_attach_things_to():
    return MockThing()

x = mock_function_that_returns_an_object_that_you_can_attach_things_to()
x.blah = lambda y: y*2
print(x.blah(23))
 
3:05 PM
@Kevin yeah sry I was unclear, I ended up with:
    def mock_function(*args):
        return MagicMock()

    @patch('get_data.get_data.show_loading_screen', side_effect=mock_function)
 
@MisterMiyagi inspect.getgeneratorstate, got it
the inspect module really loves its reallylonglowercasenames
 
@MisterMiyagi True. No amount of defensive coding, no matter how clever, can guarantee that everything is cleaned up after an unexpected gruesome death.
 
yestheydoitsfreakysometimes
 
Ultimately, if a micro-meteoroid traveling at 0.9c smashes through your CPU, then you have to accept that some of your file handles will go unclosed
 
@Kevin geographically redundant data processing xD
That's actually why we got to get to mars :)
 
3:12 PM
To put data processing centers there?
 
Change "micro-meteoroid" with "supermassive black hole" and your backups on Mars still won't do you any good
 
I kinda feel like we have other problems at that stage but I can't put my finger on it
 
man se meta is really a parallel world
 
Hmm, but Mars is at least 187 light seconds from Earth, so if it gets destroyed by a black hole traveling .9c, then Earth has 18 seconds to beam your program state into deep space in the hopes that a traveling alien probe will catch it
 
@Kevin that's why we got to colonize the milky way and beyond :D
@Kevin haha exactly :D
 
3:16 PM
I would say "after 10^100 years the atoms comprising your galaxy-distributed computer will spontaneously cease to exist", but we're talking about unexpected termination, and 10^100 years is plenty of warning time to wind things down
 
@Kevin let's hope your doom detecting thread holds the GIL, then.
 
Python 3's EOL is slated for Jan 1, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020 AD, so please migrate (to a higher plane of existence) before then
By the year 10^101, the universe will only be wisps of electrons, and 2.7 programmers who still don't have enough funding to upgrade
 
well, there's still Tauthon for all us poor souls that are stuck on Py2 and want to use asspressions...
 
But who's going to do garbage collection in 10^100 years?
 
Wall-e
 
3:26 PM
And you know he's going to find a bug somewhere... :D
 
Black holes will perform a thorough cleanup from 10^40 through 10^100. After that, anything you still can’t cope with is therefore your own problem.
 
> It is not guaranteed that __del__() methods are called for objects that still exist when the universe exits.
technically true
 
Does the plural of status -- "statuses" look strange to anyone else?
 
3:41 PM
Usually their content is far stranger
 
Perhaps a little, but any other alternative would be worse
Wiktionary verifies that "statuses" is correct, although I suspect you know that already and just want to poll our subjective opinions
 
Yes, I gave it a cursory google to be sure that it was correct. Just seems off to me, but "stati" doesn't look too great either.
 
Sometimes I find that I need to nest pluralizations. A list of widgets is called widgets. A list of lists of widgets is called widgetses. A list of widgetses is called widgetseses
 
Something like "I have a list of apples here. Let's call it apples". Then you realize you have multiple kinds of apples so you make appleses to hold them. Suddenly you remember all of these apples were coming from different places, so here comes appleseses to keep them together.
That's basically what all my code looks like ;)
 
Sometimes this happens in actual English - the plural "fish" can be made into the doubleplural "fishes" when referring to multiple kinds of fish
There's also "hobbitses", but that's an archaic dialect
 
3:53 PM
Yuck, they're filthy...
 
Yeah. Prehistory is a messy place.
This corporate training module has established a rich lore about the imaginary trading partner it uses in its examples, and I want to know how I can get on that writing team.
Founded in 1910, set up a controversial overseas manufacturing plant in outer Elbonia in 1948, currently competing for marketshare with two other sprocket suppliers... It's like I'm really there
 
"sleeping with the fish" kinda loses its impact, though
 
1930s mobsters only dispose of finks in bodies of water with a healthy ecosystem of multiple aquatic species. They don't want to encourage monocultral factory fishing by giving them free food.
 
@KieranMoynihan The OED says the plural is "status", but American dictionaries have "statuses". Here's a question on the topic: english.stackexchange.com/q/877/96998
FWIW, some languages have a special dual form in addition to the singular & plural forms. I.e., if you have a collection of 2 things you have to use the dual form, the plural form is used for collections of 3 or more. en.wikipedia.org/wiki/Dual_(grammatical_number)
 
4:13 PM
Currently on slide 19(!) of the rich lore module. There have been quizzes.
 
@Kevin Not sure if I have the C++ syntax or std capitalization all correct, but I once received some legacy code to troubleshoot with the following:
typedef sintmap std::Map<std::String, int>;
typedef ssintmap std::Map<std::String, sintmap>;
typedef sssintmap std::Map<std::String, ssintmap>:
...
typedef ssssssintmap std::Map<std::String, sssssintmap>:
 
How elegant :>
If I was using an explicitly typed language, I probably wouldn't bother to name my N-dimensional widget collection widgetseseses, since explicit typing makes it easier to determine the type of a variable without having to get hints from its name.
Any IDE worth its salt will tell you that it's a List<List<List<Widget>>> when you hover over it
 
Oh man, my C is sure rusty - I guess it should be typedef std::Map<> sssetc; (just in case anyone wants to use that code)
 
@PaulMcG Wait? C? That's not C++?
 
Just left the FB Python group. Worst few days of my life :P
 
4:20 PM
typedef in C++ is the same as C
 
Oh I was thinking about the Map<>
 
My C++ is rusty too
 
@PaulMcG Is anyone truly not rusty at C++?
 
And my rust is really rusty!
 
My Python is rusty lol.
 
4:25 PM
You should have a doctor look at that...
 
@KieranMoynihan Of course this exists
 
Because I have to be special and unique, my skills don't rust, they tin rot
 
Lmao "Parking this name because it's good." Nice. Late stage capitalism right there
 
4:41 PM
I've always considered it a bit antithetical to open source philosophy that there are these kinds of centralized resources that people can call "dibs" on. If four completely different projects want to name themselves Tetanus, let them.
Obviously this would cause a ton of logistical problems, but in Perfect Thought Experiment World, those problems are already solved. Perhaps with... I don't know, blockchains.
 
4:59 PM
facepalm
just ran a delete on the wrong database table...
 
was it a production database? Do you have a backup?
@Kevin Is philosophy open source now?
 
@Code-Apprentice No, dev database, only problem is I have to manually add in new records for testing now...
Someone else is probably also going to be missing data for testing, so I'm expecting an unhappy email or two today.
 
In our shop, we each have our own dev database on our local dev computers...but then we also build relatively small systems with like a dozen tables give or take.
 
5:24 PM
@Code-Apprentice Most philosophies are open source, except for Steve's Deluxe Enterprise Theory of Mind, which requires a five figure yearly service contract and an NDA
 
5:52 PM
Hello, I'm thinking about embedding a scripting language into our app (to help "content creators" supply their own math formula, and have basic AI behaviour -- it's a simulation). As of now, my options are Lua (for ease of integration) and Python (because we use python for our scripts). Now, reading about this, I landed on this page which said:
> If you ask the #python IRC channel about embedding Python in an application, you will almost always get the same response: don’t.
Given the rest of the text, it looks like embedding python is really complicated, specially if you want to do it safely. Is that the reason of the advice to just don't?
 
Oh, pshaw! When they say "don't", they mean "don't cheat and use eval/exec" because those are rife with unpluggable security holes.
 
Safety can be a concern, sure. It's quite difficult to construct a sandbox that the user can't break out of.
However, if the app is only running locally on the user's machine, then when bad guys break out of the sandbox, they'll have gained access to... Their own machine.
 
*gasp*
 
cabbage so I have a DRF application with several apps
 
If the users' scripts run on your server, or if there's a marketplace where users share scripts with one another, then security should be taken more seriously
 
5:59 PM
Here is a repo for someone who wrote a little language for animating recursive algorithms, all embedded in Python: github.com/zchtodd/recurser. Because he wrote his own internal interpreter, he could close down the access to the dangerous bits. (Disclaimer: the underlying parsing engine is pyparsing, of which I am the author). Parsers can also be written in PLY, funcparserlib, parsimonious - Ned Batchelder has a more complete list of Python parsing options.
 
Ideally I would like to have my router work such that the toplevel api contains /api/app1 and /api/app2 etc etc
 
I don't think embedding python should be terribly complicated. You download an interpreter and ship it with your app, done. (Though depending on what exactly "embedding" means here, a bit more work may be required)
 
but when you click into one of those toplevel apis you get a viewset api for each model
for example /api/app1/tables and /api/app1/rows
I hope that makes sense
 
@MalikBrahimi What have you done to implement that particular structure? And what problems have you encountered?
 
I don't know DRF, but I'm confused by the phrase "click into an api". APIs usually aren't clickable things
 
6:01 PM
@Kevin Yeah, the program will be run only on the user's machine. I heard some game engines prevented any kind of access to the network and the disk via the mods they allowed, because mods a shareable.
 
@Aran-Fey DRF implements an HTML view for the API that can include links to navigate through the routes provided by the API.
 
@PaulMcG That's one of the way to run python strings, I assume?
@PaulMcG Ok, I'll take a look at this, thanks!
 
@Vaillancourt Yes. Here is a link on the pyparsing github wiki that has links to a number of blog posts where people wrote their own little languages or DSL's (domain-specific languages): github.com/pyparsing/pyparsing/wiki/…
If you google for DSL's you'll get much broader information. Again, Ned Batchelder is a great resource. David Beazley (author of PLY) also.
 
Obligatory: Eval really is dangerous, an essential read for anyone thinking "how hard could it really be to prevent my users from doing import urllib?"
 
Ok, thanks all, that gives me a great entry point to the subject :)
Lots of stuff to read!
 
6:14 PM
Hi. Is there a more algorithmic way of writing this: if any(j in path for path in collection.values()): ?
 
that looks fine to me
 
That's as efficient as you can get, if that's what you're asking.
 
I don't know what "algorithmic" means here, but I'm pretty sure there's no better way of writing that
 
ok thank you
 
@PaulMcG So the way around using eval/exec is to write my own parser?
Or I should strip all calls to eval, exect, import before 'running' a chunk of python code? (Or I do that with the custom parser?)
 
6:24 PM
"strip all calls to import" is going to be quite hard, because there are an unlimited number of ways to call __import__ without ever using the letters i, m, p o, r, t in your source file
 
Errr, ok, I wasn't aware of that!
 
Parsing the code yourself doesn't do anything to make it safe. You either have to validate that the code doesn't do anything dangerous (parsing the code is pretty much a necessity for this), or write your own interpreter that completely lacks "dangerous" features
 
The difficulty of building an inescapable snadbox is effectively what nedbatchelder.com/blog/201206/eval_really_is_dangerous.html is trying to demonstrate
 
If it needs to be safe, don't use python.
 
Proposal: run Python in a virtual machine which has no access to the real operating system. Then the bad guys can pat themselves on the back for accessing the file system and network connections, then say, "hmm, the file system only has C:/Python, and there are no network connections"
 
6:26 PM
@Kevin Yeah, I read that one, but I guess what you're trying to highlight is that even if I strip the eval parts from what I'm parsing, I will have to call it on some code, is that it?
 
Basically yeah
 
@Aran-Fey Yeah, that's the conclusion I'm leaning towards, now :P
@Kevin Ok, thanks a lot!
 
I may need to write a little scripting language for a project I've got in mind... Unless the Scope Creep mugs me in a dark alley, it won't have to be Turing complete.
 
6:41 PM
@Vaillancourt Don't make yourself unhappy cramming an entire Python VM into your app. LUA is practically made for this task.
if you want to write your own language, start with a LISP'ian micro-language and see whether you are motivated to go any further.
 
How can I access 'b' from dt ={'a': ['b', 'c']} ? dt['a']['b] is not working
 
dt['a'][0], although this requires you to know ahead of time that b is the first element of the sublist
 
i just know the value, not index
 
then why do you want to access it?
you already have it.
 
If you know the index and need the value, use dt['a'][0]. If you know the value and need the index, use dt['a'].index("b"). If you know the index and need the index, do nothing. If you know the value and need the value, do nothing.
 
6:48 PM
@Kevin wait, what about KevinScript?
 
KevinScript is too powerful for this project. I need something that can run on an alarm clock.
(the project is not for an alarm clock specifically, but something with about that much processing power)
 
I get "cant assign to function call for dt['a'].index("b") "
 
do you want to replace the entry where 'b' is by any chance?
 
If you're doing dt['a'].index("b") = "Q", that won't work. Try idx = dt['a'].index("b"); dt['a'][idx] = "Q"
Excercise: what happens if you have dt ={'a': ['b', 'c', 'b']}?
 
@MisterMiyagi Hehe yeah I wouldn't go as far as creating a VM for Python. I guess the first thing I'll need to do is to clearly define what I need, the go from there.
Civilization VI(?) has a bunch of python code in it, I'll take a look at how they did it and if I need something like that or something much simpler.
 
wim
7:00 PM
@Kevin hah, nice footgun. I wonder how many people have a %Y/%M/%D kicking around in production without realizing it
 
I also wish to register my displeasure that "month" and "minute" start with the same letter
Please sign my petition to rename "month" to "quadweek", as %q is not yet used in the standard
 
more like quad-and-a-half-week
 
To compensate for quadweeks always being 28 days long, there will be 13 of them.
 
wim
not bad suggestion
 
And the last day of the year? That one's monthless?
 
wim
7:06 PM
since a week is more closely based on the lunar cycle IIRC
 
That brings us up to 364. The remaining 1.25 days will be used to implement Halloween 2 and occasionally 3.
 
wim
more than our random assortment of month lengths are anyway
 
while we're at it, we should also make minutes 100 seconds and hours 100 minutes long
 
wim
france tried that
 
let me guess, it didn't end well?
 
7:09 PM
Tangentially related: while watching Disenchantment, I noticed a clock that only went up to 10. From the context, I expect the owner uses decimal time.
 
wim
 
@Aran-Fey that's how gradians happen. Stop that right now.
@Kevin ha, I miss most such details
 
> In the 1890s, Joseph Charles François de Rey-Pailhade, president of the Toulouse Geographical Society, proposed dividing the day into 100 parts, called cés, equal to 14.4 standard minutes, and each divided into 10 decicés, 100 centicés, etc.
Sounds fun...
 
they got their foot in the door with "grams" and suddenly they thought anything was game
 
7:12 PM
Dude had one heck of a name
 
Futurama was crammed with little things like that, and I suspect the Disenchantment team wants to live up to that too
 
I didn't know it was a different team
 
I haven't actually checked ¯\_(ツ)_/¯
If it's the same people, they can still want to live up to their own reputation
 
Don't we all...
 
@Kevin true
@KieranMoynihan I'd imagine you want more of a challenge than that
 
7:13 PM
Youch
 
cries in imposter syndrome
 
to be clear I was only referring to your pythoff condition
 
wim
The "local score" ordering on leaderboard is so dumb. If you're busy one night, you're done.
 
Let's see... Matt Groening is still on the team, obviously. Both animated at Rough Draft Studios... Significant voice actor overlap... Looks like only 3 out of 9 producers returned, Groening and Claudia Katz and Patric Verrone
 
7:17 PM
I never understood the significance of producers beyond "they pay for stuff"
 
What libray one would suggest to extract a tabular form data from PDF to Python lists?
 
I guess the corollary is "they ask for stuff for their money"
 
I don't have a clear picture of how the writing team is comprised for either show. I could look through the episode list for both, but... Effort.
Disenchantment S1E2 is written by David X Cohen, Futurama's executive producer, so there's no burned bridges there
 
The French Republican Calendar had 10 day weeks, and decimal time. en.wikipedia.org/wiki/French_Republican_calendar
 
Why do I get the feeling that someone eventually got decapitated for it?
 
7:27 PM
probably decimated as well...
 
It wasn't popular. Mostly because people only got 1 day off per week, and 1/10 is significantly smaller than 1/7.
 
ouch
definitely legal grounds for defenestration
 
> dec·i·mate
> verb
> 1. kill, destroy, or remove a large percentage or part of.
> 2. [HISTORICAL] kill one in every ten of (a group of soldiers or others) as a punishment for the whole group.
Those are two very different meanings...
 
yeah, that's come up before
 
I dunno if I'm in a group of ten an one of us is going to be history, I'm thinking that percentage is too large
 
7:37 PM
Totally unrelated, several hours ago, Aza fed a bunch of Meta SE comments to a ML program, which then generated fake comments (presumably by a Markov process). Some of the results were humorous, but mostly they looked like genuine comments. ;) You can see them in The Tavern transcripts, starting around here: chat.meta.stackexchange.com/transcript/message/8123269#8123269
 
wim
7:50 PM
@PM2Ring wow, it looks like a pin-up calendar!!
 
Hey, does anyone have CI/CD experience with actually testing Python release artifacts? Or know of any articles.

I'm thinking of a kind of workflow that looks like:

- run unit tests against code
- build <version>b<N> package
- install aforementioned package in a virtualenv/container/whatever
- run entire test suite against installed package
- ???
- profit!?

The ??? is the part I'm not sure about...
like... in an ideal world, all I would do is re-version/rename my release artifact - just pull the b<N> off, and we're done
but I'm pretty sure that won't work, because metadata. So really we'd have to bump the version, re-commit, and run the whole process again, right?
 
wim
you're have to clarify what you mean by "release artifacts"
 
sdist/wheel
something that can be pip install'd
 
@wim Indeed, Messidor, Thermidor, and Fructidor are quite revealing.
 
Unless of course there's a better way to do it shrug
 
7:56 PM
@wim Yes. A rather classy pin-up calendar. :)
 
I don't see any ankles
 
"Hey Kieran, summarize the system you've built over the last few months in a few powerpoint slides so you can present it to people who know nothing about what you've been working on."
Please.... I barely understand it myself.
 
00:00 - 20:0020:00 - 00:00

« first day (3348 days earlier)      last day (1592 days later) »