« first day (1925 days earlier)      last day (3039 days later) » 

1:52 AM
Good evening everybody! What's up?
 
being a kitty cat
 
Drinking and watching It's Always Sunny.
 
2:27 AM
I watched two episodes of Restaurant Startup with the wife, and now we're just sitting around. You guys around still?
 
cbg all
 
hey!
 
cbg
 
apparently we're down to 2 minutes to delete stuff?
 
oi, I missed some fun it seems :|
Ah, well. Happy, happy grad student am I
 
2:35 AM
no, you can read the history...
 
missed is a relative term
3/4 of my work this semester is pure research and data processing (and 2/3 of that is in the area I like to research and that relates to my dissertation) :) :) :)
 
cbg guys!
I have a quick question - how come this one liner doesn't work? f = [(open(arg, 'r') if arg != '-' else sys.stdin) for arg in args]
 
Cool
 
Trying to read in a script currently and it worked previously with [open(arg, 'r') for arg in args] , so I'm a bit confused.
 
I'd remove the parens, unnecessary
 
2:42 AM
does it give an error and, if not, did you check to see what f contains?
 
Hey Martijn! Thanks! Sorry to bug you.
@OneRaynyDay you get that?
 
@AaronHall I did afterwards, same error :/ I searched on SO: list comprehension with if else, and I saw the answers and I followed their approach and didn't work
 
no, you look fine, what's args?
 
@JGreenwell I actually wrote the entire python script(it was meant to be a amateur version of comm)
args is the sys.args
 
how do you know it worked previously?
 
2:46 AM
if you're not familiar with shell commands, command for comm works something like
 
are you in a python shell?
 
comm file1.txt file2.txt
and the sys.args reads in file1.txt and file2.txt
It worked previously because I put in file1.txt and file2.txt and it works
however, I have to implement piping in as stdin
I'm using the shebang #!/usr/bin/env python3
so yeah it runs in my anaconda distro of python 3.5.1
 
$ cat > foo.py
import sys
print(sys.argv)
$ python foo.py -- file1.txt file2.txt -
['foo.py', '--', 'file1.txt', 'file2.txt', '-']
 
@AaronHall I'm sorry for this horrendous copy paste on pastebin (using vim and don't know how to copy out)
but I'm using a class called optparser(now deprecated but our teacher is a dummy)
actually no I can't say he's a dummy since he invented emacs
 
Stallman?
 
2:53 AM
Paul Eggert (he's some really old guy who does a lot of stuff on gnu, so he's pretty well known in that community)
 
surely you can clean that up?
 
@AaronHall Yeah, my apologies. I'll send you a better one pastebin.com/DPiX2h22
 
That's no better
 
@AaronHall Delete you or delete the message?
 
The message, sorry for the mixup, I should have been more clear
 
2:59 AM
glad I checked... ;-)
 
@AaronHall bleh - I'm sorry, if you look at the raw paste I tried formatting it (vim had line #'s and if I copy paste it it also contains white space) It's okay though - I found the error :)
but hey, if you remember a while ago, I was that kid(there were probably a ton of people like me) who asked for IDE's for python, and you suggested vim. so here I am using vim ^_^
 
I suggested VIM?
I would have thought I'd have suggested emacs... :)
But you can use emacs with vim keybindings, it's called evil mode. Cause vi is the editor of the beast.
 
and the devil is in the code
 
There is no system but GNU, and Linux is one of its kernels.
I'm pretty sure none of these comments can be read as a suggestion of VIM:
 
 
3 hours later…
user559633
6:27 AM
cbg
 
8:05 AM
 
8:45 AM
cbg
 
9:13 AM
cbg
 
cbg
 
morning cabbage
 
@thefourtheye Sure, it can be annoying, but really you just need to harden your mind's context switching. Like Mrs Roberts...
Oh-oh. Another person who thinks LPTHW is some kind of official Python primer. stackoverflow.com/questions/34961779/…
 
9:47 AM
But I guess that's another black mark against LPTHW that a student can get a quarter of the way through it and not know how to run their Python script from the command line.
 
9:58 AM
wait wat? You can run python scripts from the command line!? :p
 
It's a trick only us real advanced hackers know.
 
@PM2Ring darn... I hope one day to be so elite... :)
 
@AnttiHaapala LPTHW should be called "Let's sabotage Python newbies `cause I love Ruby"
6
 
10:26 AM
@PM2Ring She is at Ninja level. I am not sure if I can ever reach that level.
 
And it's unlikely that you'll ever be a Ginger Ninja. :)
 
