« first day (3702 days earlier)      last day (1240 days later) » 
01:00 - 20:0020:00 - 00:00

1:37 AM
Does anyone know how I can print the raw image data from a jpg with Python? I want something like pISk«¡ª£jҝŸVÓÍ=M# T·îwõUg¯u[k­ÝÅ:5ß©«šM³N´²Í«›¯¶éyü;µGìQSOT¥ðËĦünÓFtÕý»Lö]aÜlݪýl¬©¹TA-4Ú;ík¦K3·Úª£“ú¢Sˆ´S?Jåp†ß\u´ú­›nÉÿÜ+MÑÎÛ­øâÏEo«¬ŽÌÇÅ|ôß!’{g“ׯ'¯LµWÇ/˜Îj¯’K'åÛ½Š»òzôë=~Újڈ©üÆujŠ²Šáæ3«ßåÜ¡òzõ` and I am currently getting something more like 8c\xfd\xcb\xfb\x8c\xf7b\x97D\x17cV\xf6 \xe2\x10u\x92\xd6\xeb\xf3*SD\x1a\xb4WA\xf3)\x9ab\xca\xf9`
I'm trying to "print" an image to a browser in a python cgi script
Using:
 with open(f"/var/www/html/{imagePath}", 'rb') as f:
        print(f.read())
 
 
2 hours later…
3:19 AM
That's how you'd do it, but you will need to send the correct Content-Type headers such that the browser will know to render that as an image rather than text.
Well, one more thing, you will need to use sys.stdout.write rather than print, as the print function will take the bytes.__repr__() to produce the escape sequence you are seeing.
@NoahBroyles more specifically, refer to this stackoverflow.com/questions/18791004/…
 
user13415013
3:43 AM
@AndrasDeak, I was blocked again from asking question in stackoverflow. So i switch betn them when asking questions.
But you know this :D
 
4:51 AM
@wim your module still doesn't have a waiter?
@NoahBroyles most importantly what you're gettign is not "something like 8c\xfd\xcb" but very exactly something that starts with b' or b"!
 
