« first day (1754 days earlier)      last day (3201 days later) » 

12:28 AM
Woot.
 
Good supper, eh? My wife made some good stuff, including some sort of quasi-Paleo jammy dodgers for dessert.
If you don't like classes for namespaces, you're going to love this
 
I'm scraping a page auto generated by Lotus Notes FML
 
Is there anything good about Lotus Notes?
 
I love Jammy Dodgers
Local store just started carrying them cause so many British people are moving/visiting here
 
@PatrickMaupin I think that would've been an appropriate question even 15 years ago
 
12:38 AM
What are you talking about? I was asking it 22 years ago...
 
hahaha
 
@PatrickMaupin I'm trying to think of when I should have used this paradigm. And I can't think of such a time. I think I would have used a plain old dict or declare a global. And I've never had to declare a global before.
 
I don't use it either. But I do use classes for namespaces for constants.
 
12:54 AM
Yeah, for inheritance, right?
 
Even when not inheriting some times. Not sure if I have a public example; let me think for a minute.
 
I work in a pretty big code base, I've seen some bad stuff. I've seen hokey stuff too. I don't think I've seen anyone use a class just for a namespace. But we do use lots of instances as just plain-old namespaces. And then we can give them __slots__, and properties, and even functions.
And I think that is pretty useful.
 
__slots__? So you store your constants using self.xxx = ?
 
Yeah, we call them config files.
It's all Python.
 
But if you don't bother with the instance, then you only have to do xxx = ...
 
1:17 AM
class Thing:
    __slots__ = 'name', 'config1', 'config2', 'category'
    def __init__(self, name, config1, config2):
         self.name, self.config1, self.config2 = name, config1, config2

class Things:
    __slots__ = 'category', 'things'
    def __init__(self, category, things):
        self.category = category
        self.things = {thing.name: thing for thing in things}
        for thing in things: thing.category = category

Things('category 1', [
  Thing('name1', 'config1.1', 'config2.1'),
@PatrickMaupin And I stick the objects in a different module.
 
How is that better than a named tuple?
 
A-ha, you can't dynamically assign the category with a named tuple
and mutability isn't really a problem
 
Ah, missed that for loop.
 
And we have lots of these configs.
 
My typical use-case (without inheritance) isn't a config file. It's just tidying up modules, really. If you imagine something that lends itself to procedural programming, you might have a call-graph of 5 or 10 small functions in a module, and you might have some global variables that are each only used by one of those functions. (Perhaps it's global because its computation was expensive.)
You could do like a java programmer and have 10 20-line modules that follow your call graph, or you could let everything hang out in the global namespace, or you could make it much clearer what goes together by grouping them together, and just using classmethod or staticmethod functions.
Obviously, you could instantiate everything, too, but honestly, why bother?
@AaronHall If you have a lot of those, why wouldn't you use a DSL like YAML?
Actually, I hate YAML itself, but some of the ideas are good. I did my own called RSON. Here is an example of a stylesheet
 
1:29 AM
We have our reason. But the reason seems to be obsolescing.
 
In general, I have nothing against config in Python. But when you start using __slots__ for static typing, it tells me that maybe some of your users shouldn't be touching Python...
 
I could see us doing it in YAML, but we get an entire entry on one line which is easy on review and maintenance. I wonder if we tried to do the same with YAML what it would look like...
Maybe some of our users shouldn't be touching Python, but we like it to be idiot proof.
And I think that's another advantage over YAML.
We've been tightening up who does what, but configs is one of the first things new people seem to get handed.
 
"an entire entry on one line" -- did you look at the stylesheet I pointed out? Or other files in that directory? (BTW, that's not YAML -- that's RSON)
 
I looked at it, you're right, you can do it.
 
YAML may be better now, but the grammar was originally so atrocious that no two YAML parsers worked the same... (Of course, there is AFAIK only one RSON parser, so that's not really a fair comparison :)
RBRB -- GTG pick up my electric car from the charging station -- the city subsidizes my miniscule exercise efforts by giving my car an all-you-can-eat electric buffet for $50/year, with the nearest feeding trough a mere 0.4 mi from my house...
 
1:56 AM
Some of our configs are just lists of dicts.
I wrote unittests to validate the inputs.
But an object is self-documenting, and we can mix positional args and kwargs.
 
2:10 AM
I'm sure it works, but I'd get tired of typing quotes.
 
Most users are just copying and pasting, or editing preexisting lines.
 
2:29 AM
Hello, Meaty!
 
Hello! :)
Guys, has anyone of you maybe used windows10?
I can't run python scripts on it :S
 
Meaty! Read the rules! :D I don't know anything about running Python on Windows 10. :P
 
Which rules, sorry if I'm breaking any. :O
 
Top right, link, preceded by the words "Room rules:"
 
Info? If it's multiple posting, sorry, it's just kind of sickness of mine, I'll try to reduce it as much as possible :)
Okay, I'll read! :)
Oh, I broke rule number two with the question, right?
 
Thanks man! :)
 
not that your going to like the answers (which are basically "It just came out and stuff hasn't been adapted")
I've been re-writing C#/VB.NET ASP.net stuff all week just cause of this - so its an issue across the board (hence why most haven't updated yet).
 
Yeah, a little dissapointing :P
I'll just have to wait for it to be fixed I guess. :)
I understand. Thank you for the heads up.
 
or install a Virtual Machine
or use a cloud based one
 
I have Kali somewhere, might put it to use finally lol. :)
 
