« first day (1572 days earlier)      last day (3601 days later) » 

00:00
@JoeSaad each row is a tuple of columns. You appear to be querying one column, so you get 1-tuples back. Which is why your json looks like that.
@davidism yeah, might be fine, but I felt like putting (at least a bit) effort into a "let me google that for you" answer. I might try to avoid that in the future. Thanks for checking the code, though!
no, I didn't check the code...
oops, misread
I checked it when answering (which is the effort I'm talking about). anyways... sorry if this was kind of offtopic.
@ZeroPiraeus aww, I was typing the exact same thing :)
@davidism Sharp eyes... :)
00:13
it was @Zero, not me
@davidism waited around for a bit, but that comment thread wasn't the ideal place for the answer and it didn't look like anyone else was going to, so ...
yeah, I was waiting for Sarvesh to answer, lol
might want to change the first loads to results.json() so at least other encodings are handled, if that ever comes up
@davidism Done (but left the pprint bits alone because I think the explanation's clearer that way).
0
Q: Python: Pipe Putty serial console in a cmd prompt screen

user3528365So I am trying to launch a putty window that establishes a serial connection, and then have the main cmd window(the one that launched my python script) control the putty window. The putty window will still be open and showing everything, but I want to disable the stdin on it and just have it get ...

thats an interesting question ... I cant think of anything that would make you want to use putty for serial from python
00:29
yeah, just use paramiko for ssh in python
00:43
@davidism, have you ever used sqlalchemy's event listeners, by chance?
yeah
is that the appropriate tool to use to update a few model columns whenever they are modified?
Probably, although maybe a hybrid_property with a setter would work. I'd have to know specifically what you were trying to do.
I don't think that any sort of method would work, because I am accessing it purely with flask-restless and HTTP requests
If it's something like "hash a password when it's set", that can be done with a hybrid. If it's something more complicated across multiple columns at once, or effecting other models, events would be better.
You still have control over your model, and restless I'm pretty sure follows hybrids, so there's no reason the method of querying should stop you.
00:51
two cases:
1. someone edits a model, a last_edited tag is updated with current date and time
2. someone adds or remove a model related to another, a column referring to the number of that model related to it must change
well the first case, you can just set the onupdate attribute of the column
Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
the second one can't tell what you're saying, are you referring to the foreign key?
sorta, it's a many to many relationship, but one model must keep an integer representation of how many of the other model it's related to, if that makes sense
ah, denormalizing a count
is that what it's called? That makes it so much easier to google haha
in that case, I'd say an event would be appropriate
00:55
when a relation is added/removed, does that fire the after_update event?
normalization is when you reduce the redundant information in a db, which is a nice concept but can sometimes be inefficient, denormalizing is adding technically redundant information rather than calculating it during the query
uh, I'd have to check
oh that counts as normalization? I always thought of normalization in terms of primary and foreign keys
that's a common case, but there's other things like precalculating aggregates
use the append, remove, and set events, which are triggered when collections are updated
or you can use the before_flush event if you want to use fewer events, but then you have to loop through the session's new, dirty, and deleted instances to find the ones to update, rather than setting the event directly on the attribute
ah okay, thanks so much for the help
no problem, almost done?
01:02
pretty close, can create, delete, and add relations, just leaves editing and testing
nice. rbrb for now
night
buh, forgot the syntax for passing just a plain method to a decorator function
@davidism so why is each record appearing as its seperate array [ ]
i@davidism i changed the sql statement to be select * from artist and i'm getting :
which still doesn't look right to me: "[[1, \"AC/DC\"], [2, \"Accept\"], [3, \"Aerosmith\"], [4, \"Alanis Morissette\"], [5, \"Alice In Chains\"], [6, \"Ant\\u00f4nio Carlos Jobim\"], [7, \"Apocalyptica\"], [8, \"Audioslave\"], [9, \"BackBeat\"], [10, \"Billy Cobham\"]]"
01:19
what's wrong with it, Joe?
looks like each record has primary_key and artist_name fields, so it's pulling both
do you know the field names in the table (e.g. is it yours?) Try just doing SELECT ARTIST_NAME_OR_WHATEVER_YOURE_CALLING_IT FROM ARTIST
01:43
He doesn't understand why the results are lists even when he does that Adam. It's because every row is always a list of columns even if only one column is selected. Needs to modify the results after doing the query to return the list of single values rather than lists.
As I explained more cryptically before.
Rbrb from phone
01:57
Ahhh ok
 
1 hour later…
03:05
cbg
shameless plug
9
Q: Story with children that have magical powers imbued by wearing stones around their neck

Jon ClementsI believe I first read this in the mid/late 80s. Here what's I can recall: It involved a boy and a girl - I believe 7-10 years old - I don't recall if they were friends or brother and sister They were given a "stone" on a string necklace that enabled magic and protection of some sort from some ...

user559633
03:28
that question is agist against younger answerers. stop oppressing me
user559633
[but actually, good luck on the search]
thanks I think?
user559633
haha. sorry, overtired and listening to awful stories from salespeople in the hotel bar/lobby is doing long-term damage
user559633
from now on, i'm going to teach people that # is called an "octatherp" when used in code dougkerr.net/Pumpkin/articles/Octatherp.pdf
user2555451
From this question: '''Docstring omitted.'''. I'm SO using that next time my boss whines about me not documenting a function.
03:35
@tristan our MTFL is being damaged? We pray to cabbage the outcome isn't too "weird" :p
(how we can tell is another thing though...)
user559633
Oh good god @JonClements. Last night, a group was lamenting the age of consent being 16 in some states ("16 is already an adult woman!"). Tonight, "isn't it hilarious how i pressured a junior employee into a $1000 severance because he needed to move cross-country, and, later that week, he got into a serious car accident and ended up spending way more than $1000 on medical bills?"
in the UK, unless, you're "posh" you don't generally have to worry about medical
user559633
"posh" people receive fewer services?
nah - they just have private care
user559633
a man in soft-bottomed leather shoes trips and breaks his nose. he shows up at the urgent care and the receptionist sighs in exasperation and extends her finger to point to a sign that says "no posh"
03:42
The four publicly funded health care systems in the countries of the United Kingdom are referred to as the National Health Service (NHS). The systems are primarily funded through central taxation. They provide a comprehensive range of health services, the vast majority of which are free at the point of use for people legally resident in the United Kingdom. The four systems are mostly independent from each other although some functions might be routinely performed on behalf of the UK Department of Health or for one of the other three systems (e.g. Northern Ireland has no high security mental hospitals...
so... instead of the rest of the world, it's funded not by being able to show a credit card/proof of insurance, but my tax and NI... blah blah
user559633
i'm of the mindset that most injuries can be solved with duct tape, a lighter, whiskey, and/or being told to harden up
user559633
I do actually believe in the NHS -- but last time I had to use an A&E (via ambulance) - it was filled with drunks
user559633
an A&E?
user559633
03:47
What is an A&E?
accident and emergency
user559633
And yeah, in principle, I believe in free healthcare, but having been to a hospital in the states, the people that we give free healthcare to tend not to be desirable and use the emergency room to complain about headaches to seek drugs.
user559633
ah, we're talking about the same thing and have the same criticisms.
oh yeah... publically/private funded - there's people here that still turn up to hospital in A&E saying "got a headache"
now... if you've got a dehabiliting headache that's been going on for months.... that's okay... you should probably have been there with a GP note...
anyway the NHS here is political foot ball sadly - a "sacred cow"
user559633
it's better than some of ours in the states, to be sure
03:57
apparently the 3rd largest employer in the world or something
user559633
not sure i believe that
user559633
seeing as there are more than 3 worldwide fast food chains
umm, think it has about 2.4 million employees
user559633
that's approximately 1/27th of the residents of the UK
user559633
parliament.uk/briefing-papers/sn03228.pdf suggestions the working population is 40,243,000, so 2.4mm employees would say that 1 out of every 16.77 people are employed by the NHS
user559633
user559633
1 out of 23.67 people... wow
user559633
bbc suggestions 1.4mm a year earlier, so that doesn't seem too far-fetched if both are considered reasonably reputable
yeah, the conseratives are trying to run down the budget
user559633
that's a somewhat absurd ratio. is the whole of the Uk some sort of mill town for sick people
well, it was founded after WW2
user559633
04:12
and? the UK did well in ww2. didn't the USA formally give you the "runner's up" title?
you've never read history?
user559633
what's a history?
user559633
04:29
I'm off. Take care Jon Clements
05:13
good morning friends.....
 
1 hour later…
06:31
Cbg
cbg :-)
@Zero the "3-parent" baby law got passed
06:41
3 babies can be parents now?
I have no idea what that is ... something to do with poly couples?
(sorry, one should drink more coffee before posting!)
@ZeroPiraeus it's to do with reducing the risk of inherited disease by getting someone else's DNA in there as well
See also: adoption
06:43
The technique uses a modified version of IVF to combine the DNA of the two parents with the healthy mitochondria of a donor woman.

It results in babies with 0.1% of their DNA from the second woman and is a permanent change that would be passed down through the generations.
Just took a look ... seemd pretty sensible.
In the case of adoption, that percentage is slightly higher
Prime Minister David Cameron said: "We're not playing god here, we're just making sure that two parents who want a healthy baby can have one."
Rule of thumb: if doctors are for it, and priests against, it's a good idea.
chops brain in half for study in world war 2
06:45
@RobertGrant okay so it's not an iron rule ;-)
Reich you are
yet... I'm amazed at myself, being an atheist and scientific by nature... I, err, feel awkward by this news...
Being Christian and scientific, I don't think it's a problem, except that there are thousands of babies born who need to be adopted, and I'd 100% go that route instead
Which would also fulfill Cameron's proclamation
Ps. did I mention adoption?
@JonClements I can see where you're vcoming from. It's a type of meddling with our own nature that we haven't done (afaik) before. Personally I'm fine with it, but I can understand it feeling weird.
06:48
cabbage @Sevanteri
cabbage
Sevanteri is my colleague sitting next to me here
Welcome @Sevanteri :-)
Hey :)
@JonClements also will the NHS pay for it?
@Sevanteri cbg
06:53
@Robert yep, adoption = a good thing :-) Given that the urge to reproduce isn't going anywhere though, this seems to be about healthy babies vs. unhealthy babies. You aren't going to persuade all potential parents "here, have this one we made earlier instead"; the biological imperative is too strong.
Well, I dunno if it's too strong or people just don't really consider it as an option
I'm coming from the point of view of free will of course
youtube.com/watch?v=0fWhYJNZt08 <-- taiwan has this amazing safety culture :D
@RobertGrant It's one of the top seven :-)
Life processes yes, not things we can't override
Revert our lives back to just obeying primitive instincts and that would be a crappy, precivilised world, just with nastier weapons
07:09
a mate popped around late last night, had some homebrew stuff
Going to have to disagree with you there. The urge to reproduce is, for obvious reasons, a fundamental one - not everyone feels it strongly (and it can vary over time), but it can be extremely powerful. Aside: while I have no problem with people believing what they like, it does piss me off when religious people argue that others should "exert self-control" when it comes to instincts that they personally happen not to share, or to share to the same degree.
smelled not great, but being polite, a bit of lemonade...
... wicked hangover?
not sure in the worst of hangovers I've ever actually had felt my liver before
07:11
Ouch :-)
think the way he'd done (as in brewed/matured) it, I pretty much ingested nearly pure alcohol (god bless lemonade)
@ZeroPiraeus thank goodness I didn't say that, then
hem, you cannot get above 20 vol% easily
without distillation
so, I'm still doubtful
@ZeroPiraeus and saying "it does piss me off when people do X" is basically the same thing as someone else saying "thou shalt not", as you may imagine it being said
he's Irish....
I think it was his attempt at poteen
07:17
@Robert this is probably one of those conversations we should drop for the sake of room harmony :-)
it is always so exciting to try home-distilled spirits, it is like "oh wait I can't see anything OMG.... oh noes, oh yes, it was just power outage"
@ZeroPiraeus I don't see that in the list, sorry :)
@ZeroPiraeus just don't appreciate it when people start putting words in my mouth, basically.
too meta for python room already :D
I do not even understand what you 2 are talking about anymore
when did we start saying "basically" in sentences.
My own interpretation of "be nice" in this particular context is "don't subject the rest of the room to a predictable escalation of a well-rehearsed argument" (directed at myself, not you). I apologise for offending you; it was not my intent.
07:20
I hear it a lot. Along with "like" where not needed.
@ZeroPiraeus no problem :)
As I said earlier, I don't have a problem with the procedure from that point of view
@RobertGrant @ZeroPiraeus is there something about a conversation I should be aware of, and if so, can we call it quits and nice being forward...
@JonClements basically
@JonClements In all seriousness, I don't understand that sentence :)
... though it is fascinating to follow such a heated discussion from far away; usually I am the one generating the heat :D
just listening to a news report that started with "Well, basically..."
07:26
Oh for the days of BBC announcers in dinner jackets with cut-glass accents ;-)
@JonClements isn't it better for you that they say "Well, basically", instead of "In principle yes, but..."
@ZeroPiraeus would like to not go back to that, but non-abuse of the language would be nice :)
Be happy they didn't start "fing is, right ..." :-)
&quot;programming&quot; - lol
@AnttiHaapala Nah - it's never used like that... just say your bloomin' sentence
07:29
and if any of you didn't get it, "In principle yes, but..." is from radio Yerevan, so if you hear it from the broadcast you are living under a Communist dictatorship...
nothing wrong with dictatorship as long as it's mine :p
Dictatorship of the puppytariat?
that's what Stalin said ;)
Q: Is there a difference between capitalism and communism?
A: In principle, yes. In capitalism, man exploits man. In communism, it's the reverse.
@ZeroPiraeus Good :)
07:39
priceless :d
I'm going to adopt that approach for the mod elections (should they turn up) - what could go wrong!? :p
you have my vote, puppy!
woof woof!
@thefourtheye I think that's dog for "thanks!" - hope I didn't insult his Mother or something
@JonClements for talking about language already, you now get picked on for capitalising mother incorrectly
user3522371
07:46
hello people, is it ok to create more than one profile on SO ? Because I have a series of bad questions to ask in something I am just a beginner
early popcorn
@RobertGrant It could have been a reference to Pachamama ;-)
Ah, okay. Bullet dodged!
bah: The user has been kicked and cannot return for 30 minutes. Moderators have been informed.
07:57
@Jon can you remember the time increments for kickmute? I am curious, but do not wish to experiment on a live subject.
Uh, I have been formatting my skype chat with SO's markdowns...
I think it's 1, 2, 5, 10 ,30
/me does something similar
08:33
Is OpenCV as efficient when used in Python as in C/c++ ?
no, everything is slower on optimal Python compared with optimal C/C++, but the question is: "is it relevant"
cel
cel
08:52
Hmm... I dont like the reject :/ stackoverflow.com/review/suggested-edits/6942257
_csv.Error: line contains NULL byte
at for line in tmpreader:
why oh why??? why does it need to even scan for nulls there?
Why imread() function of OpenCV is not well documented in its Python side ? I mean, they do not specify the return value which a a matrix of pixels as they mentioned for C/C++ : docs.opencv.org/modules/highgui/doc/…
shrug - go complain to their bug tracker
09:31
hai
if i define a funtion within a funtion, the frame with definition of that function still exists until program exists. why is that?
re-cbg
why is that?
You've returned the function to the outer scope though.
@overexchange Didn't this help?
no it didnt
09:38
Which part?
please read my latest comment, that is where am stuck
Winter GM Meeting. February 17th 15:00 UTC. Be there or be pickled.
5
my question is, why frames f1 and f2 are required to exist? the frames that return int type object, we do not maintain such frames. and in any case both are returned by reference
@overexchange Do those frames really exist, or are they shown just for readers reference?
@Ffisegydd Wolfram alpha 2015-02-17 15:00 utc in local time does not work for me...
@Fenikso hmmm strange, it works for me :/
That link is automatically added to the webpage to help in converting times.
09:46
@Ffisegydd My teacher says, yes they exist. Otherwise object which is pointed by n is required because when you call add1_4(3) or add2_4(3) you are just passing k, where do we get value of n from?
@Ffisegydd It works from my proxy, but not from the work one. Weird.
@overexchange Right. The n is not stored anywhere. Makes sense.
@overexchange Mother of god... A teacher teaches this? Where are you studying?
Or is the n stored in the function that is passed out?
yes sir, am a loser who started learning computer science(past 6 months) with this course from internet. this is recording of UOC berkeley taught by google employee(alumni)
@thefourtheye Yeah, the thing is, that even when I consider myself very good with Python, I never bothered with such things.
09:50
@Fenikso yup, that kind of beats the purpose of using Python :D
@overexchange Come on, you are learning... Cheer up :-)
@thefourtheye am 10 year old in IT industry after my college ): Hope you understand now ): Basics are Basics, If I miss that, I will pay for it in long run
@Ffisegydd Yes:
>>> def g(n):
...     def f(k):
...         return n + k
...     return f
...
>>> f = g(4)
>>> {v: c.cell_contents for v, c in zip(f.__code__.co_freevars, f.__closure__)}
{'n': 4}
10:02
@thefourtheye yes but moving to NZ in next 6 months
>>> y.__closure__[0].cell_contents = 56
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: attribute 'cell_contents' of 'cell' objects is not writable
That seems like a good thing ...
But it would open up all kinds of black magic voodoo.
@ZeroPiraeus I did not understand this syntax >>> {v: c.cell_contents for v, c in zip(f.__code__.co_freevars, f.__closure__)} {'n': 4} what exactly are we doing here? am new to python
10:06
It's called a dictionary comprehension.
It's just a dictionary comprehension .... the point is that n is stored in the function:
>>> f.__code__.co_freevars[0]
'n'
>>> f.__closure__[0].cell_contents
4
oh ok, "code" is a member of function type object, you are trying to view members of it
__code__ contains everything related to the code of the function, it is the immutable part of it
__code__ (immutable) together with __closure__ (mutable) are made into a new function
Might as well onebox the answer I copied that dictcomp from, I suppose - might aid understanding:
Oh, Python internals lesson right here. That is why I love this room.
10:10
2
A: What is a cell in the context of an interpreter or compiler?