cbg
 
11:22 AM
-4
Q: Exercise 13: Parameters, Unpacking, Variables - Totally lost

Ginja NinjaI have got to section 13 of Learn Python The Hard Way. Having followed all the rules and directions given to get this far. I am not a programmer and do often hit sticking points where I need step by step guidance. I have done everything in this section, and I have a named my file section12.py a...

new updates
I asked for reopen
 
Ok; I also reversed my downvote
 
Ok, lol I was just called from afghanistan.. ANd yesterday I received a call from Syria. Should I be disturbed?
 
after that I think it can be closed as a duplicate of something
 
I also cast my vote to re-open that. Atleast OP tried something and failed.
 
actually
I dunno why I read "visual studio" :D
File "C:\Users\Photo Design Studio\Desktop\section12.py", line 3, in <module>
what is this anwya?
is it from idle? the RESTART line
 
11:34 AM
@paul23 Hmmm, yes. Better buy a bunker and hide. Since you cannot use ATM/Debit cards, operate bank accounts and access your properties, would you mind transferring it to SOPython? ;-)
Rest assured. SOPython will never let anyone have it. You can be sure of that. Even if that "anyone" is you. Deal?
 
sure number?
Oh good one! You'll trick me into sending money to you, by now giving me YOUR bank account number instead of SO's..
Not going to fall for that one, nice try!
 
this human can think and decide. Exterminate him by barking at him all day and night
 
This guy changed his question after it was answered. So I rolled it back And now he's rolled it back again. :( IIRC, I don't need to do anything. Or should I flag it? stackoverflow.com/questions/34962614/…
Psychic Ninja Power!
Hi, Martijn! I was just thinking about you. :)
 
u go to bed and see another girl instead of your gf - that's ValueError. U see a raccoon - that's TypeError http://goo.gl/Wp1uLS #python
@bereal ^^ :-)
 
how cute. You work for a week on a feature and then requirements change.
 
11:50 AM
The trick is to ignore requirements and write whatever you want, then they can't change on you.
"Trust me, you really need this wifi in your pen."
 
@khajvah Yeah. It's bad enough when you're getting paid to deal with stuff like that. But when it happens on an SO question it's unacceptable. Fortunately, we can retaliate by rolling back. :)
 
I wonder if this happens to embedded developers
 
OP has rolled back again.
 
Flagging this question for moderator attention, as OP is keep reverting the question to the edit which makes substantial changes to the question which renders the answers useless. — thefourtheye 1 min ago
 
@khajvah pff you software devs have it easy
it's only customers that change requirements.
(Ok: mostly)
 
11:55 AM
Do we roll back again or leave it?
 
It was the manager in my case. "Do X". "Ok good, X doesn't make sense, do Y instead"
 
Work for 5+ years on something and then governments create stricter regulations...
 
@khajvah I have heard stories about the number of prototypes made and rejected by Steve Jobs. Does that count? ;-)
 
@Ffisegydd IIRC, 2 rounds of back & forth rollbacks trigger automatic flagging, but 4theye;'s already flagged it. So we now leave it and let the mods handle it.
 
@Ffisegydd I am actually waiting for mods to take action. Should we interfere?
 
Ah leave it, it's been answered. I was just worried that someone else may come along and answer the changed version while we wait for mods.
But as it's been answered, hopefully someone won't answer the new version.
 
The B707 was never supposed to use turbo-jets, but instead they were supposed to be given in-wing jet engines. However just after it entered production rules were sharpened, making in-wing engines unfeasible. So the design had to be changed to fit turbo-jets.
 
@PM2Ring I didn't know about that trigger actually. SO devs are awesome :-)
 
But the larger turbine cases meant the engine-ground clearance couldn't be reached. So the size of the undercarriage had to be increased. Which was also problematic as there was no more room to stow the undercarriage (leading to an extra "bulb" to fit it in below the fuselage).
Now THAT is a problem with requirement change...
 
@thefourtheye From meta.stackoverflow.com/a/267883/4014959 "A rollback war (repeated rollbacks by the same user) raises an automatic flag; a moderator will come looking soon enough and lock the post if this continues." -- Martijn Pieters.
 
12:15 PM
Cool
 
comparing ("== - operator") two tuples compared element-by-element right?
 
Yes.
 
Hello all.
 
12:31 PM
Greetings, fg nu.
 
Quick question. What is the difference between the two:
bar = list(range(0,8)).append(23)
print(bar)

