« first day (2030 days earlier)      last day (2912 days later) » 
01:00 - 15:0015:00 - 22:00

1:18 AM
vimeo.com/151465912#t=59m36s - this was me asking Gerald Jay Sussman why MIT switched from Scheme to Python. - thought you'd all find it relevant...
 
1:55 AM
hey guys, how do i delete columns from a csv
heres the small twist
a couple of rows have a bit of non-uniform spacing. Like if I import into excel and I choose to use spaces as my delimiter I can control for the screwed up spacing
i have like 25000 files where ill be analyzing data rom so Id really like to cull them from 300 columns to the 8 i need
 
 
6 hours later…
7:48 AM
cbg all!
I wrote a code that reads from a touchscreen/whiteboard and moves the mouse. github.com/abhigenie92/pyusbwhiteboard/blob/master/…
the problem it clicks at each coordinate that means it draws dots.
instead of continuous lines
how can I make it draw lines btw coordinates using the information whether mouse is up or down
 
8:09 AM
cbg
@AbhishekBhatia you draw a line from the previous dot, obviously.
 
Made a graph plotter in Python.
-1.0    -0.7    -0.3    0.0     0.3     0.7     1.0
     /-\                 |    /-\                 1.0
    /   \                |   /   \                0.9
         \               |        \               0.8
   /                     |  /                     0.8
                         |                        0.7
          \              |         \              0.6
  /                      | /                      0.5
           \             |          \             0.4
                         |                        0.4
I'm sure somebody could make a better looking one.
 
8:29 AM
Cbg
Rather than go for a parkrun, I walked 25 minutes to where I thought parkrun was, saw it was the other side of a river and walked home
 
I see the room makes its own culture.
 
@AnttiHaapala thanks for the reply. Yeah I fixed it using drag function.
 
8:49 AM
@AnastasiaDunbar that someone (late John D. Hunter) has made you matplotlib.
 
matplotlib in ascii?
 
@AnastasiaDunbar closing as duplicate of stackoverflow.com/questions/20295646/…
 
I saw that question.
I thought it would be fun to make one by myself.
Should I answer?
 
well basically such "which tool" are off-topic quesitons on stackoverflow
 
How do I install numpy?
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\numpy\__init__.py", line 170, in <module>
    raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
>>>
 
8:58 AM
you need to install a binary package
 
first of all :D
is there any particular reason for you using python 2.7
if you do not even have packages for it
 
Maybe of PIL.
PIL may be out-dated?
 
no
PIL is outdated crap, you should use Pillow
it is 100 % compatible.
but due to how pypi and google works, no one knows about it
 
Pillow is for images?
 
9:00 AM
PIL ===== Pillow
 
Oh.
Well thank you.
Haven't seen it.
 
but it is python 3, and it is installable
the PIL name was taken by that original crap
so the fork had to use another name
 
Let me look into my versions of Python.
 
all the code you ever see for PIL works without changes for Pillow.
 
3.5 is my newest ones.
 
9:01 AM
I am using PIL(low) on Python 3.5 myself.
 
Is Pillow faster?
 
no, it just works, unlike PIL.
 
Because I wanted to convert an image to mosaic, it's slow.
 
"If you have ever worried or wondered about the future of PIL, please stop. We're here to save the day."
 
Requirement already satisfied (use --upgrade to upgrade): pillow in c:\python27\lib\site-packages
oh shit im installing update
nvm
 
9:03 AM
yeah... you did have Pillow already.
 
but I can't import it? Maybe case-sensitive
 
no, the importable package is named PIL.
 
It's just PIL?
 
as I tried to tell you several times, it is a 100 % compatible fork.
it wouldn't be 100 % compatible if you needed to change each PIL -> Pillow
 
I'm trying to do matlab inv() function in Python, but have no idea how it works. It's a matrix multiplication of itself?
 
9:08 AM
no, it is A^-1
meaning A^-1 * A = 1
 
you cannot divide by matrix
 
But x^-1 = 1/x
 
these are not real numbers.
if A and B are matrices, A*B is not the same as B*A either.
 
I know about that.
But how do I program matrix inversion?
With two matrices?
 
