« first day (1603 days earlier)      last day (3350 days later) » 

12:02 AM
would a filehandle be an iterator or a generator? I say iterator but i might have been using it wrong all along
 
actually, it's all 3
but it's generally referred to as "iterable"
however, it's not an "iterator" by itself
but it does have a sufficient method to return a generator that's iterable
f = open('blah'); it = iter(f) - now it is the iterator
not to be confused with the fact that f itself is iterable
 
12:22 AM
cabbage :)
 
@JoranBeasley roughly speaking, a filehandle is an iterable. If you call iter() on it, you can an iterator that will yield all lines of the file from the filehandle
A generator is an object that looks like a function but actually returns an iterator when called
 
hmmm ... but since the bytes are consumed as you go that doesnt make it an iterator?
 
12:41 AM
I wouldn't say that. It's only a side effect of the reading cursor advancing while the iterator call readline(). That doesn't confer to the filehandle the property of being a python iterator (basically, having a next attribute)
 
file.next()
A file object is its own iterator, for example iter(f) returns f (unless f is closed). When a file is used as an iterator, typically in a for loop (for example, for line in f: print line.strip()), the next() method is called repeatedly. This method returns the next input line, or raises StopIteration when EOF is hit when the file is open for reading (behavior is undefined when the file is open for writing). In order to make a for loop the most efficient way of looping over the lines of a file (a very common operation), the next() method uses a hidden read-ahead buffer. As a cons
from docs ...
I thought f=iter(f) was the same as f=open(fname)
@JonClements f = open('blah'); it = iter(f);it is f
 
maybe not a great example :)
 
12:57 AM
A file object is its own iterator
:P
I declare victory ... perhaps prematurely
 
you won... just because I hate that, I will argue that you talked about a file handle, not a file object :D
 
 
2 hours later…
Does anyone know if there is a "standard" algorithm/data structure to solve this problem? codereview.stackexchange.com/questions/83205/…
 
3:40 AM
Hi All
I want to loop through 3 different lists, but each iteration I need to get whole list not one item of it. I tried this:
a = [{'age': 0, 'foo': 1}, {'age': 1, 'foo': 1}]
b = [{'name':'b', 'bar':2}]
c = [{'id':1, 'ht':'test'},{'id':2, 'ht':'test2'} ,{'id':3, 'ht':'test3'}]


for d,e,f in zip(a, b, c):
    print d,e,f
It gives:
{'age': 0, 'foo': 1} {'bar': 2, 'name': 'b'} {'id': 1, 'ht': 'test'}
but, what I want is:
[{'age': 0, 'foo': 1}, {'age': 1, 'foo': 1}], [{'name':'b', 'bar':2}], [{'id':1, 'ht':'test'},{'id':2, 'ht':'test2'} ,{'id':3, 'ht':'test3'}]
 
4:01 AM
@CoKoder If that's actually what you want, then all you want is a list [a, b, c]
 
4:30 AM
I'm voting to close this question as off-topic because this question is not about a practical programming problem, as laid out in the help center. — Martijn Pieters 11 hours ago
@MartijnPieters u w0t m8? edit nvm refer to meta
 
 
1 hour later…
5:31 AM
@smci Please don't ping individual users unless it is absolutely necessary. Please go through the Chat Room Rules once. Hope you understand :-)
 
 
1 hour later…
7:16 AM
@thefourtheye should I delete? — user2909415 41 secs ago
Can we recommend to delete?
 
It's been deleted :p
 
7:31 AM
Oh... I feel bad now :(
 
cabbage everybody
 
7:49 AM
cabbage :)
@Ffisegydd I commented some code as you suggested
Is my question a bit more understandable?
3
Q: Drag n Drop inside QgraphicsView doesn't work (PyQt)

Mr_LinDowsMacI created a custom class for some buttons. Those are a "draggable" buttons, which its name indicates, are buttons that you can drag and drop into each other (depending if is allowDrag property is set) and then make an action. The code of those dragbuttons is already posted here: Drag n Drop Butto...

 
8:03 AM
(going through this user since he needs to have posted lots of interesting questions)
stackoverflow.com/questions/8203883/… simple typo and the answer gets it wrong
 
