« first day (1414 days earlier)      last day (3525 days later) » 
02:00 - 17:0017:00 - 23:00

2:32 AM
cbg, all. Or anyone, really...
 
cbg @Matt
 
slow night around here?
 
It would appear so ... I'm disappearing myself shortly (might have company).
What everyone's up to on a Friday evening / Saturday morning is a mystery ...
 
that's exciting (I hope). Unless you take it to mean you'll be disappearing through the back window because company is armed and knocking down your door.
 
Heh ... no, although there's a reasonable chance she'll have had a drink or two (works leaving do), so there's always a possibility of something getting knocked over.
 
2:43 AM
Awesome. Those are good Friday nights. As for me, the wife seems to have gone to bed early. Marriage is fun :)
 
From what I remember, it's a mixture of fun, terror and the bits inbetween ;-)
Ok, gotta go ... enjoy the silence ...
 
take it easy
 
 
3 hours later…
6:01 AM
Yay! I have 17,000 fake internet points!
 
6:17 AM
@MattDMo all your fake points belong to Skeet!
@MattDMo just 3k more and you've unlocked everything...
 
Just 19,586 more and i've unlocked everything :)
 
@Swordy I challenge you to do that by the end of this month!
 
6:32 AM
Let's see, its 30th August here , 12:00 pm , I have 36 hours left
that is equal to approximately 545 rep per hour
hmmm easy task but I am not in the mood :P
 
The awesome thing is that you can read .tsv files using .read_csv ,[[dint consider with open(...tsv) ]]
 
6:45 AM
Guys, how do I generate n random numbers within a range with conditions? The conditions can be, for example, that a set of numbers appears twice as often as they should.
 
That is non trivial to do.
Depending on your conditions you may have to change the actual hard code
 
@ShubhamGoyal are you basically after a weighted distribution?
 
cabbage folks!
 
@Ffisegydd STEWIE!!!!!!!!!!!!!!!!!!!!
@Peter just got up or just going to bed - never know with you :)
 
@Jon Briiiiiiiiiiiiiiian
I'm gonna say just got up
I reckon he's pushed all the way through
 
6:59 AM
if I didn't mentioned it before: all google-chromers and youtube-lovers try streamus! I've been testing it for a while now, and it is super amazing :)
4
@JonClements I think I finally reset my clock -> I almost slept all-day-long yesterday, and now I got up at 3AM or something like that
hopefully I will go to bed before midnight
 
@Peter almost back to "normal" hours then :)
 
yepp -- I hope I can keep it that way
(although my biological clock says its 2PM now... so I guess I'm going to have a hard battle during the afternoon against my own body)
 
Caffeine drip!
 
anyway, back to refactoring ;)
don't forget to try streamus ;)
rhubarb for now ~
 
Well, I've got a couple of DBs syncing/replicating, so can't do much for a bit... I might just go back to bed for an hour :)
 
7:19 AM
@JonClements - Yes
 
7:45 AM
IS there something like the followng in Python
switch(condition):
    case:
        code...
    case2:
        code...
    case3:
        code...
it would be really cool
dictionary way is ugly
 
8:45 AM
@PeterVaro thanks it looks like rejected
it sucks balls...
 
 
2 hours later…
10:46 AM
Hi guys, I'm learning python, in this UDP client code ( pastebin.com/zFFhRUSQ ) I'd like to add a timeout on data reception from server. It seems to have some problem in the timeout exception management (lines 28-30), what's wrong? Thanks in advance.
 
11:05 AM
Ok, I've found the bug. Thanks the same guys!
 
please don't add greetings to your posts
 
11:31 AM
Cbg
 
Cbg
Is it possible to run with I/O some other langauges REPL in python?
 
Looks like I posted another popular (though silly) question on meta :D
 
12:26 PM
cabbage
why don't python3 strings support the buffer protocol? what's the reasoning behind it?
 
Because you can use bytes exactly for that
 