9:11 AM
you use numpy
a) install python 3.5
b) install numpy
 
I wish I'd understand more about complex numbers.
 
c) numpy.linalg.inv for example
these have nothing to do with complex numbers as such
 
Numpy inspired by Matlab?
 
I think it's because you said they aren't real numbers - maybe he thought you meant as opposed to complex numbers
 
^ correct
 
9:14 AM
numpy is inspired by matlab as much as toyota is inspired by chevrolet.
 
But I am still curious how inv() works without numpy.
 
which inv?
what
 
He just meant matrices aren't numbers, so you can't do normal arithmetic with them.
 
example

inv([[3,0,0],[1,2,0],[0,1,-1]])*[30,18,2]
[10,4,2]
You have two arrays. (Which should be represented as matrices)

A=[[3,0,0],[1,2,0],[0,1,-1]]
B=[30,18,2]
Does it go like this?

B[0]/A[0][0] = 10 (a)
(B[1]-(answer*A[1][0]))/A[1][2] = 4 (b)
I think it's much more complicated than that.
Should I make determinant function for that?
 
9:30 AM
Sorry, are you asking about mathematics or Python?
 
It's really unclear what you're talking about.
 
Just inverse of array/matrix A without libraries.
 
Why are you doing it without libraries?
 
Because I just want to know how it works.
Some programming languages don't have libraries.
 
9:32 AM
I am aware of this fact.
It's still not clear what your actual problem is.
 
If this is homework, it may be worth asking a teacher as they can fill in gaps on paper more easily than it can be done in typed text
 
9:51 AM
@Ffisegydd I believe @AnastasiaDunbar is suffering from a severe case of nihhitis
 
cbg @AnttiHaapala
 
cbg
btw, googled "ereyesterdaily", 3 google hits including 1 where I say I am the first person to use ereyesterdaily and nihhitis on the internet :d
 
Not homework and what do you mean by 'nihhitis'?
 
a severe disease that causes an itch that cannot be cured by conventional means, thus you'd have to invent your own remedy. Also known as the NIH syndrome
also related to inventing more wheels.
 
Yeah, I am trying to do fourier transform too.
 
9:58 AM
it is rather funny that you'd want to reimplement inv in pure python despite not knowing what it is and what it does.
 
Also interpreter.
 
exactly
perhaps an operating system as well. Or at least a graphical windowing environment
 
I am looking after how to implement inv.
 
then shouldn't you at first understand what it is.
 
I have a bad understanding.
 
10:00 AM
usually people who build cars have a faint idea on what it should do (e.g. use wheel locomotion to move forward, and steerable by the driver)
 
Hey, I think I know the inv() function now.
 
so please explain to me
 
It's for each value in array that will be 1/x.
 
that'd be no.
@IljaEverilä :D
 
10:02 AM
@AnttiHaapala D:
 
I think I need more coffee.
 
Might be
 
@AnastasiaDunbar perhaps you should join chat.stackexchange.com/rooms/36/mathematics
 
People will hate me for not completely knowing what matrices does.
 
No, I am just wondering whether you're trolling or I should assume that Hanlon's razor applies here as well.
 
10:08 AM
Not trolling. I am just a beginner.
I see a pattern in matrix inversion.
When you multiply your matrix with the inverted one.
Looks like I'm not reading.
 
10:25 AM
You always get the same thing when you multiply a matrix by its inverse
 
Hello I am new to stackoverflow and am learning Python
 
@RanWang welcome :) Hope you enjoy the room; there are a couple of room rules here to help you get started!
 
Does it go like this?
inverse(matrix) = 1/determinant(matrix)*adjugate(matrix)
 
10:49 AM
If you need help with mathematics, you'd be better asking on Maths.SE
 
Okay, but I know a little bit more about inverse of a matrix in MATLAB:

eval((1/det(A))*adjoint(sym(A)))

Sorry for off-topic stuff.
 
