« first day (3642 days earlier)      last day (1531 days later) » 

06:28
Hi
greetings
07:10
do we have a canonical for "how to avoid CMD window when running Python on Windows"?
07:27
was this here yet...
FFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
basalt = 1
if(basalt == 0):
    print("We have found no basalt rocks.")
print("Done checking basalt rocks.")
there's a "report an issue" link at the end (but I can't click; I guess it requires JavaScript)
is there anything wrong in that? parenthesis in condition?
3.

What is the proper code for an if-statement?

if(condition):
      do something

if(condition);
      do something

if(condition):
do something

if(condition);
do something
def OutputRocketText():
    rocketNumber = 1
    print("Rocket will launch soon!")

    return

OutputRocketText()
print(rocketNumber)
Even their code highlight suggests that's a class name
if my aim is to collect a variable sent to the form and set it as an attribute of the form object would this init be the right way to do it dpaste.com/CWN7BZNTP
@Kwsswart no.
07:38
how would i need to do it?
considering the variable that i want to pass would be a query item dpaste.com/9JGMPRHXT
So, in that case shouldn't you have a parameter by name obj.
i.e. def __init__(obj)
and that's it
[' '.join([(i if i not in final_class) for i in str(message).split()])] , can anyone point where is syntax error
if is in wrong place, can't do it there. Need to be at the end
i for i in ... if i not in final_class
@Taylor a list comprehension matches exactly in behaviour the following structure:
import numpy as np


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

print(a @ b)
based on what the matrix output here
result = []
for i in ...:
     if i not in final class:
         result.append(i)
07:43
[[5 4]
 [3 4]]
@Taylor for and if need to appear in the same order.
@AnttiHaapala yes got it... Thank you @AnttiHaapala
@αԋɱҽԃαмєяιcαη matrix multiplication...
def __init__(self, obj):
self.user = obj
@AnttiHaapala sort of like that?
07:46
@AnttiHaapala Thank you.
thanks man
Sam
Sam
Hi all, wondering if anyone here has used mlflow server inside Docker containers before? Seem to be running into issues with the artifact store, in that data isn't being saved there when it should be.
Hii, had some issue while coding, i wrote a class and is there a way to get it to return something, like if i say obj = classname() i want it the obj to have a value returned from this class
i heard using return in __init__ will give some error as it should only return None
Sam
Sam
@CoolCloud Why do you want the object to return a value? Sounds like you either want a value as opposed to a class instance. Can you explain a little more about what you're doing?
its basically tkinter, i have a window and get user to type in some value to the entry and i want the obj of the class to have that value entered
i used __str__() and it was fine, but type(obj) comes to be not str
Sam
Sam
08:02
If the value is attached to the object, can't you just access it? e.g. obj.value
i actually dont want to use any instance variables, just directly from the obj
question about a Response Object -- I want to convert a string into JSON, with flask jsonfy --- reading the docs its turns the string into a Response Object wich contains the the Data, what else is in the Response Object ?
print gives me <Response 11 bytes [200 OK]>
as an output
Sam
Sam
@CoolCloud At this point i'd like to see a minimal example, finding it hard to follow.
@Amundsen Have you inspected the object? dir(response_object)
class Random:
    def __init__(self,a,b):
        self.add = a + b


obj = Random(3,4)
print(obj)
i want obj to be give result of self.add
def __str__(self):
     return str(self.add)
or something more complicated like
def __str__(self):
     return f'the result was {self.add}'
08:14
from tkinter import simpledialog
from tkinter import *


root = Tk().withdraw()
a = simpledialog.askinteger('hey','hello')

print(type(a))
Sam
Sam
@CoolCloud Which is correct
you cannot change the type of an object.
in that example, type(a) returns int
then do not create a Random object
have a function that returns an integer.
def Random(a, b):
     return a + b
oh i see
something like this?
class Random:
    def add(self,a,b):
        self.added = a + b
