« first day (1799 days earlier)      last day (3374 days later) » 

 
1 hour later…
04:26
Cbg
 
2 hours later…
05:59
@rene I'd say the 2 most important things we have as ROs is 1) a Trello board for keeping track of a) decisions, b) internal news (e.g. UserX is away for a month) and c) a problematic users list (aka naughty list) full of repeat offenders and what their behaviour tends to be (typically with links to chat messages) and 2) a Slack chat for real time private chat away from the room.
Slack is really invaluable, it might not be used for weeks at a time but is useful to have if necessary.
People may assume it's used to bitch about people in private :p and certainly for @Rob that is true, but a lot of the time it can actually be used to call each other out on behaviour.
Of course both of those things are internal, and you seemed to be after some externally facing ideas, but thought it was worth an explanation.
 
2 hours later…
Error 10053 An established connection was aborted by the software in your host machine
Nvm, its gone.
when i am trying to take a response on chrome extension
any idea
?
and i am using flask to make a pyhon server
08:41
Hello people. I've got a project that is news aggregation. I found Flipboard to be a very good example. But on the internet during my research, I found a link where Evan Doll (the co founder of Flipboard) said, they have a generic scraper for almost every websites they scrape. But my question is, how is it possible to build a generic scraper since almost every website is built on a completely different structure?
09:02
@Ffisegydd Tnx for that insight. We are setting up something similar now. I understand that you'll need a back-channel to coordinate between RO's. My concern is indeed about the external facing part. I want to make sure that the regulars are conscious about the RO's moderation in-side the room. To prevent that it comes as a surprise that a RO steps in. I think I'm looking for a Theory of RO-ship and a RO-agreement.
09:15
@rene in that case yeah write some rules out. We're actually in the process of re-writing our rules to make them shorter and more to the point.
And that'll be a community-driven thing where we ask for suggestions on our wiki sopython.com/wiki
It depends on the individual room, of course.
Some things that occur in The Lounge would not be tolerated here (not saying that the C++ guys are barbarians, just a different culture)
We are doing the same atm. Our effort started here but we are in an update process as well. Let's keep each other informed about our findings/progress/tips&tricks
@Ffisegydd I agree that it is a per-room-thingy
And because it's a per-room thing, it obviously helps for each room to have their own little rules page detailing it all :P
even if it as little as We have no rulez! :D
Y U no say C++ R barbarians? ;)
morning, by the way
morning, and yes, having warm feelings for C++ needs a kind of barbarianism, I think. So that comes natural to that room.
09:31
:D I did c++ at college many moons ago. Not a fan. Apart from operator overloading
Ahhhh
stackoverflow.com/questions/32471327/converting-double-to-bigdecimal-in-java/326‌​35804?noredirect=1#comment53174041_32635804
Proud face
(sorry not python, but it's quiet y' know)
That reads as a great answer (I'm not into java nor into the problem being solved), nevertheless all the reasons to be proud!
09:47
Thanks @rene, it caught my interest as you can see, so pleased the op is happy
Happy OP's is the fuel that keeps us going...
10:02
Cbg @antti
Btw @JRichardSnape do you have any comments/suggestions for my answer (and/or question)?
10:22
Yo guys whats up
Lets say you have a string of characters, you want to replace certain characters or symbols with numbers, for instance the string 'abc' would turn into 'a' 0b100 'c'
This really can't be a string anymore, so I need to change it into either a list or something else, whats the best practice of doing this? I can change the string into a list and go over each character and replacing it with its encoding, I just wanted to see if there's a more pythonic way to do that
@GLaDOS can you give some actual examples of what you're trying?
I'm writing a huffman algorithm that compresses data.
That means literally nothing to me :P
Do you have a more complex example than 'abc' to ['a', 0b100, 'c']?
cabbage
10:37
So I assign an encoding to each symbol. Lets say my string is 'aaabbccd '
After running huffman on it I'll have a list containing new encodings of the chars
since 'a' appears most of the times it'll get '11', b is '10', c '110', d '111'
Now what I do is replace the string with the new encodings, this saves space since the most frequent characters end up using a smaller encoding. so I need to go over the string and replace the characters there
So 'aaabbccd' becomes what in the end?
I could do a for loop on the string and create a new list and append the encoding to the list. That's what I did for now.
oh
And why does a go to 0b11 and not 0b10, for example?
@JRichardSnape Nice to see you got a bounty on that one. FWIW, calculating zeta(230 + 30j) with 120 digits of precision in mpmath the real part will be ok, but the imaginary part will only be accurate to 61 digits. To get 120 stable digits I had to go up to about 190 digits of precision.
it should be something like 0b11 0b11 0b11 0b10 0b10 0b110 0b111
sorry the string should have been 'aaaabbbccd'
It becomes like that because you create a tree with the probability of each character in some sort of fashion, the last level of depth has the least probability to appear in your data. After you do that you assign 1 to a left turn and 0 to a right turn from the root of your tree, then you start searching your tree for all of the symbols, creating the encoding as you go and voila
Wikipedia has a nice demo gif for it
10:43
@GLaDOS: I'm slightly confused. Why does 'abc' become ['a', 0b100, 'c']? Why aren't all the characters in the string being replaced by their bitstring encodings?
they are
Okay this is going too far over my head, sorry, and I don't have the time/inclination to read too much on a Saturday morning :P
alright
I was going to suggest using a dictionary though.
Thats actually what I ended up doing for the encodings themselves
I have a dictionary where dict[symbol] = encoding
10:44
FWIW, the usual Pythonic way to do this sort of thing is a list comprehension: [encoded(c) for c in data_string]
I see
yeah maybe I should do that
s = 'aaaabbbcc'

d = {'a': 0b100,
     'b': 0b110,
     'c': 0b111}

a = [d[k] for k in s]
print(a)
# [4, 4, 4, 4, 6, 6, 6, 7, 7]
encoded_data = [encoding_list[character] for character in DATA_TO_COMPRESS]
You could tidy that up actually EDIT: have done.
I was kinda asking questions so I could make the dict, but if you can make that yourself then awesome :P
Yeah that seems elegant enough
10:48
And ultimately you need to convert your string of zero & one characters to a byte string of actual 0 & 1 bits. But that's not too hard to do
no the dict isn't the problem
It's not too hard but there aren't any good libraries I've found that does it
I'm currently using BitStream
I don't like it that much though
I think I'll use BitArray now that I think about it
The fastest way I know (in pure Python) to convert a tuple of the form (1,1,0,0,1,0,0,1) to a byte '\xC9'is to use a dict:
def bin8(i):
    return bin(i)[2:].zfill(8)

bit_dict = dict((tuple(int(c) for c in bin8(i)), i) for i in xrange(256))
That's not the part I'm thinking about though
the problem is that I need something that generates some sort of a bit stream
since I want to actually save space with my encoding
I don't want it aligned to bytes because that would lose the purpose of the compression
11:04
@GLaDOS Of course. So you just save all the zeroes & ones produced by the Huffman encoding into a list, padding it if necessary to make the size a multiple of 8, and then parse that list in chunks, converting it into bytes using a technique similar to what I posted above. The answers to this question show a variety of ways to parse a list in fixed sized chunks.
I don't want a fixed size though
I want something that would turn [0b1, 0b100, 0b1011] into 0b11001011
How would you convert it back?
Assuming that is necessary.
@Ffisegydd The beauty of a Huffman encoding is that no code is the prefix of another so you can always unambiguously split the bit stream.
I read the stream and run the characters through my huffman tree. whenever I reach a character I add it to my decompressed string and start the process again
yeah
Huffman is the shit
11:07
Sounds like witchcraft to me. I'll stick to science.
It's actually pretty intuitive once you look at enough demo's
I think i'll use BitString. I just hate using strings as a representation of binary data
@GLaDOS I think you misunderstand me. You need to break your encoded bitstream up into chunks of 8 bit bytes.
but it does save me the trouble of prepending a '1' to each of my characters
oh
yeah actually that could work
Kind of think about I've already done the same thing once
Silly me
and I remember doing this really funky list comprehension that seperates into bit chunks
@GLaDOS Python has nice tools for splitting & joining strings, so they're a handy way of playing with bit strings. Alternatively, you can use lists / tuples of 0 & 1 integers. I don't recommend handling your Huffman codes in 0b011 form as that's less convenient for manipulation, although I guess you can use the << and >> bitshifting operators as well as & and |
What about efficiency when converting to lists, tuples or strings and working with them instead?
11:16
If seq is a list whose length is a whole multiple of rowsize this will chunkify it:
zip(*[iter(seq)] * rowsize)
OTOH, many prefer the more straight-forward approach:
[seq[i:i+rowsize] for i in range(0,len(seq),rowsize)]
I think I used something similar to the second example
but I think zip is a lot more readable
it does cut the remaining data
I'm not very familiar with the use of * in python as a reference or so
maybe I should look into it some more
@GLaDOS I think the easiest way would be to store the encodings for each char in a dict, with the char as the key. If you store the codes as '011' style string then you can join the individual strings with the str.join method. Alternatively, store the codes as [0,1,1] style lists and join them with list.extend in a for loop.
thats almost exactly what I've done
@GLaDOS The first * in that zip thingy is affectionately known as the splat operator. It tells the function (zip, in this case), to extract the contents of the following tuple or list, and use each element of the tuple / list as a separate argument.
@PM2Ring Damn well I have to go now. I'll be back in a few hours if you'll still here :) It's been nice talking to you
11:27
Take care, GLaDOS.
@PM2Ring yeah I looked into it and when they said that python refers to this as the unpacking operator (ruby refers as splat) it kind of clicked with things I learned a year or so back
Excellent. We also have a double splat ** for unpacking the contents of a dict.
I even knew that as well!
 