2:38 AM
Why not just wipe Windows and install Linux?
 
I don't know, I've been using Windows my whole life, it just feels like huge step and I don't even know if it's backward or forward.
 
cause I already have two Linux boxes and work requires Windows *#$&^.....stuff
yeah, stuff
let's pretend that's the word I wanted to say
 
Plus I have problems with my laptop, it was shipped with win8, so whenever I try to boot any linux, I get a bunch of text I don't have time to read as it lasts for a second or two, last thing I caught was "kernel panic".
Friend had BT5 and I've tried Kali. No luck whatsoever...
 
Add a VM so you can play around with Linux (Ubuntu takes well to VMWare I know) then you can move towards multiple boot partitions or reinstalls if you find it helpful later
 
Yeah, VM sounds good, I'll do that. :)
Well, it's 4:41 here, thank god it's holiday tomorrow here. :D
Thanks for all the help (again). Good night fellas!
 
2:42 AM
or cloud VM if you don't know how to do all the setup for VM (lots of good free ones)
 
I've spent a couple of minutes in VM, I think there should be no problems. :)
Got the basics, I mean.
 
me and windows are in a drag-out fight right now cause all I've been doing is massive reconfigures of SharePoint, ASP.net, etc: cause of course we have to update to the newest platform....the day it comes out.....instead of after its stable :P :\
 
Microsoft & co made it harder to install Linux with the whoe UEFI thing. I helped a friend install Ubuntu, took an afternoon. He had shipped back one laptop he couldn't work out the BIOS/CMOS whatever... his face was red before I finally got past it.
I didn't realize it, but everyone else at the meetup thought he was mad at me.
 
Quick question: If I know the size of an array I'm going to create, is it worth initializing the array with this size instead of using array.append()?
 
A fishy fish. I wonder where that fish had gone.
 
2:49 AM
I know the array is going to be, say, an array of 1,000 integers (though I don't know which integers yet)
Is it worth saying something like array = [0]*1000
before adding stuff to it?
 
a list isn't an array. Well it is. it's an array of pointers. But it's not the array you get with numpy or array.array.
 
Oh, sorry, yeah. I often use them interchangeably, but don't mean to.
Anyway, replace "array" in my question with "list"
so does it actually save anything or not?
 
No. you initialize it empty and append items to it. If you have an iterable, you can use extend.
 
ah, cool. Thanks. :v
A side-question: Why is it, in Python, appending to a list is no slower than initializing it and referencing each spot explicitly?
 
though at 1000 entries with calculations (depending on the calculations) that might be better as a numpy array
 
2:54 AM
(It's actually going to be a list of some other objects, not integers—integers was just easier for the sake of the question)
 
It's not quite as fast, depending on what you're doing, but Python preallocates list entries using a pretty smart algorithm.
Sometimes I preallocate lists, but that's mainly when I'm rearranging stuff with slice magic. But when I do that, I usually do something like mynewlist = len(myoldlist) * [None] e.g. I'll deliberately use a value that will throw an exception if I screw up and try to do math or string stuff with it later.
Basically any time you need random access during the actual construction of the list. Otherwise, append() or extend() are usually fine.
 
Ah! Excellent. I was actually considering doing exactly that—but I think saving access 'til the end and using append() will be easier :D
Thanks much, @PatrickMaupin !
 
I dunno if this is a good way to do random access stuff, but you could make a list of tuples of (index, value), and then run a list comp over a a sorted version of the list of tuples to get the values in the right order
 
3:26 AM
@RobertGrant Yeah, in some cases I think that's the right answer. But would you do it here?
 
It's 5:30am - I can't tell, sorry :) Will try and think about it when more awake :)
 
