« first day (2501 days earlier)      last day (2440 days later) » 
03:00 - 17:0017:00 - 00:00

5:00 PM
Yep, py2 errors were so cryptic at times. Py3 is beautifully helpful, either by erring properly and showing what's actually wrong or by not erring / handling things the correct way.
 
Could someone please help me to use this socket?
I am trying to send a file from a server to the client (actually only localhost, windows 10 64 bytes python 3.6).
My script work with small files, like 6 kb. But if I send biggers file, like 200 kb the files are biggers than the original ones... and if I send files bigger even, like 600 kb or 1 mb my script doesn't work. It get stuck (the client recieve a slice of 4085 bytes instead of 4086 and the server try to send it again, and again, and again.... and doesn't stop...). What can I do?
 
Current eclipse status:
 
DSM
Neat! Sun is still comfortably round from here. :-)
 
The eclipse can only be saw in the north side of the planet, right?
 
5:16 PM
@EnderLook It will be partially visible from parts of South America, but otherwise yes.
 
cbg
get your dragonglass ready everyone
it's happening
 
DSM
Peak in LargeCanadianCity isn't for an hour or so.
 
yeah same here
 
Sh*t, Jon Snow isn't back with his mined stash yet.
 
the eclipse is going to bring an army of walkers among us
 
5:21 PM
Portal to the world beyond
 
user image
4
No GoT spoilers!
 
LOL
@Code-Apprentice My comment was a play on the eclipse today
 
References are appreciated
 
@Code-Apprentice My bad, that was unintentional. Although, not much of a spoiler :-p
 
5:32 PM
just wait until you find out this is all in the harry potter universe.
 
@EnderLook You're making it needlessly complicated by splitting the file into "lines". Just keep track of how many bytes you've sent/received and only send the part that's left. I'll send you a proper implementation after I've cooked and eaten dinner.
 
DSM
#westphall
 
For those unfortunate souls like me - Watch eclipse live (Nasa)
 
DSM
Hmm. Breakfast, or jump right to lunch..
 
brunch!
 
5:40 PM
I'm disappointed in Py2.7: subprocess doesn't support unicode on windows but does on Ubuntu.
 
Welcome to Python3 ;)
 
Hmrph, how do I make my Meta post sound less like a rant (which it is), and more like an actual question...
 
Yeah, gonna have to port to 3 it looks like
 
friends
wait
enjoy and you're welcome
 
heh. I've seen that one on Facebook I think
 
5:43 PM
@vaultah is there anything we can do to consolidate disagreeing hammers? How should hammer disagreements be resolved?
 
@AndrasDeak The thunderdome
 
I have a feeling that Python dupes were being reopened too quickly in the past few weeks, but the data doesn't really support it
 
well if Shog has any say in it, the data doesn't support anything :P
 
The plot thickens: if I pass a unicode string, subprocess complains. If I pass a normal string with unicode in it... it works? what?
 
@vaultah Try to get the person who hammered to come here and discuss it. IMHO, it's not good for the gold badgers to argue in front of the newbies.
 
5:49 PM
@PM2Ring newbies are not on meta
 
It would be cool to have something to link gold badgers to
 
@TemporalWolf A normal Python 2 string with Unicode in it (i.e., one without the u prefix) actually contains the encoded version.
 
Joe
Hi I have a question
 
@AndrasDeak Well, sure. But I think it would be better to resolve stuff like that in a Chat room, and only take it to Meta if it can't be resolved easily.
@Joe Excellent. We may have an answer. ;)
 
Joe
why solar eclipse causes bad wavelengths?
 
5:52 PM
well, we're talking about unhammering dupes without any discussion; that's not pretty nice to begin with
@Joe it imbalances the chakra flow in the higher atmosphere?
 
Joe
what is chakra flow?
 
what is bad wavelength?
 
Joe
UV
 
it doesn't
UV comes from the Sun whether you like it or not
but during an eclipse people are more likely to stare at the Sun
 
Joe
but solar eclipse cause eye damage
 