2 hours later…
13:56
hey hey hey
 
1 hour later…
15:15
@Ffisegydd that would not be the only Slack room used for that purpose
 
1 hour later…
16:36
Seriously. A business requirement to use the same local name as a global?!
@Martinj Pieters good catch of str. But what if in some business requirements wants me to do this. I can do this by using other language like Java and C++. You mean python doesn't have anything for this? — dnup1092 3 mins ago
16:49
Hmm, can moderators cancel close votes of other users?
17:13
@MartijnPieters It gets even better -- now he wants Python to support this alleged business requirement. "May be devs will consider to take the good things of others lang."
user559633
I still get a bit starstruck and have a bit of idol worship when answering in a thread alongside Martijn.
Prediction: If he doesn't work for a government, he'll be out of a job soon -- either the business will fail because of stupid requirements like that, or he'll get fired for his egregious misinterpretation.
@tristan I had the same feeling, with this answer ;-)
@thefourtheye There was a lot of work in that answer...
Well, going against the lord is not that easy, you see.
user559633
17:18
@thefourtheye Bookmarked to read later :D
user559633
Heading to the airport gate. Have a good weekend all :)
Have a safe trip :-)
@vaultah I tested the execution time of the two approaches, which showing the try-catch is slower when exception caught, why? see my answer below — zhangxaochen 12 mins ago
Ideas?
17:34
I suck at editing online
def ind(e, L):
    L.append(e)
    index = L.index(e)
    L.pop()
    return index
