« first day (4050 days earlier)      last day (1122 days later) » 

06:54
@roganjosh should I ever need to drive again.. the plaid model of tesla.com/en_gb/models looks really quite sexy
(price tag is just a not going to bother I'd prefer to buy/put most of a deposit on a house... but wow - if I won the lottery... that thing would be on the list
This entire 64bit thingy isn't going to catch on anyway.
08:39
Hi Everyone!

I am trying to write a python code that checks for csv files in the source folder and target folder and copies only those files which are
available in source and not available in target to the target folder.
Is there a way?
Yes. What you've described should be straightforward to write as a program.
Is there a specific step you are struggling with?
Note that if your goal is only to sync directories, tools such as rsync do that out of the box.
Right now I am using this code to copy all csv files from source to target.
import os
import shutil

file_extension = ".csv"

def copy_csv(source_folder, target_folder, file_extension):


for item in os.listdir(source_folder):
source_fn = os.path.join(source_folder, item)
if os.path.isdir(source_fn):
copy_csv(source_fn, os.path.join(target_folder, item), file_extension)
elif item.endswith(file_extension):
if not os.path.exists(target_folder):
os.makedirs(target_folder)
shutil.copyfile(source_fn, os.path.join(target_folder, item))
08:54
Well, you are already checking if the target folder exists. You can also check whether the target file exists.
There are plenty of ways to figure out if a file has changed:
1) Check if the modification time changed
2) Check if the hash changed
3) Check if the size changed
4) All of the above
09:37
Whoa, python 3.6 EOL is coming up soon. No more worrying about dataclasses, ordered dicts, or contextlib.nullcontext!
Do you worry a lot about those things? :P
I find creative ways to avoid using nullcontext all the time, yeah
 
2 hours later…
11:54
cbg
I found: vavatch.co.uk/books/banks/cultnote.htm Really cool read. It's just that the book I read itself, is kinda less impressive then the general description of the culture. I got hyped reading this article, but I'm not sure I can commit to reading another book
12:09
So I'm looking at a directory that contains many Rails apps. Those apps have controllers that convert incoming queries to curl commands that subsequently get dispatched to a central api defined in one of the apps. How would you find where the api is defined?
okay one can grep from the parent directory through all the children for the route handler
TypeError: unsupported operand type(s) for +=: 'Q' and 'Q'. huh, isn't += just defined as foo = foo + bar? I thought it's automatic, looks like it needs to be manually implemented(odd) and Djangos devs decided it not worth their time, unfortunate
ah no my b it's &= not +=
12:24
yeah, and just for record, + and += may not always be same, += goes for iadd dunder, and may be implemented with different meanings for mutable datatypes. lists are a great common example
(whether + and += "should" always behave similarly is, however, a fair point to discuss about. i make no claims on that one way or another)
Implementing & is enough to support &= as well. They must've gone out of their way to explicitly disallow it
12:52
@ParitoshSingh wait what do you mean?
x = []
x += [5]
x = []
x = x + [5]
This does the same for both
+= is a mutation. make another reference and see
let me make you an example
l1 = l2 = [10]
l1 = l1 + [42]

print(l1)
print(l2)

l1 = l2 = [10]
l1 += [42]

print(l1)
print(l2)
[10, 42]
[10]
[10, 42]
[10, 42]
so yeah, not quite the same. can also lead to some sneaky bugs if you're unaware
13:09
I see interesting
13:28
Nice example
Is Q a built-in Django type? What is its real name? Or, if it's a type you defined, does it inherit from any Django types?
I agree with Aran-Fey's idea of "They must've gone out of their way to explicitly disallow it". Now I'm curious how they did it, and whether it's publicly documented anywhere
Probably just a return NotImplemented
I don't think that's enough, by itself. Consider the toy example:
class Fred:
    def __init__(self, x): self.x = x
    def __repr__(self): return f"Fred({self.x})"
    def __and__(self, other): return Fred(self.x + other.x)
    def __iand__(self, other): return NotImplemented
