« first day (1415 days earlier)      last day (3523 days later) » 

12:44 AM
I would just like to point out to @davidism and @JonClements that when I do subprocess.check_output with the arguments as an array I cannot get it to run. Only if I run it as a string.
 
Interesting. What platform, and Python 2 or 3?
 
 
1 hour later…
1:59 AM
Howdy, interested in learning Python just wondering if anybody has read Learning Python 5th Edition by O'Reilly that could tell me if it's a good book to start with
 
2:09 AM
@Datsik definitely. I couldn't recommend a better one.
 
Cool thanks
 
 
2 hours later…
3:49 AM
Python C-API Question: Is tp_methods only for C-extensions, or are subclasses created in python accessible there too?
Between the language used in PyMemberDef, tp_dict, etc. I'm confused.
...as they don't explain this "different mechanism".
 
4:11 AM
Anyone up?
Hey Swordy
Can you help me out?
 
Help with what?
 
Class variables
I've got a class where I declare: self.Window.size = (size)
I've got a statement after that line that prints the size. It works out fine
 
ask your question , someone might answer you once theyre online
 
Alright, I'll write it out in full then:
self.Window.size = (400,400)
print(self.Window.size) > > "400,400"
 
Or consider asking on SO . you will get an answer in no time
 
4:17 AM
print(self.Window.size[0]) > > "400"
BUT. When I write in another method of the class: X,Y = self.Window.size[0], self.Window.size[1], I get the following:
NameError: global name 'size' is not defined
It's accessible to all methods, should not be undefined.
 
did u specify it as the argument in ur method?
 
What do you mean?
I've assigned the variable to "self". It should be accessible from all methods within the class.
I don't need to pass it as an argument. .
 
I'm not a pro in this , got very little experience with classes ..
 
Oh. Essentially. Anything you assign to "self". EG: self.A = B, should be visible to any method(function basically) within a class.
Ah I fixed it!
 
what was the probleM?
 
4:27 AM
Here was the problem:
X,Y = self.Window.size[0], self.Window.size[1]
!=
X,Y = self.Window.size[0], self,Window.size[1]
Do you see the mistake?
 
,
 
ye
 
Well , in future you should consider pasting the code that gives you problems
 
I guess. It was difficult to spot the mistake. Especially with the font I have in IDLE
 
4:42 AM
Are you really up Jon?
 
Just checking on a couple of things to see how busy I'm going to be today
@Owatch how've you been?
 
Well. Busy as well. I've started courses now
 
How you finding it so far?
 
Depressing.
 
umm... in what way?
 
4:51 AM
The general population of students are highly uneducated, or mentally disabled.
If you don't know, I'm currently in a local Community College. I had to drop my choice University since I couldn't afford it.
 
That's the probably with education as it doesn't come cheap...
So... while you can't go where you'd probably be best off, you're basically stuck with some idiots that might drag you down? Is that what you're saying?
 
I'm hoping to move to France next semester.
I'm stuck with people who make me feel worthless. It's not a nice thing to say, but it's why classes are disappointing for me. I'm not taking anything associated with my interests, and the college doesn't offer anything similar. I'm currently in general education courses (English, History), stuff I did in High school I was hoping I could move away from now.
 
Do you have to do college - can't you get a trainee job somewhere?
 
b'\xff\xfes\x00p\x00\xc4\x00m\x00'.decode('utf-16') What does the 'b' in the beginning mean?
 
@Datsik means its bytes
 
4:59 AM
oh ok thanks
Is that normally used?
 
I take it you're using Python 3.x?
 
I'm waiting for job interviews at the moment. Nothing good. I've only got a highschool diploma. But I'm hoping to fill in the rest of my weeks with work.
 
2.7
Reading Learning Python 5th Edition, I'm at a part where he's talking about stuff like file = open('unidata.txt', 'w', encoding='utf-8') but trying to use the encoding flag gives me an error I'm assuming because I'm on 2.7
 