well, yes, but at the cost of encoding first
for instance, present issue
in a parser, I want to be able to match patterns against the input buffer
the buffer object and parser object are distinct
if the buffer is bytes, then no problem
can return a zero-copy memoryview to the parser object
but if the buffer is a unicode string, can only return a copy of the buffer (slice) to the parser object
seems a waste
can workaround it, by always keeping the buffer as bytes and decode as necessary
e.g. if the buffer contains b'asdfgh', and the parser is doing lookahead, say wanting to match b'fgh' at position 3, it's simple to do memoryview(buffer)[3:] == b'fgh'. But with a string (`buffer[3:] == 'fgh'), there's a copy taking place. And I don't understand the reason why it has to be like that.
 
12:50 PM
str objects are a container for unicode code points. They don't have an binary form until encoded.
From a conceptual point of view.
 
Hey, whaddya know? My starred posts haven't been quasared off the screen by Kevin yet
 
ok, but if a string is conceptually an array of unicode code points, what's the big deal in obtaining a (read-only) memoryview of it to avoid a slice copy when required (much like obtaining a memoyview of an array.array of short or int, depending on whether the implementation is using UCS-2 or UCS-4 code points)?
i.e. buffer[3:] == 'fgh' is saying I don't care about the binary encoding, I want to compare code points. But why does one have to get a copy of those codepoints first?
in python 2, the 'unicode' type supported buffer protocol. what's the difference between a python 3 string and the python 2 unicode type?
 
1:19 PM
cbg btw
@isedev guess there is no difference other than that in 3.3, 3.4 the strings are variable width
 
>>> buffer(u'a')[:]
'a\x00\x00\x00'
That fact about python2 unicode types is surprising to me.
 
       a   b
1.    1   2
2.    3   4
3.    5   6

A good way to get a list of tuples? like [(1,2),(3,4),(5,6)] .
def iternamedtuples(df):
    Row = namedtuple('Row', df.columns)
    for row in df.itertuples():
        yield Row(*row[1:])
doesn't look good :(
 
why not?
tuples or namedtuples?
 
{Row(a=1, b=2), ....
is it because of namedtuples?
 
yes
what are you asking?
 
1:28 PM
A good way to get a list of tuples? like [(1,2),(3,4),(5,6)] .
 
from a string like that?
or from where?
 
actual data looks like
   PhraseId	SentenceId	Phrase	                                 Sentiment
0	 1	 1	 A series of escapades demonstrating the adage ...	 1
1	 2	 1	 A series of escapades demonstrating the adage ...	 2
2	 3	 1	 A series	 2
 
if this is in file, then use the csv module
 
i want a list of tuples of phrase and sentiment
 
then use the csv module for example
 
1:30 PM
how should the above method be modified
ohk let me see that , will get back :)
 
or if you really read it already?
 
import pandas as pd

df = pd.DataFrame(data=dict(a=[1,3,5], b=[2,4,6]))

t = [tuple(x) for x in df.values]
 
@Ffisegydd except the data did not look at all like in the original I guess
@Swordy if you have the previous, then:
 
Yep
 
it should be applicable to strings too
 
1:32 PM
In [4]: df
Out[4]:
   a  b
0  1  2
1  3  4
2  5  6
 
hey guys will be right back , give me 20 minutes :|
rbrb
 
ah didnt realize this was pandas all the way down already
 
@Antti yeah I have the advantage of knowing Swordy works with pandas :P
 
@isedev also, if you parse using regexes, remember to use the start and end parms for matchers...
 
How do I declare an empty global "file" object. I will fill it up later with the right file pointer in a local context.
 
1:43 PM
Why do you need to declare it?
 
so that it is visible in other functions.
because if I open the file in a local function. It will be visible only in that function.
 
How about declaring it global in the function?
Will that work?
 
Or you have a function that returns it and then have it at the top level in a variable?
 