@vaultah Obviously, you wouldn't want to do this if L was being used by a different thread, and also it will have some bad behavior for certain lengths of L. Avoids setting up a try/accept, though. I can't be bothered to time it or think about it any more right now, so if you like it, it's all yours.
Also, I guess del L[-1] might be faster than L.pop()
cabbage?
cabbage
cabbage
Someone's baking brownies...
18:30
I ❤️‍ spam: ">>Your Guardian Angel 🔮<< >>is trying to come into contact [👨]<< >>with you<<"
19:19
Block party down on the street. Their music is loud. I'm thinking of calling 311 to complain. But too lazy.
Welcome to old age.
19:41
thats why we need robots
(this sentence works as an excuse for almost everything)
20:02
just wanna say thank you to the python chat room..... i was awarded the best programmer in my class
6
i still have a long way to go as a programmer but you guys have been really helpful
20:15
Well done @danidee
so I heard this SO chat is awesome
*this SO chat thing
Popping in real quick to share this video:
Ok bye
 
2 hours later…
22:39
hey guys
what would you rather have
iterator.next() or next(iterator) ?
Context?
using generators
I just wondered if theres some global usage of one over the other
next(iterator) seems to be the way of the future...
thank you
any special reason?
Also, what do you think about using 2 generators as of handling a stream of data
In Python 2, generators had .next methods. In Python 3 they have .__next__ methods. iterator.__next__() is obviously not the usual done thing.
I don't understand your next question. I use chained generators all the time...
23:03
Ok. I want to parse a stream of bits, they are strings of zeros and ones. my stream could be a very big stream so I use a generator that yields 0x100 bits each time.
I take the chunk and start parsing it, I have a huffman tree and each bit is either a left or a right turn in my tree, until I get to a leaf. I might find myself reaching the end of the chunk before I got to a leaf, this will require a new chunk. I thought about the possibility of using yield to do something like that. It's not optimal so I'll probably do something else, but just out of curiosity, is it something that people do
Also, next() can return a default if the iterator raised StopIteration.
Like len(object) versus calling object.__len__(), use the standard library API, not the special methods (which are there for the API to call).
23:49
Is there anyway I can save some part of the history in an iPython session and automatically include all dependencies for that code as well ? ( imports and functions calls etc... )

« first day (1799 days earlier)      last day (3374 days later) »