08:25
surely there must be a better canonical than this for "how to run Python without a CMD window popping up"? But it was the only one I could find stackoverflow.com/questions/55869789/…
@tripleee so ask another one and we'll hammer
of course the pythonw should be the accepted answer
that seems wasteful, I can't believe there are not other questions, I'm just not being lucky with google
162
Q: pythonw.exe or python.exe?

itdoesntworkLong story short: pythonw.exe does nothing, python.exe accepts nothing (which one should I use?) test.py: print "a" CMD window: C:\path>pythonw.exe test.py <BLANK LINE> C:\path> C:\path>python.exe test.py File "C:\path\test.py", line 7 print "a" ^ SyntaxError: invalid synt...

I was googling for "cmd" all the time
08:41
how to get the content of a flask response class
09:00
hi, i have a python 2d list i saved in a csv file, now i want to read that same list into a 2d list (and eventually a pandas df) but when i read the csv it only comes through as 1d list?
09:42
@ThelurkerLurker you probably shouldn't have saved it as a csv, or you did it wrong. No MCVE, no help.
ye it seems so - the file looks like this: ['speaker1:', 'Oh'],['speaker2:', 'Oh man.'],['speaker3:', ""If you want an explanation, you you'd better go to John's house.""],['speaker2:', 'Yeah. He lives about four houses away in the bad side of town.']
10:35
@ThelurkerLurker lol.
i know
im redownloading the data... easier that way
i find the csv library more trouble than its worth
@ThelurkerLurker you could do ast.literal_eval with each cell
I would like to take this further... :D
11:18
cbg
@ThelurkerLurker since pandas already comes with its own CSV support, there is no reason at all to use the regular csv module if you want a dataframe in the end.
Though if your adventures with the csv module really produced this file content, revisiting what you have done may be a worthwhile learning experience.
12:20
I have a large list of OrderedDic objects. I don't want to load it all at once because it takes super long to iterate through it. I want to slice it up, I tried for row in rows[:100] but it loads up the whole list and is still same as slow as before. What can I do? How can I iterate fast through a very large list of OrderedDic objects?
cbg folks
What exactly does "loading" the list mean here?
I need to display it in .pdf, .excel, etc
I use django rest framework renderer
We need to know where the list is coming from, not what you're doing with it
From DB but DRF returns list of OrderedDict. django-rest-framework.org/api-guide/renderers
and that list sometimes can be super large (10k+ rows)
12:25
Okay, I don't know django, but I'm fairly sure a renderer wouldn't create a list of OrderedDicts
if it did, is there a way to iterate through it fast? without loading it up all into the memory all at once?
let's say you get [OrderedDict(), ..., OrderedDict()...] and it has over 10k entries, how would you iterate through it effectively? is it even possible?
In that case your problem isn't iterating, your problem is that a list with 10k entries exists
Actually, maybe I misunderstood the question. Do you want to iterate through that whole list or only through a part of it?
I'm assuming you have to process the whole thing
Through all of it and display it in .html which will be converted to .pdf. But getting just one part of it (the first column which is id) effectively and executing a query with those ids, and using a paginator on it maybe could work.
But I tried [row['id] for row in rows] and it's not that much faster
And is there a problem with loading the whole list into memory at once?
It is super slow. It takes minutes.
12:33
Are you running out of RAM?
I just tried it, actually I'm not running out of RAM, but it is super slow
And cpu threads just hit max 20% of capacity
We've established that you need to process every entry in that list. So the only choice there is to make is whether to load the whole list into memory at once or not
If you're not running out of RAM, then I don't see a problem with loading the whole list. It's impossible to say what's taking so long, though.
It is iterating in the template: ```{% for row in rows %}
{{ row }}
{% endfor %}```
@Tomas So far you are only showing how you are using that list. By this point, the list has already been created so any chance of gains from not creating the list are gone.
We need to know how you load the list in the first place, if you want to optimise that.
The problem is not iteration, the problem it takes a very long time to load it to memory I think.
i = 0
for row in rows:
i += 1
print(i)
rsp_rows.append(row) - this takes long time to start, but once it's started, it's almost immediate
12:48
And rows is...?
@Tomas please see our code formatting guide to chat and practice in the sandbox if necessary. Quite obviously triple backticks don't work here.
rows is the list of orderedDicts that django rest framework passes
Also, yeah, printing 10k lines of text will take a while
I guess the conclusion here is that django rest framework is slow?
I think I need something like StreamingHttpResponse but for .pdf and excel. I managed to do this super fast for .csv export
It is not really clear to me how the things you talk about relate to the problem. You initially said the data comes from a DB – streaming from/to the client is inconsequential for this.
 
1 hour later…
14:11
Good Morning

Reading an excel file using Pandas.
In excel, column is in Time format, but when I read it using Pandas, some values are shown in date-time format (e.g. 1900-01-12 15:52:00).

Can anyone help what I can do to just extract time (e.g. 15:52:00 from 1900-01-12 15:52:00) if a value is listed in date-time format?

Also, `df.dtypes` showed my col type as Object. So I tried converting to datetime using:
`df['my_col'] = `pandas.to_datetime(df['my_col'])`

I get an error:
`TypeError: <class 'datetime.time'> is not convertible to datetime`
How are you reading the data into pandas in the first place? Maybe there's an option to extract it differently.
@Kevin Thank you for responding.
I am reading excel as:
`df = pandas.read_excel('C://project//my_excel.xlsx', sheet_name='Employees')`
@LinuxUser My guess would be that your data contains a combination of datetimes and times.
jfyi if anyone has this problem as I did, using an iterator (iter) solved my problem.
@AndrasDeak Thank you for replying.
Any ideas how can I format the col in pandas so that only times are listed?
I don't want date.. just need time.
14:19
Well if pandas' built-in converter doesn't work I'm sure you can convert manually
I wonder if it would help to supply a dtime argument to read_excel?
Is there even a time dtype in pandas?
¯\_(ツ)_/¯
stackoverflow.com/questions/49206158/… seems a bit relevant, but that probably needs homogeneous input
@Kevin (I doubt it)
I suspected the question was rhetorical, but I do like to post that emoticon.
14:23
@LinuxUser perhaps you can first call to_datetime with errors='ignore' or 'coerce' and then handle the offending values separately
@Kevin semi-rhetorical, as I'm not a pandas user
But you know numpy, and between those two libs the walls are thin
it's just thick enough to keep the pandas on the other side, fortunately
The night is dark and full of adorable terrors
anyone got a snippet they can point me to, for overwriting printed lines using (potentially, though not necessarily) the curses module? I want to replicate tail -f but with a "band of N lines on the command line" so that the output doesn't scroll off the screen/page
@Kevin who doesn't love shrug
14:38
¯\_(ツ)_/¯
¯\_(ツ)_/¯
/shrug
I fail at life
If your past is not littered with failures, then you haven't been ambitious enough
15:02
/Shrug
\shrug
\Shrug
shrug
SHRUG
For convenient shrug access, I will now plug the Unicode Emoji Adder user script
(╯°□°)╯︵ ┻━┻
( ͡° ͜ʖ ͡°)
/makemeshrug
/replaceshrug
/asciishrug
/ascii_shrug
/asciiShrug
15:07
:/
:/shrug:
nope... doesn't work
:shrug
:/shrug
Bold of you to assume that chat has any useful markup features
I thought it did. I vaguely remember someone once telling me that there was a replace of some sort
There may or may not be a userscript out there that's better than mine because it scans your input for :shrug: and replaces it without you having to pick it from a menu
 
1 hour later…
16:17
The latest instalment of my alternate life with people giving out my email address - a jpilkington somewhere is evicting Steve from his house. I'm not so keen on this alter ego :/ I don't suppose there's some weird clause in GDPR where I as the recipient keep receiving everyone's confidential stuff, and I can make a claim
Just to be clear: do you want Steve's flat?
I don't think he's treated it very well by the sounds of the letter, so I'll pass
17:02
what are the chances of getting a T-shirt from Hacktoberfest this year?
Anyone?
Hi, I need help. I have a network and I want to remove randomly edges from this network keeping the nodes. Everything is saved a Source-Destination. How can I do?
@HugoB I won't be able to help but I suspect you'll have to provide more information anyway. The library you're using, for starters.
@AndrasDeak I'm using networkx
yeah, so is it ok to just keep destionation-null?
17:15
@TanishSarmah I suspect it's strongly correlated to whether you contribute PRs to open source projects
Note that there have been serious issues for Open Source library maintainers with shedloads of pointless PRs coming in
Ugh, I'm in the second hour overtime today and in the hack it till it works phase. I'm sure I'm just producing garbage right now, but it needs to be done soon
cbg everyone.

Strangely I've been having issues connecting to SO chat rooms (room6 is the only one I actually care about connecting to) for a few days now. I can confirm there is nothing wrong with my network. It just shows connecting.. (on Chrome of course), & then after a good chunk of time, it tells me - 'connection timed out'

& to my surprise, using a VPN fixes the issue in connecting. Is it a known issue or it's just that I'm unfortunate?
@TanishSarmah I tried but they need 4 open source contributions (approved PRs ), and I didn't seem to pull that off this time.
@roganjosh Well I completed the four PRs on the first day itself :)
I hope they were useful
@roganjosh Oh yeah ! some fixed typos lol :D
I mean spelling errors
17:23
Yeah, I'm almost certain they have some good investigations on repos. If you fixed typo in one PR it's fine. but not all 4 of them. (i read that in their contest rules)
@PSSolanki Oh ! Okay ..I have done some other things too.
Then you'll probably be counted in as they are gonna select 70k (IIRC) people for prizes. I hope you do :P
18:18
Hi
Does someone know why Django's send_mail won't send my email but smtplib.SMTP will do?
Port and host are the same
You'll need an MCVE
Should I describe what to do?
You will need to provide a link to some code so that people can see how you've set things up. It's just not possible to understand why it doesn't work for you if we can't see what you've done
ok wait a moment...
18:22
Considering it's django, there could be multiple files involved. It might be best to set up a gist and link that
it's strange that it's working using smtp but not using Django's send_mail
btw I'm using FakeSMTP for development
I don't use Django but it looks like there are some other config variables that you might need
management: hey, you ready to interview the candidate?
me: the one calling tomorrow? I figured I'd compose some questions this afternoon.
management: no, I mean the one five minutes from now.
me: ... Oh.
If all else fails, I'll make him write me a fizzbuzz
Is this a joke or real :O ?
Depressingly real
18:30
Just grab a quick list of the old Google questions. "You're a Borrower trapped in a salad bowl. How do you escape?"
Hey everyone, I asked this a few days ago, but I'd like some more input: I'm trying to improve the MoviePy API and I need some help re naming/conventions: Currently the central objects are various types of Clip. Clip has several methods such as .set_fps(), .set_layer() etc. Currently these methods work 'outplace' i.e. they don't modify the object, they return a new Clip with that modification done to it. This causes a lot of confusion because they don't act like you'd expect a 'setter' to.
Is there a better standard that we should switch to? I was planning on renaming them to .with_fps() and .with_layer() etc, but perhaps it would be better to make them inplace? What are the advantages and disadvantages with that?
"I asked this a few days ago" sorry if you think that it is spamming :)
yeah, sorry, I just noticed that part
2nd and last time I promise!
I just remember you getting some feedback, but I admit I don't remember how substantial that was
I would follow a strict pattern, everything else often just ends up in chaos. So if you have already named everything in a `set_` convention, I would let the methods change the object instead of creating a new one.
But adding more useful methods is also very handy, so maybe consider adding both.
18:37
How do you quantify "lot of confusion"? There's no shortage of people getting confused about inplace/new objects on SO, for example, but I wouldn't deem them as a driver to change the API
for reference here's some of the previous discussion chat.stackoverflow.com/transcript/6?m=50605449#50605449
True, there'll always be people getting it wrong no matter what we do. However in this case I think that outplace set_ is deliberately obtuse and 'incorrect'. Feel free to correct me if you disagree?
Eh, it looks like Aran-Fey is a user of the library and he's a better authority on this than me anyway, so it's unlikely I'll have anything constructive to add
I would agree, though, that set implies inplace to me
I did not weigh in on this discussion previously, but I can definitely share some thoughts from pyparsing. In pyparsing, I went for a fluent API, one in which setters return self, so that you can write code like obj.set_name("Rect1").set_color("#00FF00").set_outline(False). I prefer this to using the initializer with 12 possible keyword arguments. And these setters are in-place methods (they return self, not a copy of the object). BUT...
There was one unfortunate exception in pyparsing, setResultsName, which has to return a copy of the parse expression so that the same expression can be used multiple times with different results names (much like named groups in a regex).
It has caused quite a bit of confusion among users (also because there is a similar-sounding method setName, which is an in-place setter).
bah, {coworker[1]} is taking all the good questions like "tell us about one significant challenge you overcame"
18:45
@PaulMcG very interesting, thank you! I hadn't really considered inplace + return self...
So you can still have your chained set_xxx methods if you just have them end with return self. (This is kind of a Smalltalk style of coding - see en.wikipedia.org/wiki/Fluent_interface).
Yeah that's quite nice
For this job I'm in now, I got totally blind-sided by one by the CEO: "Give an example of an opinion you have that most other people would disagree with" @Kevin
Simultaneously flooded with examples and some horrendous real-time filtering going on. Tough question but not overly horrible
Presumably your objects get copied before being changed fairly often?
The one that stumped me when I intereviewed at a previous job was "How would you write a recursive Fibonacci method?" and I couldn't get past thinking "Why would you want to do THAT?"
18:47
In case anyone is reading this and has the same problem I had with Django testing emails. Here is the solution: stackoverflow.com/a/49432944/9878135
that unpopular opinion is an interesting question. Now you have me thinking about my opinions
It stopped me dead for over 30 seconds and even then it was tentative ground
@TomBurrows They hardly change at all once they get configured. And I discourage the use of setResultsName() now by adding an implementation of __call__. Now if someone's parser uses an integer expression in multiple places, they can do something like move_command = "MOVE" + object_name + "FROM" + integer("from_posn") + "TO" + integer("to_posn").
The call syntax is suggestive of constructor syntax, so you could even look at this as a quasi-Prototype kind of pattern, and further suggests that construction is happening, not just setting.
It is still somewhat obscure, and is probably a weakness of the API, but it is what it is.
@roganjosh "tea with cream and lemon is acceptable"
Oh that's a nice solution
18:55
Thanks
That was aimed at Paul :)
Why would you have cream and lemon with tea??
You just said it was a nice solution!
18:56
@TomBurrows hence unpopular
It's only a solution if the cream and lemon dissolve in the tea substrate
Andras was presented a race condition and grabbed it with both hands :)
There's an itch at the back of my mind that cream wouldn't technically dissolve because milk and cream are colloidal. But I closed the book on my Chem Eng life years ago so I should probably move on
oh in that case, I routinely exclude the cream and eat only the biscuit part of oreos
By the way, this method-chaining was a core idiom in Smalltalk, to the extent that it was unusual to have setters that did not end with ^self (with "^" indicating "return"). It made it very easy to do graphical coding like new Rectangle :at 10, 10 :height 5 :width 6 :color "green". Each ':xxx' indicated a "message" being sent to an object, implemented as a call to method xxx. I think JQuery uses this style too.
The alternative, to have a constructor with all those elements, is that you potentially have 4 integer args in a row, and then you are always wondering "does height go first, or is it width?"
Ah, reading that Wikipedia article, the Python section refers to a post by Guido which could be titled "Use of Method Chaining Considered Harmful (or at the very least unPythonic)".
I like the aesthetic of method chains, although in practice I hesitate to use them in any class that doesn't have intuitive default values for the attributes you can chain
Rectangle().height(5).width(10) is all well and good, but what is the area of Rectangle().width(20)?
Either the base constructor picks a semi-arbitrary value for height, such as 1, or it sets it to None and get_area() crashes until you initialize the object completely
The latter approach gives me the willies because I like having the certainty that my objects are initialized after __init__ runs
19:14
I'm pretty sure there was some default, but it may have been 0, so that the default area is 0, at position 0,0. There is actually a current reincarnation of Smalltalk that I've seen mentioned on Twitter, Glamorous Toolkit.
I'm inclined to agree with Guido there, he gives a very good explanation
But I don't object to allowing the constructor to handle it as an alternative
Well that post was from 17 years ago, some things that were anathema then have emerged to become the new hotness, so...
Isn't Guido's objection there completely opposite to what SQLAlchemy implemented, and become popular?
Although, the method chaining in SQLA ultimately uses a different "design pattern" I guess, if you can call it that
Actually, I don't know what you'd call their approach when it takes the method chaining and translates it to an entirely different language
I've not looked at SQLA in a while, does it look like this example from the wikipedia article? en.wikipedia.org/wiki/Fluent_interface#Java
Happily it seems he wrote a blog post
@PaulMcG yep
I suppose pandas is closer to what was being discussed, because SQLA goes to a declarative language, while pandas actually passes a df object through the chained operations. Whether people like the pandas API is probably also more contentious
19:33
Perhaps method chaining is best reserved for explicitly typed languages where it's easy to inspect the return type of any method
I suspect that modern Python IDEs are only smart enough to know that Foo().bar().baz().qux() returns a Foo instance if each of bar and baz and qux are type-annotated. And even that might not be enough.
When I was first exposed to SQLA, I wrote littletable as a way to try to get my head around it: top_5_sales = employees.where(dept="Sales").sort("sales desc")[:5]. More method chaining... (I spent most of this past weekend implementing outer joins in littletable, in haste/delirium pushed out a buggy version, pushing out a fixed version this evening.)
@Kevin Naive statement that you'll probably be able to smash apart with a counter-example. It shouldn't be possible to design an interface whereby you successively get objects that implement the next method in a chain... which would fail more spectacularly than doing each operation in single steps?
What I'm hearing is "widget.chop().screw().perforate() is no more dangerous than widget.chop(); widget.screw(); widget.perforate(). If a widget is considered not fully initialized if it hasn't been perforated, then you have a risk of partial initialization regardless of whether you have implemented chaining"
The failure is really no more or less spectacular than individual statements, you just have to go down another level in the traceback to see which method in the chain went bad.
In pandas, you'd only chain operations that you thought had a reasonable chance of success e.g. in the groupby --> transform idiom. It's possible that an intermediate step would return an empty df and crash the rest, but you'd still get that from doing the steps individually and ideally you'd want a single type of return from the function, so just wrap the chained operation in a try and give the desired, singular, return value
19:45
No you have a point where the Widget class does need to initialize itself to a consistent state, and then each setter needs to maintain consistency. Perhaps that imposed contract helps keep the setters from doing more than a setter should rightly do.
I need to break off here. I'll check the archive later.
I suppose in my mind there is a distinction between Rectangle().height(5) and Widget().chop(). height() is little more than a simple attribute setter; chop() performs a transformation that may be quite complex.
I guess my instinct boils down to "Don't do Foo().bar(baz) if you can do Foo(bar=baz) instead"
It's kind of redundant to add type hints to magic functions, isn't it?
Thirty seconds of googling lead me to the hasty conclusion that most type checkers don't need you to annotate dunder methods.
They can figure out that Foo.__init__ returns None, and Foo.__new__ returns a Foo
I think we're coming from different angles, the more I ponder. I think I've come to think of a binary output - "I can/can't frobnicate your bizbaz". It's rarely easy to be able to pinpoint what went wrong, in a useful way, so I'll just chain it and wrap in a try/except and hope
But maybe that's something I should be working on. I don't feel like I'm going against the grain with canonicals with the library, though
@Kevin I was asking more about your personal opinion rather about whether most type checkers support it or not
19:53
In that case, my opinion is that it's redundant :-)
thank you
it just feels... so empty without the arrow :C
Well, annotations are more for the benefit of the programmer than the computer, so do what makes you happy
One frustration with method chaining I've had in C# is, sometimes I'll get a stack trace like "nullReferenceException on line x.chop().screw().perforate(); with no indication of which method threw the error. In a perfect world the stack trace would continue to the exact line inside the bad method, but sometimes details get lost on the boundary between libraries, or if the author of the class is doing naughty things to mangle the inner stack trace data.
In those cases I have to rewrite my code to y = x.chop(); \n z = y.screw(); \n z.perforate(); to get a useful line number
Ah, well if they're anything like Java stack traces, I can't be answerable to those :)
That said, I suspect that it's Visual Studio's fault 95% of the time, and not the language or the technique
FWIW, in my background efforts to replicate the jsprit library in Python and, knowing the way vehicle routing data comes through, it wasn't possible to sensibly avoid being able to chain methods like pandas or call setters of an object at multiple points. The result of what I have (unpublished anywhere) is a yam-load of try/except all over the library to prevent your rectangle area issue
My initial "oh, this will be fun" attitude of the project at the start of lockdown has rapidly gone to "why on Earth did I think this was a good idea?"
20:07
Relatable
20:20
Re: "It's rarely easy to be able to pinpoint what went wrong, in a useful way". I agree. You've got to evaluate on a case-by-base basis whether it's worth the effort to have fine-grained failure reporting. Sometimes the best bang for your buck is to raise FrobnicateError("Something went wrong :-(") and trust that the dev team can figure out the rest
Tangentially related to this conversation, the Gang of Four describes the Builder pattern, which constructs complex objects, possibly using multiple consecutive method calls.
Earlier I said that I don't like a design where Rectangle().width(10).get_area() could crash with a "height attribute is null" error or similar. But plenty of nontrivial Builder classes would do the same thing if you tried calling getResult before calling Construct. So there are scenarios where it's valid to crash because the user was supposed to call X before Y.
21:11
That's why I have a tangle of logic checks on what is actually set. All attributes default to None, but it's a mess for me to maintain an API that can consistently give clear exceptions
And it's not clear for other people who inspect the code base
Lol, for poops and giggles, here's one file. I've only been playing around to try settle on a structure but Vehicle is just borked
.id and ._id? :P
Oh yeah, you better believe it!
That's because id will be an auto-incrementing key id in the SQL table. But see the persist() method? It's optional whether you wanna call the library to solve the problem or whether you want to actually store a problem in a db and revisit it
I wanted it to be as fancypants as you could imagine, and just got caught up with my own ideas
No, I just see a perist method
... less keystrokes. It's a convenience method for persist that I forgot to show
wim
wim
21:31
21:47
> Merge (|) and update (|=) operators have been added to the built-in dict class. Those complement the existing dict.update and {**d1, **d2} methods of merging dictionaries.
didin't remember that one
sums = [s for s in [0] for x in data for s in [s + x]]

Unlike the := operator this idiom does not leak a variable to the outer scope.
you know you've got an excellent language feature when for s in [s + x] is a preferred alternative
22:26
Hello, I'm trying to walk a directory and determine if any files in it have global permissions other than 0 octal set. My current code is pastebin.com/ENit9A7k However, just because it may have a non-0 value set doesn't mean you can access it as the parent level permission may prevent it. How can I check to see if the file is truly globally readable, writable or executable?
I presume I may have to login as a new user to run the script.
@crypticツ I have some automation tests that check for file accessibility and I have to include directory permission checking. It is a very confusing and unintuitive bit of Linux permissioning.
                   Del/Create/Rename   Dir            Read File     Write File
 Dir Permissions   Files               List           Contents      Contents    Chdir
       ---
       -W-
       R--                             names only
       RW-                             names only
       --X                                                X             X         X
       -WX                X                               X             X         X
       R-X                                X               X             X         X

« first day (3642 days earlier)      last day (1531 days later) »