5:54 PM
because it's easy to be stupid and stare into the sun before/after totality
 
The room should be renamed to PySun for it's current state.
 
you don't see it bright fast enough, so your pupils are dilated, so the UV part of the spectrum damages your retina
but Ashish is right; this has nothing to do with python :P
 
@PM2Ring I mean, if subprocess will take it, I'm happy.
 
Joe
ok thanks
 
@AndrasDeak Suns are welcome this day. *puns :-p
 
6:01 PM
@TemporalWolf Fair enough, but see stackoverflow.com/questions/45783584/…
 
6:19 PM
Now one bad OP can't take away my precious tag wiki edit privilege :-p
 
@EnderLook There, a proper server and client.
 
DSM
LargeCanadianCity is shrouded in cloud-in-front-of-the-Sun darkness..
 
first zombie sighting
 
in the clouds?
flying zombies would make quite a nightmare for some...
 
6:49 PM
So I'm pulling a json dump from an api and scanning it for relevant data. Right now, I'm just using a basic for item in items: if item in response.content: # proceed to filter out responses which do not contain any of the keywords I'm looking for. Any ideas on speeding up the process? the gross majority of the json is irrelevant; I'm picking out like 1000 bytes of 1MB: content is of the format ['buckets':[{'name': 'b1', 'items': [...]}, ...]]
I care about only specific items
The issue I'm encountering is adding more than 2-3 items to search for slows down the parse enough that I start falling behind the api
 
@Rawing Thanks! Now I will read the file to learn about it!
r'D:/users/rawing/desktop/temp {e}/Kappa Dealer.png', what means r?
 
@EnderLook It's a raw string literal. It disables backslash-escapes like \n or \t:
>>> print('\t5')
        5
>>> print(r'\t5')
\t5
 
Ok, thanks
 
It also shows up immediately if you Google python string with r in front.
 
6:58 PM
If I had written that path with backslashes and as a normal string like "D:\users\rawing\desktop", the \r would've turned into a carriage return character
So it's generally a good idea to use raw string literals when you're working with file paths
 
DSM
PSA: you can use forward slashes on Windows as well.
 
and even better, use pathlib
 
