« first day (3482 days earlier)      last day (1473 days later) » 

12:46 AM
I don't mean to start a war, but what column width do you guys enforce your line length to?
 
wim
whatever black's default is
 
wim
that sounds right
 
ok cool
do you bother manually wrapping the long lines that black doesn't wrap itself?
like long strings
 
wim
no
 
1:03 AM
ok
thank you for your answers
 
1:21 AM
Bytes object has no attribute encode?
Sending e-mails worked in Python 2 but in Python 3 this is an issue driving me and everyone else nuts
And it's coming from somewhere in here: pastebin.com/X8eAGZQP
 
In general, you encode to bytes and decode from bytes. That might help?
So a byte object has already been encoded, you might want to decode it instead.
 
@jigglypuff csv is a bytes object because it's in the format b'...'
But that's about as far as I got
This line seems to be causing it:
	record.add_header('Medicare-metadata', 'attachment',
                  filename=os.path.basename(csv))
I removed that line and it's working now
Now here's the second and last problem:message = service.users().messages().send(userId=user_id, body=message).execute() throws the An error occurred: Object of type bytes is not JSON serializable exception...
but message is {'raw': base64.urlsafe_b64encode(message.as_bytes())}
Oh
It's because I passed message.as_bytes, but when I try message.as_string(), I get: TypeError: a bytes-like object is required, not 'str'
I am truly, terribly lost
It wants bytes, but when I give it bytes, it's not serializable
 
1:52 AM
hmm sorry can't help you, but maybe this page will give you some pointers: docs.python.org/3.3/library/pickle.html
 
2:11 AM
Lol
Is MIMEMultipart and MIMEBase outdated??
 
2:34 AM
@jigglypuff It worked!
    	# Return the message
	raw = base64.urlsafe_b64encode(message.as_bytes())
	raw = raw.decode()
	return {'raw': raw}
 
 
2 hours later…
5:01 AM
cbg
 
5:29 AM
@wim I abused my hammer to clear 2 cvs that the "ordered set" had, yet again, got...
 
Post Closed as "Duplicate" by Ken Kinder, larsks, Antti Haapala python of

Does Python have an ordered set?
who are these guys anyway?
 
@AnttiHaapala They're probably people reading old 2.x books/tutorials/blogs, uploaded PDFs etc. The same people who don't know not to call lists 'arrays'
 
one is 150k engineer at redhat :P
their close reason wasn't that, they had closed as "too broad"
 
outdated engineer :D
 
6:01 AM
Which plotting package does anyone use, for squarified treemaps? seaborn/matplotlib + squarify vs plotly Treemap vs Altair/Vega vs Pygal Treemap vs Bokeh. Pygal: nice but doesn't seem to have traction for interactive use, but has some for generating SVG for publication.
 
there is also holoviz
 
6:37 AM
I just launched IntelliJ for the first time in months... it took so long to even display the splash screen that I was convinced something went wrong and it didn't start at all >.<
IntelliJ: slow as yam
VSCode: broken as yam
next on the list: ???
 
Vim ;)
 
I think that has a bit too much of a learning curve for me :/
 
Also it's not an IDE, so I was kind of joking :P
Kind of... (join us!)
 
I've now installed 5 updates and restarted IntelliJ 3 times... this almost feels like booting up Windows after a long time of using linux
 
Gah, this is not something I wanted to hear. Just installed IntelliJ, because I need to do some Java.
 
6:54 AM
glad I don't have to suffer alone ;)
 