8:20 AM
stackoverflow.com/questions/8135989/… (though there are right and wrong opinions) :D
 
@AnttiHaapala It is taught in class that data abstraction is a methodology to enforce an abstraction barrier between “how data values are used” and “how data values are represented”.
I need a clarification on the same.
Using python we are taught to build data abstractions
 
source
no materials? :D
 
am done till exercise 5 there
 
8:26 AM
this is actually exactly the stuff from the other course i found in google, that does the same example in scheme
the idea is that in python, classes are 1 way of data abstraction, but
 
Infact it was taught by google employee who works for NLP domain
 
the example 3 demonstrates exactly the data abstraction in general sense
these rationals are represented as tuple (num, den),
but they are used through the functions like mul_rat(a, b)
but the examples are not good at all :D
it is just that the teacher follows scheme materials with Python :D:D
 
here is exercise 3...
1
Q: Representing rational numbers using functional paradigm

overexchangeIt is taught in class that data abstraction is the methodology to create barrier between "how data values are used" and "how data values are represented". Also, an abstract data type(ADT) is some collection of selectors and constructors, together with some behaviour conditions (invariants). It i...

Basically am trying to understand that what ever am learning is corect or wrong
Because these are crucial concepts in comp sci
So, I have some questions on this, which I need to clarify
Can I ask?
 
8:31 AM
crucial and crucial... :D
so ask
but don't expect me to give the correct answer :D
because I haven't read the Structure and Interpretation of Computer Programs :D
 
If one does not learn SICP, How would one build a big software without knowing these concepts?
 
I do not know what is it called, I just use them
 
that is the point. SICP was written to explain the existing patterns
not to invent something new
ppl used the thing first, then someone said ok this is an abstract data type
the thing is, this is like: you can fix a car even though you do not know what the car parts are called in English.
 
May be I would like to have some concrete discussion instead of using car, with code already written by me as part of exercises.
 
8:36 AM
you had a question on programmers and got an answer which says "you're right" :d
so what more do you need to ask
?
 
please read the comments(by jorg) under the answer, they say something different
so am reading the paper written by Cook
which is bit confusing to me.
 
see there in cook's paper my point: "The general con-
cept of data abstraction refers to any mechanism for hiding
the implementation details of data. The concept of data ab-
straction has existed long before the term “data abstraction”
came into existence."
@overexchange about this
 
In the class, the definition is given as Data abstraction: A methodology by which functions enforce an abstraction barrier between representation and use I think both definitions are same right?
 
abstraction is about hiding detail in general @overexchange
 
yes, In addition, do you agree with this point? It is compound data that needs data processing which actually enables to think about data abstraction because the user would like to use this compound data as single unit.
geopostiion (longit, latitu) is compound data
 
8:44 AM
@overexchange the class definition is from SICP so I'd say it is as right as it can be :D
 
If we have non-compound data, We do not require data abstraction, Is that correct?
 
no it is not correct.
 
example?
 
the point is the data type is abstract
it does not say about it being compound or not
for example your geoposition, I did 1 system that packed the lat-long into a single integer coordinate
in 2.5 km squares :D
so my abstract data type was represented as a simple integer
An abstract data type is a structure that implements a new
type by hiding the representation of the type and supplying
operations to manipulate its values
 
But we are taught www-inst.eecs.berkeley.edu/~cs61a/fa12/slides/08-Data_1pp.pdf slide 9, that compound data is actually enabling us to think about data abstraction(DA).
 
8:48 AM
who cares
it helps about thinking
but you said: If we have non-compound data, We do not require data abstraction, Is that correct?
 
@overexchange lets put it this way:
if you are not defining a new data type, then you do not need to define a new data type
you need not abstract an integer since, well it is an integer.
so yes, in that sense.
but the abstract datatype need not be represented as a "compound of primitives"
it is its representation and it is not a concern for you.
unix for example stores timestamps as a seconds since beginning of 1970 in UTC
well, that is (almost an) abstract data type time_t, with procedural interface to convert it forth and back and to do calculations
 
let me tell you, how am differentiating data abstraction from abstract data type as I have an implementation shown on programmers that also explains with code.
data abstraction(DA) is the methodology to create barrier between "how data values are used" and "how data values are represented". an abstract data type(ADT)is some collection of selectors and constructors, together with some behaviour conditions (invariants).
I want to give an example here
If you go thru code written in programmers.stackexchange.com/q/275373/131582
to understand data abstraction I commented code that is coming under repre and use
 