3:44 AM
Well, by the time you figure it out, I'll be more asleep :) Rhubarb and g'nite/g'day.
 
4:17 AM
Good night guys, great spending time with you.
 
Cabbage :-)
 
I think tonight I had my highest score on a new answer/question. +8. Incredibly lucky me.
Seriously, never happens to me.
 
@AmagicalFishy appending to the list is of course slower, but it is not slower by more than a constant factor, and thus usually it does not matter.
now, if you insert in any other place in the list beside the end, then that's really going to suck in performance
 
Argh. Installed sqlalchemy-continuum. Now getting sqlalchemy.exc.UnboundExecutionError: This session is not bound to a single Engine or Connection, and no context was provided to locate a binding when accessing a model that's got __versioned__
 
4:47 AM
Hm, but only for some of them. Interesting.
 
5:01 AM
you sure you don't have 2 metadatas or so
aah
hmmm...
 
Nah
But I haven't done anything to link continuum to the pyramid DBSession, so maybe it just picks it up by accident sometimes, but basically it isn't configured right?
 
5:29 AM
Antti, congratulations, looks like you've just hit the top 1% of all time.
That rep cutoff is about 25,600.
 
6:23 AM
@RobertGrant hmmmm also...
 
7:02 AM
@AnttiHaapala also....:)
 
7:46 AM
I posted a question, and someone made suggested edits that just added bold to certain keywords. Stupid, or worth approving?
 
8:05 AM
I decided: stupid and rejected it
 
Yeah.... un-necessary edit
 
8:26 AM
Thanks!
 
Makes a change to see bolding though - it's normally inserting unnecessary inline code blocks
 
@AaronHall I know you've mentioned that before, but I don't get it. e.g. Antti is #2442 of all time. According to the side bar, there are 4517438 users - putting him in top 0.05%, or if you only count those tracked in leagues (200+ rep), there are 576067, putting him top 0.4%. I think you might be doing yourself down if you want to track your exclusive club membership rating!
@RobertGrant A bold decision!
cbg everyone
 
8:43 AM
cbg :)
 
How's life, Jon?
 
and my rep change says "top 0.13 this year"
hmm
i am close to getting bronze badge in
@AvinashRaj beware :P
 
9:07 AM
@IntrepidBrit check out openproject; it's much nicer looking than redmine. Dunno about features, but it is an active fork.
 
9:22 AM
@AnttiHaapala Bronze in regex is like a badge in masochism ;)
 
10:04 AM
Hi !! I'm new to Python, actually Jython and I'm struggling with the setting up of my project. Is there some kind of tool like Make or And for Python?
 
10:19 AM
Ah right, I get it. I had added up a cumulative table, so wrong, wrong, wrong :( Apologies @AaronHall / @Antti. So the denominator for the all time tables is 245516 (200+ all time) and for the year tables is either the same or 235379 (total users in the year rank table) - making sense of the numbers.
Yes, it is coffee break time and I am indeed obsessive about trivial stats
Years of ranting at newspapers about the numbers they quote will do that to you :(
Makes for strange statistics. But hey ho...
 
@Kevin also: parents who try and reason with young kids. And who use a passive-aggressive phony "please" after telling their kids to do something. Not like me. I think I'll be a terrible parent! sets self on the road to ideal parenting
 
user559633
@CedricH. make just runs a script in a specific format. there's setup.py and other tools for distribution of python.
 
10:38 AM
@RobertGrant chuckles to self
 
@JRichardSnape stop that please
 
who, me? what? studies alternate top corners of room, looking innocent
 
@AnttiHaapala I'm ready to welcome you...
 
user559633
phrasing
 
11:03 AM
Gaaaaah, Java upgrade breaks all the things, ergghhh. Give me sanctuary, sweet python.
 
Thankfully no Python upgrade has ever broken anything significant :)
 
0
Q: How are room owners chosen in SOPYTHON?

user 5061I know there is a process when it comes to stackoverflow moderator elections, with votes, questions, and so on, ensuring a person that knows well the rules and has the qualifications for the job is elected. There are as well some requirements like badges and the elections last several days. e.g....

 
Lol I like how the person's name is legible
 
yeah - anonymous but not too anonymous, right. We are all anonymous, but some are more anonymous than others.
 
wwwwwwwwwwat?
 
11:10 AM
@JonClements don't worry it's not you :)
 
Room owner? I didn't vote for you!
 
I am guessing there has been some behind the scenes interaction here as I recall that user asking to speak to RO's / email , so I'm going to step back here, I think.
At least until someone says "have at it"
 
