« first day (2500 days earlier)      last day (2441 days later) » 
00:00 - 22:0022:00 - 00:00

12:00 AM
@hope94 I can read your last message as a subtle remark on _my_ way of saying what I say (whether you intended this or not). So I'd like to note something that I've been contemplating to say.
No matter how good you ever get in something, there will always be people who disagree or just outright dislike what you do. And in the STEM fields there's probably also a larger-than-average chance that people won't try (or can't) sugarcoat what they're trying to say, so even objective criticism can easily come across as overly blunt (after all, the feelings of the fellow engineer are a secondary conc
 
is it possible to access the index in a repeated string expression? '{}'*10 like '{#index}' *10
 
no
'{}'*10 is literally '{}{}{}{}{}{}{}{}{}{}', no more, no less
you can do ''.join(['{{{}}}'.format(k) for k in range(10)]) or something
but this might be an XY problem
 
that would help in creating format strings :). Any suggestion on how I would create a format string and unpacking a list's elements? I got '{LIST}'.format(**obj). Where obj = {LIST: listofitems}
I know '{LIST[0], LIST[1]...}' is possible.
 
are you bothered by the brackets and commas when you just pass the list by itself?
In [597]: '{}'.format([2,4,5])
Out[597]: '[2, 4, 5]'
 
yes, if I'd many items in the list.
 
12:14 AM
and you don't need to put labels in there if you just want to use each argument once
 
( obj = {NAME: name1, LIST: items} )
then I need labels, right?
 
I have no idea what that means
can you put together a small MCVE of 1. what your data is and 2. how you want to print it?
 
if obj had more than one key then it's necessary with labels, right?
 
Oh, I missed "I got '{LIST}'.format(**obj). Where obj = {LIST: listofitems}"
 
12:17 AM
@HajderRabiee well, yeah, but if you only need one you can pass the value directly
as in {}.format(obj[key])
or ('{} '*len(obj[key]).format(obj[key]) or something
then again there might be an idiomatic way to do this formatting
 
socket.recv(bufsize[, flags]): Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize. What happens if I send more data? That additional data won't be received? And if I send less, would the script wait for more data...?
 
this suggests that you need to do such formatting yourself
an alternative route might be pprint depending on what your end need is
 
Hello, World. from hell.
exec("import re;import base64");exec((lambda p,y:(lambda o,b,f:re.sub(o,b,f))(r"([0-9a-f]+)",lambda m:p(m,y),base64.b64decode("NDkgMmQgNTIgZiAjNDU6MQo0OSA0IDUyIDNjICM0NToyCjQ5IDUxIDUyIGUgIzQ1OjMKM2UgMWUgKDViICk6IzQ1OjUKCTVmICJcMzNbMzZ7fVwzM1s0YiIuNjAgKDViICkjNDU6NgozZSAxYiAoNWMgKTojNDU6OAoJNWYgIlwzM1s1OXt9XDMzWzRiIi42MCAoNWMgKSM0NTo5CjNlIDE5ICg3ICk6IzQ1OjExCgk1ZiAiXDMzWzU4e31cMzNbNGIiLjYwICg3ICkjNDU6MTIKM2UgM2YgKGMgKTojNDU6MTQKCTVmICJcMzNbM2J7fVwzM1s0YiIuNjAgKGMgKSM0NToxNQozZSAxYSAoYiApOiM0NToxNwoJNWYgIlwzM1szYXt9XDMzWzRiIi42MCAoYiApIzQ1OjE4CjNlIDFjIChhICk6IzQ1OjIwC
 
@AndrasDeak thanks a simple for would suffice for now. I have to read the links you sent me.
 
@RickyWilson I'm not sure I want to run anything foreign that starts with exec
@HajderRabiee neither will be of direct help to you, so a for loop is probably fine
 
it will probably be the most readable
 
@AndrasDeak repl.it/KRKW
 
you already linked that once
 
The chars are printed in random colors in the shell.
Your code has been rated at -195.00/10 says pylint.
 
12:38 AM
Hi how would i pass a list into a str only function like rmtree to be specific
Traceback (most recent call last):
  File "C:\Users\Daft\Programming\TorCleaner\moveTor.py", line 28, in <module>
    shutil.rmtree(dirs, onerror = onerror)
  File "C:\Python36\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Python36\lib\shutil.py", line 365, in _rmtree_unsafe
    if os.path.islink(path):
  File "C:\Python36\lib\ntpath.py", line 252, in islink
    st = os.lstat(path)
TypeError: lstat: path should be string, bytes or os.PathLike, not list
is what i'm getting if I just pass in dirs
 
Well either you need a function that accepts multiple dirs, or you need to pass in one dir at a time. Right?
 
12:55 AM
one dir at a time would be optimal i think because I'd be looping an entire parent folder to have subfolders deleted
doing a function with multiple dirs would be complicated because I'm not looking to type in each directory each time
 
1:09 AM
If I want to turn a string into bytes shall I do X.encode('utf-8') or X = bytes(X, 'utf-8')?
 
encode() p sure
That's the one i've used before at least
 
Ok, thanks
 
 
1 hour later…
2:19 AM
I started reading Mastering Object-oriented Python. Is this a decent book?
 
 
2 hours later…
 
2 hours later…
6:21 AM
recbg
 
6:34 AM
Good morning cbg!
 
7:30 AM
Cabbage
@EnderLook See Antti's answer on the page that Code-Apprentice linked. The default encoding of the str.encode method is UTF-8, so you don't need to specify it, and it's actually faster if you don't specify it. IOW, mybytes = mystring.encode() is the fastest way. But I guess mybytes = mystring.encode('utf-8') is a little more readable.
@HajderRabiee I'd love to answer this question, but unfortunately I don't understand what you're actually asking. ;) A MCVE would help.
 
 
2 hours later…
10:00 AM
@HajderRabiee I understood.
@HajderRabiee that's your own decision. Primarily opinion based / depends on the case
 
Puppy power \o/
*scratches nuppy's ear*
 
awwww.... :)
 
OP self-deleted \o/ He's the real mvp
 
10:52 AM
@Jon insight request on that typo: OP deleted but there was a fresh answer. Deletion wss merited, but Shog says that self-delete shortly after an answer counts against OP in a question ban. Do you think it would matter if OP undeleted and others delvoted instead?
 
I'm not sure... but it might be the system considers that worse... removal of something you know is useless (not great, but there's something for tidying up after yourself), 3 users doing it for you instead... less good...
 
I'm not sure either. Here's my go-to source: meta.stackoverflow.com/a/311812/5067311
it says that 0-score deleted doesn't count except self-delete after answer
that's how I read that I mean
maybe I should bother Shog :P
 
well... just shrug and move on... nothing to worry about
 
OK, thanks :)
I did upvote one of OP's acceptable questions to make this all less likely
 
If you're going to answer a typo question that's likely to get closed, that's your problem. If you're going to ask a question you didn't notice something pretty obvious before hand and played with it a bit, again - that's your problem. All in all... who cares - it's resolved itself :)
 
10:59 AM
the Darwinist approach, eh? ;)
 
Indeed!
 
11:25 AM
Completely off: I've been drinking a lot of boxed fruit juice lately, and they all come in nice Tetra Pak boxes. I couldn't figure out the opening mechanism, so I googled it. The world must know!
 
@AndrasDeak Err... fascinating? I'm starting to worry about you. Did a lot of these fruit juices happen to be fermented apple maybe? :p
 
I remember when Tetra paks were actually tetrahedral
They were usually sold frozen. It was common practice to smash them around before opening them to turn the contents into slush; this was before slushies were invented.
 
11:44 AM
@PM2Ring <3
would you like to have a 'trip'? :d
 
:)
 
I WANT THEM BACK
 
@PM2Ring "before slushies were invented" - > "It was common practice to smash them around before opening them to turn the contents into slush"... and someone put 2+2 together for convenience and lo' and behold...:p
 
Probably. Kids at school used to smash them against a brick wall, or throw them on the ground. The packages were pretty tough, but accidental splitting did happen from time to time.
 
yet another great Swedish invention. And what did Finland invent?!?
lol :D
reading the history of tetra pak :d
invented in Sweden, were introduced then in Germany and Finland; then Soviet Union and Mexico before the US :d
 
12:04 PM
cbg
 
you're welcome
 
12:54 PM
hey why is web module not available for python3?
 
user8451312
@AndrasDeak That's why i said i appreciate DSM found nice way to say it. It's not hard to be nice to people :)
 