@Zacrath: I will look for doc on that keyword.
@Ffi*dd: I'd like to avoid function calls, as it would slow down my program
in the long run if I call the print enough number of times.
 
Do you know it'll slow it down? I mean do you know it'll actually make a difference?
 
1:47 PM
It probably won't be observable.
 
Premature optimisation is the root of all evil.
 
Any small optimizations you make will be made redundant by python's inherent slowness.
Rule #1: Don't optimize.
Rule #2 (Experts only): Optimize later.
 
@Ffisegydd works a charm, that was simple but it prints out 2L ,3L, 1L for second column
 
That's because you're using Python 2 and the L signifies a long integer
It's still an integer though
 
that shouldn't make any difference ,right?
 
1:56 PM
Nope
 
@antti yeah, it's what I'm falling back on - that and startswith(...,pos)
 
In Python 3 all integers are "long" integers but they don't bother showing the L
 
Looks like the time has come to switch to Py 3.4 :P
 
You don't need to
It'll make no difference
 
just wanted to understand the reason why unicode strings can't be zero-copy sliced. I'm sure there's a good reason, but it's eluding me.
 
2:00 PM
Coding for the kaggle competition , analyzing movie sentiments
 
What do you mean by "zero-copy slice'? As far as I know, slicing always makes a new object.
 
i.e. support buffer protocol
 
@Swordy really? I'm going to be entering some Kaggle competitions soon with Games.
 
check this
You mean "Saw" type games ?? "I wanna play a game"
 
No I mean Games Brainiac the sopython regular.
 
2:03 PM
ohh cool :)
 
Thanks guys.
 
2:17 PM
CBG
If some command line takes a file as a argument.. can you pass text instead of the file somehow?
I tried somecommand -i < "println("hi mom")
 
Usually using "-" as the file argument makes it read from stdin.
GNU tools do that at least.
 
oh
what do you mean?
 
Took a second look at your post, I think you want:
`echo 'println("hi mom")' | somecommand -i`
 
oooo
thx
<unknown>:0: error: no input files
 
how to remove empty strings in the tuples which was present inside a list?
 
2:33 PM
@AvinashRaj example?
 
[('', 'Brodie Loy', '3', '53'), ('', 'Hugh Bowman', '3', '47'), ('', 'James McDonald', '', ''), ('', 'Kerrin McEvoy', '', ''), ('', 'Tommy Berry', '', ''), ('Ms', "Kathy O'Hara", '', '')]
 
[tuple(s for s in tup if s) for tup in list]
You can't remove items from a tuple so you need to re-create it.
 
it does not make sense to remove empty strings from tuple
 
@Johnston What is the "somecommand" that you are running?
 
say if you remvoe empty strings from ('', 'Hugh Bowman', '3', '47'), it would make the hugh be the title, bowman given name and 3 surname...
 
2:40 PM
@Zacrath it's xcrun swift -i to run swift from the command line
-i is immediate mode
Also tried :
    xcrun swift -i < cat println("hey you")
    zsh: unknown file attribute
 
I'm having trouble finding a man page for it. What's the syntax for running it with a file argument?
 
just pass the file xcrun swift -i first.swift
Here is the -help
http://pastebin.com/4NhvuaqD
 
Try: echo 'println("hey you")' | xcrun swift -i -
 
O
YOU DID IT
I got a little excited there.
Thank you!
 
3:01 PM
@Ffisegydd Worked like a charm... Thanks.
is there any python documentation about file processing?
i want to search or add or remove somelines in a file through python.
 
3:13 PM
@Ffisegydd it adds a comma after some texts. See
>>> [tuple(s for s in tup if s) for tup in m]
[('Brodie Loy', '3', '53'), ('Hugh Bowman', '3', '47'), ('James McDonald',), ('Kerrin McEvoy',), ('Tommy Berry',), ('Ms', "Kathy O'Hara")]
 
@AvinashRaj that's fine
The comma signifies that tis a tuple
 