What do you mean "not too anonymous?
 
@user5061 wb "John White" - what brings you here this time and your meta post?
 
cabbage, chaps. WFH today - my stuff (shipped May 5) arrives from the States today
 
11:11 AM
@user5061 You can clearly make out the name of the person saying ***kers if you know the room regulars here
 
@JRichardSnape It was not my intention, and it's not visible in my opinion..
anyway i can edit the image even mroe.
 
You need to be a bit more assiduous with your blurry tool if you really want to make it invisible.
:24898166 true - I didn't even think of that.
 
heya @jonrsharpe good to see you again - you should pop in more often under normal circumstance and all that
 
Also I can see that the swearword is {word}ers - a reference to @AnttiHaapala's least favourite way of templating. The diabolical cunning of it all.
 
@JonClements I just enjoy the drama ;o)
 
11:14 AM
@RobertGrant ?
 
Don't you rather use XML than moustaches?
 
@jonrsharpe easier when you're not in the midst of it I guess :p
 
@JonClements oh, snap
 
Pfft - this room's not a democracy - no way drama can do anything
 
@JRichardSnape Fixed :) Now it is 100% anonymous.
 
11:17 AM
@user5061 did you mean to reveal you downvoted that answer, though?
 
@MartijnPieters Really?....
@MartijnPieters No actually i meant to learn based on chat criteria a room owner is chosen.
 
@user5061 but why drag in a comment with language you don't like?
What does that have to do with how room owners are chosen? It feels like you are on a mission to smear, not to learn, here.
 
@user5061 If you actually want to know about chat room ownership that last paragraph is at best redundant and at worst outright obscuring the issue
 
So you suggest i should removing it? I thought it was relevant. As in elections where people comment under people's posts taht want to be elected.
I ll remove it if you think i should
I have seen events in those comments, like the one i mention in my question.
This why i post it as well.
@JonClements Oh hi john clements :) I missed your message.
 
The current (?) room owner's actions have absolutely no relevance to the process of how room owners are chosen. Especially not in a meta post like that.
 
11:25 AM
Yes, you should absolutely remove that. If there was an actual election, then perhaps such concerns are valid and you can directly ask a candidate about that.
But your question is not about an ongoing election. You are asking about the process. By adding that paragraph, I get the feeling you are questioning the appointment of a room owner in this room, which is a different subject altogether from the rest of your post.
 
@MartijnPieters maybe if gets generalized it could live
 
@user5061 and note that, in an election, it is actually addressed to the person in question, not just a vague Meta post hinting at it. If your question is simply "How are chat room owners selected?" then ask that.
 
@rene: I removed my comment, by the way. your answer does answer the question...
 
@rene yes, without that paragraph it is general enough. It could be made more general by removing the reference to a specific room.
 
Agree with that
 
11:29 AM
@user5061: and given your past interactions with the room owners here, there is grounds to believe that your motivation to include that paragraph was personal, yes.
 
That paragraph was removed.
 
As long as this room is mentioned in the meta post a room-owner should answer it. Feel free to grab my post as a basis. If the post doesn't focus on a specific room I'll undelete my answer.
 
@rene your answer is as good as any, it applies to the process for this room too.
 
Tnx, but I rather keep it as is.
 
Well that was a fun interlude
 
11:40 AM
hahahaha sure was :)
 
ROs are chosen like this: on the private RO message board, an RO proposes a community member for room ownership. There is a brief 1-2 day period of discussion, and if general consensus is achieved, we extend an offer to the user.
We have no formal process for de-ownering a user. AFAIK, the only times we have revoked RO status is when 1) the RO voluntarily stepped down and 2) the RO had not been active for many months.
 
@Kevin I see.. thanks mate. :)
 
If this seems like a less than ideal system, we can discuss alternatives in the room meeting on August 19th at 15:00 UTC.
 
What about the criteria that ROs use to select a new RO?
By "we" you mean ROs or anyone?
 
Anyone :-) the meeting is open to the public.
 
11:49 AM
morning everyone
 
No formal lists of prerequisite qualities exist, but most discussion revolves around "is the user frequently active in here? Do they actually know Python? How likely are they to go crazy and de-RO everyone but themselves?"
 
Wow I'm already 1/3
 
@Kevin: sounds like an answer for the Meta post too. :-)
 
If all else fails, you can take solace in this fact: moderators can and have revoked room ownership for users that have been especially naughty. So this will never be an entirely rudderless ship ;-)
 
Yeah, i noticed :)
 