OK heres a hard question about django, should I start?
lets cut the chase...I'm in a windows environment, when starting a django server using python manage.py runserver it throws an utf8decodeerror, I looked it up, found this post: stackoverflow.com/questions/25714826/…, but not quite sure if it is the right direction
I know using python in windows is not ideal. but still want to get to the bottom of this
I mean this is ..not "hard", but maybe windows user are rare here so it does requires some experience to solve
 
1:20 PM
@Sajuuk can't help I'm afraid - don't have a windows system to play with... I'd only end up googling like yourself and trying things
If you have a completely fresh django project (literally just straight after startproject) and you runserver - does that do the same thing?
That should isolate whether you need to look at the system settings or at something in the project
 
yes even if I'm using a completely new project.
I created this project like: django-admin startproject myproject
heres a mildly related question: since my problem is probably a encoding problem, I wanted to check the encoding of my source code files. in my text editor which is Microsoft VS Code, I can see the opened file has a status: UTF-8 in the lower right corner, but I don't know if that is indicating the file encoding or how VS Code is trying to intepret this file.
 
what does sys.getdefaultencoding() show you?
On a side note... when I have the "pleasure" of working on Windows, since I'm normally having to integrate with git etc... I generally install git-for-windows.github.io - means the command line is also more useful for bits and bobs...
 