@Datsik not normally required in 2.7... but it's just an explicit indicator that the string is a raw list of bytes... (ie - not text with some encoding)
 
If things go my way, I'll have saved enough for a ticket to France by the end of this semester. I was born there, and have a French mother. I'm hoping I can attend a better school for cheaper. I'll be staying with friends if I do.
 
5:02 AM
@Datsik in 2.7 - you'd have to use io.open
 
Thanks
One last question for now-
D = ['1', '2', '3', '4', '5']
D.join()
''.join(D)
 
(note the stuff at the top about bytes/strs/unicode) between the python versions
 
How come I'm unable to just do D.join?
 
@Datsik str.join works only on strings.... ''.join(map(str, D)) - assuming you're after '12345'
 
Ah gotcha
Back to reading, I'm sure I'll be back :)
 
5:05 AM
rbrb for now
@Datsik we have some common questions/gotchas/other bits on our site: sopython.com - check it out at some point
@Owatch by the sounds of it, you'd benefit more from work experience than just doing more English/History
 
I guess. .
In other news, I found out my py2app app was broken
If it interests you, I've applied for a cosmetics job at a pharma/drug store
Maybe I'll be our resident skin care expert for chat room 6.
 
Well, modern geeks, pretty need skin care and caffeine pills... we rarely see daylight :)
 
What's a "daylight"? Can I buy one?
 
@Zacrath not sure... I've only heard rumours... might be worth googling...
 
No. But I can offer you Pond's(C) Luminous Finish BB Cream . . . .
(R), (TM)
 
5:14 AM
LOL
 
Does .split() always default to white space?
 
@Datsik try help(str.join) in your interpreter :)
 
Thank you I tried help(''.split) and nothing came up, wasn't sure what else to type haha
and I typo'd it to '.split **
 
errr... I meant help(str.split) obviously
cough
 
Yeah :P
How long have you been using Python?
 
5:21 AM
~2001 I think
 
Damn
 
@Datsik or the docs for Python are generally always good: docs.python.org/3/library/stdtypes.html#str
 
I was just reading about Django, I normally write in JS via Node for my apps, but Python has been something I've always wanted to learn, but I can't really use Django if I don't understand Python (even in its simplest form)
 
I'm off. Goodnight people
 
@Owatch take care
@Datsik that's a sensible attitude to take - most people seem to "learn" Django first by a bit of copy/paste then get stuck with actually doing stuff that doesn't have a django supplied function.
 
5:25 AM
Yeah, I kinda did that with Javascript / Node I started playing with Node and then as my apps started getting bigger and I wanted to do more I started to have to learn JS, I figure I won't make the same mistake twice haha
Been a while since I've done much programming though, I used to mod on the Javascript chat, I can honestly say it's less hostile in here, though I don't know if the same people are still in there like Zirak and what not
Anyways back to reading thanks
 
Nope... I think Zirak was before my time... we're a team that had our own Python room.... then we merged back into the original room (kinda of assimilated it)
We like to think we're welcoming and helpful (certainly not as many complaints as other rooms anyway :p)
Enjoy your reading...
 
!!>
 
5:42 AM
list(set(['yy', 'cc', 'aa', 'xx', 'dd', 'aa'])) what would the point of this be? Why not just ['yy','cc','so on so forth']
 
You're aware of what a set is?
 
kinda sorta
not really
 
It's something that contains unique hashable elements
 
unordered unique elements is all i really understand
 
Well... it doesn't make much sense using a literal to feed the set as yes, you could prune it by hand if it's small... but input at run-time, you couldn't do that
text = raw_input('Enter some text: ')
print 'Your unique letters were:', ''.join(sorted(set(text)))
heya @dgun
 
5:58 AM
Seriously it's 2014 why can't we just scan books into our brains
 
Just ask "the operator" to load the program while you're hacking the Matrix
 
hahaha
Using Django is it possible to say run shell commands?
 
Of course it is...
 
Django views can do whatever Python can do.
 
Cool juuuuuuuust wondering
 