no, see the comma after James McDonald.
 
For instance ('s') is just a string surrounded by brackets, right?
But ('s',) is a string inside a tuple
 
is there any way to get the ouput without the trailing comma?
 
The comma is part of the tuple.
It's just the way tuples look.
 
3:15 PM
'James McDonald',
'Tommy Berry',
i mean the comma inside tuple
 
Yes exactly, ('James McDonald') is a string inside parenthesis, ('James McDonald',) is a string inside a tuple
The comma is part of the tuple.
 
(ie - it's the way you can instantly and visually recognise that it is a tuple, as opposed to another data type)
 
Yes exactly.
 
hmm. So for strings there must be a trailing comma..
 
No
(1) is an int in brackets
(1,) is an int in a tuple
(1,2) is 2 ints inside a tuple
 
3:17 PM
is there any way to remove the comma?
 
You don't need the trailing comma there because you can tell it is a tuple.
 
Is this possible or not?
 
Subclass tuple and re-write __repr__?
And __str__
 
Why do you hate the trailing comma so?
 
Or use string formatting to print it
 
3:20 PM
Hi All
 
is that possible to access the first name in the first tuple?
 
Yes.
 
if so, then how i do that?
 
Morning/Afternoon/Evening/Night @CoKoder, pick your poison
 
@IntrepidBrit lol :-)\
 
3:23 PM
I have quick question. I am trying to convert image from .webp to jpg with this code:            from PIL import Image
im = Image.open("aq1.webp")
print(im.format, im.size, im.mode)
but i am getting raise IOError("cannot identify image file")
IOError: cannot identify image file
 
HI @davidism
 
cabbage
 
21 mins ago, by Avinash Raj
is there any python documentation about file processing?
 
this is the image i downloaded and named it as "aq1.webp" lh4.ggpht.com/…
 
@Ffisegydd thanks for your help :-)
 
3:24 PM
cbg @davidism
 
i want to do text processing through python...
 
Use NLTK
 
but it won't support for python 3.X
 
@davidism Cabbage
 
3:26 PM
Any ideas?
 
1 message moved to Trash
Dude you've already asked once :/
Please don't flood the chat with your questions.
 
@CoKoder Mate, PIL doesn't support webp images
 
is that possible to delete some particular lines in a file through NLTK?
 
I think I'm going to go jump in my pool. Good way to wake up.
 
@davidism Grab me a whisky on your way back
 
3:29 PM
@IntrepidBrit, but i already used pillow as from PIL import Image
 
@AvinashRaj have you tried to Google around the subject? Incidentally don't use NLTK actually.
 
so for this simple task NLTK is not necessary.. Am i correct?
 
@IntrepidBrit, thanks i just got the new version and the problem has fixed
 
@CoKoder Excellent. I was about to run you through the basics (are you SURE it's a webp file you actually have on your computer? etc etc)
 
@AvinashRaj No it is the incorrect tool.
 
3:34 PM
does re.sub function works on multiple lines?
 
Which tense are we in?
 
ALL OF THEM.
 
correct?
 
:18587932 That's fine, just trying to work out what you're actually asking. It works on multiple lines, as long as they're a contiguous string
(Although I'm not too hot on python re's, I rarely get the joys on working at such a high level of abstraction ;) )
(Why does my driver stream hate me?)
(Aha! It hates me because I am rubbish at naming variables)
 
How can I get the errors from subprocess.check_output
 
3:50 PM
Cbg
 
cbg()
 
:)
 
When I run subprocess.check_output there is stuff getting printed the command line that isn't going into my variable.
 
Yo :)
 
3:55 PM
@Johnston is the thing you're running printing to stdout/stderr or what?
 
Not sure. I am unfamiliar with which is which. But when I run the command normally it prints out about three lines of code. When I do with check_output it only prints the last line if no errors. If there are errors I don't know how to print them.
I am giving users access to a different languages repl
Oh it's stdin
how do I print out stdin
 