'ascii'
I have installed Cmder, a utility that provides me with many useful *nix like commands
 
What does chcp show you in the command prompt?
 
936
 
1:35 PM
and if you do chcp 65001 - does that succeed okay?
 
let me see..
Still the same error..
 
Let me double check but I think you can manually run cmd /U to force a brand new command window..
Ahh - that looks like the right command yeah... try that and use the new window instead...
 
I checked the chcp in my new cmd windows, it truely is 65001
but same error.
 
shrugs... I give up then... sorry - vaguely recalled something about code pages and had a look... that's me out of ideas
I know when I've run django on windows I've not had a problem
 
you already made me much more clearer of the scope of this problem, thank you very much
 
1:40 PM
(the only real problem was with modules that needed compiling and all the associated stuff, but wheels mostly fixes those for all the popular stuff anyway)
@Sajuuk good luck solving it...
 
Yep it's me or it
 
Go you! :)
 
2:08 PM
Well it seems that it's caused by Non-Unicode Characters in environment variables. removed that environment variable and django runs fine.
It tooke me so long because I was only looking in %PATH%.. turns out it's other variable
 
1-0 to you then... :)
 
this no more round for it though. it's gone :p
 
cabbage
 
is there a way to import global constants from a package (defined in it's init.py) using the path to that package folder
 
2:20 PM
I would've thought that from package import CONST would work if CONST is a global in the __init__.py
 
Yes and it does
I'm just wondering how to achieve those same results using the path of package not it's name
These are my own package, not in the site-packages or any other dir on the python path
If I was to from package import CONST from anywhere it wouldn't work
os.getcwd() would have to be in the same level as package
Plus I'm looking to use strings/filepaths so that wouldn't really be an option anyway
 
oh, I see, I missed the emphasis on the path
 
Hmm, I wrote some code to import packages by path a while ago... not sure if I posted that as an answer anywhere
 
Aug 10 at 8:24, by Rawing
def import_package_from_path(name, path):
    origin = str(path/'__init__.py')
    loader = importlib.machinery.SourceFileLoader(name, origin)
    spec = importlib.util.spec_from_file_location(name, origin, loader=loader)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module
Aug 10 at 8:39, by Rawing
Welp, that was an easy fix. Just had to add the module to sys.modules before executing it.
 
ah, the import package by path problem..
 
2:31 PM
I remember this one -------------------------------^
 
Oh yea right, chat history is a thing.
 
' I only remembers the problem I hadn't solved ... it's a pretty useless perk in this site.'
 
What's that, 7 lines? Wow. That code blew up to 100+ lines meanwhile just because I added support for importing subpackages.
 
@Rawing @AndrasDeak Thanks guys. I'll try it out
 
full code here if you need it
 
2:35 PM
I'm in python2.7
says importlib has no attribute machinery
 
well... Good luck and have fun learning the inner workings and intricacies of the python import system then :P
No idea how to port that to python 2, really
 
ok lol
 
re-cbg
@MalikBrahimi You could install your package, so that the directory containing the package is in a directory where Python knows how to find it. As a temporary solution, you can put that directory into sys.path, just so you can test that it works correctly.
IOW, if your package's directory is myproject, and myproject is in mystuff, then insert "mystuff" at the start of the sys.path list. You'd do that at the top of a script that's in the normal place you run Python from, and then that script will be able to import myproject, assuming myproject has the necessary __init__.py files.
 
2:57 PM
@PM2Ring I think I resolved the issue by including a separate module for constants instead of using them in __init__.py at the package roots
 
Oh, ok.
 
3:26 PM
@MalikBrahimi why are you on python 2.7?
 
@AnttiHaapala Better package support
It's gonna take a while for 3rd party open source to move toward 3x
 
those packages that do not support py3 by now, will probably never support py3.
 
which packages
 
3:27 PM
they will be replaced by the others that do support
I don't know, you yourself stated you have some 3rd party packages that support Py2 only
 
@MalikBrahimi you know that Python 3 has been around for 9 years now.
 
@AnttiHaapala Development for most of Python's most popular packages began before Py3 was a thing
Yeah ik
I actually started on 3 and moved back to 2
 
if the packages weren't ported in 9 first years, they likely aren't going to be ported in last 3 years either...
... unless you do it
 
I dunno, there'll probably be a flurry
 
3:33 PM
@MalikBrahimi py3readiness.org
I am running ansible with Python 3 even though not "supported"
 
@AnttiHaapala much reasoning, very science, wow
 
@Sajuuk ...?
 
Which reminds me, broken Unicode guy still wants to be able to ignore errors:
How can I change TypeError builtin class? I want to change things in it such as fixing unicode error. — Ali Hallaji yesterday
Or maybe he just wants to intercept them all in one place & deal with them there.
 
Unfortunately, he's got a bit to learn about Unicode before he'll have the skills to fix this problem, as you can see from the example he's added to his question.
 
3:41 PM
@PM2Ring what he wants to do is to have "implicit utf8" decode...
but the result is still ambiguous - text or utf-8?
 
Tell me about it.
 
os.path.getsize(Path) or os.stat(Path).st_size is better to get file's size?
 
pathlib.Path(path).stat().st_size is better than both of those :p
 
There are 3 ways to do the same thing???
 
Yep. Working with paths was quite messy before pathlib came along.
 
3:55 PM
Do you know the difference between them?
 
Not sure if there is a tangible difference. They probably all do the same thing internally.
 
but as I was told, "pathlib is magic"
 
Ok, thanks.
 
pathlib is the new way. But it's very recent, so it won't be available on older systems.
os.path.getsize is a convenience function when you just need the size. It still makes a system stat call, but throws away all the other info. So if you do want that other info (like file time stamps), then it's better to do os.stat and extract the stuff you need from the object it returns, rather than making separate calls for size, timestamp, etc.
 
it's 3 years old by now
 
4:11 PM
@Rawing Sure, the docs say "New in version 3.4".
 
 
1 hour later…
5:30 PM
can't believe that PM2Ring has been using Python 3 for ages by now...
Nov 10 '16 at 23:08, by PM 2Ring
$ python3
Python 3.6.0a0 (default, May  9 2016, 02:54:33)
 
ages, eh?;)
so it's 4 more ages until python 2 support is dropped
 