foo = list(range(0,8))
foo.append(23)
print(foo)
In other languages, an instance is usually created on-the-fly, is that not the case with Python?
 
Hmm working my way to find a clean way to compare objects in a generic way using "tie breakers" (IE object has variable "a, b, c" - a's are equal "b" is used, and if they're also equal "c" is used). Currently writing: return l.a < r.a or ((l.a == r.a and l.b < r.b) or (l.b == r.b and l.c < r.c)) but this gets ugly quickly, and becomes error prone after the third level.
@fgnu append doesn't return a thing. so "bar" is None.
 
Ah
 
lists are mutable, so they're changed in place
 
Got it, thanks!
 
12:41 PM
@paul23 Yeah, put your comparison keys into a tuple or list. Here's a class that shows the comparisons run from left to right.
from __future__ import print_function
class A(object):
    def __init__(self, data):
        self.data = data
    def __repr__(self):
        return 'A(%r)' % self.data
    def __eq__(self, other):
        print('EQ', self.data, other)
        return self.data == other

a = [A(i) for i in range(5)]
b = [A(i) for i in range(5)]
print(a == b)
 
@paul23 The right thing to do then, if I want to create and extend the list in one go is to use `+`?
bar = list(range(0,8)) + 23
 
@fgnu It's a general rule in Python that if a method mutates an object it returns None. This can be annoying at first, coming from other languages. But you get used to it. And it's nice to have consistency. :)
That needs to be bar = list(range(0,8)) + [23]
 
@PM2Ring Thanks, I think that was basically it -- I was expecting the append to return a handle to the underlying object.
 
Note that, in contrast, Python strings are immutable, so the string methods (eg str.lower()) have to return a new string.
I guess the one that trips people up the most is list.sort() which does an in-place sort. This annoyed so many people that eventualy the sorted() function was added to the language. :) It's convenient, but inefficient since it creates a copy of the original list and in-place sorts it. So unless you need to preserve the original ordering it's generally better to use the .sort() method rather than the sorted() function.
 
@PM2Ring Coming from C++/JAVA this was kind of logical. I'm wondering which language focusses so heavily on using returns? - And thus value-semantics instead of reference semantics
 
12:58 PM
@paul23 @PM2Ring My primary language is R, which being a functional language works the way I was expecting that piece of code to work.
Basically, there are no in-place operations.
No side-effects.
 
Well true, since to prevent side-effects a language has to remove the notion of "memory"
(In the sense of computer memory)
 
IMO, the value vs reference distinction isn't a useful way to think about Python's data model. Forget that stuff and instead think in terms of objects, names and binding. See SO veteran Ned Batchelder's article Facts and myths about Python names and values
 
@PM2Ring Being somewhat new to Python, I was going to ask for just such a reference.
 
@fgnu Fair enough. I'll think you'll enjoy Ned's article. It's not perfect, but it is very good.
 
@PM2Ring What better way to spend a Saturday morning. :-)
 
1:02 PM
:)
 
Hmm I notice a lot of time is spent in my current scheme making dozens of copies of lists :/
bad_copies = set(c[0] for c in itertools.permutations(all_copies, 2) if not check_post(*c))
all_copies = [c for c in all_copies if c not in bad_copies]
wonder if that latter lane can be optimized..
 
Also see Naming and binding in the official docs, although I must admit that Ned's article is easier to read. :)
 
I'm programming with a heavy electrical engineering background - so for me I can't program unless I physically interpret the functions into a way how the cpu (assembler) works..
 
This Q&A has some nice stuff: stackoverflow.com/questions/20699736/…
 
uh does python really change the memory location when I write a = 2; a=3? That seems hopelessly inefficient (always an extra layer of abstraction/reference that needs to get dereferenced)?
 
1:15 PM
@paul23 Well, that changes the id of a because 2 and 3 are different integer objects. But a isn't actually a pointer to an integer. It's a name bound to an object, essentially a dictionary key with the (reference to the) integer object as its associated value.
 
@PM2Ring yes but that means for each lookup, it has to lookup in the dictionary where the actual data is located.
 
Your example's not as inefficient as it could be since Python caches small integers in the range(-5, 256). But yes, making everything an object is slower than what happens in languages like C.
 
Might be the reason why numpy can achieve such huge speed boosts for seemingly trivial things
 
And actually for performance reasons local vars are not implemented as dictionary lookups. But it's easier to pretend that they are. :)
@paul23 Indeed.
And you can speed things up a little and reduce RAM requirements for your own classes by using __slots__ for your class's attributes.
 