Zero PiraeusIn Python, cell objects are used to store the free variables of a closure. Let's say you want a function that always returns a particular fraction of its argument. You can use a closure to achieve this: def multiplier(n, d): """Return a function that multiplies its argument by n/d.""" d...

and what about this code?
why n does not exist in the frame where it is defined until the program exits?
What about it? It's a straightforward function. I'm not sure what you don't understand from Alex Martelli's answer, to be honest.
@overexchange Result is 2, what's the problem?
In the second case, instead of returning a function type object am returning int type object. So, My question, Why name n is not visible in second case unlike first case?
@ZeroPiraeus strictly co_freevars/cells have non-global free variables
10:16
@overexchange No you aren't ... what on earth makes you think you're returning a function? You're returning an integer: specifically, the integer 2.
I mean returns by reference in both cases return n and return g
@ZeroPiraeus Am i clear with my question?
Not really ... but I think you have some fundamental misunderstandings. There's not really any such thing as "return by reference" in Python.
hem, there is nothing else in python except "by reference"
well strictly speaking
10:21
@overexchange To make it easy to grasp, basically value of n is not needed when the function ends and returns the value in second case.
@AnttiHaapala yes you are right
isn't it clear, I and Zero are both right, there is nothing like return by reference excepting the fact that everything in python is returned by reference :D
In first case, the value of n is needed every time that function stored in add_1_4 etc. is called.
@overexchange: in the second case the n is internal to the code object...
>>> def foo():
...     n = 2
...     return n
...
>>> foo()
2
>>> foo.__code__.co_varnames
('n',)
>>> dis.dis(foo.__code__)
  2           0 LOAD_CONST               1 (2)
              3 STORE_FAST               0 (n)

  3           6 LOAD_FAST                0 (n)
              9 RETURN_VALUE