5:42 AM
bwaah why can't I see star stats on local leaderboards :'(
 
wim
6:14 AM
If you mean something that blocks until the puzzle unlock ... I was planning on doing that tonight
@AnttiHaapala you mean the last star timestamp?
 
well, it is possible to order by stars, including last achieved but I wanted to e.g. see when did you get your second and couldn't figure out how
 
wim
it's the mouse hover event, or use the json api
probably someone wrote a tampermonkey script to add a column to the table..
 
hmmm...
 
 
2 hours later…
noice :D
@wim though perhaps it should eat the day + year too :D
 
wim
hmm ok I will make it print the local unlock time
just a moment
 
def get_aoc_data(day: int) -> Data:
    """
    Get the wrapped AOC data for a given day

    :param day: the day
    :return: the data
    """

    try:
        return Data(get_data(day=day))
    except Exception as e:
        print('Got exception', e, '- perhaps no data available yet, blocking')
        blocker()
        return Data(get_data(day=day))
 
wim
should I make get_data accept a block=True ?
 
yes that would be most preferable :P
so in my case, what I am doing is when the data is ready I'll see excerpt of it in one window while I read instructions in another :D
 
9:01 AM
Hey guys just a quick one is a while loop a good option for this as it doesn't seem to be working as expected
>> academy = Academy.query.filter_by(name='Nuevos Ministerios').first()
>>> academy
<Academy Nuevos Ministerios>
>>> name = 'SMM - 1'
>>> name2 = 'SMM - '
>>> lesson = Lessons.query.filter_by(academy_id=academy.id).filter_by(name=name).first()
>>> les_count = Lessons.query.filter_by(academy_id=academy.id).filter(Lessons.name.like(name2 + '%')).count()
>>> les_count
3
>>> while lesson != None:
...     name = name2 + str(les_count + 1)
...     lesson = Lessons.query.filter_by(academy_id=academy.id).filter_by(name=name).first()
the idea is to essentially assign the name programmatically and if there is one change the name and recheck until there is no database file with the same name then break, but it seems to get stuck in the while loop
 
of course the loop gets stuck; nothing changes between two iterations
You probably meant to do something like this
for i in itertools.count(1):
    name = name2 + str(i)
 
9:23 AM
I can't believe I always forget about AoC... it's not like it's been happening every December for a while now or anything... doh
 
 
3 hours later…
12:39 PM
Hi to all.

Any idea what this line does in python2.7 ?

line = string.strip(lines[i])

I always thought one has to also pass the string to be stripped, line string.strip(s,[])

And how would I write the above in python 3?
Thanks
lines is a string.
 
strip defaults to removing whitespace. So string.strip(lines[i]) will remove leading/trailing whitespace from the i'th line.
 
Umm, that would be str.strip(lines[i]) actually
 
On both Py2 and Py3, I'd recommend lines[i].strip() instead.
 
string.strip(lines[i]) will strip leading and trailing lines[i] from string
 
is string a string or the string module?
 
12:50 PM
The string module has no strip function, so...
 
python what now?
didn't realize we were talking about prehistoric times, my bad
 
I've spent 10 embarrassed minutes this morning recommending Awesome Things to my student. Only to realise none of them worked in the Py2 he has to use due to compatibility.
 
poor soul
 
1:22 PM
Student stuck with python 2? When did he enter hell?
 
When he signed up for high energy physics.
 
1:38 PM
poor soul
 
2:23 PM
@metatoaster Thanks, that worked like a charm! I already had the necessary Content-type headers, I just needed sys.stdout.buffer.write().
 
2:53 PM
@AndrasDeak Would you say there is any advantage to learning Python 2 before Python 3? Like learning C++ before Python, I hear, is useful.
I jumped right into Python 3 and have not regretted that choice
 
@Dodge no to both
Python 2 was a broken version of python, why would you want to learn any of that?
you'd have to unlearn the broken things
 
Yup, that would have been my guess regarding the matter
 
@AndrasDeak I hear they didn't even have asspressions D:
 
>:|
 
Hey all, is anyone available to answer a quick question
 
3:02 PM
::<>
AOC is taking its toll... :/
 
I have a normal CDF, just a nice smooth line, then I want to plot an axhline up to a certain point on this line, and then from that point also an axvline straight down. There must be a package that can take care of this for me but I have not been able to find it
Do any of you maybe know anything about this?
 
@CharlieShuffler you are using matplotlib terms; why not use matplotlib for this?
do you really need an axhline as opposed to hlines?
 
I am, but there is no easy way afaik to do draw an axhline right up to a specific point and same story for an axvline
 
@CharlieShuffler I'm pretty sure you can do any series of two point line segment you want in matplotlib
 
not necessary, no, I'd just like any solution
 
3:05 PM
@Dodge axhline and axvline overlap the axes, as opposed to just plotting data
but I suspect you can use manual annotations to do whatever
I just want to make sure the question is precise
@CharlieShuffler well if you want lines in your plot: draw lines
 
@AndrasDeak I know what they do, they simply make quick vertical or horizontal lines
 
ax.plot([0, x0, x0], [y0, y0, 0]) is the simplest option
 
sure, its possible to brute force it, but I thought I recalled some function where you just pass two coordinates and it draws an axvline and axhline going up to exactly those coords
 
@Dodge do you also know the difference between ax.axhline and ax.hlines? That's what I'm talking about.
 
"I want to plot an axhline" made me think of a single line
 
3:08 PM
you are ignoring what I'm saying
whatever
 
I suppose your solution @AndrasDeak works good enough for what I need since I can just adjust color and alpha etc. Thank you
 
No problem. I doubt there's a built-in for this in pyplot, because it's pretty specific. Perhaps in something like seaborn which is about making plots look fancy.
 
yeah agreed, I might go and check that out anyway
 
@AndrasDeak I am not ignoring what you are saying, I am focusing on what I thought the original issue was, plotting a single line to a point and then plotting a perpendicular line starting at that endpoint. I though my response was reasonable. I readily admit that you will likely give better advice and am happy to just get out of the way.
 
Does anyone have tips on how I can become a better programmer in python?
 
3:14 PM
@Dodge it's alright, I just don't like feeling that we're talking past each other
 
@Andras Yup agreed, it works better when that doesn't happen
 
@CharlieShuffler having checked the docs now, both axhline and hlines support xmin/xmax keywords so you could have just used those the same way
 
@Rezaamin Practice. Familiarize yourself with the stdlib. Practice. Read other people's code. Practice. Read your own (old) code. Did I mention practice?
 
Yeah true, but theyre specified in percentage terms of the length of the x-axis which is quite inconvenient
 
@CharlieShuffler according to the docs both use data coordinates. I know for a fact that hlines/vlines use data coordinates.
 
3:16 PM
fair enough, then i'm probably wrong
 
perhaps the axhline docs are wrong; my memory was also that it used axes coordinates
 
@Aran-Fey any website you would recommend?
 
either way im only plotting a few of them so the difference is minimal
thanks for the help though
 
@Rezaamin nope
 
@Rezaamin good starting point for practice: Do this year's advent of code in python, it started just 4 days ago so it is still manageable to catch up
 
3:18 PM
@Aran-Fey so how do u practice?
 
Uh, by writing code? Why would you need a website for that?
 
@Arne Thanks sir!
 
no problem, happy coding
 
@Aran-Fey you misunderstand me! I mean like do you just write a random code or do you do some tasks from a website?
 
If you're thinking of coding challenge websites like Leetcode or Codewars or whatever, don't. Those can be useful for checking out how other people solve the problems and learning small tips and tricks, but once you know the basics of the language, they become useless
I'm not sure I'd recommend AoC either, by the way. Little programs that solve puzzles don't teach you much IMO
Find a real program/library to write
You'll learn how to structure your project, how to package and publish it, versioning, testing, documenting. Puzzles teach you exactly none of that
 
3:25 PM
I tend to think that being able to solve problems is also an important part of being a good programmer
but I agree that code challenge sites that run your code are never the solution
I like those that only give you a task and ask for an answer, letting you solve it in whatever way you want
 
@Aran-Fey Thanks!!
 
"problem solving" is a bit of a broad term. Having to solve puzzle-like problems (e.g. optimization problems, etc) is... pretty rare, in my experience. I think all the other stuff I mentioned is much more useful to know in day-to-day programming
(At this point it's time for a friendly reminder that I'm just a hobbyist and I could be completely wrong)
(brb, checking if "hobbyist" is an actual english word... ... yup, it is)
 
nah, you're right. I don't think I ever had to use my knowledge on graph-traversion in my day job
 
Most people probably don't have to solve knapsack problems on a daily basis. But facing the problem of "how do I turn this string into a list of dicts by parsing key:value pairs in it" should not make you want to ask for help on stack overflow.
 
probably also depends what kind of job you have of course, so this is also only my personal experience
 
3:36 PM
Sometimes I wish I had more optimization problems to solve... design problems like "Should this be a class?" or "How exactly do I want my public interface to work?" tend to kick my butt much harder than any optimization problem
 
3:48 PM
Streaming Advent of Code day 4: twitch.tv/davidism
 
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-10-9e2a6639b84b> in <module>
----> 1 from seq2seq_trainer import Seq2SeqTrainer
      2 from seq2seq_training_args import Seq2SeqTrainingArguments
      3
      4 BATCH_SIZE = 4
      5

~/seq2seq_trainer.py in <module>
      6
      7 from transformers import PreTrainedModel, Trainer, logging
----> 8 from transformers.configuration_fsmt import FSMTConfig
      9 from transformers.file_utils import is_torch_tpu_available
I do not know where this error could be coming from
Obviously transformers.configuration_fsmt must have come with seq2seq_trainer, did it not?
Like, how is seq2seq_trainer functioning if transformers isn't?
Somebody sent me this exact code and it worked in his environment. Is it the case that I somehow imported s2s without importing transformers.configuration_fsmt? Even worse, I know that transformers is there. What could be the problem?
Even worse, there's a line before this error in the notebook that says !pip install transformers. Transformers must be there, right?
 
4:06 PM
transformers recently released version 4, so I guess the author of seq2seq_trainer has botched its dependencies (i.e. it only works with transformers v3, but still lists v4 as a valid dependency)
 
How do I import a specific version?
Like version<=4 or whatever, how do you do that?
 
by installing only the correct version
 
How? Also, how do I check which version s2s had been using?
 
I'm not entirely sure how to do that tbh, I've never had to
pip install transformers<4 maybe?
 
Trying it right now.
Something that was working previously is now not working, and I need to get to that before I get to the transformers problem
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-dd92c84a1085> in <module>
3 import gzip
4 from urllib.request import urlopen
----> 5 from tqdm.auto import tqdm
6
7 def get_data(url):

ModuleNotFoundError: No module named 'tqdm.auto'
So I added before that cell
!pip install tqdm
And it said
Requirement already satisfied: tqdm in /data/rc/apps/rc/software/Anaconda3/2020.07/envs/DeepNLP/lib/python3.6/site-packages (4.26.0)
mkl-random 1.0.1 requires cython, which is not installed.
mkl-fft 1.0.4 requires cython, which is not installed.
transformers 2.4.1 has requirement tqdm>=4.27, but you'll have tqdm 4.26.0 which is incompatible.
tensorflow 1.11.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
spacy 2.0.12 has requirement regex==2017.4.5, but you'll have regex 2018.7.11 which is incompatible.
What is this? How do I fix these requirement issues?
 
4:17 PM
step 1, upgrade pip
step 2, uninstall everything before trying pip install transformers<4 again
 
Permission denied
Does that require root access?
 
doesn't require more access than installing
 
Full error
Collecting pip
Using cached https://files.pythonhosted.org/packages/ab/11/2dc62c5263d9eb322f2f028f7b56cd9d096bb8988fcf82d65fa2e4057afe/pip-20.3.1-py2.py3-none-any.whl
mkl-random 1.0.1 requires cython, which is not installed.
mkl-fft 1.0.4 requires cython, which is not installed.
transformers 2.4.1 has requirement tqdm>=4.27, but you'll have tqdm 4.26.0 which is incompatible.
tensorflow 1.11.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
spacy 2.0.12 has requirement regex==2017.4.5, but you'll have regex 2018.7.11 which is incompatible.
 
...actually, it might depend on where it's installed. You may not be able to uninstall globablly installed modules without root permissions
uh, is it normal that you don't have write permission in that folder? That seems weird
 
For some reason adding --user fixed that
Ok pip is upgraded
How do you uninstall everyhting/
?
 
4:24 PM
you can get a list of all installed modules with pip freeze
 
Can I !pip freeze > uninstall * or whatever the command on the right hand side should be?
 
Hello all,
I am looking to design something like a 'wiki' where users can search for the info based on the search criteria.
Anyone can help me please what tools/technology I would be looking at?
I already have the data with me split into various html files.

Currently, our technology stack for front-end is HTML5, CSS3, JavaScript, Bootstrap.
and back-end Python/Flask
 
@JohnnyApplesauce I don't think so, but I'm not a shell scripting guru
 
user14596741
I personally feel somehow family when i come to python room.
All known faces :)
 