11:00 AM
I think so...
Can I ask a question about Python packaging?
I am using
i am using Cython to package some of the cpp class into Python. I have create a shared library
Say mixed.so. After exporting the path, I can import in the Python console directly.
However, in the next step, I am trying to create a generic Python package. In the init.py I said import mixed
Then Python complains that cannot find the package mixed. I find that I can only make it ok if everything I fire up a Python console I manually copied the mixed.so into the location.
Anyone knows how to fix this?
Thans
 
cbg
I am going to try my best today not to infuriate anybody with my questions!
 
11:18 AM
cabbage
@LemusThelroy do you have a history with that?:D
good luck, then
 
potentially
here goes nothing... If the question is inappropriate I will retire from this room
How can I go about asking Python if it recognises the following as a list of tuples or a list of strings?
a = [('GroupA', 2),('GroupB', 2)]
b = ['("GroupA", 2)','("GroupB", 2)']
 
don't worry, you'll be kicked without having to retire;)
I don't get it
the first one is clearly a list of tuples, the second clearly a list of strings
 
nobody cares about my question cry......
 
>>> type(a[0])
<class 'tuple'>
>>> type(b[0])
<class 'str'>
 
oh, I get it
+1 for @Robert's mentalist badge
 
11:21 AM
excellent. I thought they were both different but I have a function that seems to treat them the same
I will have a play with type
 
No, your input is wrong
check your input, it's not what you think it is
or it's not treating them as the same
depending on the definition of "treating something as something"
the only relationship between tuples and strings is that they are both immutable
 
it's pretty annoything tbh, postgres gives me output B but I want it to look like A, so I have to fiddle in python as my understanding of postgres is dire!
 
well, and iterable?
 
print: row[0] gives me: ("GroupA ",1)
when I append this to an empty list, it adds 'speech marks' around it
making it '("GroupA",1)'
 
speech marks:D
print doesn't print what you think it prints
try print('1,3,5')
 
11:29 AM
ahh so print is deceiving me
 
you shouldn't trust print for type information
 
so if I do type(row[0]) that should tell me more about what it is I am printing
 
well, it will tell you the type:P
You might be needing ast.literal_eval, I'm not sure about this one
I mean, this works, but I don't know about how canonical this is, there can always be security issues:
In [47]: [ast.literal_eval(k) for k in ["(1,3)","(4,5)"]]
Out[47]: [(1, 3), (4, 5)]
 
I'll give that a try
@AndrasDeak is ast available in python 2.7?
 
why are you asking me that?
you have the exact same tools as me to determine that
 
11:38 AM
ok
 
If you expect others to do your thinking for you, you quickly become a help vampire
please don't do that, that's harmful for everybody involved
this might explain your original concerns about you asking things
Asking things is OK as long as you make an effort to solve your problem first. Leeching on others with every single step of a problem is a whole different thing, and is not sustainable in the long run.
I wouldn't tell you this yet, but your preamble worries were a red flag:)
 
okay, a better question, what's the best way of searching the internet to find out if your version of python would support a module and what an equivalent module might be? I am having trouble sourcing the information myself
 
The key to solving your own problems is improving your searching skills:)
I think you should first try to import the module...
and start worrying if it can't
if it can't, try to install the module
and continue worrying if it can't
you get the idea?
 
okay, thanks for your help
I will have to do a bit more research
 
Cabbage
 
11:44 AM
@PM2Ring cbg
@LemusThelroy no problem. As long as you make an effort yourself, we're here to help:)
 
cbg
 
FWIW, it's easy enough to parse those strings "by hand". Using ast.literal_eval is easier, OTOH, it may be safer to do it by hand so that it fails if you get a string that doesn't contain the representation of a tuple of ints, since in that case you probably don't want it to be converted silently.
Here's a simple example. Note that int() copes with whitespace in a string argument.
def parse_tuplestring(s):
    return tuple(int(u) for u in s[1:-1].split(','))

data = ["(1,3)", "(4, 5)"]
newdata = [parse_tuplestring(s) for s in data]
print(newdata)
OUTPUT
[(1, 3), (4, 5)]
As I said, it's just a simple example. It doesn't check that the string is bounded by ( and ), so it will also happily convert "[1, 2, 3]" or even "{1, 2, 3>".
 