11:52 AM
@MartijnPieters Yeah, I'll compose one if I get a minute
 
user559633
As "fun" (tedious) as chatroom drama is, I feel like we've been overly patient in this specific instance.
 
Drama? DRAMA? YOU'RE TEARING ME APART, TRISTAN
4
 
user559633
No, but seriously, this was handled outside of the room and it's settled.
 
cbg o/
 
user559633
Greetings
 
12:12 PM
Interesting, when I call GetKeyboardState on this machine, it returns the state the keyboard was in when the script started, but doesn't update after that.
I wonder if that's some kind of BigCorp anti-keylogging measure.
This is troublesome. Whenever I see a post asking about creating globally accessible keyboard shortcuts, I always suggest GetKeyboardState, but now I see that it doesn't always work.
 
The intro to this movie review is really funny, but I have no clue why it is
 
user559633
@Kevin Can you do a SSCCE? I'll run it here
 
Let's see if I can whip something up.
import win32api
import win32con
import time
for i in range(30):    #loop for three seconds
    key_states = win32api.GetKeyboardState()
    if ord(key_states[win32con.VK_RETURN]) & 0x80:
        print "The enter key is currently down."
    else:
        print "The enter key is currently up."
    time.sleep(0.1)
 
user559633
Oh, win api, sorry :/
 
It continually prints "The enter key is currently down." if I hold the key long enough so that it's depressed when the process fully spins up, even if I let go afterwards. And it prints "up" if I give the key a quick tap to start the script, and let go before it starts.
I'm pretty sure it's not my bitwise arithmetic that's the problem, because it prints "0" and "128" respectively if I merely print the ordinal value of the list element.
Same behavior, albeit with uglier output.
I'm 90% this is BigCorp's fault.
I wonder what dark magic they invoked to change the behavior of the windows API like that.
 
12:26 PM
How easy is it for me to test?
Do I need to install the win32 stuff, or does it come with python?
 
Not with any install I'm aware of, no
 
Seems it does not
Also that's Python 2, and I'm a 3-only zone
 
I think you can get a wheel off of the gohlke site. Pretty sure "pywin32" is the actual name of the package. Maybe.
The licenses in the pywin and win32 folders in python/lib/site-packages both say they were written by Mark Hammond, so there's certainly some kind of affiliation.
I guess this is as good a time as any to figure out how to install wheel files.
 
Haha I was about to ask
Isn't it just a pip thing?
 
> Wheel files can be installed with a newer pip from github.com/pypa/pip or with wheel’s own command line utility.
Oh, GetKeyboardState returns a string in 2.7 and a list of ints in 3.x. What fun.
Revised 3.X script, for the record:
import win32api
import win32con
import time
for i in range(30):    #loop for three seconds
    key_states = win32api.GetKeyboardState()
    if key_states[win32con.VK_RETURN] & 0x80:
        print("The enter key is currently down.")
    else:
        print("The enter key is currently up.")
    time.sleep(0.1)
 
12:43 PM
Tried installing the 64bit one and it didn't work; just getting the 32
 
Mine gave me a syntax error when I installed, but it installed anyway, because the error is in some unimportant sample file.
Don't forget the post-install step: "Requires to run python.exe Scripts\pywin32_postinstall.py -install from an elevated command prompt. "
 
meow?
 
Bleh, that install step broke
Oh no it works, sorry
So I run it (finally, sorry) and it just says the enter key is down, even if I just tap it to run the script
And if I tap it really fast it says it's up. So yeah - that's the same as you saw.
Maybe the shell just gives its state to the script on start and the script refers to that frozen state
 
I'll have to check the known working code I have on my home computer. Maybe there's some important step I'm forgetting.
Alternatively, both my work computer and your computer have the same key detection prevention package, and my home computer doesn't.
 
fetches tinfoil hat from Faraday cage
 
12:51 PM
Hey, Robert, btw, after I showed you that code snippet about using x * [None] to initialize a list, I went to bed and immediately realized that I didn't actually need to do that in that instance, since one of the things I was putting in half the list was a constant anyway -- still preallocates, but with useful value now...
 
But yes - could be McAfee
@PatrickMaupin ah :)
 
That's what happens when I build a solution step-by-step and don't go back and optimize.
Cbg
 
Cbg
 
cbg @Patrick and @wonder
 
12:53 PM
:)
 
cbg, Jon
 
bah... trying to use paypal
the interface has changed a lot in ~12 years
 
Yeah, and it's specifically designed to make it difficult to use your credit card rather than your bank account.
 

« first day (1754 days earlier)      last day (3201 days later) »