6:05 AM
But don't use os.system, use the subprocess module.
 
The thing I'm gonna have to really work at I think will be all the comprehensions
 
@Datsik they're remarkably powerful, and fairly simple to grok (until you get into some nested fors and nested generators and other stuff)... but they are very, very useful
 
6:35 AM
I must have missed something what does triple quotes mean?
 
multiline string literals
 
gotcha
Is that just in the vm
 
@Datsik might be worth learning how to search the documentation :) - docs.python.org/2/reference/…
 
good idea instead of being a help vampire
 
Well... if you're unsure of what terms to search for - feel free toask, but a lot of these are quite easily found...
 
6:45 AM
docs.python.org/2/search.html?q=print can't seem to find print, just wondering what end='' does
I think it's kind of explanatory now that I look at it in a different light
 
@Datsik you won't in the 2.x docs
that's an argument to Python 3.x's print function
If you're doing the book you're doing - you're better off installing 3.4
 
It just appends whatever to the end of the print I guess?
I got 3.3 installed now
 
Ahhh okay
It does, yes :)
The default is end='\n'
 
the most confusing thing so far is all the [:] [1:] [3:3]
 
@Datsik term for that is slice notation
 
6:49 AM
thanks
Dictionaries much different from Objects in JS?
 
They only support key syntax. d['key'] = value
 
cbg @davidism
 
cbg
Instead of sleep, I watched most of the second season of Parks and Recreation.
It was worth it.
The only reason I stopped was that Netflix stopped working. I think it was a sign.
 
@davidism maybe Netflix are watching you - you just think you are watching Netflix? :p
 
terrifying, so that's how their recommendation engine works now...
 
7:06 AM
Well... there recommendation engine has to work in some way...
"We've noticed you've watched a load of 18 rated, sci-fi/horror films... - we suggest My Little Pony"
 
Oh, you got that recommendation too? Hmm...
Maybe if we watch a bunch of cartoons, we'll get recommended the 18 rated stuff.
 
That'd be great for kids... you've watched all the Disney films... - how about Hostel/Saw and Pulp Fiction?
 
"Mommy, do you want to play a game?"
 
"Dammit billy I thought I told you not to come out when mommys working"
 
7:12 AM
@Datsik fan of dubstep by any chance?
 
Yeah :D, more so just general electronic, nothing specific
 
"What" ain't no country I've ever heard of. They speak English in What?
 
Could you tell by the Datsik name / Monstercat logo? lol
 
You're a very dedicated fan.
 
Haha
 
7:15 AM
 
@David so that's why fedex are unreliable... don't train their pilots very well on landings...
 
haha
 
They do provide a convenient bridge for yak-driven carts though.
You know what bothers me for no reason? The logo is wrong, it doesn't have the arrow in "Ex".
 
open(r'C:\Python33\Lib\pdb.py').readline()what's r in this context, google not helping
 
@Datsik it says on the page I've already linked you to regarding multi line strings
 
7:21 AM
Dammit let me find it
 
(well, I linked you to the Python 2.x page, but it still means the same in 3.x)
 
see when I search things I get like a huge list and I'm not sure what to click on
 
cbg()
hi to monstercats
 
The important part being: Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters
 
8:25 AM
bbl
 
8:37 AM
Cbg :)
@PeterVaro Streamus seems pretty awesome, if you could specify when a song starts and ends that would be perfect IMO as some acoustic songs I like e.g. have little intros and outros I'd rather not listen to
 
@IanClark then I guess you should send a feedback to the developer
that guy seems very friendly -- according to the streamus' website
 
:) yeh will do, +1 for the link, TY
 
np -- it was a great discovery, I'm glad someone else thinks it is useful too
 
:)
Oh, already in pipeline github.com/MeoMix/Streamus/issues/4
 
8:54 AM
sweet :P
 
9:39 AM
cbg
 
10:10 AM
 
10:57 AM
CBG
 
11:56 AM
Running gunicorn from mac, have virtualenv running... getting no module named flask.
 