@Fenikso nailed it....
10:26
unlike n which is not part of code object of g in first screenshot?
ok
@AnttiHaapala what about this code? why do we need to maintain frames f1 and f2?
@overexchange in the first example, it's a free variable. In the second, it's a local. Did you read the answer I posted earlier?
@overexchange they are not maintained!
only the free variables bound from upper non-global scopes are maintained
Too broad
Hrm, It appears I neglected to say:
Cabbage!
@MartijnPieters Cabbage!
A brassic welcome to you, sir.
10:37
@Fenikso so what for __closure__ attribute used? only for such scenarios?
@overexchange __closure__ holds closed over variables.
cells.
So any non-local name used by a nested function or generator expression or list comprehension or any such code object.
(except for globals)
@Fenikso I think answer from Zero is what I was expecting in my query. sorry for confusion!!!
Hi, can someone please explains me what 157 represents here ?
guess 0 is the channel, and 157 the value from 0-255 :P
Look up the object docs and see what it's __str__ method does.
10:47
@AnttiHaapala thank you very much
For BGR image, it returns an array of Blue, Green, Red
the accepted answer is not right
@AnttiHaapala really ? why ?
because I said the correct one
img[100, 100, 0] returns the blue channel value of the pixel at coordinates 100, 100
you can get the whole pixel as img[100, 100]
@AnttiHaapala totally different answer then. Please answer me above that question and I will accept yours
and it will give a BGR list such as [157, G, R]
no time, you can read the docs carefully and then answer yourself and I will upvote :d
10:52
I did a screen shot for this conversation for deeper reading. Thank you a lot. @AnttiHaapala
@MartijnPieters so func_closure attribute does not exist in python3? Do we use 'closure' attribute in python3?
@overexchange yes

« first day (1572 days earlier)      last day (3601 days later) »