@PM2Ring in the original the tuples contain strings as well
33 mins ago, by LemusThelroy
How can I go about asking Python if it recognises the following as a list of tuples or a list of strings?
a = [('GroupA', 2),('GroupB', 2)]
b = ['("GroupA", 2)','("GroupB", 2)']
of course you can spice up the parser, I just wanted to note this
 
Ah. So they do... Thanks, Andras.
 
I was too lazy to use a corresponding example:P
 
11:59 AM
def parse_groupstring(s):
    group, num = s[1:-1].split(',')
    return tuple([group.strip()[1:-1], int(num)])

data = ['("GroupA", 2)','( "GroupB" , 3)']
newdata = [parse_groupstring(s) for s in data]
print(newdata)
#OUTPUT
[('GroupA', 2), ('GroupB', 3)]
 
12:10 PM
:)
 
12:33 PM
afternoon cbg
 
cbg!
 
14 hours ago, by tristan
part of growing as a developer is learning when and how to plagiarize
 
@idjaw How goes it?
 
@JonClements :) hey. Pretty good. Getting things re-organized since I came back from my trip last week. Tearing through the jobs backlog I couldn't get to. :) Only a couple left.
how about yourself?
 
SSDD :)
 
12:46 PM
@tristan :sings to the tune of The Gambler: "You gotta know when to code 'em, know when to modem"
 
@PM2Ring Ooo... Kenny Rogers - haven't listened to him in a while :)
 
w00t. Cleared the jobs board :D
 
my wife and I are having a discussion on whether to put our bbq on our deck under our awning. Any thoughts on safety concerns?
I feel like something does not seem right doing that
 
what is the difference between str and len ?
The end of this answer stackoverflow.com/a/20981876/3646408 explains slightly but it not very clear to me.
 
12:52 PM
@JonClements :) I hear that song fairly frequently on the radio here. BTW, did you ever get around to listening to Harry Chapin's - Taxi ?
 
@idjaw I have zero experimental evidence, but putting something hot under something might indeed be problematic
for instance, subjecting the awning to extended heat might wear it out in the long run, right?
or the occasional burst of funeral pyre-grade flames might interfere with it:P
@AbhishekBhatia what's the similarity between str and len? Apart from both being three characters long?
 
@PM2Ring It's bookmarked :)
 
@AbhishekBhatia str is a type. You can use it in two ways. You can use it to construct strings, eg str(42); and you can also use it to test if an object is of string type, eg isinstance('hi', str) or type('hey') is str.
 
@AndrasDeak both are functions
 
@AbhishekBhatia nope
 
12:59 PM
@AbhishekBhatia str isn't a function. But it is callable. And when you call it, it creates a new object of type str.
 
@idjaw I wouldn't put it directly under something else.
 
backup up by experimentalist evidence! ^
:D
 
@PM2Ring thanks for the reply! Can you explain the difference between a callable and function?
 
@Ffisegydd exactly that's my argument. Thanks
 
Sry, I was going over the python tutorial and found no mention of callable.
 
1:01 PM
I'm looking up more things to back me up. My lady is very convinced this is fine
 
@idjaw tell her that two physicists suggest against it
science'd!
 
@AbhishekBhatia len is a function that invokes the __len__ method of the object you pass it. For Python's built-in container types, the __len__ method simply returns the object's attribute that stores its length, so it's very fast. However, a class may define a __len__ method that computes the length of the class instance, if you really need to do that, but it's generally more efficient to keep track of the length and store it in an attribute.
 
