« first day (3341 days earlier)      last day (1607 days later) » 
00:00 - 21:0021:00 - 23:00

9:00 PM
always use raw strings for regex... everyone who's worked with regex for a while has alarm bells go off in their head if they see code matching re\.\w+\([^r]['"] anywhere
 
Yeah, I usually use raw strings for regex patterns even if I don't have any special characters.
 
(yes I know the regex is wrong, but you get the idea)
 
It's good enough for the gag
 
I'm still undecided on always using r-strings for the replacement in a re.sub call. 70% of the time I think "that's really not necessary", and then 60% of those times I get an error because I later add a backref like \1 and forget to add the r
 
@wim what can I post it to instead? Or should I post here directly?
 
9:04 PM
Yeah that's my experience too
 
wim
I'm surprised nobody told them to avoid regex yet
all they wanted to do is strip certain characters, which is better with str.translate
 
had a small emergency to take care of...reset password functionality was broken on a system I work on.
 
His question is secretly in Alteryx and not Python, so who knows if he even has access to a .translate method.
 
>>> f'{1.5:.3f}'
'1.500'
>>> f'{1.5:.3g}'
'1.5'
 
wim
hmm
 
9:05 PM
In a pinch you could just chain five .replace calls together
 
@wim Here's the MCVE from pastebin. I'd like the result to be '1.50'
 
Telling someone to read a tutorial is slightly more satisfying than telling them to rewrite their code ¯\_(ツ)_/¯ (I'm just kidding)
 
so 3 significant figures
 
wim
before we go down the rabbit hole, do you know exactly what "significant figures" means?
 
yes
I took chemistry and physics in college and had to learn all about it there.
>>> f'{0.15:.3g}'
'0.15'
This would be '0.150' with 3 sigfigs
 
wim
9:08 PM
correct
ok, but that is not what the 'g' format specifier does, regardless
 
ok, that's probably a misunderstanding on my part
 
wim
it's about the exponent
>>> format(15000000, ".3g")
'1.5e+07'
>>> format(15000000, ".3G")
'1.5E+07'
>>> format(15000000, "")
'15000000'
 
TBH, if it is more complex than a format specifier in the fstring, then it's too much effort for my purpose
yah, if it is big enough or small enough for E notation, that's fine, too
 
I'm trying to save html without BOM but i still keep getting it. here's the code repl.it/@AmericanY/Issue
 
9:11 PM
I was just wondering if there was a trivial way to get the trailing zero in these examples
>>> format(15000000, ".3g")
'1.5e+07'
So '1.50e+07' in this case
 
wim
try ".2e" maybe
 
@αԋɱҽԃαмєяιcαη Use utf-8 instead of utf-8-sig?
 
i tried but it's not make sense
 
>>> format(15000000, ".3e")
'1.500e+07'
which gives a lowercase e
and looks like the given number is used as the number of digits after the decimal place
anyways, that's all the time I'll take on this. Thanks for your help, wim
 
@Aran-Fey just solved it using the following
import requests


r = requests.get(
    'https://www.wuxiaworld.co/Master-Hunter-K/1061716.html')
r.encoding = r.apparent_encoding
with open('page.html', 'w') as pop:
    pop.write(r.text)
plus encoding='UTF-8'
 
9:39 PM
So, my AoC testing time is now at least twice as fast, and best as I can tell taking about 1/10 of the memory. :D
 
wim
@toonarmycaptain let me guess, you changed a huge list buffer into a defaultdict(int)
@Code-Apprentice tbh if I want to see "significant figures" in a table and not just "decimal places" I will rather to see "1.50e-01" than "0.150".
 
@wim Hmm, no, I wasn't quite that sophisticated. A regular dict did just fine.
 
I need to parse some rsts (that include other rsts) (or the resulting html) and output to ipynb, any recommendations? I have pandoc, sphinx, and nbconvert (which looks like it goes the wrong way...), not sure I'll get any other libs...
 
@wim yah, that makes sense.
 
wim
yo dawg, i herd you like to restructure your restructured text
 
9:44 PM
@wim zactly
 
Either way, 1.5e-01 vs 1.50e-01 or 0.15 vs 0.150 mean different things in a scientific context
 
worst case scenario I'm parsing html to generate the notebooks...
I'm thinking there's probably a way to inject some behavior in sphinx to read the rsts, do the includes and other directives, and direct the output to ipynb...
best case scenario, somebody already did it and has example code somewhere...
(or pandoc's got the magic for it maybe...)
 
rhbrb all
 
wim
note the op_offset calls and incrementing offset val
109,1,  # offset
204,-1,  # output (relative)
1001,100,1,100,  # add (position, immediate, position)
1008,100,16,101,  # eq (position, immediate, position)
1006,101,0,99  # jump if false (position, immediate)
it will probably be useful to get familiar with these ops because for sure they are gonna ask us to optimize loops later in the month
 
10:43 PM
@wim that log is yammin' cool, would make debugging easier. I have not looked at your code yet but that log makes me want to
Why do you do except IntComputer.Halt: instead of except self.Halt:, why is it a class within a class?
 
00:00 - 21:0021:00 - 23:00

« first day (3341 days earlier)      last day (1607 days later) »