4:40 PM
@JohnnyApplesauce it's $ pip freeze | xargs pip uninstall -y
 
Added. Thanks Arne
 
Wait a sec. It's Anaconda throwing those errors
Did you install miniconda?
 
@ro
What?
 
How do I check if I have miniconda?
 
4:41 PM
See the lines:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/data/rc/apps/rc/software/Anaconda3/2020.07/envs/DeepNLP/bin/pip'
I don't know if you can. I don't know if there's any real difference between Anaconda and Miniconda other than the libraries bundled with it (basically none with the latter). It may come down to you remembering what you installed
 
I'm using someone else's computing environment. I'm not sure how to check what's there other than through interacting through the shell
 
@LinuxUser That sounds pretty much all you need. I'm not sure what tooling, specifically, you are looking for?
@JohnnyApplesauce Does the conda install command work?
 
@roganjosh Thank you as always for responding!! Appreciate it.
I mean how can I combine all the files and put them together to be made searchable by users?
I need little help here.
 
That depends. It might be the case that the wikipedia model is more suited for NoSQL so you might want something like MongoDB as the backend storage
 
This is a shell question but it's directly relevant
Conda's giving me "proceed y/n"
The jupyter notebook interface doesn't give a place to type anything
What do I need?
!conda env create --file environment.yml < echo "y" or something?
 
