So I am working on a how to be able to print out 50 values from a list each time, meaning if a list contains a length of 120 values, it should print out first 50, then the second 50 and then the rest 20 in that case but the 120 would be a value of X meaning it could be changing all the time:  so what I have created so far is basically just a simple list  listTest = [1233,12412,12412,34653,78556,23523,1231231,345353,4574574,234524523,24124,34534534,4576445,23523523]  for x in listTest:     print(x)   data = {     "recipients": #List of first 50 then it should loop and take the second 50,                    # then loop again through this request and so on,     "originator": "testing", }  response = requests.post("https://test.com/messages", json=data)   which I just made a simple loop through the list but I have no idea on how to make it work that it should print first 50 values in a list, then the second 50 in a list, then the third 50 in a list etc etc until there is no more values in the list.  So it would be like etc:  print     &gt; list of first [50 values]     &gt; list of second [50 values]     &gt; list of third [50 values]     &gt; list of fourth [24 values]   How can I be able to do that?
I have a list of arbitrary length, and I need to split it up into equal size chunks and operate on it. There are some obvious ways to do this, like keeping a counter and two lists, and when the second list fills up, add it to the first list and empty the second list for the next round of data, but this is potentially extremely expensive.  I was wondering if anyone had a good solution to this for lists of any length, e.g. using generators.  I was looking for something useful in itertools but I couldn't find anything obviously useful. Might've missed it, though.  Related question:
PHP preg_match (.*) not matching past line breaks Why does Ubuntu only support versions for a limited time (and what does it mean)? Are the decimal places in a CSS width respected? Is it possible to run commands from spotlight? I run commands in terminal a lot and i'm wondering if it is possible to run the commands from spotlight. For example in spotlight  would like to run the command(because i have a lot of network issues):   ping google.com   And then spotlight to load terminal and execute the command instead of having to load terminal because it takes so long to load. So is this possible? How do I add myself into the sudoers group? Possible Duplicate:          I've added myself back into the admin's group I think, by following   But I still can't do commands like:  sudo aptitude update   I get the message  oshirowanen is not in the sudoers file.  This incident will be reported.   How do I add myself into the sudoers group now that I am in the admin group? This is a follow up to   I am using a SHA-256 HMAC function on a single-word input: sha256hmac(privatekey,word) = output. The private key length is 128 bits, it does not change. The "word" is literally one short word.  Assuming an attacker knows "word" and "output" for multiple words (e.g., dog = "dsfwrw3r3r323211", cat = "3erwerwetwewer"):   Is it significantly easier for an attacker to identify the private key by brute force with the above word/output pairs, as compared to a situation where they do not have those pairs? Is this brute force vulnerability (with word/output pair knowledge) an actual security concern? Parenthesis works in bash shell itself, but not in bash script "Stack Overflow requires external JavaScript from another domain" message Visas to travel the world I understand that you have to have visas to enter some countries, but I was wondering whether you have to pay for each visa separately or you can get a visa to go everywhere. You see videos and lists on what you should pack to travel the world, but no lists on the documentation needed. Internal keyboard and trackpad stop working after plugging in USB device I got a new MacBook Pro with OS X Mavericks. When connecting my phone via USB, the internal keyboard and the trackpad immediately stop working -- not always but in most cases. The bluetooth mouse and an external USB keyboard are not affected. Everything else works also fine. The power button of the internal keyboard still works. Reboot helps. Any ideas? New question asking form sometimes leads to accidental double posts of questions I've noticed that with the new question asking form, sometimes, attempting to submit a question will post two identical copies of the same question.  I've  (), but at the time, I assumed it was just a temporary fluke. As far as I remember, I just reviewed the question, saw no errors, and submitted it. (That's all the info I have.)  However, I just saw this happen to someone else, so it can't just be a fluke on my end. , and . The author claims there that they did indeed double click the "Review" button, but their question didn't go through since it didn't have a required tag, but when they tried to submit the question with the required tag, they only clicked it once.  Also, now that I think about it, it could not have been just a temporary client-side issue on both our ends. The system is supposed to  if one tries to post more than one question in 30 seconds. Neither of us got a CAPTCHA. This means that the server accepted the double post, and so it's a server issue.  This has the effect of denying users badges that they would have otherwise qualified for, since a single negatively-received, closed, or deleted question . This means that even if the double post is deleted and the original is upvoted, the user won't qualify for that day since they've made a "bad" question on that day. (While they may be able to later reverse this 60 days later by undeleting and re-deleting their question - questions deleted more than 60 days later aren't considered "deleted" for the check - they often won't be able to, since most of the time, users will have downvoted the double post, which also disqualifies one from the badges.)  Can an employee go through server logs to see what happened in both these cases, and add some safeguards to prevent accidental double submissions of questions? This seems to have come up when the new asking form was deployed.  Update: There was another case just now:  was . As both have the exact same time of submission, this is an instance of this bug, since as I said above, this thing is ordinarily prevented by a CAPTCHA. If $\mathop{\mathrm{Spec}}A$ is not connected then there is a nontrivial idempotent jQuery/JavaScript: accessing contents of an iframe I would like to manipulate the HTML inside an iframe using jQuery.  I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:  $(function(){ //document ready     $('some selector', frames['nameOfMyIframe'].document).doStuff() });   However this doesn't seem to work. A bit of inspection shows me that the variables in frames['nameOfMyIframe'] are undefined unless I wait a while for the iframe to load. However, when the iframe loads the variables are not accessible (I get permission denied-type errors).  Does anyone know of a work-around to this? I'm studying abstract algebra for the first time.  let $F$ be a field. I learned that polynomials over field $F$ means polynomials with coefficients in $F$ (denoted by $F[x]$). But when I keep studying, I get to confused the word, 'polynomial functions from $F$ to $F$'.  Firstly, I consider this as induced functions from $F[x]$, so I guess all coefficients of these functions are in $F$. But let $F_{4}$ be a finite field consisting of four elements $\{0, 1, a, b\}$. and let $f: \{0,1\} \rightarrow \{0,1\}$ be a function defined by $$ f(x)=ax^2-ax$$ Since $\{0,1\}$ is a subfield of $F_{4}$ and $f(0)=0, f(1)=0$, I think $f$ is a example polynomial functions from $F$ to $F$ of which coefficients are not in $F$. Am I wrong? if so, please help me.  I encounter this problem while solving 'the set of all polynomial functions from $\Bbb{Z_{3}}$ to $\Bbb{Z_{3}}$ cannot possibly be isomorphic to $\Bbb{Z_{3}}[x]$'. PGFPlots: Understanding how to draw plots on different layers and arrange them Per-chapter bibliographies in biblatex I'm really new in using biblatex, compile the sample placed in , but what I get is    1.1 Foo    Some text [B02x ].    1.2 Bar    Some text [B02y ].   Do not get the bibliography by chapters, or the global references.  Really not remains to be done   \documentclass{report}  \usepackage[style=alphabetic]{biblatex}  \addbibresource{references.bib}  \begin{document}  \chapter{First chapter}  \section{Foo}  Some text \cite{childs_temperature}.  \printbibliography  \chapter{Second chapter}  \section{Bar}  Some text \cite{hashemian}.  \printbibliography  \newpage  \printbibliography  \end{document}   And the references.bib    @BOOK{childs_temperature,   title = {Practical Temperature Measurement},   publisher = {Butterworth - Heinemann},   year = {2001},   author = {Childs, Peter R N},   address = {Great Britain},   edition = {1},   isbn = {0 7506 5080 X}   }    @PHDTHESIS{hashemian,   author = {Hashemian, Hashem Mehrdad},   title = {Measurements of dynamic temperatures and pressures in nuclear power plants},   school = {{The University of Western Ontario}},   year = {2011},   type = {PhD {T}hesis}   }   I need to obtain references by chapter and global cited references, but i don't know how compile. Often in fantasies involving magic casting spells requires a certain physical or mental toll on the caster. I don't recall any mention of spells being physically or mentally taxing in the Harry Potter universe.  Does this mean they can cast an unlimited number of spells in a given day without any negative effect to themselves? When selecting a new site in the app, the user name remains displayed in the bar above.       How to reproduce:   Look at a user's profile. Click "All (number) sites" Click one of the icons that are displayed in the left.   The user name at the top remains displayed.     App Version: 1.0.89 Device Manufacturer: asus Device Model: K011   OS Version: 4.4.2 (JP_K011-JP_user_3.1.23.189_20141124-user-20141124) Get name of caller function in PHP? Issue with QGIS 2.10.1 Clip and Intersect Tools