you gave an example on programmers. the whole program in question is about data abstraction; your adt representation is (n, d) which is abstract, and the use of them is through all the methods
ah that is your problem
 
9:01 AM
let me complete
 
your repre and use is wrong :D
 
see the use is like this:
a = Rational(2, 3)
b = Rational(3, 5)
c = mulRational(a, b)
print("The result is: %d/%d" % (getNumer(c), getDenom(c))
this is the representation is internal
 
user cannot say getNumer(c), getDenom(c) user is breaking the barrier
 
can
it is not breaking the barrier since
 
9:06 AM
read this:
 
it is a selector
 
In the above 2 implementations we have 3 abstraction barriers:

1) Parts of the program that work with rational numbers to perform computation use mulRational(..), addRational(..), eqRational(..) && toString(..) computation processes only.

2) Parts of the program that implement mulRational(..) use constructor and selectors only.

3) Parts of the program that implement constructors & selectors would use built in datatypes or built-in functions.
 
ah :D
yes
 
the reason user can't use getNumer() because see the second code implementation where I changed the repre
please read the question completely in this link programmers.stackexchange.com/q/275373/131582
If reading is done, I would like to ask, Would you agree with definition of abstract data type(ADT) in my query that is defined with invariants?
Because I still have doubts there.
 
9:16 AM
oh they teach same?
 
of course
 
they are using scheme I guess
 
as I said the mit text is the direct from SICP
and the python stuff is only a poor translation thereof
so you should read it from there :D
yes, in this implementation they have 3 barriers if you want.
 
Do you agree with the definition of ADT in this equery?
`Constructors` & `selectors` constitute ADT.
In the above two implementations:
There is an abstract data type that supports an invariant:
a) If we construct rational number `x` from numerator `n` and denominator `d`, then `getNumer(x)/getDenom(x)` must equal `n/d`.
b) If we construct rational number `x` from numerator `n` and denominator `d` then `getitem_pair(p, 0)/getitem_pair(p, 1)` must equal `n/d`
 
@thefourtheye: pay attention. :-P
Uhm
Right
 
9:23 AM
@MartijnPieters If booru is not found in the dict, it will return the default value, which is a string and you are calling it
 
I need caffeïne.
 
lol...
 
Off to get some.
 
I ll clean up the comments.
 
@overexchange yeah you changed the type in there...
 
9:24 AM
change the type? sorry I did not get you?
 
I am getting headache already
 
I think I should read SICP
 
one last question, While objects and ADTs are fundamentally different, they are both forms of data abstraction. How do I understand this point from this paper
I did not understand what objects mean in this statement
 
objects means objects from object oriented programming
 
9:28 AM
In java or python, How would I interpret objects?
 
in python everything is an object :D
 
In java?
 
in java non-primitives are all objects; but...
see there
 
you mean instance of class Xyz{}?
 
the problem is that with objects the objects can decide the behaviour except...
 
9:31 AM
In programmers, I got a comment: In your title you ask about object-oriented programming, in your text, you ask about abstract data types. Objects and ADTs are two fundamentally different means o............ See On Understanding Data Abstraction, Revisited by William R. Cook for cl.... is that in Java-like languages classes define ADTs, interfaces define objects. So, if you have classes, you aren't object-oriented. Only interfaces are OO. – Jörg W Mittag
 
In a pure object-oriented
style, classes are only used to construct objects, and inter-
faces are used for types. When classes are used as types, the
programmer is implicitly choosing to use a form of abstract
data type
 
for this query
 
yeah, your title says OOPS
there is no oops in your question at all
it does not have any relation to this at all.
 
data abstraction is part of OOPS
 
so go and read the damned paper again
the whole paper is about the thing that ADT does not have anything to do with OOPS
 
9:35 AM
ok
 
and also says that those who say that OOPS is the way of doing ADT or something like that are wrong...
 