Quick question. Is there a better way to do something like this:

try:
entire program here
except:
display dialog box to user
write exception info, globals and event log to disk
exit

So that throughout the entire program when fatal exception is raised, it doesn't just crash?
 
That's what I do when I start off any program
But I find it's often best to try/catch around areas you think are likely to fail. For example, if I'm going to write a file to disk, it's entirely possible your user may run out of storage space and the write will fail
This is something the user can do something about, and it's useful for them to know why it has failed, so that they can do something about it
 
12:23 PM
I catch all errors which can be recovered from, but for others I'm currently using this setup rather than having every other line of code in their own try/except statement
But it seems like a poorly written hack to me :)
 
1:00 PM
Well, 1) It's better than NOTHING at all
2) As I said, ones that are likely to fail. And if you can't recover from it, what else are you going to do about it?
 
1:32 PM
cbg
 
1:44 PM
cbg
 
1:55 PM
if I db.ReferenceProperty(MyPolyModel) can an instance of this property be a child of MyPolyModel?
I would assume so, since the children have class `[u'MyPolyModel',u'MyChild'], but would like to check..
 
Does anyone know a good way to remove duplicate semicolons in python? I am currently looping through the characters of the strings. I couldn't seem to think of a good regex...
 
Can you give an example of what you have/want?
like "foo;;bar" want "foo;bar"?
 
"this is content;;this is some other content;;This is more content;"
This should be replaced with
"this is content;this is some other content;This is more content;"
 
What's wrong with string.replace(';;',';')?
 
I don't know.. :-|
 
2:09 PM
:)
Should be fine if that's all you're doing
 
Oh man. I am in bad shape this morning apparently.
 
Haha, we all have those mornings..
 
Now what if it is 2 or more semi colons?
Would this work [;]{2,}
 
Hmm. I mean, you could keep applying the above until nothing is changed. The return value is the new string, not C-style 'number of changes', so you'd have to compare. But a regex would seem more suitable.
 
ok
 
2:16 PM
Um, I'm no expert at regex, I'm not sure how to match them at arbitrary positions (and arbitrary many)
 
@Johnston try this
import re
a1 = "this is content;;this is some other content;;This is more content;"

a2 = re.sub(";;",";",a1)
print a2
 
2:59 PM
what is the diff between python-docx-0.7.4 and docx 0.2.4 ?? 0.7.4 is the latest version so should I go with it? importing is a bit different as we require a list comprehension for the newer version.
 
OK guys. Thanks to the help of @JonClements and @davidism I made a swift online repl aka swift fiddle. skipcasts.com/repl. It's super beta. But let me know what you think.
 
@Johnston looks like a good base :)
 
cbg guys
 
@JonClements I can't believe it works. But thank you so much for your help
 
@Johnston as long as swift is as secure as it claims... I couldn't delete the file system or read your password files, or DOS your machine with it could I? :p
 
3:11 PM
I know
I don't know. We shall find out
Now if only I could figure out how to limit the time of running processes.
What happens when someone runs:

for a in 1..<1000000 {
println(a)
}
I mean that's not the worst but it could get bad
 
What happens when everyone in this thread now tries that to see? :p
 
I'll hear my old mac sitting next to me start to melt.
 
@Johnston apply some sort of ulimits to the process launched :)
 
@JonClements What do you mean?
 
Oh, great. OP uses a code from my answer to wrap it into a package, adds that link to his own answer and accepts it. What should I do?
0
A: How to list available tests with python?

xliivI found some time and used code by: @vaultah wrapping it into python package. The tool is: https://pypi.python.org/pypi/utl/1.0.0

 
3:16 PM
ulimit -t 60;
 
Technically the answer is correct but it's a link-only answer
 
@Johnston use whatever tools your OS has to limit either run time, max memory, max cpu usage etc...
 
O. I see. I'll give it a try. That's a good idea
 
@vaultah Weird that he credited you on SO but not in the repo or package...
 
python documentation is actually very bad
right now tried to look into documentation about if ZipFile is passed a file-like object, if it is closed on ZipFile.close()
ofc the docs did not say anything, needed to check the source.
 
3:26 PM
Wow. I don't know what actually happened but it's down already
I am gonna need another solution.
 
why are there so many dumb people
 
Because some idiot called Columbus got on a boat and sailed away from Britian.
 
@vaultah what a dumb thing to do. I like how the MIT license isn't even filled out, and it says AUTHOR <that guy> without mentioning you
 
Well, he changed the code a little..
 
But now it basically reads: "I wanted to create a package, look I already had a name picked out, but don't know how to code, but vaultah's answer solved that problem."
 
3:46 PM
PHP is a hose, you usually plug one end into a car exhaust, and the other you stick in through a window and then you sit in the car and turn the engine on.
 
@Ffisegydd :D
 
@vaultah Bah, that sort of yamming nonsense annoys me.
 
4:01 PM
What's a convenient way to do a one-time convert of a 'list-formatted string' to a Python list?

List elements have commas in, so I can't split on comma. I want to pretend `list()` exists, basically.

I have:
"[SomeElement(a,b), Another(a, b)]"

Want to interpret it as a list, not string.
I know it's a bad situation that leads to it - but as I say it's a one-time hacky fix, but needs to be programmatic.
OH! eval will do this right?
 
Hey, @MartijnPieters stole my comment answer! stackoverflow.com/a/25590331/400617 :)
Also, that question, since it was just a typo.
 
@davidism Thief!
 
4:20 PM
Oh my fair @davidism, you had me at "no attribution to vaultah's answer" — BoltClock ♦ 36 secs ago
@vaultah flagged ^^^
 
:)
 
4:42 PM
That answer is now deleted
 
I was considering converting it to a comment but I decided screw it, he'll see my comment anyway even if I delete it
 
@vaultah I just came in on the tail end of all of that - amazing.
Interestingly, the author's personal email address is in the package's source on bitbucket. Not that I'm implying anything...
 
His home address too..
http://www.baseball-excellence.com/Images/Products/FullSize/l116_youth_hardwood%201173p.jpg
 
no thanks, I'm not in the mood for baseball. I was thinking more along the lines of certain "non-mainstream" tastes in adult-themed literature and photography, conveniently delivered nonstop for your enjoyment.
 
5:07 PM
I know I can do: `if not "blah" in somestring: continue'
Is there a pythonic way to say "if any words in list in somestring:continue"
 