The check_output will capture the standard out of what you run
eg: If you called another Python script using it, you'd receive the output of its print statements
Wow Stoke City beat Man City...
(that makes it time to take the piddle out of a few friends on Facebook)
 
It doesn't for me
To my command line where I am running python... it prints:
Swift version 1.0 (swift-600.0.34.4.5)
Target: x86_64-apple-darwin13.3.0
But to the variable I saving output of check_output it saves the last line
Which is the result of the command I sent to the repl a 3
 
Produce a gist with the python call, the output, the command you're running and its output... just so it's all in one place - it's Saturday evening... don't fancy 20 guesses :)
 
4:11 PM
haha
Of course sir
output = subprocess.check_output("python -c \"print 1 + 2\"")
 
Okay... for a start, it's ill-advised to use a string, instead use: output = subprocess.check_output(['python', '-c', 'print 1 + 2'])
 
ok
 
Otherwise, some shells might take it as one big executable name to try and run (or otherwise get confused with escaping and other stuff)
 
4:26 PM
OK
now
if you replace 2 with r it would throw an error
how do I grab that error.. it doesn't print
 
So are you telling me it works now, but you're asking for further information?
 
No. I was trying to get you from point a to point b
But yes
It was my original intention...
 
@Johnston okay... sorry for being slow... you're not the most clear of people though - you catch the exception that's thrown (as stated in the docs), eg:
import subprocess

try:
    output = subprocess.check_output(['python', '-c', 'print 1 + 2'])
except subprocess.CalledProcessError as e:
    print e.message
else:
    print output
So 1 + r, will give you:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'r' is not defined
 
Aha.
 
Your flask instance is getting the 500 error as that exception is slipping through...
 
4:32 PM
ok
 
re-factor that accordingly to whatever you're trying to do :)
 
Ok so here's the thing
That doesn't work for me
I can't get it to return that error.
 
Doesn't even like you want check_output, just .call is fine, try: gist.github.com/joncle/551c957e63b1039c49ba
 
Ok.
That's cool
I get an error with that.
TypeError: 'int' object is not iterable
for the retcode, output = subprocess.call(['python', '-c', 'print 1 + r']). I don't understand why that would give that error
 
oh... did I get the code, output the wrong way around
Oh... me being dumb one sec
@Johnston there yago
 
4:47 PM
Thank you btw for taking the time. The error is still printing to the command line and not being returned
 
What error?
 
e.output is blank
The python error that 1+ r returns
trying e.message
I am trying to return the error from python to the browser by using that return statement. That error doesn't seem to be located in e.output or e.message.
 
Output... does it work if you change it to print 1 + 2?
ie... is your if statement even executing
 
It does
I get back 3 to the browser.
 
@IntrepidBrit OK, got the whiskey, how are you going to get it?
 
4:53 PM
It's only when there is an error I can't get the return of that error
 
@davidism email it to me... I'll take good care of it until I meet him
@davidism can you see any reason why gist.github.com/joncle/551c957e63b1039c49ba wouldn't work in flask?
 
@davidism Whiskey?! I didn't ask for Whiskey with an 'e'! I was wanting the finest of Scottish malts. Not that I'm a snob or anything :P
Thanks though ;)
 
I think the whiskey with an e will stay in my bar until I get a proper teleporter set up.
@JonClements nope, I'll try to run it in sopy
 
@davidism cheers, it's for @Johnston, and we've spent about 30+ mins trying to work through this... (I'm on the media laptop - don't have all my dev setups on it)
 
@davidism @JonClements The only issue is that the error is not sent back.
And thank you very much to both of you
 
4:59 PM
are you aware of the /console route that werkzeug already sets up? werkzeug.pocoo.org/docs/0.9/debug/…
of course it only works in debug mode
 
02:00 - 17:0017:00 - 23:00

« first day (1414 days earlier)      last day (3525 days later) »