I got a comment saying: One simple (although not foolproof) rule is that in Java-like languages classes define ADTs, interfaces define objects. So, if you have classes, you aren't object-oriented. Only interfaces are OO.
as per this statement, I did not understand what for class is used and what for interface?
I am reading this paper, but I got stuck at this point: The familiar built-in types in most languages, for example the integer and boolean data types in Algol, Pascal, ML, Java and Haskell, are abstract data types. Because I thought ADT is collection of constructor and selectors that support some invariants.
 
if you have a method that accepts a certain class as a parameter only then you are not object-oriented (though actually that is not exactly right either since you allow the class or any subtypes thereof)
 
interfaces define objects I could not understand this in java as mentioned in above comment.
 
9:53 AM
think about in python and duck typing
 
am yet to learn duck typing, If I ask somebody, they say quack like a.. I don't know How to ): am bad in that
 
it means: you need to hammer a nail, you do not need an instance of Hammer, but some object that can .hammer(nail), thus you can use a Shoe too
 
@Antti that's your shoe is it?
 
@JonClements and my fingernails
Today is my weekly cross-dressing day
 
Does your wife do the same? Or is this like a secret pleasure thing? :p
Umm... well, the OP has managed to open the file I guess: stackoverflow.com/questions/28913618/…
 
10:06 AM
Oh shit, I cannot remove that line anymore, it was meant for your eyes only, oh well, now everyone can find it from the transcript :P
 
And some evil person has just gone and pinned it to the board... :p
 
:D
yeah I am cross-dressing according to my secret nerdette dream, that she would wear the "codenomicon: go hack yourself" shirt.
 
@Antti you also appear to have an outstanding invite for the sopython github
 
pass... was just looking at something and it had a "1 pending invitation" in the user list...
 
10:13 AM
hmmmmm but where do i see these :d
 
no idea :)
Invitations are sent via email and can be accepted at github.com/sopython
that's what the dialog box says anyway
 
omg
Keiron Pizzey has invited you to join the sopython organization on GitHub. Head over to github.com/sopython to check out sopython's profile.
yeah
the link to inv is: https://github.com/orgs/sopython/invitation?via_email=1 in case anyone wonders what the link is to accept
no need to go to email :D:D
 
Where can i download MySql server with CLI like this vid on Windows: youtube.com/watch?v=lhU2OZCKXhQ
 
Hmmm... Something is definitely wrong. Same exact questions and same exact answers. Looks like copy & paste.
 
10:26 AM
@thefourtheye same answerer
 
@AnttiHaapala What do you mean by this statement? SICP was written to explain the existing patterns
 
Yup. Looks like sockpuppetting...
 
@thefourtheye nope
 
Might not be... But I left the mods to decide that.
 
flagged the q
dunno about the A
might be that that was copied over after kasra cvd the post
ah no
 
10:31 AM
Within a minute the answer was posted :D
 
I looked at the same answer tiwce :D
I thought it was copied over to the duplicate target after it was written to that sockpuppet q
that is some serious programming there :D
 
The best part about that question is
> I have started writting the code but not able to continue the code :
> import sys
> for l in sys.stdin:
> data = open('D:\python\input.txt').read().strip()
 
In computer science, the longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique. Longest increasing subsequences are studied in the context of various disciplines related to mathematics, including algorithmics, random matrix theory, representation theory, and physics. The longest increasing subsequence problem is solvable in time O(n log n), where n denotes the length of the inp...
yeah there is some pseudo
it is like 50 lines
 
Cabbage everybody
 
that needs dynamic programming etc...
wish there was the "lacks minimal understanding"
 
10:37 AM
Looks like nobody likes to read at all... Just post the question in SO and ask the answerer a hell lot of question till he logs off...
 
yeah
just downvote to oblivion
do not spare the dv
 
Downvoting questions is free of cost anyway :D
 
even that deserves a downvote that the question is about subsequence
and the title says "subset"
 
cbg
 
At least someone has commented my post
 
10:44 AM
@thefourtheye That's not exactly a great start, is it. :)
 
Should I add the code that I already posted in another post?
It is some way relevant, but didn't want my question marked as duplicated post or something
 
@AnttiHaapala It's not an easy task to do efficiently. But if you're only processing a small list you can brute-force it easily enough. OTOH, I suspect that even a brute-force solution would be way beyond the OP's capabilities.
 