user8451312
5:47 PM
Hi. What do you think is the best algorithm for text mining in Python?
 
6:06 PM
@AnttiHaapala I've been using Python 3 for longer than that:
May 8 '16 at 17:07, by PM 2Ring
Thanks for all your help, @Antti. I couldn't have done this without you.
Is this being helpful, or is it being mean? I linked him to Ned's Unipain in a previous comment, so hopefully he now has enough clues to figure it out:
Here's a little test that may help explain why your cronjob is having problems. Assuming your terminal is set to use UTF-8, the following command should print A®Z. 1 python2 -c "print 'A\xc2\xaeZ'" 2 python2 -c "print 'A\xc2\xaeZ'" | cat 3 python2 -c "print 'A\xc2\xaeZ'.decode('utf8')" But this will raise UnicodeEncodeError 4 python2 -c "print 'A\xc2\xaeZ'.decode('utf8')" | catPM 2Ring 13 mins ago
 
@Rawing Jesus christ, don't try to judge what I'm doing when you have no idea. Grow up. I know it makes you feel superior and that is what you think you need in your pathetic life, but Horribly wrong? What do you think? I'm going open a portal to hell? Sheesh, some people... — AbstractDissonance 53 mins ago
deep sigh
 
@PM2Ring why on Earth would that be mean?
@Rawing you can flag comments like that
(if you won't, someone else will)
 
I'll try to leave a helpful comment instead of flagging. Let's see how he reacts.
 
It won't help, but good luck :) Engaging idiots like this will only make it worse
then again you might already be in for misplaced revenge downvotes
 
I prefer to learn things the hard way ;p
 
6:19 PM
@AndrasDeak Well, I haven't actually explained why you can get a UnicodeEncodeError when you try to send unencoded Unicode through a pipe. But I'm hoping that the voyage of discovery will lead to enlightenment. ;)
 