@idjaw the internet says "We've had several situations where people barbecue under an overhang on their porch and ignite their house with convective and radiant heat"
I hope the missus listens to the internet at least (that's where credible sources live)
 
@AbhishekBhatia A callable is simply an object that you can call. All function objects are callable, but not vice versa. An example of a callable that you should be familiar with is a class object: when you call a class it returns an instance of the class.
 
science'd. Thanks guys.
 
1:08 PM
@PM2Ring that's actually very similar to what a type does, right? [sorry for triple ping]
type_name(init_object) will construct an object of the given type
much like a class constructor, bearing the name of the class
 
@idjaw FWIW, my dad has a BBQ under cover, but the roof above it is steel, and at least 2 metres above the BBQ plate, with plenty of clearance, in a fairly breezy location.
 
You'd be surprised how quickly a plastic awning could melt.
 
and even 2 metres doesn't sound all that much if there's a blaze
though that shouldn't happen with a bbq under normal conditions, right?
 
@PM2Ring our deck is not closed off. So it's fairly open. The awning is material. I would say it is about just under 7 feet for where we were thinking of putting the bbq
 
on the other hand, the house shouldn't burn down under abnormal conditions either
it has to be foolproof
(or, equivalently, fireproof)
 
1:12 PM
Real life needs unittests
And mock patching . Definitely mock patching
 
@AndrasDeak Sure. A type is a type of class. :)
6
Q: Types and classes in Python

sasukeI'm a bit confused about types and classes in Python. For e.g. the following REPL conversation confuses me: >>> class A: pass ... >>> a = A() >>> type(a) <type 'instance'> >>> a.__class__ <class __main__.A at 0xb770756c> >>> type([]) <type 'list'> >>> [].__class__ <type 'list'> >>> type(list) <...

 
@PM2Ring OK, thanks. I just didn't want to say something stupid
 
thanks
 
From the 2nd link: "Since Python supports inheritance, all classes can be used as templates for additional classes, which means that all classes are in fact types.

This is especially true since the advent of "new-style classes," derived from object, which unify the type hierarchy of user-defined classes with the built-in types. Classes were always types, but now they are the same kind of types as the built-in types."
 
1:17 PM
confusing but interesting:D
 
FWIW, you can use the 3 arg form of the type constructor to construct new types / classes on the fly, which can be more convenient than using a formal class MyClass: definition. I guess it parallels defining a function with lambda instead of a def.
@idjaw Ok. Don't risk it. Fabric tends to burn at a lower temperature than steel. :)
 
@PM2Ring I don't know that one, I'll look it up:)
 
Thanks. Science to the rescue.
 
1:35 PM
Two branches diverged on Git, and I - I merged the one less travelled by. Now all the builds are broken.
 
Resetius currentius BRANCHIUS! waves wand
 
I don't know what to say about this question. Cargo cult doesn't begin to cover it.
 
whaaaaat
Even my general-purpose latex preamble makes more sense than that.
wow that's bad
As I start to look at it more closely, more and more levels of wow are unfurling.
 
1:51 PM
Someone clearly has no understanding of anything
 
g = {}
d = g.copy()
my favourite so far ^
 
they're just using words that they've read an hoping the magic happens
oh man... I didn't notice that was d because that's the variable name that was the path earlier
 
"I put my codes here" even sounds like a lolcat
 
I have a sneaking suspicion they thought they were turning the file into a dictionary with that command
 
g is an empty dictionary, so it has no keys. Most of your code doesn't do what you seem to expect it to do. I think you need to go and re-read the relevant sections of your textbook / course material. — PM 2Ring 39 secs ago
and then learn another language, please
 
1:54 PM
lol. Trying to keep out the riff-raff, eh?
 
maybe it would be enough to learn this one
 
If you're having trouble with Python...
 
@AndrasDeak Exactly. I first saw the os.path.isfile(d) != True, and thought "Ah, a common newbie error", but then I saw him trying to get the file size withsys.getsizeof(d) and thought "How strange". And then it just gets progressively worse. :)
 
IMHO islice is overkill when all one needs to do is count the rows read so far... — martineau 4 mins ago
grrr....
 
so is it lice, or not?
 
1:57 PM
snrk
@Ffisegydd Good thing you can just use git teleport co to get to the other branch ;)
or even git bisect to figure out where everything went sideways \o/
 
git helpmeJoe if Joe's the guy with the phone number
 
@WayneWerner Yep. It's definitely programming by magical incantation. At least cargo-culters can read the code they're ransacking well enough to cobble chunks together in a vaguely coherent fashion even if they don't fully understand how those chunks work. But not this guy...
Jan 13 '15 at 8:41, by PM 2Ring
One day, I won't be able to stop myself from commenting: "Perhaps programming is not for you. Have you considered finger-painting?"
 