@DSM I can use / instead of `\`?
 
CBG, type "this is fine" as a chat message :)
 
DSM
@EnderLook: in most cases, yeah. You can get yourself into trouble mixing separators if you use sep-aware functions, I think (my memory was trained in a pre-pathlib world, so I don't know about the state today.)
 
7:02 PM
Ok, thanks
 
@PM2Ring Created an issue, will submit a PR once I get some time - bugs.python.org/issue31252
 
@Rawing, why server_socketisn't self.server_socket?
 
Kindly add comments if you have any good examples in mind.
 
@AshishNitinPatil Looks good.
 
@EnderLook I considered doing that, but there's no reason to make it an instance attribute. It's only used inside that function after all.
 
7:14 PM
ahh, thanks.
 
Kindly reject edit to stackoverflow.com/questions/45803911/… and / or add tag.
 
while True:
     client_socket, client_addr = server_socket.accept()
     self.send_file(FILE_TO_SEND, client_socket)
     break
@Rawing Why you make a while True if in the first loop you break it? I don't understand that.
 
Oh yeah, I couldn't figure out how to kill the server on Windows, hence the break.
 
I mash ctrl+c and ctrl+z like a madman, nothing happens. *curses windows terminal*
 
7:21 PM
curses, terminal...it checks out
 
@Rawing Submitted a meta for this
1
Q: Posts timeline - "closed" as duplicate action should show target in comments

Ashish Nitin PatilInspired by Rawing, as the question states, current comment just states "duplicate". For e.g. check this timeline (shown below), the 2nd from bottom row is for a dupe-closed action (hammered). We should have the dupe target included here so that there is appropriate and easy(?) history.

 
@AshishNitinPatil Neat. It would make more sense to show that info in the timeline instead of as a revision IMO.
Heck, the question doesn't even have a clickable "edited at [time]" link even though it has 3 "revisions"
 
You should make that comment on the question too.
 
well edits are explicitly in the revision history
OK, so are the dupe targets stackoverflow.com/posts/45797001/revisions
 
if not buf:
    break
@Rawing That means if buf is "empty"?
 
7:32 PM
yes
 
Thanks
 
Getting upvotes on meta feels... odd. I'm not used to this.
Even if it's only a comment.
 
hehe, it feels much better than getting downvotes though :)
 
True. I guess downvotes on meta often mean "I disagree" as opposed to "your question/answer sucks", but it's still not a good feeling
 
cbg
Daily vote limit reached :/
 
@AshishNitinPatil I don't know Jinja, so I'll have to trust you on that one. ;)
 
You can trust Martijn (dupe's answerer) :-p
But yeah, it's exactly the {% raw %} that would do the trick in this case too.
Can't wait to say "I, Thor Odinson, wield my mighty gold hammer to banish this question as a dupe".
Sadly, only 30% progress towards gold.
 
Is it just me (and my rather ancient Firefox), or has the Chat link totally disappeared from the main SO pages? I see there's still a Chat link in the Stack Exchange sites drop down, and I guess the old link on the page itself was a bit obscure, but still...
 
8:11 PM
It's under the hamburger speech-bubble thing in the upper right.
 
Yeah, the one that has the title text "A list of all 170 Stack Exchange Sites"; that's what I meant by "the Stack Exchange sites drop down"
 
Maybe you're being A/B tested.
It should be between the "help" and "log out" links.
wait
 
same for me
Are we the "B"s or the "A"s in this case? :-p
 
are you saying there used to be a link outside the hamburger bubble?
 
@user2357112 Yes! Down the bottom of the page, in the black section.
 
8:16 PM
Looks like that's gone.
 
Eg, see the far left column at the bottom of this page, which still uses the old style: astronomy.stackexchange.com
 
Yeah, that's quite different
 
@PM2Ring I see "Stack Exchange Network with some categories underneath.
@PM2Ring s/left/right
 
@PM2Ring input is evil (eval?!), example - stackoverflow.com/questions/45804941/…
 
@Code-Apprentice This is the far left column I see there:
Astronomy

    Tour
    Help
    Chat
    Contact
    Feedback
    Mobile
 
8:48 PM
oh, I thought you were referring to the column that goes to the list of other SE sites
 
9:27 PM
How can I get my own IP in python?
 
@EnderLook One of my answers has the code that you may be looking for - stackoverflow.com/a/33875657/2689986
 
I just found socket.gethostbyname_ex(socket.gethostname()) but I am not sure...
I'll check your answer
 
It relies on an external website though, and depending on which IP you want, it may be definitely wrong
late night rbrb, today was a good long day.
 
bye
 
9:45 PM
Quick question: How do I add a border around a pcolormesh?
 
10:06 PM
I don't know what ia a pcolormesh...
 
10:26 PM
How can I get a list of IPs (and maybe hostnames) of all computers in my lan?
 
Is it common to use del to delete class ? Or creating a function class.delete() is more clear ?
 
@SpazaM I don't use much class and I am not an expert but I would use del. It's easier. Also, I am no sure how to code the another way.
 
@EnderLook In any other programming lang there is a delete function.
 
Oh, I only know a little of python, nothing more...
 
11:00 PM
When in my program I want to open a module I always do import but I notice that I can't import two times the same module, how can I open the module without import it?
 
Hey guys I have a question about Django.
I have a parent model called ParentA and it has multiple models in relation.
And I have "edit_date" field on each model. I want to figure out a way to get "max" edit date value of all those related models
How would you approach this?
I guess I am trying to do something similar to stackoverflow.com/questions/35751862/…
but in Django way
 
@SpazaM if you are referring to delete in C++, that is very different than del() in python.
python does garbage collection, so you do not need to worry about freeing memory.
also, there is a huge difference between del(some_class) and del(some_variable).
@EnderLook assuming you can do it, what is the purpose of importing a module twice?
if you are trying to execute the same sequence of code several times, try making a function in the module. Then you can call the function as many times as you want.
 
I am doing a menu, when you choice something it's executed another file.py. My only idea is using import file
 
@EnderLook You should put the code to execute in a function. Then do file.func().
as a general rule of thumb, do not put any global code in any file. Put everything inside functions.
Doing so provides much more flexibility and better reuse.
 
11:17 PM
ok
Is there any "general" name for that function? Like file.execute() or file.general()?
 
what does the function do?
In this situation, there is no typical name. I suggest picking a descriptive name for the purpose of the function.
 
mmm, I had some modules:
In my actual program: server (open a server ---> send file), client (connect to the server ---> get file)
Before that I was tring to make a game and I had: profile (open character profile), rest (heal the player), train (train stats)...
That means something...?
 
I don't understand the question.
What is the file which you are importing and trying to execute?
Is it the file which is sent from the server and received by the client?
 
11:33 PM
In my menu I want to open two files:
Server.py
Client.py
 
yes, then import them both and execute the correct function in the correct module.
server.start_server()
 
or
client.start_client()
or come up with a better name if you have one in mind
just start() might be better since then you don't repeat yourself.
server.start()
client.start()
 
How can I do something like this...?
 
what do you mean?
something like what?
 
11:37 PM
import msvcrt

print('What do you want to do?:')

to_do = {   # Description               File
            'Make a server'         :   'server',
            'Connect to a server'   :   'client'
        }

for x,y in enumerate(to_do.keys()):
    print('({}) {}'.format(x,y))

inp = msvcrt.getwch()

for x,y,z in enumerate(to_do.times()):
    if inp == x:
        from core import z
 
which file is that? the menu?
 
Yes
# That thing doesn't work
for x,y,z in enumerate(to_do.times()):
    if inp == x:
        from core import z
 
You cannot import based on a string variable name.
 
I know
But there is some way of doing something similar?
 
import both modules explicitly:
import server
import client
then
if inp == 1:
  server.start()
else if inp == 2:
  client.start()
 
11:40 PM
@Code-Apprentice ah ok. I was trying to found if there is a way to do that automatly.
 
do you mean "dynamically"?
You could do something like this:
 
Yes
If I had 1000 modules I wouldn't like have to write 2000 lines...
 
    import server
    import client

    to_do = {   # Description               File
            'Make a server'         :   server.start
            'Connect to a server'   :   client.start
        }

    for x,y,z in enumerate(to_do.times()):
      if inp == x:
        z()
Following the suggestion I gave earlier, this code should really go inside a function.
 
@Code-Apprentice really? It's the main file...
 
yes, you should have as little global code as possible. Usually the main file has a block like:
if __name__ == '__main__':
  main()
then the code which actually does anything interesting is in main().
main() is also usually quite short and just calls a few other functions.
 
11:46 PM
@Code-Apprentice I don't like that :(, I always forget how to write that line...
 
if you do it often enough, you will memorize it quickly
 
@Code-Apprentice Yes, I have learned that by practice.
 
putting code in functions makes it much more reusable.
 
You have right
mmm, I am trying to use this:
for x,y,z in enumerate(to_do.times()):
      if inp == x:
        z()
But it doesn't work
(I know that times is items)
 
what happens?
what error do you get?
 
11:49 PM
Traceback (most recent call last):
  File "H:\PYTHON PROGRAMA\menu.py", line 24, in <module>
    main()
  File "H:\PYTHON PROGRAMA\menu.py", line 21, in main
    y()
TypeError: 'str' object is not callable
 
@vaultah Trash?
 
Do not post long snippets of code here. Use an external paste tool instead. (the rules)
 
ups, sorry
I discover that if I change inp = (msvcrt.getwch() to inp = int(msvcrt.getwch())now it works.
 
cool
and in the dictionary that is returned by to_do.times() be sure that the function names are not in quotes.
they are function names, not strings
 
11:58 PM
Yes, I notice that
I also notice that if I add () to them they execute. Even if they are in a dictionary.
 
03:00 - 17:0017:00 - 00:00

« first day (2501 days earlier)      last day (2440 days later) »