except python *cough*
 
@PM2Ring aaaah.... I'm sure they'll be fine :P
 
@AndrasDeak The description is clear enough if you're familiar with GTK, but a MCVE would help enormously. I'll post a comment & see how the OP responds before I vtc.
 
well I'm with OP: "None of this probably make much sense."
 
@PM2Ring ah it was just upgrade :D
@hope94 please elaborate
 
6:26 PM
@Rawing I agree with you. Even trying to manipulate the relative sizes in a Paned widget can be a little frustrating.
 
it is as if you ask "what's the best method for painting"
well, depends, a car, wall, fresco?
but if you have not done so yet, please do read all of the NLTK book.
 
user8451312
@AnttiHaapala i am making a model for classifying tweets that consider/not consider observed topic. I used countvectorizer to get frequency of each word. And i wanna get weights for each word and use them to make a model.
 
Yeah, size management is bad enough in Gtk; but reducing it below the minimum size is on a whole 'nother level. Not sure how he can believe he's not doing something horribly wrong.
 
@hope94 so even more so, have you read all of NLTK book yet :?
and remember that with tweets you can use other tweet metadata too
 
user8451312
6:30 PM
I haven't. I don't know nothing about metadata. :(
 
see there is no such thing as a "best text mining algorithm"
but tweets are such small pieces of text that you must use other data too
 
I just noticed that GTK guy hasn't actually mentioned what language he's doing this in...
 
well he's using
 
and are you categorizing English tweets only?
 
user8451312
@AnttiHaapala I am categorizing Serbian tweets that refer to Intesa bank in Serbia. I should eliminate all tweets that are about Intesa bank in San Paolo, Montenegro, Slovenia etc. and tweets which contain words like intesa, intese which are spansih words...
 
user8451312
6:36 PM
and, for example, montenegro and serbia use the same language
 
see ... that's again a different thing
you can use language detection
you don't even need to use words... for most part
 
user8451312
there are many tweets in serbian language that dont refer to the bank. Thats why i have to use
 
yes but you eliminate the easiest first
or... meaning, you need to provide features that identify the wrong ones easily
one of them is language detection using letter-ngrams
got ñ -> probably not serbian...
 
user8451312
I already did that with letters. That's helpful, but i already made model that works great on train and test data in RapidMiner, just have to do the same in Python... Now i need algorithm
 
stemming, remove stopwords, make ngrams and ngrams with skips perhaps
if you're doing a dummy classifier
then you prolly need to teach it anyway...
 
6:45 PM
I want to get the directory of myfile.py: Which shall I use? os.path.dirname(os.path.realpath(__file__)) or os.getcwd()?
 
umm...
so which one would it be :D
@EnderLook try: "cd ../.." and then "python path/to/myfile.py"
 
But I want to get the path and then add the name of another file to finally get the size of it.
 
@EnderLook Antti's trying to give you hint. I'll make it a bit more obvious; What does os.getcwd() return if you run the script from outside the directory it lives in?
 
path = os.getcwd() or os.path.dirname(os.path.realpath(__file__))
path = path + 'my.txt'
size = pathlib.Path(path).stat().st_size
 
6:53 PM
mmmm
 
no or
 
@EnderLook that may work in javascript, but not python. or will give you True or `False.
 
@Metaphox no
>>> 'asdf' or 'ghij'
'asdf'
>>> None or 'asdf'
'asdf'
 
@Metaphox With or I wanted to say I that I don't now which of both codes use.
 
@AndrasDeak (facepalm) yeah right...
@EnderLook well, getcwd() is where you start the script, and __file__ path is where the script lives
 
7:09 PM
ohh, thanks.
 
user8451312
Suddenly i can't anymore import and use nltk package. Maybe it's because yesterday i installed weka and it didn't work, i don't know.

Error says this, when i run "import nltk":


File "C:\Users\Nada\Anaconda\lib\site-packages\nltk\corpus\reader\plaintext.py", line 42, in PlaintextCorpusReader
sent_tokenizer=nltk.data.LazyLoader(

AttributeError: module 'nltk' has no attribute 'data'
 
eclipse cbg!
 
cbg
Isn't the eclipse tomorrow? Or are you developing java now?
 
yes, but the tourists are already in town
 
oh...
 
7:19 PM
so it's eclipse weekend
 
@PM2Ring that word question thingy looks interesting
have just had a quick play for 5 mins and got something working... not particulary fast though
 
@JonClements Yes, it does! I'm also working on something, but I've just started, and I haven't fully mapped out a strategy yet.
 
what word question?
 
It's a word chain thingy: stackoverflow.com/q/45785582/4014959
 
the fact that both Jon and you called it "a thingy" makes me very wary :P
makes me think of an alien life form which shows unusual (and aggressive) behaviour
 
7:28 PM
oh shuddup deak :p
from collections import defaultdict
import networkx as nx

with open('/usr/share/dict/words') as fin:
    words = defaultdict(set)
    for word in (line.strip() for line in fin if line.islower() and len(line) <= 6):
        words[len(word)].add(word)

graph = nx.Graph()
for k, g in words.items():
    print('doing len={} with count={}'.format(k, len(g)))
    while g:
        word = g.pop()
        for other in g:
            if sum(c1 != c2 for c1, c2 in zip(word, other)) == 1:
                graph.add_edge(word, other)
That's my very first just hammer something out and see if it works... just trying to figure out if there's a more optimal way of grouping words that are only one different
oh wait... I'm not removing the words from the candidate space... missed that line out... woo hooo... that'll speed things up...brb
for k, g in words.items():
    print('doing len={} with count={}'.format(k, len(g)))
    while g:
        word = g.pop()
        matches = {w for w in g if sum(c1 != c2 for c1, c2 in zip(word, w)) == 1}
        for match in matches:
            graph.add_edge(word, match)
        g.difference_update(matches)
I think that's better
 
That question has a lot of code that isn't related to transforming one word into another at first glance...
 
user8451312
Rawing, can u help me with this? I am getting an error when i try to import nltk:

File "C:\Users\Nada\Anaconda\lib\site-packages\nltk\corpus\reader\plaintext.py", line 42, in PlaintextCorpusReader
sent_tokenizer=nltk.data.LazyLoader(

AttributeError: module 'nltk' has no attribute 'data'
 
you need to import nltk.data (perhaps)
 
I've just come to realize that PyPi has deprecated it's uploading API
 
@MalikBrahimi um, no
registration is
 
7:38 PM
I'm using twine now in compliance with the new standards still getting Gone HTTP status
@AnttiHaapala Ok my bad
 
@hope94 No idea what could be causing that. Like I said, I'm not an nltk person. Have you tried the easy way out, i.e. reinstalling it?
 
user8451312
how i uninstall it from pip?
 
user8451312
pip uninstall nltk?
 
@AnttiHaapala I've followed all available tutorials still getting crappy HTTP status
@hope94 yes
 
When in doubt, pip --help
 
user8451312
7:40 PM
oh, thanks :)
 
wait ... so if u have an account with the old pypi
you have to create a new account?
Or are they migrated to the new service
I'm trying to use the same email/username says it's used ... idk
 
Ugh... actually that's not better because you lose the other routes... darn
In [1]: nx.shortest_path(graph, 'cat', 'dog')
Out[1]: ['cat', 'cot', 'dot', 'dog']
 
7:59 PM
Nevermind I got it to wrok
work
 
8:27 PM
any of you work with Django in IntelliJ IDEA/PyCharm?
and with virtualenv?
I'm not yet figuring out how to create a simple "Hello, World" type project in IntelliJ
maybe I'm getting ahead of myself and should just learn django with a text editor and command line first
hmm...I really need to figure out a place to set up my Linux desktop.
my apartment is so small and crowded right now...
 
8:43 PM
@Code-Apprentice Yes
Not with virtualenv tho (bad practice ikr)
Honestly the best place to learn besides the tutorials docs
is the new boston
give it a search in youtube
 
just watched Jurassic Park 3 in its entirety... what an awful film...
 
I'm completely youtube self-taught lol
@AnttiHaapala do u happen to use django
 
@MalikBrahimi thank god, no.
 
lolololol
it's not that bad
why does everyone seem to prefer the other py web frameworks
I spent the good part of today creating a better URL router for django
 
Anyone know about sockets?
I am trying to send a file to another computer (actually only localhost...) but I'm having this error in the line 56 of the server:
ConnectionAbortedError: [WinError 10053]: An established connection was aborted by the software in your host machine. (My host machine is Windows 10 64-bits, python 3.6).
I don't understand why the connection aborted.
This is my server: https://pastebin.com/zyag7NYB
And this is my client: https://pastebin.com/Fh20CAzp
I found in internet that there is a command to set a time limit to the connection, but I don't use that so I don't und
 
8:58 PM
unrelated, but: pathlib.Path(path+'\\'+name) -> pathlib.Path(path)/name
backslash won't work on linux. You're throwing away platform independency for no reason
 
Think you can have a \ in a filename in linux, it's just not a path separator...
 
You missed the whole point of pathlib. You only used it to query the file size lol
You're supposed to use pathlib.Path instead of string paths
 
@Rawing I only use Windows and this is for personal purposes so I don't have problem with compatibility.
@Rawing Ok
@Rawing ok... I will check that.
 
For example os.path.dirname(os.path.realpath(__file__)) could be just Path(__file__).parent
 
@Rawing That give me: NameError: name 'Path' is not defined
 
9:04 PM
from pathlib import Path
 
ahh
 
Level up: +1 lazyness, -1 RSI
 
@Rawing RSI? What means?
I don't like use from x import y...
 
A repetitive strain injury (RSI) is an "injury to the musculoskeletal and nervous systems that may be caused by repetitive tasks, forceful exertions, vibrations, mechanical compression, or sustained or awkward positions". RSIs are also known as cumulative trauma disorders, repetitive stress injuries, repetitive motion injuries or disorders, musculoskeletal disorders, and occupational or sports overuse syndromes. == Definition == Repetitive strain injury (RSI) and associative trauma orders are umbrella terms used to refer to several discrete conditions that can be associated with repetitive tasks...
I'm getting an error in the client:
Traceback (most recent call last):
  File "D:\Users\Rawing\Desktop\temp {e}\temp.py", line 37, in <module>
    rece_file(sock)
  File "D:\Users\Rawing\Desktop\temp {e}\temp.py", line 21, in rece_file
    sock.send(len(msg))
NameError: name 'msg' is not defined
This is never going to work:
if get == len(to_send):
        connection.send(False)
get is a bytes, len(to_send) is an int. And you can't send a boolean.
 
@Rawing I haven't checked that yet because I have an error before.
@Rawing Sorry I will check that
 
9:25 PM
I make a few changes:
Server ---> https://pastebin.com/SfWLdgqz
Client ---> https://pastebin.com/u8xBT04A
Now I get ConnectionResetError WinError 10054 - An existing connection was forcibly closed by the remote host in the line 45 of the server...
 
There's some code missing in the client
 
ups, give me a second
Now? I have edited the pastebin.
 
Interesting. When I click "raw" it still gives me the old version. Almost copied the wrong thing.
 
@Rawing Sorry, I've made something wrong, It's the first time I use pastebin...
 
Traceback (most recent call last):
  File "D:\Users\Rawing\Desktop\temp {e}\temp.py", line 38, in <module>
    rece_file(sock)
  File "D:\Users\Rawing\Desktop\temp {e}\temp.py", line 22, in rece_file
    name, file_size = stats.split('/')
TypeError: a bytes-like object is required, not 'str'
generally speaking, ConnectionResetError == the other script crashed
 
9:37 PM
@Rawing ahh
 
That should be stats.split(b'/') I guess
 
I run the server scrip in the Visual Studio to get the crash reports but the client scrip I run with "double click" so I don't get crash reports...
 
run it in a terminal
 
@Rawing ... sorry but I don't know how to do that... I only use double click...
Can I use IDLE?
 
That should work too, yeah
 
9:41 PM
I've already edited the client
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 12: invalid start byte?
 
worked fine on my machine
I thought it hanged at first, but it was only the time.sleep(100)...
 
mmm, I was trying to move a pdf but I didn't worked. I changed it with a png and I worked... any idea of what is happening?
 
It's probably something related to your buffer
AFAIK you can't assume that connection.send(buffer) will send the whole buffer.
It returns an int that tells you how many bytes it sent
 
@Rawing I know
  while True:
       get = sock.recv(max)
       sock.send(str(len(get)).encode())
       check = sock.recv(max).decode()
       if check == 'True': break
 
Well, you aren't doing anything with the int it returns.
 
9:55 PM
This check that all the data has been sent
 
check == 'True', ew :|
 
I do this:
 
No no no no no you can't do that.
 
1) Send data to the client.
2) Count the amount of bytes.
3) Send the amount to the server.
4) Compare the amount of the client with the sended.
5) If the same: send "True" and follow.
6) If less: start again.
 
@JonClements I posted an answer to that word morph question. stackoverflow.com/a/45787130/4014959 I also found a site that can be used to create (start, target) pairs: xworder.com/MorphBuild.aspx
 
9:58 PM
You can't assume that connection.recv(chunk) receives the entire chunk.
You need to save the return value of sock.send(...) and use that to determine what to send next.
 
@Rawing Ok, I will try.
 
You really don't need all these connection.send('True'.encode()) by the way.
 
00:00 - 22:0022:00 - 00:00

« first day (2500 days earlier)      last day (2441 days later) »