Though numpy != python in style - at all. - Trying to fit to numpy style in your own python function is actually really really annoying (automatic array-propagation is hard, but it's mostly because strings are also iterable yet numpy won't propagate those).
Worse: trying to derive from numpy arrays is almost impossible (and it's easier to just write wrappers) - where python focused a lot on being able to extend it's standard library.
 
1:22 PM
Is there a way to handle client forcibly closed connection without program failure gevent ?
 
@paul23 To be honest, I've hardly ever used Numpy, and that style-mismatch is one reason I've never been comfortable with it. But I guess if I needed to use Numpy I'd just have to get used to it. :)
 
@PM2Ring Actually I find the style very powerful - allows you to write "as if" it's simply scientific, hiding the "CS-logics" from the "mathematical-logics".
x = np.linspace(-100, 100, 1000)
y = x**2 - 2 * x + 1
plt.plot(x,y)
Won't get more "clean" than above :P
pythons way:
y = [_x**2 - 2 * _x + 1 for _x in x]
But the power really starts shining when "x" isn't a one dimensional thing, then python list comprehensions become a mess quickly.
 
I can't argue with that.
 
1:39 PM
Morning cabbage.
 
2:21 PM
Does someone who uses Windows want to help this guy find a cmd prompt?
This might be a silly question but where do I run the programme? Where do I type section12.py something other here, to make this work. Please bear in mind I have no programming knowledge. I am sure will kick myself as the answer will be so basic. — Ginja Ninja 1 hour ago
 
I'm always amazed that people can't use google.
 
I find his comment a bit weird since he's managed to run the script somehow, and was able to copy & paste that error message. I guess he's using some sort of IDE...
 
I assume the builtin REPL.
 
Anyone on cr here?
 
cr == Code Review? Not me.
 
2:33 PM
codereview ye
 
I suppose I should spend some time there, but it sounds like hard work. :)
 
cbg
 
hehe hoping to get a second opinion of which version looks "best" :P
 
part of my template looks like
        {% for line  in code %}
            {% if forloop.last %}
 <span>{{ line }}</span>
            {% else %}
 <span>>>> {{ line }}</span>
            {% endif %}
        {% endfor %}
but it produces spaces between two span tags.
donno how to avoid or remove those spaces.
 
The "2 liner that looks amazingly pythonic but abuses set(a in b if c) structure to count as any". Or the "elaborate 10 line version using lots of ifs".
 
2:38 PM
@PM2Ring exactly..
 
@paul23 Well, set calculations can be much faster than the equivalent bunch of ifs. And although a terse 2 liner may not be easy to read a maze of ifs isn't exactly easy to read, either. So in that situation I'd tend to go for the 2 liner, with comments if necessary to explain what's going on.
 
@PM2Ring Well speed difference atm is actually in favour of the "if-statement-mess" but only by 0.3% (negligible).
Algorithm is n^2-n checks however in the if-statement case I optimized it to j*(n^2 - 2*n) + i*n - where i < j (Special case)
 
In that case, maybe there's room for optimization of your set code. :)
Anyway, it's getting late here...
Rhubarb
 
2:55 PM
cya
 
 
2 hours later…
5:03 PM
cbg
@RobertGrant congrats
@tristan @tristan made me wonder... is there anything vegan+kosher+chinese food... probably not :d
 
Boiled rice.
 
5:18 PM
I'm looking for guidance on how to structure Python code on my filesystem. I'm writing an application in Python. It's a one-off application that does something I need, but is not meant to be a redistributable package. I can't tell if the advice at stackoverflow.com/questions/193161/… (for example) is applicable to me. People seem to use "application" and "package" interchangeably, which may be accurate but I'm confused by.
 
5:40 PM
I'm just using pycharm projects - and for simple things you won't need to package things (package is just a way to group scripts so they can use hierarchical namespacing). Just use different modules (files) in a flat folder at first. You'll notice when it becomes unmanageable.
 
Snowed-in weekend-cbg for everyone
 
5:54 PM
@paul23 That sounds pretty practical. Have you ever messed with PyCharm's "Project Structure" prefs, where you can mark a folder as "Sources"?
 
nope...
 
6:05 PM
Seems like that allows absolute imports in subdirectories of your project (e.g. if you want a /src folder). Still poking though. Its existence is documented, but not what it does.
 
user559633
6:59 PM
@AnttiHaapala yes, lots. soy based protein and just avoidance of egg. there was a vegan chinese food place near my last apartment in ny
 
7:37 PM
cbg
 
cbg
 