4:52 PM
:S I think I'm out of my depth at this point, sorry
@Aran-Fey semi-serious; apply at our place :) That's all we do
 
I was tried to capture all words which are starting from the upper case using the following regex

([A-Z][a-z]*)+

String is HewawasamAththanayakeDeewani
but it only grouping the last word

this is regex fiddle
what's wrong with the regex ?
 
in /dev/chat on The Stack Exchange Network Chat, Nov 1 at 22:17, by Andras Deak
near the end of https://docs.python.org/3/library/re.html#re.Match.group
in /dev/chat on The Stack Exchange Network Chat, Nov 1 at 22:17, by Andras Deak
> If a group matches multiple times, only the last match is accessible:
 
@AndrasDeak any solution on that?
 
I found it, it's yes | ...
 
@underscore I don't know, this is not something I've encountered with regex
 
5:00 PM
No, that didn't work
 
@underscore if all else fails you can start matching one by one in a while loop... but there's hopefully a better solution
 
(?<TRANS>[A-Z][a-z]+)
this is also the same as previous one
i need this for VsCode
to find and replace some chars
no programming language would be used at that stage
42
Q: RegEx with multiple groups?

joslinmI'm getting confused returning multiple groups in Python. My RegEx is this: lun_q = 'Lun:\s*(\d+\s?)*' And my string is s = '''Lun: 0 1 2 3 295 296 297 298'''` I return a matched object, and then want to look at the groups, but all it shows it the last number (258): r.g...

:(
Your regex only contains a single pair of parentheses (one capturing group), so you only get one group in your match. If you use a repetition operator on a capturing group (+ or *), the group gets "overwritten" each time the group is repeated, meaning that only the last match is captured.
 
I want to say that the third-party regex library might help, but that's probably not how vscode works and to be honest I'm not even sure this has anything to do with python
 
This feels a bit like an XY problem to me.
If you're just trying to, say, replace each word's capital letter with an underscore, than you shouldn't need "dynamic" capturing groups for that
 
:)
i just need to set \U ( upper ) and add _ before any word
\U$1
like this
 
5:14 PM
I don't have VSCode but I do have Notepad++, which has a regex find/replace. I assume they work pretty similarly. If my document contains "I Have Ten Apples", then the find pattern [A-Z]([a-z]*) and the replace pattern _\1 will give me _ _ave _en _pples
Similarly ([A-Z][a-z]*) and _\1 gives _I _Have _Ten _Apples
If the top-level problem is "how do I find all PascalCase variables in my program and replace them with Capital_Underscore variables?", you might need lookahead for that
converting to lowercase_underscore is, I think, impossible with conventional regex
 
(?<FIRST>[a-z]*)(?<TRANS>[A-Z][a-z]*)
samithaHewawasamAththanayakeDeewani
samitha Hewawasam Aththanayake Deewani
 
find pattern ([A-Z]) and replace pattern <space>\1 will put a space before each capital letter
 
freezSetup.noOfFreezedDays
how do i regex upper in this word ?
 
What's the desired output?
 
FREEZ_SETUP.NO_OF_FREEZED_DAYS
 
5:29 PM
As far as I know, changing the casing of a letter is impossible :-/
 
see this
\U works
[A-Z] this doesn't work inside that regex
 
I'm not sure I understand that example. The input string and output string have the same casing, don't they?
 
no. different casing
("US.TL.PACKAGES:freezSetup.noOfFreezedDays")
this is actual input
("US.TL.PACKAGES:FREEZ_SETUP.NO_OF_FREEZED_DAYS")
this is the desired output
 
I don't completely understand but I'll poke around a bit
Ah, I found the documentation for \U: "Transforms text to uppercase until either end of string or a \E is encountered. This is a feature only available on regex101.com."
Don't think this will be very useful in VSCode
 
it's works in VsCode too
:)
 
5:38 PM
Ok then.
 
now the problem seems
("US.TL.PACKAGES):([A-Z])
combinations doesn't work
any idea on that ?
 
I could write a regex that converts "fooBarBaz" into "foo_BAR_BAZ" or "_FOO_BAR_BAZ", but it's hard to both convert the leading "foo" into upper case and not put an underscore in front of it
It wouldn't be too hard to write two regexes, one inserting underscores and one changing the casing, but that's no fun
 
how could ?
 
find ([a-z])([A-Z]) and replace \1_\2 turns "US.TL.PACKAGES:freezSetup.noOfFreezedDays" into "US.TL.PACKAGES:freez_Setup.no_Of_Freezed_Days"; find [a-z] and replace \U\0 turns "US.TL.PACKAGES:freez_Setup.no_Of_Freezed_Days" into "US.TL.PACKAGES:FREEZ_SETUP.NO_OF_FREEZED_DAYS"
Of course this capitalizes the entire file and not just words that appear on the same line as "US.TL.PACKAGES". If that's bad, perhaps a negative lookbehind...
 
5:54 PM
yes
([a-z])([A-Z])
need to add "US.TL.PACKAGES:
into that
 
Dang, I can't use * in a lookbehind. So much for that idea.
 
(?:US.TL.PACKAGES:):([a-z])([A-Z])
this even doesnt work
non capturing
 
We're officially out of my depth at this point
 
6:09 PM
(?:US.TL.PACKAGES:)|([a-z])([A-Z])
no it doesnt
:D
 
6:36 PM
Hi guys,

Somehow I've broken my Python install as I'm getting this error while trying to use win32com.client

AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToPackageMap'

I've found this https://stackoverflow.com/questions/52889704/python-win32com-excel-com-model-started-generating-errors and this is suggested as the solution https://mail.python.org/pipermail/python-win32/2007-August/006147.html but the problem I have is that I'm not experienced enough in Python to understand how to implament the solution. Can anyone help?
 
6:48 PM
I'm not sure why that takes experience in Python, which stops you from finding the directory and deleting it as suggested
What would take experience in python would be why there's an issue from 2007 still being answered in 2019 :/
 
but then you need to "run makepy", how do I do that? when I ran "from win32com.client import makepy;makepy.main()" it just gave me a list
 
Are you talking about the following comment? Because the answer doesn't suggest that, it just references it from a linked thread
And for those that are wondering how to run makepy after deleting the gen_py directory navigate to C:\<python install directory>\Lib\site-packages\win32com\client and then run makepy.py. — Jason Apr 28 '19 at 20:22
 
yes, so are you saying that I should delete this folder 'C:\Users\JAMESM~1\AppData\Local\Temp\gen_py\3.7'?
 
I'm saying that the answer is saying that :P
<totally absolves self of blame>
 
Ok, so I don't need to do anyting after I've deleted that folder... just hope that "XL = win32com.client.gencache.EnsureDispatch('Excel.Application')" works again?
 
6:54 PM
I don't understand basically anything about the underlying issue, sorry
 
randomly win32com.client.gencache.EnsureDispatch('Excel.Application') stopped working for me and gave me this error:
AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToPackageMap'
 
Sure, you've already stated that. Doesn't mean I understand its underlying cause
 
yea, nether do I. It looks like Chris who asked this question two years ago found that this just happened randomly to him too "The code has not changed from yesterday to today. I have no idea what is happening!!!."
the solution does say that you need to be "re-running makepy" after "Deleting the gen_py output directory"... so do I not need to know how to run makepy after deling the directory?
 
Well I also linked you to a comment that suggested how to do that... on the same answer. At this point, I'm just reading back to you what you originally linked
 
ahh yes, sorry, I will try deling this directory and doing the above
When I run makepy, it gives a box with a list selection... which do I select?
 
7:14 PM
Hi guys, I was working with datetime library and I think I hit a dead end, im trying to compare times I get from one = datetime.strptime('01:00:00','%H:%M:%S') and twenty3 = datetime.strptime('23:00:00','%H:%M:%S') but here it always returns the oppt of what I want, because it thinks that both the time are of the same date, but when I say 1:00 it does not move the date forward. Any ideas?
 
Are you trying to get the time difference, so in your example you would want to get out 22?
 
What i mean is twenty3 < one should actually return True for me, but it does not, as twenty3 and one are of the same date(1900-01-01) and hence twenty3 > one. Anyway to change the date of this time?
@JamesMcIntyre Not the time difference, Im trying to compare the two times.
 
@JamesMcIntyre oof. Something is going on tonight with the difficult questions (there's been a few, not just yours)! :/
 
@roganjosh cbg, I found your secret indian website xp -
 
I don't even know how to differentiate the first few options
 
7:21 PM
hello
 
@CoolCloud gosh, I may have had a few too many that night because I have no recollection of building that; but I was certainly productive!
 
one = datetime.strptime('02/01/2020 01:00:00','%d/%m/%Y %H:%M:%S')

twenty3 = datetime.strptime('01/01/2020 23:00:00','%d/%m/%Y %H:%M:%S')

one > twenty3
Out[22]: True
 
@roganjosh laurel!
@JamesMcIntyre So I have to give the date input too?
 
@CoolCloud yes
 
if you want one to be more than 23 because of the date, yes
 
If you want to use datetimes, you should provide a meaningful date value. If you don't have a meaningful date value, you should use time, but then you can't meaningfully compare them with ">" or "<"
"Is noon later than midnight?" is an incoherent question without date info
 
A timestamp without a date is pretty meaningless to a computer (though intuitively totally meaningful). The default is just to be 1900-01-01 for the date
 
I'm having problems with conda and the yes flag
It's not doing anything
25
A: conda stuck on Proceed ([y]/n)? when updating packages in ipython console

aromaAdd --yes at the end of the command. For example: !conda install --yes seaborn

I have the same problem as the OP here
 
But yeah, the only reasonable interpretation is that 1 < 23
 
These are all the variants that I have tried
!conda env create -y --file environment.yml
!conda env create --yes --file environment.yml
!conda env create --file environment.yml --yes
!conda env create --file environment.yml -y
!conda env create -y --file environment.yml < echo 'y'
!echo 'y' | conda env create -y --file environment.yml
 
7:27 PM
@JohnnyApplesauce conda env create --file environment.yml <<<'y' ;)
 
And each time I have been met with Proceed ([y]/n)?
 
Ah, that's your last one
It might be another shell doing the asking for y
 
I'm in a notebook and don't know what other context I need to give. How might there be another shell?
 
@roganjosh Do you know which of those options I should choose for makepy?
 
There might not be because the notebook might not even be able to launch another shell
8 mins ago, by roganjosh
I don't even know how to differentiate the first few options
 
7:30 PM
Ok, if there isn't another shell, what else could be causing the problem?
 
@roganjosh ahh sorry, I didn't see that :/
 
Just because it can't be launched in the environment doesn't mean it wasn't meant to exist
 
@JamesMcIntyre Yep that worked, thanks!
@Kevin Actually ya, i made no sense, i knew i made no sense too. I wanted to know a way to add the time on.
 
@CoolCloud No worries, it's not often I manage to help somone :D
 
@roganjosh Yep its true, thanks!
 
7:32 PM
@CoolCloud are you aware that manually adding two different dates will ensure that the later day will check larger than the earlier day?
 
@AndrasDeak Yeaa lol
 
OK, just checking
 
You guys recon I need to reinstall my Python install then?
 
<abstains from vote> I don't think I understand most of the last hour or so
 
@AndrasDeak I am aware of that, though its what I want right? cuz 23 of a before day will always be less than 1 of next day
 
7:34 PM
@CoolCloud yes, but then why are you even checking anything?
 
IIRC You can't add two datetimes, but you can add a timedelta to a datetime or a time or a date
So if you're dead set on adding one day to the 1 AM time, there you go
 
@AndrasDeak Its just how my if statements work, smh, i prolly restructured my code the worst way possible, but ya.
@Kevin oh okays, thanks !
 
@Kevin
 
Reminds me of how TV guides in Japan will list late night programs as airing at e.g. "Mon 26:00" rather than Tues 2:00
 
(?<=\bUS\.TL\.PACKAGES:\S*?[a-z])(?=[A-Z])
 
7:36 PM
@Kevin Damn they made new time.
 
They're living in the future over there
 
@AndrasDeak TBH, im checking with diff time, if my current time is between the two given time constraints
@Kevin True xp
 
"Does 3 AM come after 11:00 PM and before 5 AM?" is a meaningful question and not totally trivially solvable with time or datetime
 
Maybe it would be better to ask what the timestamps represent
 
It's more of a modular arithmetic problem really
 
7:42 PM
For example, I've used timestamps for shift patterns that are date-invariant. 10-6 is invariably 10pm from the previous day to 6am the next day
 
@Kevin the phrasing makes that tricky. It's not actually a before/after question, but a between question. That's why it's meaningful.
 
Yeah the semantics here are treacherous
 
True
 
You're the one supposed to be clarifying, though? :P
 
Looks like I'm gonna be resintalling Python on Monday then... I do appreicate all of your help. Thanks for your time here again @roganjosh
 
7:44 PM
Im the one supposed to be learning here xp like working with datetime ive literally gone mad
 
@Kevin not a bad practice
 
Have a good weekend guys
 
@JamesMcIntyre you too
 
you too
 
you too :)
 
7:47 PM
def is_between(x, left, right):
    if left <= right:
        return left <= x <= right
    else: #right > left -- midnight bisects the range we want
        return left <= x or x <= right

print(is_between(11, 10, 12)) #True - 11 AM is between 10 AM and 12 PM
print(is_between(3, 24, 6))   #True - 3 AM is between midnight and 6 AM
 
What if i wanted dynamic if statements? Like if my dataframe hav 6 columns, then i need 6 if elif statements, any idea? This would save plenty lot of code lines for me xp
 
err
MCVE please
 
TBH i dont know how to come with an example for this, thats why i havent asked any questions on this site about this yet.
 
If you can't come up with an example, though, how do you expect us to be able to answer it?
 
But maybe i could explain my case a bit more
@roganjosh I realize....but yeah
 
7:51 PM
I'm not trying to be difficult. But you must see the issue with that situation?
 
people answer no-MCVE problems all the time, so they probably don't
 
My imagined MCVE is, how to write this without writing is_between more than once:
if is_between(current_time, 6, 12):
    print("breakfast is available")
else is_between(current_time, 12, 17):
    print("lunch is available")
else is_between(current_time, 18, 21):
    print("dinneer is available")
else:
    print("closed")
 
Something like this makes sense
@Kevin but ive to use the if statements over again right?
im trying to reduce the if
 
So map a tuple of (start_hour, end_hour) as keys to a dictionary over the dataframe
 
ranges = {"breakfast": (6,12), "lunch": (12, 5), "dinner": (6,9)}
for k, (min, max) in ranges.items():
    if is_between(current_time, min, max):
        print(f"{k} is available")
        break
else:
    print("closed")
 
7:54 PM
There is no if with map. What you're suggesting (or, I'm inferring) is that you're iterating rows of a DF
 
Oops, I used 12 hour time in my dict. you know what I meant.
 
You see? Answers :P
 
Im not iterating, yet, but i want to
 
So I suggest that there are other problems and it's not helpful unless you give an MCVE
 
@AndrasDeak lol
 
7:54 PM
Ugh
 
@Kevin no probs, understood
 
Also probably pick different names for min and max unless you don't mind overshadowing the builtins
 
@Kevin that's good satire considering the original "11 PM vs 3 AM" problem
 
Let's pretend I did that intentionally >_>
 
This is how my dict looks, like
 
01:00 - 20:0020:00 - 00:00

« first day (3702 days earlier)      last day (1240 days later) »