5:19 PM
if not [w for w in words if w in string]: continue
 
:D
nope
 
(evaluates to if not [] or if not ['a', 'b', ..., 'z'])
@AnttiHaapala nope to me?
 
@Johnston if any(word in somestring for word in list)
@OllieFord nope, nope to me, as I read incorrectly the question first
@Johnston if you have fixed set of words, and lots of strings, you'd use re module...
 
ok
Thank you! Any.. didn't know about that
 
any and all are such that they shortcircuit
they stop testing as soon as it becomes clear that the outcome is known
 
5:34 PM
Didn't know about that either, kinda neat.
I'll forget about it so often though that whenever I do use it, it'll be less readable (to me) than explicitly writing the loop :p
 
@AnttiHaapala I don't really trust people under 100k sorry. jk
 
@Johnston then ask Martijn to validate it whenever he pops into the room
 
twas a joke.
That code is pretty incredible
 
I don't understand it - docs state `any()` is functionally equivalent to:

`def any(iterable):
for element in iterable:
if element:
return True
return False`

So where is this positional 'memory' coming from?
 
5:39 PM
def get_random():
        random_id = id_generator()
        exists = Design.query.filter(Design.uuid==random_id).first()
        if not exists:
            return random_id
        else:
            return get_random()
Would this work for making "design.uuid" is unique?
 
Okay.. embarrassing q: how do you format blocks of code in chat?
 
Paste them and click fixed font
Theres a button
 