@Mr_LinDowsMac you should definitely put the relevant code in. It should be a minimally working example.
 
@AnttiHaapala Too broad or just too unclear? At least the OP is responding to comments, but the responses aren't very helpful.
 
too broad maybe
 
Nice
 
$2$ is the only even prime, making it an odd prime indeed. — MartianInvader yesterday
this :d
 
@Ffisegydd Done
 
Just confused my GF for 5 minutes with the "How do you split 12 lumps of sugar one..."
 
upvoted that
fizzygood is speaking in riddles
 
11:03 AM
I liked “There are two types of primes, odd and even, and they cause the same amount of trouble.”
 
Arhghgh.... it's sooooooo temping to give a completely OTT teacher would recognise it isn't their student's work answer
 
@JonClements Do it! And make your variable names spell out "stackoverflow". :)
 
@JonClements answered :D
lets see if I can get the peer pressure now :D
 
@Antti you're all 'bout that badge, 'bout that badge no treble? :p
 
11:12 AM
@AnttiHaapala I guess that means you want as many people as possible to down-vote it?
 
which one, that one?
no
just upvote my comment :D
and refuse to answer until there is something "for example" :D
 
@AnttiHaapala I meant the crazy answer you just posted to "increasing and decreasing subset in python".
 
Almost, almost: visited 999 days
 
@PM2Ring yeah also ok
 
@AnttiHaapala: hrm, aren't you stalking that user a little too much?
 
11:22 AM
@MartijnPieters :D not really
 
I agree the questions are now off-topic, but going through a list of user questions is frowned upon.
 
just noticed some off topic qs by that user so decided to see them all
 
@Martijn flagged... might be my 2nd flag on MSE ever :(
 
and they're old
nothing against the user :D
 
@JonClements here's your chance at a 3rd then:
 
11:27 AM
@Martijn thanks.... seems weird not having 100 flags :(
 
My stats on Meta.SE: 184 posts marked spam / 184 deemed helpful
Out of 504 helpful flags.
 
@MartijnPieters yeah, in any case maybe shouldn't have cv-plsd I guess queue will take care of them
php <3
 
Shog9 or Tim Post once said it's not done to go through a user post list like that; the posts are old, so it isn't all that urgent to have them all closed right now.
You have a serious hiring and / or training problem if you have 30 developers with no clue about XSS and escaping practices. — Martijn Pieters 26 secs ago
 
really old post but :D seeing that someone who currently has 50k, I get the feeling that this is the standard practice in PHP shops
 
11:34 AM
At my current contract a pentest was done of the product that found some minor XSS issues (you need to be logged in as admin and involved a part of the product used by less than 1% of the customers; customers counted in the 10s, I may add).
We fixed it properly, as we found one location where JSON data from the backend was indeed not handled properly. Minor oversight, good job pen testers.
 
But note that the company had invested in a proper penetration test to ferret these issues out!
 
or cv
 
@AnttiHaapala already dealt with from my end.
I was the first to vtc it.
 
I have 130 metarep
so I cannot see the cvotes
 
11:36 AM
True, you get to forget not many people on Meta.SE have 20k+.
 
:D
now I have 140, thanks :D
 
thefourtheye: Got it. That was something they'd pinged me about. So I supposed I just wait when I see a question deserving urgent close-as-duplicate as we've all agreed a week before, and people don't VtC
 
@Martijn well, I would have 2k+ on meta if I hadn't bountied so much ;(
cbg @smci
 
how long did the close votes stay?
forever?
how does the close vote queue work
 
@smci I appreciated thefourtheye from removing that post. I follow Meta, and I am not the only one with opening and reopening votes. There was no need to ping me (and rather useless, as you pinged at 3am my time).
 
11:48 AM
(martijn cvd that one already)
 
We should write a canonical post for that and have the teachers wonder why a lot of the students are handing in exactly the same code :p
 
cbg
@AnttiHaapala i'm the first..
 
@AvinashRaj ? :D
yeah
 
Anyone get what this is about? Seems to start with some IDE settings, then a load of code about a binarytree class....
 
11:59 AM
@JonClements looked at that for 2 secconds, and decided to close it as "unclear"
 

« first day (1603 days earlier)      last day (3350 days later) »