omg - badger badger badger! :p
 
A snake?
or mushroom?
 
7:56 PM
@Martijn it obviously has to be a snake given the context of this room :p
 
We did scare Wim away, it appears..
 
maybe he doesn't like mushrooms...
or just tired... doing the badger dance 24/7 must drain ones energy
 
 
2 hours later…
10:20 PM
evening
 
10:55 PM
Does this analogy for objects and attributes work?
-- An object is like a binder full of pages. When you call the object, Python hands it to you, complete with all of its pages.
An attribute is like a page in that binder, but when you call an attribute, Python reads the page to you, then returns the page to the binder and puts it away.
The data it reads to you is not the page itself, so even if you change it, the page in the binder (object) remains the same.
Methods and functions being situations where someone has hollowed out the pages in the binder and put a handgun into the space inside.
 
I don't think it works as an analogy, but it might as an example - you don't usually call objects (unless they're semantically functions) but you call methods on objects. If you had e.g. class Binder(object): def __iter__(self): for page in self.pages: yield page then iter(Binder()) would call Binder().__iter__() and return an iterator on the pages.
Does that make sense?
 
does anyone know how safe is autobahn and are there some performance data about it ?
 
That's a good point. "Call" isn't the right word there.
"Reference" is closer to what I mean, I think.
MyObject returns the binder (object), MyObject.attr reads the page in the binder then puts it away (returns the content of attr).
 
11:16 PM
ok, sure, why not?
 
I mean, the concept is really basic, but I thinking about it and I wasn't sure on it.
Thanks
 
If you really want to grock attributes you gotta understand descriptors and how they affect dotted lookups.
 
In this case, it's fine if it's super-shallow. :y
 
:)
The shallower approach is to learn how methods, classmethod, and staticmethod - and property, instance attributes and class attributes behave.
Learning about descriptors helps you understand how they do what they do.
@Augusta if I recall you're in South America right?
 
Nope!
I'm in Canada at the moment, but I'm kind of all over the place these days.
 
DSM
11:30 PM
The True North is a fine place to be.
 
It comes and goes. Montreal is pretty great; Vancouver I could take or leave.
Right now, I have elected to "leave." =_=
 
DSM
Huh. I quite like Van. Ocean; mountains; rainforest. Lots of rain, though, or at least it rains on me every time I visit. Think I prefer Quebec City to Montreal in Quebec, though.
 
Fair enough-- different cities for different people.
Everyone says Vancouver is so beautiful, but I found it to be the same century-old, ugly, West Coast North American city, just smashed into a really beautiful million-year-old natural landscape.
 
DSM
I will say this about Montreal, though: I was expecting people to scoff at my rather schoolbook French, but they were quite friendly about it and replied in French though it was obvious I was an Anglophone.
 
The weather is mild, and that bores me terribly.
 
DSM
11:36 PM
Should've left it. "Bores me terrible" has a certain archaic, quasi-poetic quality.
 
"And thusly, I was bored a terror." :y
I much prefer the people of Montreal to Vancouverites. Vancouverites are, to me, cold and extremely distant. They can be friendly, but they're horrible to try and actually make friends with.
Unless you have an in, expect to meet a lot of people there from elsewhere.
..And to drive there is to take your life into your hands. They say every city has the worst drivers, but Vancouver has drivers from every city.
Vancouver isn't a bad place, mind you-- it's just not for me at all. SO! I left.
-kvetch kvetch yammer kvetch-
 
I can't make new friends either.
 
DSM
My cousin lives there (yet another dev in the family). Might visit him this summer. I'll try to strike up conversations with strangers and see how it goes.
#nonewfriends
 
I can never understand how it is possible to have a conversation with a stranger
 
Me neither. I think an important part is to find an engaging stranger before you try.
 
DSM
11:43 PM
"Hello, good sir! Might you have an opinion on the GIL?"
 
"Hello, good sir! I'd just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX."
 
"Good day! How are you this fine evening? If I may ask, what is your favourite number, in base sixteen?"
 
DSM
"Summon your second! I reject your Stallmanite tyranny, and prefer Raymondian liberty! We will have it out, knave!"
 
"My name is Prisoner 24601. My friends call me Jean, though!"
 
"Hello! I prefer tabs over spaces."
gets shot in the head
 
DSM
11:47 PM
An unfortunate but not unjust outcome.
 
"Oh man, I could talk about semicolons all day.."
"Actually, it's pronounced jif.."
abducted by men in black helicopters
 

« first day (1925 days earlier)      last day (3039 days later) »