7:04 AM
@Arne Thanks. But which one do people use, or do you recommend? It seems to fragment: straight data science people use matplotlib/seaborn, JS/dynamic website types use plotly (if they don't mind the freemium/cloud subscription model, Tableau alternative) or else Vega/Altair, people who want to write complicated interactive stuff use bokeh... can't see why Pygal was created
 
our datascience people use holoviz/panel, because it offers notebook integration and comes with a good toolbox
 
FYI a useful reference: The Python Graph Gallery
 
I can't give much more details, because I'm actually not a datascience person any more
 
@Arne Generic perspective is welcome, also from web people
 
my naive perspective is that notebooks really lend themselves to create & document datasets that are used for an analysis, so using panel to build the plots right out of them (and the option to turn them into html with sphinx, which it supports out of the box) closed the whole discussion for me.
the only thing I didn't like was that setting it up without conda is a pain, but that shouldn't be much of a problem for you or any of the guys closely working with data, since it's standard there
 
7:31 AM
Cabbage fellas
 
cbg
 
superb google extension
just discovered it
I dont own or am part of the dev team of this but this thing looks like a good idea
its free for now.. at least thats what is on the site. Not sure its worth paying for the additional services.
 
Hi everyone
Can I ask a question related to data science?
 
when you break does that immediately move to return the function?
 
7:52 AM
Yes @Permian
 
thanks @RaphX
@RaphX yes
 
break exits the loop, nothing more
 
@Aran-Fey thanks
 
This was a question related to a course I was doing to solidify my theoretical understanding of basic ML concepts
Initially I had chosen options 1,2,3 and 5 as the answer but it was marked wrong
Then I chose the current configuration which was marked wrong as well
What do you think would have been the correct sequence and why?
 
5 might be wrong
 
8:01 AM
Why?@Permian
 
because my gut feel was 123
the only one that is definitley wrong is 4
i would have said 1,2,3,5
and i checked this on google
weird
 
You got the answer as 1, 2, 3,5 on google?@Permian
 
i googled what data does (un)supervised learning need?
email the course leader and tell him/her its wrong
actually
4 could be right as well if you use knn as regression and not classification
 
How? Wouldn't it still require some labelled points?(for 4)
 
not for training
i think that this question is crap btw
 
user12867493
8:17 AM
@tripleee Can you help me please?
 
user12867493
I am trying to convert .py to an executable, but whatever program I try it doesn't work
 
no need to ping me, just ask and see if the room can answer
 
user12867493
Ok
 
I don't have any experience with py2exe and friends, but others here probably do
but they will need more details, what did you do and how did it fail?
 
user12867493
Can someone help me? I am trying to convert .py to an executable, but whatever program I try it doesn't work
 
user12867493
8:19 AM
Tried both pyinstaller and py2app
 
on Windows?
 
user12867493
On macOS
 
user12867493
Neither of the executables work
 
and how did they fail?
 
user12867493
pyinstaller executable gives me:
 
user12867493
8:20 AM
> [53601] Error loading Python lib '/Users/dmanokhin/Desktop/Books/Program/build/SpringerML/Python': dlopen: dlopen(/Users/dmanokhin/Desktop/Books/Program/build/SpringerML/Python, 10): image not found

> [Process completed]
 
user12867493
And nothing is done, i.e. the program is not run
 
why does it think the python library should exist in that location? Did you put something in a configuration file, command-line argument, or environment variable, or perhaps run this in a virtual environment which was incorrect or funky?
the argument to dlopen should generally be a dylib file
 
user12867493
The python file uses the current working directory if that makes a difference
 
user12867493
And py2app creates an app but says there is an eror
 
you need to supply is with the full error message, not vague rumors
 
user12867493
8:31 AM
 
user12867493
That's the console error log which keeps printing messages
 
images of text are always a bad idea
without access to the code which produces those messages, we have no idea what they mean
 
user12867493
default 09:33:12.214013+0100 hidd [HID] [MT] dispatchEvent Dispatching event with 3 children, _eventMask=0x0 _childEventMask=0x222 Cancel=0 Touching=1 inRange=1
default 09:33:12.389842+0100 bluetoothd Advert timer expired for client 12 after 2.00 seconds
default 09:33:12.390779+0100 identityservicesd Continuity update advertising with data: advertising request of type 12, priority 4, UseFG 290 (181.25 ms), data {length = 14, bytes = 0x082d300ad6379a10a64211606458}, connectable 1, addr change 1, options {
 
try to reduce this to a minimal reproducible example
 
user12867493
I can send you a link to the GitHub code if it will help?
 
I don't think you can get anybody here to do that work for you; remove stuff until only the error remains, then come back here
 
I don't see a problem with the code
 
user12867493
@Aran-Fey The code works fine running in Python
 
user12867493
Converting to an executable doesn't work
 
user12867493
Maybe I'll try on my Windows PC instead
 
8:42 AM
The executable doesn't work, or converting to an executable doesn't work?
 
user12867493
@Aran-Fey Well I converted it, it doesn't run:
 
user12867493
 
user12867493
It managed to convert
 
user12867493
 
is there a reason why you need it converted in the first place? Python is widely available on MacOS, especially for people doing ML
 
user12867493
8:45 AM
@MisterMiyagi Not really much of a reason, just wanted to try to convert it
 
user12867493
I'll try on Windows then I guess
 
guys how do you clear the form input fields after send_file ?
there's a way to do this in python or javascript is required ?
 
user12867493
@AnotherUser31 I think you need js
 
@Daniil mind helping me ?
 
user12867493
@AnotherUser31 Don't know much js, but I can try
 
8:52 AM
@RaphX Q4 is ambiguous whether "KNN works by..." refers to training, prediction or both. But training requires at least a few labeled points. Seems badly-worded. Why not just click the possibilities until you find out what their "right" answer was, then complain to the teacher.
 
<form class="input-group input-group-lg" id="myForm" method="POST">
<div class="copy-container">
<div class="copy-target">
<div class="form-group">
<input type="text" name="old" class="form-control" id="field-name" placeholder="Old Code">
</div>
<span>&nbsp;</span>
<div class="form-group">
<input type="text" name="new" class="form-control" id="field-value" placeholder="New Code">
</div>
<span>&nbsp;</span>
<button id="removeButton" data-role="remove" class="btn btn-danger">
<i class="fas fa-minus fa-1x"></i>
@Daniil that's my html form
 
user12867493
Add this to button: onclick="ClearFields();"
 
but that would clear the fields and the python script won't work :(
i tried that
 
user12867493
function ClearFields() {

document.getElementById("field-name").value = "";
document.getElementById("field-value").value = "";
}
 
user12867493
Add that js ^
 
8:59 AM
@wim Nice answer, and ty for the ping! TIL
 
@Daniil that clears my form before executing the python script :((
 
user12867493
@AnotherUser31 How about storing the value of the fields in two variables, clearing the form and using those variables for the python script?
 
@Daniil sounds like that would work...thing is no idea how to do that...
 
user12867493
thinking
 
would appreciate your help with this !
 
user12867493
9:14 AM
Sorry not sure
 
user12867493
I can take a look later if you want, maybe in a couple of hours?
 
user12867493
Quite busy with something right now
 
sure, no problem....can you write me in private please if tou find something ?
i was thinking...maybe save the form data to a json file...and run the script based on that json file...
no clue if that would help...
 
user12867493
@AnotherUser31 how do you want me to write 'in private'? By email?
 
user12867493
ok
 
9:17 AM
thank you !
don't know if i'm allowed to send here my mail...sorry in advance
 
user12867493
@AnotherUser31 No, it's ok
 
user12867493
You're allowed
 
alright, thank you very much ! spasibo !
 
user12867493
@AnotherUser31 you're welcome
 
12:07 PM
hey when Im stuck with my code I post on stackoverflow and get an solution to my problem nearly immediately, how to learn from that answer they most ?, Im struggling with implementing my own solution when it takes a little bit longer, and there is an easy solution --> Stackoverflow to that , have you guys the same probem ?
 
Erm, do you understand the solutions given to your problems?
 
yes I try to break them down to understand them
 
Well, that's basically all you can do outside of solving the problems yourself.
 
 
3 hours later…
3:06 PM
Hi
Can somebody tell me how do I compile a python file to .py so that it doesn't need installing modules? I wanna run it cross platform
Without installing modules there
and I don't need an exec
 
If by "I don't need an exec" you mean "I don't want to compile it to a .exe", then I think you're out of options
 
Aww
i am sad
Like why?
there must be a way
 
"cross platform" and "doesn't need installing modules" are two different pairs of shoes
and very hard to put on both at the same time
unless you are willing to pack all modules for all platforms
 
3:56 PM
when i have a instance of a class and want to use a method of that class why do I need to use self infront of the method self.method instead of method(self) ?
 
'cause that's how python works
I'm guessing the design decision has something to do with "explicit is better than implicit"
 
Hey guys.
 
Given a numpy array [0, 1, 2, 3] how can I turn this into [[0, 1], [1, 2], [2, 3], [3, 0]] efficiently?
 
method names are not accessible by direct name access because names bound in the class body scope are not visible in child scopes
 
Do you thinking appending too frequently to a txt file (as a log) should be avoided? I'm talking like 1000 times a sec. Is it bad for HDD?
 
4:05 PM
I acknowledge that this is not a useful explanation
 
@DominikSchmidt I'd just copy it, if it's not huge
>>> arr = np.arange(4)
... np.stack([arr, np.roll(arr, -1)], -1)
array([[0, 1],
       [1, 2],
       [2, 3],
       [3, 0]])
 
user12867493
Can someone help me with my pygame install please on macOS?
 
user12867493
I ran:
 
user12867493
 
user12867493
It gives me:
 
user12867493
4:20 PM
> ERROR: Command errored out with exit status 1:
 
user12867493
I tried this but it didn't work: stackoverflow.com/questions/22974339/…
 
@AndrasDeak Thanks!!
 
Language-agnostic Q. I see some datetimes in my database that correspond to September through December of 2456. Is there some kind of Unix epoch or something that corresponds to that timeframe?
 
@Daniil Why not just pip3 install pygame?
 
user12867493
@Aran-Fey Same error
 
user12867493
4:23 PM
The fix here doesn't work as well: github.com/psycopg/psycopg2/issues/903
 
user12867493
Homebrew can't find pygame
 
@Milad see this
 
I have a (10, 10) numpy array A and an index array B=[[1, 5], [7, 8]]. How can I get the array [A[1, 5], A[7, 8]] efficiently?
 
user12867493
Managed to fix it
 
user12867493
For anyone with a similar issue:
 
4:35 PM
It's not really a python problem but there may be a python solution to your underlying application. Are you really repeatedly opening the file to append single records, @Milad? Could the writes perhaps be batched? That said, I have used Splunk in the past to navigate logs that are being written to at similar frequencies
 
user12867493
pip install pygame==2.0.0.dev6
 
The logging docs don't seem so hot on this. They mention BufferingFormatter once in the docs and the SO Answer on it is... brief
 
@Kevin no idea. Are these encoded as a single large integer? Do you know how they get decoded on windows? I only know that the standard epoch is "seconds since the world started in 1970.01.01" but you must know that too
 
@roganjosh thanks
 
The Unix timestamp for that year is 15336709200ish, which doesn't look significant at all to me. Nor its binary representation, 0b1110010010001000111001110001010000.
 
4:45 PM
Taking a step back: is your question whether these are the result of some wrong encoding? Or is the question whether those correct dates correspond to something interesting?
 
I was hoping for some arcane knowledge to pop up, like "Oracle on Windows uses the Julian timestamp, which happens to translate 2456 into 0xFFFF"
 
@DominikSchmidt A[tuple(np.array(B).T)] if B is really a list and not an array
 
@AndrasDeak If I understand your meaning, I'm asking both at the same time. "could this date be the result of a meaningful date that got mangled into a future date via improper encoding?" and "could this date be the accurate representation of a date that was set by code faithfully executing some wrong-headed business logic?"
 
hello guys , just want to ask lets suppose i have jupyter notebook , and i have variables nameing from c1 to c100 . and i want keep c90 rest i need to clear . what should be the code for . i know i need to use del c11 and so on many times , is that a way i can keep only like del !=c90 . i am just make it up ..
 
An example of an answer to the latter might be "perhaps the column was set to the C# value DateTime.MaxValue, which happens to be December 20th 2456, for complicated reasons"
 
4:49 PM
@DominikSchmidt first the index array is turned into [[1, 7], [5,8]], then it's converted to the tuple ([1,7], [5,8]) which when fed into the indexing expression you get A[[1,7], [5,8]] which triggers advanced indexing to do what you need
@Kevin OK, yeah
 
(In actuality DateTime.MaxValue is December 31 9999, so that explanation is a bust, but that's the shape of the answer I'm looking for)
 
@NabiShaikh do you really need 100 variables with such names or are you just falling into the variable number of variables trap?
 
@Kevin with a little <-> big endian flip I get 1991
>>> datetime.fromtimestamp(15336709200)
datetime.datetime(2456, 1, 1, 6, 0)

>>> datetime.fromtimestamp(int(bin(15336709200)[:1:-1], 2))
datetime.datetime(1991, 9, 30, 12, 57, 27)
Only thing I can think of
 
@roganjosh i am trying to make an example , just like in R we do rm(set diff variable names) . similarly can we have in python .
 
@AndrasDeak Hmm, that's worth investigating, thanks
 
4:54 PM
But then I'd expect them to scatter more...
 
Even if it doesn't pan out I'm happy nobody replied in 30 seconds with "you fool, that's the famous y2456 bug" so at least I'm not missing an obvious answer
 
@AndrasDeak That's reversing the bits, not the bytes
 
I'd rather hunt down mystery bugs all day than have a reputation for a foggy crystal ball
 
Including a new PEG parser that could clear the way for some syntax/AST improvements.
 
5:00 PM
> String methods to remove prefixes and suffixes
^ that's like 20 years overdue
 
@Aran-Fey good point
I guess reversing the endianness would blow things up
>>> np.array([15336709200]).view('<i8')
array([15336709200])

>>> np.array([15336709200]).view('>i8')
array([5808556729423626240])
 
user12867493
5:16 PM
Can someone help with pygame please?
 
user12867493
How can I change the colour of an already created object?
 
@Daniil please read our formatting guide and practice in the sandbox if necessary
 
user12867493
class Square(pygame.sprite.Sprite):
    def __init__(self):
        super(Square, self).__init__()
        self.surf = pygame.Surface((25, 25))
        self.surf.fill((0, 200, 255))
        self.rect = self.surf.get_rect()
 
user12867493
Initially, I create the square using:
 
user12867493
square1 = Square()
 
user12867493
5:20 PM
screen.blit(square1.surf, (40, 40))
 
user12867493
screen.blit(square1.surface, (250, 200, 255))
pygame.display.flip()
 
user12867493
How can I change it, something like the above?
 
5:40 PM
I have a flask application that has templates folder that stores all the html templates for different app.route() , but when I start the server all the pages inside templates folder show up on the first page, one below other, what should be causing the issue?
 
6:16 PM
@Daniil call square1.surf.fill(whatever) and blit it again
 
@AshwinPhadke did you use {% include %} in one of your templates that lists all the other templates in the folder?
 
6:50 PM
In today's installment of me appreciating random things late at night: Boy do I miss Christopher Hitchens and listening to his mastery of the english language
 
@Aran-Fey "I'll finish my sentence even if it kills you" :P
 
hahaha, yeah that's a good one
 
I think I've exhausted every interview and debate he has on YouTube. Such a shame he's not around for commentary these days. A good few Hitchslaps wouldn't go amiss :)
 
I have to admit I don't have the patience to sit through a whole debate. I just watch the good bits
That also spares me from having to hear word salad like Deepak Choprah's
 
I used to put them on while cleaning the kitchen etc. so managed to chug my way through them all over about a year or so. But yeah, there were some word salads from several of his opponents
 
7:12 PM
Do you remember any interesting debates or arguments? Not that I think anything will manage to make me religious, but I can at least give them a fair chance
 
7:29 PM
@Aran-Fey most of them are pretty similar. There is a longer one that he did with Stephen Fry on his team but that was more monologues than to-and-fo (though they do get to respond)
 
alright, thanks
 
The full version is here
 
is py command is not defined by default within Ubuntu ?
 
py is the python launcher for Windows. It's not a thing on linux/mac
@roganjosh Oof, 2 hours. I'll save that for tomorrow
 
@Aran-Fey Yeah, I don't want to be blamed for sidetracking you again :P It's definitely one for when you're doing the chores but I do appreciate listening to educated people debate :)
 
7:41 PM
@Aran-Fey ah ok thank you. i thought it a shortcut launcher for all OS.
@Aran-Fey :D if you can add the white theme to your site, that's will be helpful :P
 
I'll try
 
@wim ex...explain
 
ordered sets?
 
wim
methane is coredev. you will note it's a PR to their own fork
my guess is a proof-of-concept for benchmarking..
 
Ah, for some reason I thought I was looking at dict
 
wim
8:30 PM
@davidism A more cynical take on PEP 617: assignment expressions were such a bad idea that they had to rewrite the parser 😅
 
9:18 PM
Hello, I'm really struggling with a bit of code but my post got downvoted and I understand this means it disappears from the front page. I'm hoping I can get some help here.
Link: https://stackoverflow.com/questions/61489449/button-function-pause-strangely-when-opening-another-window
 
while using uuid, how should I verify the user entered string is in correct form of UUID.
`uuid.UUID(string)` fails with **badly formed hexadecimal UUID string**
Don't mind guys. I had an extra space at the end
 
9:58 PM
@neferpitou - even if something fails, you can usually perform the problem command inside a try-except and catch the exception. As in:
try:
    valid_uuid = uuid.UUID(string)
except ValueError:
    print(repr(string), "wasn't a very good UUID")
 
wim
actually kind of surprising that doesn't eat whitespace like int etc would do
 
10:18 PM
^^ different dev
 
@PaulMcG thanks. I included it after that error.
 

« first day (3482 days earlier)      last day (1473 days later) »