@OllieFord write many lines, then a button saying "fixed font" appears
shift-enter for newline
 
Ah okay. Missed the edit now -_-
 
@Johnston just use uuid
@Johnston from uuid module, and be done with it :d
 
5:41 PM
@AnttiHaapala I want it to be a short string that looks nice when pasted in a url.. Like the way jsfiddle does it
mysite/jklJdj3
won't that make it really long with the dashes?
 
then why not generate a sequential number
with uuid you do not need to check if it is a duplicate: it will not be.
 
I guess I could start with 300000 so it looks like people use the site?
 
@Johnston been there, done that
also I used some modulus to make the numbers appear more random :P
 
5:44 PM
I mean is that a good way to achieve that effect or do you know another way.
 
Something less round though.. "WOOHOO I'm user 300000! Wait a second..."
 
How do you do modulus
3958393
 
I mean.. how does that make it appear more random?
Doesn't that just give me the remainder ?
I could base64 the incremented number.. That'd work too right?
 
That's the same thing..
 
5:47 PM
CBG all
 
oh I see
Cool
Is there another one that doesn't do the == on the end?
 
((num * 1731920347) % 998999999) + 1000000
@Johnston thats what i used on some project. Ofc anyone can calculate what is being used but just to confuse a casual person
 
Awesome
that's very cool
 
998999999 unique values that fit in 32 bit integer, and lowest is 1000000
always fits in 9 digits
 
oh nice
 
5:58 PM
just increment num by 1 - actually we used that as the default value in a postgresql table, based on the internal sequence
so all the rows would get such an id automatically
 
@davidism I read the post on my RSS feed and answered from that; I didn't see your comment until I already had most of the answer formulated. :-P
 
6:38 PM
@AnttiHaapala oh wow that is really cool
 
7:00 PM
Anyone see any issues with this... I am getting 'int' is not callable:
def repl_save():
    from sqlalchemy import func
    def special_id(num=1):
        return ((int(num) * 1731920347) % 998999999) + 1000000
    if 'code' in request.form:
        last_design = Design.query.order_by(Design.id.desc()).first()
        if not last_design:
            uuid = special_id()
        else:
            uuid = special_id(last_design.id+1)
        design = Design.create(uuid=uuid,revision=0,code=request.form['code'])
        return uuid
    else:
        abort(404)
 
Uh, what line?
 
uuid = special_id(last_design.id+1)
actually it doesn't say
 
That's strange
 
your app is an int :D
it says very clearly
 
7:15 PM
haha
You know what it was.. I just figured it out. uuid needs to be a string. I was returning an int from that function
 
Arghhh... fancied a beer last night, opened it, took a mouthful, then didn't fancy it. so put it back in the fridge without a top on... what a waste
heya @PeeHaa
 
Hey @JonClements
 
@PeeHaa were we the only room left you hadn't joined? :p
 
:-) Yeah I'm kinda bored so I am room whoring :P
 
Is that all we are to you - your tomato? (see: sopython.com/salad for ref) meep meep
 
7:26 PM
If you put it that way :P
Is this normally (during the weekdays) an active room?
 
I should really get back to tearing my hair out on fixing an invoicing system that's still slightly broken... but, I'm too close to being bald alread :(
@PeeHaa normally have about 30ish "here" - peak times probably about 10-15 active
Not too bad for only really having been going since last Feb... (the room was abandoned before that)
 
Nope not bad at all
 
8:04 PM
Any GAE-ers among you ever had all the "Cloud Datastore" pages in dev console (on production server) 'fail to load'?
 
Never used GAE @Ollie - sorry
(well, used it for about 30 minutes before deciding I didn't want to use it anyway)
 
\o/
 
8:41 PM
Well, I'm slowly getting there
It'll do for the moment anyway... spec's a little vague on some bits - so the client's having that
 
 
2 hours later…
10:21 PM
Sheesh... why is just making the labels and the associated bars slightly wider such a mission in matplotlib...
 

« first day (1415 days earlier)      last day (3523 days later) »