Is the point of islice to support slicing for something that otherwise wouldn't do that? Like files?
@PM2Ring hey, at least the inentatio is consistent:D
 
@AndrasDeak Fair call.
@AndrasDeak Yep. Or a generator.
 
Meh, two typos. Don't want to ping you again:P
@PM2Ring thanks
islice sounds awesome
I should take a closer look at itertools one day
 
DSM
2:08 PM
itertools-flavoured cabbage for all!
 
@AndrasDeak you could take (for instance) every other line in a file via for line in islice(file_obj, None, None, 2): ...
 
itertools is pretty delightful. As is functools (e.g. functools.partial and functools.wraps)
 
@JonClements yeah I've just noticed your comment about the stepping:) Kicks ass.
thanks
@DSM same to you, sir
 
have to admit being a bit of an itertools freak though - possibly my favourite module :)
 
I've got to the point where now when I have a problem involving iteratables/functions I tend to go look through those modules to see if they have what i want
 
2:09 PM
cbg @DSM!
 
everybody needs some vices:P
 
DSM
Be careful, though. You start out dabbling in itertools, and the next thing you know you're writing Haskell..
 
that's some gateway drug
 
@DSM too late :( (by about 2 years)
 
@DSM True, although you can get pretty functional without itertools. Here's something I wrote the other day but didn't get a chance to post because the OP self-deleted. And the question wasn't really interesting enough to bother getting it undeleted.
#Print all non-decreasing subsequences of a given length of digits in an integer
def non_decreasing(s):
    return all(u <= v for u, v in zip(s, s[1:]))

def all_nondecreasing(num, n):
    numstr = str(num)
    it = zip(*(numstr[i:] for i in range(n)))
    return filter(non_decreasing, map(''.join, it))
 
DSM
2:23 PM
On first glance that looks like it assumes contiguity. (Or is that implied by 'subsequence'? TBH I can never keep the terminology straight.)
 
@JohanLarsson and other electric blues fans: Soulive featuring Warren Haynes & Derek Trucks - The Thrill Is Gone
@DSM Yes, we're only looking for contiguous subsequences. The question originally didn't make that clear. Once the OP clarified that point I started writing code, but by the time I'd finished it the question was dead.
 
@PM2Ring so the aim of that is to check that a number's digits are effectively in a sorted order?
Um.... example input/output? :p
 
DSM
I'd be very impressed with the attention given the SO chat if "@other electric blues fans" worked.. (although it'd be a little creepy if they were datamining our social networks to that degree..)
 
@JonClements Kind of. It's to find contiguous subsequences of digits that are sorted (ascending).
@JonClements Ok. Give me a sec.
 
Cos there's a nice groupby recipe that can do that :)
 
2:28 PM
# Test
data = (12234, 1223725671, 4321)
for num in data:
    found = all_nondecreasing(num, 3)
    print(num, found, len(found))
#output
12234 ['122', '223', '234'] 3
1223725671 ['122', '223', '237', '256', '567'] 5
4321 [] 0
 
So why isn't 1223 or 12234 in that output?
 
I have a quick question with regards to importing third-party apps for Django, anybody could help?
 
DSM
@JonClements: the 3 arg.
 
'registration' app is within 'INSTALLED_APPS', but when i say 'import from registration ....', it doesn't seem to recognize the app
 
@JonClements Because they're too long: we only want sequences of length n=3.
@JonClements I was tempted to use groupby, but I decided to try another approach.
 
DSM
2:37 PM
In this case I think the non-groupby approach might actually be cleaner.
 
FWIW, this answer does use groupby to find consecutive runs. It was a chameleon question, so there are a couple of versions. :)
 
Well have an upvote for that one - one of the more comprehensive answers I've seen that should have got more :(
 
Thanks, Jon!
 
DSM
I can't because it seems I already did, although I don't recognize the Q at all. :-)
 
here
 
2:45 PM
:) I spent far more time on that question than I expected. You may notice the comment chain extends into its own Chat. Bloody chameleon questions...
@AndrasDeak Ta!
 
01:00 - 15:0015:00 - 22:00

« first day (2030 days earlier)      last day (2912 days later) »