a = Fred(1); print(a & a); a &= a; print(a)
The output is Fred(2) for both prints. So returning NotImplemented from __iand__ won't necessarily make a &= a fail, since it will go on to test whether __and__ exists
13:44
Huh, that's kinda weird
Well, if all else fails you can just raise TypeError
I'm perusing the docs to see if there's a reccommended way to block iand specifically... docs.python.org/3/reference/datamodel.html#id10 says that setting a dunder to None will explicitly block fallbacks for operator lookups. But it's not really recommending you do it, it's just saying that's what will happen.
"don't cut your finger unless you want to be taken to the hospital" is not a best-practice recommendation for getting to the hospital. Maybe try Uber first.
You probably gave this way more thought than the core devs.
@ParitoshSingh alternatively: l1 is l2
If I'm going to overthink about something, overthinking the data model is a perennial favorite of mine
14:07
@AndrasDeak very much so, thank you. I've gone back to our company Slack and IT is telling me that all the Intel chipsets are basically sold-up :/
14:32
If your finger keeps slipping and hitting the Enter key, try composing your message in Notepad :-)
what can i do, if i needed both the library: but as one is active the other doesnt work.
from datetime import datetime, timedelta
import datetime
@discoMonkey rename one of them
import datetime as dt
I'd use dt.datetime though
@AndrasDeak: thank you for quick reply, could you please elaborate why it doesnt work "normally", thanks in advance
It works normally
For the same reason that a = 1; a = "foobar"; print(a.find('o')); print(a+1) can't simultaneously treat a like a string and an integer
14:42
@Kevin docs.djangoproject.com/en/3.2/topics/db/queries/… You misunderstood me, it's not that += didn't work and + did. It's that + wasn't even implemented, it's & and &= also worked
So, as I understood, in python, a class or module can be stored in variable? @Kevin
Effectively yes
@Hakaishin ah
Sometimes I really wonder how tired I was on a given day. for foo, bar in zip(foos, bars): and then proceed to never even use foo.... Like wut :D
@Hakaishin So & is implemented and &= is implemented and + isn't implemented and += isn't implemented? I guess that's sensible
14:46
And looking at the git log tells me that earlier there was only for foo in foos: And instead of realizing it should be for bar in bars: now I just packed it together and proceed to only use what I need :D
@Kevin correct
I think my biggest misunderstanding was assuming that Q wasn't the real name of a real type
"I guess Hakaishin edited out the actual name because it was really long or something?"
You had too much faith in library maintainers giving their classes sensible names
"Q? That can't be a real class, nobody would give a class a single-letter name"
If they were trying to be conveniently short a la jQuery's $() callable, I'd understand. I wouldn't forgive them, but I would understand.
15:02
haha, yeah that's how I reacted too upon learning about that feature. well it comes from QuerySet, but yeah it's not the 80s anymore
Also C++ why do you have to whip me so much :(((( min(vector) no candidate funtion :( I have to use min_element(a.begin(), a.end()) just to find a simple min :( like cmon
ah yes, thank you. Cannot convert '__gnu_cxx::__normal_iterator<double *, std::vector<double>>' to 'int' without a conversion operator.
Want me to move that ranting over to one of the C++ rooms? :P
sure, I forgot a * :D
dang it
Speaking of doubles and ints, I find it ironic that python can have arbitrarily large ints, but if you need a number that's larger than any possible int, you need to use a float (math.inf)
One of many reasons why type safety is but a pipe dream in python
infinity is the bubble under the wallpaper that we can push around but we can't get rid of
15:15
Has someone tried poking infinity with a needle?
it gobbled the needle up
well it's not gonna result it what you hope for :P
I tried poking it with an infinitely long needle, but the pressure wave can only travel the speed of light, so it hasn't reached the wallpaper yet
@Kevin (even worse: speed of sound)
Eurgh. I'll just round up to c to keep the math easy.
15:24
just call the speed of sound c
just set it to 1
c looks like an ear so it is ideal for sound-related constants
the speed of light should look like a light beam, so we're restricted to straight lines only. lower case L, upper case sans-serif I, underscore, hyphen, they're all good choices
And any of the Unicode ripoffs of these, such as em dashes and the like
so it's V^2 / /^2 beautiful
KevinScript does not have a number that is larger than every other number, but it does have the set that contains all sets that do not contain themselves
15:39
I'm missing the searchterm for fake_file. How can I create a file to be able to let the user download it without having to write to disk? Something io right?
fake_file = StringIO(json_data)
return FileResponse(fake_file)
from io import StringIO (or BytesIO)
but the library you're using has to support it, it doesn't always work
perhaps the non-working cases are only when a file path is expected rather than a file handle, not sure
ah I see
considering web stuff you probably need a BytesIO
I'm pretty sure I don't understand the question, but I'll leave this here anyway docs.python.org/3/library/tempfile.html
15:58
ini_time_for_now = datetime.now()
past_date_before_2yrs = ini_time_for_now - \
                                     timedelta(days = 730)
why use the backslash '\'
That's a line continuation. It tells the interpreter that the current statement continues on the next line.
for what its worth, dont write it that way :P its rare to use the backslash like that
You can also put parentheses around the expression, and it will automatically ignore newlines within the expression
past_date_before_2yrs = (ini_time_for_now -
                                     timedelta(days = 730))
I believe the Python style guide recommends parentheses over line continuations
Explicit line continuations have their place, and that place is in shell scripts and makefiles.
3
16:18
@Kevin unfortunate that that is not Pycharms default behaviour. @discoMonkey You probably see it because that's what Pycharm does when you type over the edge of the screen/ruler
it does it for you automatically?
yeah, depends on your settings
must be some crappy autoformatter then. if it can be changed out, maybe try black instead
Nah, it happens every 1000 lines or so, I just revert it and we good to go
16:40
Corporate red tape website instructions: "welcome to our portal. Your username is your first+last initials plus your SSN..."
Me: "That's a security risk. User names should not contain private personal information. But I have no choice, so continue."
Corporate red tape website instructions: "... But if the SSN has leading zeroes, omit them"
Me: "... So you're probably storing it as an integer, then. Cool."
Error while finding module specification for 'asdf.__main__' (AttributeError: partially initialized module 'asdf' has no attribute 'routes' (most likely due to a circular import))
I do not get it ...
I'm glad my phone number doesn't have leading zeroes or it would probably refuse to parse it
ah I do get it :P
"You entered: 055-5555. That is only six digits. Please enter seven digits."
why __main__.py doesn't work!?!?!?!? WHYYY
anyone can explain to meeeeee
16:46
context/mcve?
some python idiocy again
Ooh, I'm on the lookout for ways to trigger circular import errors. If you do happen to construct an mcve, please share
this doesn't have mcve :d
because
I do not have time to mcve it ...
@AnttiHaapala ask a question, say it's urgent
it has something to do with the parent module (empty init) being not there and ... yet being there or sth...
@AndrasDeak good one
16:59
I support every querent's inalienable right to say "I won't make an MCVE", for any reason or no reason. This is America, after all.
Likewise I support my own right to put 0% effort towards solving a querent's problem. Such beautiful freedom, my eagle is crying
but, this is not america kevin :(
:-P
though im sorry for your eagle. show it some white stars in some kind of blue white and red background to cheer it up, preferably with some explosions in the distance as well
iana.org/whois?q=chat.stackoverflow.com says that the site's owner, VeriSign Global Registry Services, is based in Virginia. As American as apple pie.
thats some dedication, i guess it is america after all! brings out gun and cowboy hat I'm ready now.
17:11
tools.keycdn.com/geo?host=198.252.206.29 says that their IP has a geographical location of 37.751 (lat) / -97.822 (long), which corresponds to the center of Cheney Reservoir, Cheney State Park, Kansas. Interesting location for a data center, but I suppose it's good security against ground-based forces.
17:26
western us state lines are so funny
also it's so hard to grasp the size, compared to switzerland it's so huge. And every state is larger in size and population then the whole of switzerland
17:45
I'm amused by the mental image of early settlers being like "how wide do you think the continent is? Probably like 500 miles, right?" and choosing state boundaries so they'd have 50ish by the time they got to the Pacific Ocean. Then as they continue exploring west, and keep not finding the ocean, they'd gradually allocate more area per state to compensate
I doubt that's historically accurate, but my flights of fancy rarely are
My high school history teacher said that the Treaty of Tordesillas may have been intended to divide South America roughly in half, but they undershot the longitude so it's more like 90-10. That theory might not have any academic basis though
Or maybe it's the other way around -- they wanted to grant only a tiny sliver of the east coast to Portugal, but they didn't know that Brazil protrudes eastward as far as it does. Portugal might have known, but they were keeping quiet about it.
18:31
guys I'm working on making a virtual assistant using Python using pyttsx3, speech_recognition, datetime, wikipedia, webbrowser and os... However, the code shows error whenever I try to run it, showing that speech_recognition isn't installed... Can anybody help?
BTW I'm Aizen... Sorry for the interruption :)
And you're sure speech_recognition is installed?
Andras swiftly counterspells my trap card :(
it stops being amusing after the dozenth time someone falls in it :P
at least this time it's not a 20-minute-old question on the main site
19:39
Hi
Someone can make chatbot for Stack exchange chat room in Python?
@AndrasDeak can you?
19:49
Someone here knows streamlit?
Vaguely. It might be a React question at its heart, but shoot
I want to turn the above to python GUI code
so I thought using streamlit
So you want a dropdown. How is that something we can answer?
I can give you the HTML for it but that's probably not going to help you
basically its dropdown which is the output from the command cd ~/views/Main;git branch -a
with some trims
and also has a filter fiels
the question is if I can do it in some python GUI
The answer to that is "yes"
20:01
and streamlit is the right direction?
Well, I'd always argue Flask but there's a lot of history behind that, some of which relates to the platform I'm forced to work in
Are you asking us to recommend you a GUI toolkit?
In any case, all you need is the backend to get the git branches. Once you have that, you can do whatever you want for a frontend
Terminlology debate: if a web server is written in Python, is a web browser pointed at that webpage a "python GUI"?
Yes, if it's rendered by jinja2
20:07
:thinking emoji:
if it just sends JSON payloads to React, no
I believe STREAMLIT might be helpful here. It's just new for me :)
I'm waiting for crispy duck to arrive from my takeaway, so my philosophy compass could be off. I'm hungry
Well, streamlit can do what you want. But you can easily get boxed into a corner
 
1 hour later…
21:38
how can I "await" a simple callback function? :D
I nominate threading
@Kevin nope, something like this:
    async def trigger_event(self, event, args):
        sid, data = args

        f = Future()
        await clients[sid].emit(
            event,
            args,
            callback=lambda args: f.set_result(args)
        )
        return await f
21:54
A bit outside of my skillset, sorry. But I'll think positive thoughts for you.
22:08
If I understand correctly, that code already solves the problem? Not entirely sure what the issue is
I also thought the code looked fine. I assumed the question was "now how do I define Client.emit() so that it does what I want?"
22:22
nothing about return await f looks fine to my eyes :P
Ok, then I definitely don't know what the goal is
PEP 492 confirms that return await coro() is valid, if anyone else wasn't sure
You mean await Future()?
await awaitable just about covers it, I reckon
22:42
Can't argue with that. But return await coro() is only valid if coro is a coroutine function, not a coroutine
I agree with you for certain definitions of "coroutine"
Maybe even the definition that I like the best. (not that I know which one that is)
docs.python.org/3/library/asyncio-task.html#awaitables gives definitions that match my expectations,
a coroutine function: an async def function;
a coroutine object: an object returned by calling a coroutine function.
That's a bit weird. In "generator function" I kind of think of the function as something that generates... a generator.
So if you have async def foo(): ... and you have bar = foo(), then I'd expect return await foo() to work, and return await bar() to fail
return await foo also fails, but it doesn't match the syntax I'm nitpicking, so I will ignore it
return await coro() seems like you meant return await bar()
coro is short for coroutine function ;)
22:52
Yeah, I can see the ambiguity. I blame the PEP 492 authors.
Don't shoot the messenger, I have more than enough self-inflicted foot shootings already
There's also some weirdness in there where they say "Future" when I think they should say "awaitable", but I won't harp on that because there's a good chance I'm simply wrong
Speaking of footguns, I caught up with the present concerning a webcomic published on gocomics. For a brief moment I thought I would have to write an RSSificator for gocomics too, but some blessed soul has done that already.
Oh, nice. I must peruse this list to see if there are any works I dropped specifically because they didn't have RSS.
to be clear it's specifically for gocomics.com
Acknowledged. Newspaper syndicated stuff, largely.
it would seem so
23:05
Garfield and Peanuts rather than Achewood and Kill Six Billion Demons. Although I spot Bad Machinery in there, which is aesthetically quite webcomiclike. I guess he tricked the guys at the syndicate by telling one continuous narrative for the last 20 years.
He almost wrote a story not taking place in the Shelly Wintersverse when he started Steeple, but then she showed up in chapter 6 or so
23:21
Y'all got a RSS feed reader you can recommend me?
I use liferea, it's "OK"
but I have very basic needs
It's linux-only? I'm on Windows right now :(
the name is short for "linux feed reader", so...
Hmm, this doesn't seem to be a particularly convenient way to read comics...
no, I use it to see updates and click through to each
23:29
Looks like "write a comic reader" will remain on my to-do list for a while longer
Sounds like a bit of a challenge, with the infinite ways that comics can be laid out
I managed to write reasonably robust code for that 10 years ago, so how hard can it be?
Besides, I'm planning to write specialized parsers for specific websites
This download I'm waiting for has been sitting at 100% for about half an hour now. I'd appreciate if it could actually finish sometime soon so that I can go to sleep :|

« first day (4050 days earlier)      last day (1122 days later) »