How can I print chunks of size 5 from a list and the remaining tail end that does not have chunk size of 5  For example  a = list(range(23))   I want to produce print out   [0,1,2,3,4], [5,6,7,8,9], [10,11,12,13,14], [15,16,17,18,19], [20,21,22]
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:
Where does Google Chrome automatically save pages? I opened the following page:   When disconnecting WiFi and even after rebooting the mobile phone, the page can still be read due to being saved automatically.  Left to the URL bar, an indicator looks like this:  This also shows up when opening manually saved pages, which are saved as MHTML files in the default download folder.  However, an automatically saved page can not be re-downloaded manually to get to the download folder, because the arrow is greyed out.I wish to copy some automatically saved pages into the download folder.  Where are the files of automatically saved pages stored? Removing elements that have consecutive duplicates What is the difference between a relative phase and a global phase? In particular, what is a phase? I know that $re^{i\theta} = x + iy$ for any complex number $x + iy$ by Euler's formula. How do you calculate relative and global phase? How to draw line through group plots in pgfplots? System.Drawing in Windows or ASP.NET services According to , it is not a particularly good idea to use classes within the System.Drawing namespace in a Windows Service or ASP.NET Service. Now I am developing a class library which might need to access this particular namespace (for measuring fonts) but it cannot be guaranteed that the host process is not a service.  Now there is a less optimal method I can fall back to if System.Drawing is unavailable, but if it is possible, I would rather use classes in System.Drawing. So what I would like to do is to determine at runtume if System.Drawing is safe or not, and if it is, use it, otherwise fall back to the suboptimal option.  My problem is: How could I possibly detect if System.Drawing is safe to use?  I think I should either   Detect if the current process is a Windows Service or ASP.NET service Detect if GDI is available Or maybe there is a way to ask System.Drawing.dll itself if it is safe to use   Unfortunately, I cannot come up with a way to implement any of these approaches. Does anyone have any idea? Anyone can optimized this code for better explanation and easy to understand? Why don't sandwich toasters have an on/off switch? The absolute majority of electrical appliances have an On/Off switch. However, the absolute majority of sandwich toasters do not - you just plug them into the socket and unplug them when you're done. At least, that's the case for all household sandwich toasters I've ever seen. I'm referring to this device, not the vertical toaster (where the lever doubles as a switch):    It looks like some models do have a switch, but apparently these are just the larger/industrial types, not the common variety.  Why is that? I have a contact in a generic sObject in apex and while I'm able to easily get detail field values using   sObject.get('MyContactField__c')  I'm not able to get fields off the related parent object, and I'm sure the related field is in memory, based on the debug logs. This returns a runtime error:  sObject.get('Account.MyAccountField__c')  with the error     Invalid field Account.MyAccountField__c' for Contact   How do I get a field value off of a parent on a generic sObject? How do you beta test an iphone app? How can you beta test an iPhone app?  I can get it on my own device, and anyone that gives me a device, I can run it on theirs, but is there a way to do a limited release via the app store for beta testing?  Related: Also, see  on getting your app onto phones without using the App Store. ibus Avro in Ubuntu 14.04 LTS I have a problem with the fancy package: I use the report documentclass and I have a chapter, a lot of text and then a new page starting with a section (or the next page has no chapter starting on that particular page).  The problem be, that what I defined for my header and footer is NOT on the chapter-page but only on the non-chapter page. How come? What did I miss?  Minimal example:  \documentclass[]{report}  \usepackage{lastpage} \usepackage{fancyhdr} % for use of \pageref{LastPage}  \fancypagestyle{IHA-fancy-style}{% \fancyhf{} %Clear header and footer \fancyhead[LE,RO]{\slshape \rightmark} \fancyhead[LO,RE]{\slshape \leftmark} \fancyfoot[C]{\thepage of \pageref{LastPage}} %Custom footer \renewcommand{\headrulewidth}{0.4pt} %Line at the header visible \renewcommand{\footrulewidth}{0.4pt}} %Line at the footer visible  \title{A short example}  \begin{document}  \maketitle \tableofcontents  \pagestyle{IHA-fancy-style} \chapter{A chapter} Look at the footer  \newpage \section{A section} Look at the footer  \end{document}   Take notice: No line on page 2 at the bottom - a line on page 3 at the bottom.  Any clues? How do I calculate the determinant of the following $n\times n$ matrices  $$\begin {bmatrix} 0 &amp; 1 &amp; \ldots &amp; 1 \\ 1 &amp; 0 &amp; \ldots &amp; 1 \\ \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\ 1 &amp; 1 &amp; ... &amp; 0 \end {bmatrix}$$  and the same matrix but one of columns replaced only with $1$s?  In the  above matrix all off-diagonal elements are $1$ and diagonal elements are $0$. How can I install Ubuntu without CD and USB? I want to install Ubuntu on my laptop that doesn't have a CD-ROM drive and I have no spare USB disk. I've tried Wubi, but that doesn't seem to work (since it prompts me to have the CD in the drive, which I don't have).  How can I install Ubuntu, easily and in a fast way?  P.s: I want to dual boot it with Windows 7 (which was preinstalled).  Edit:   When extracting the ISO to a folder and running Wubi it does install, but when I reboot the computer, it doesn't show GRUB, nor can I choose if I want to boot Ubuntu or Windows 7. After trying for the third time today, wubi gives me an error: Permission denied   I'm the administrator on the PC. I noticed relation between modulo operation and number which is power of two  Example I have to calculate $ 3431242341 \mod 2^5 $, which is $ 5 $ but it is equivalent to  $ ( 3431242341 \mod 2^9 ) \mod 2^5 $   I tried many examples and it seems to be true in general, and I am not sure if it is a coincidence or true in general that I can use first modulo operation ( greater number) and the result will be the same. How to get Lookup ID from Search API with REST PCA and proportion of variance explained Why does no physical energy-momentum tensor exist for the gravitational field? Starting  with the Einstein-Hilbert Lagrangian  $$ L_{EH} = -\frac{1}{2}(R + 2\Lambda)$$  one can formally calculate a gravitational energy-momentum tensor   $$ T_{EH}^{\mu\nu} = -2 \frac{\delta L_{EH}}{\delta g_{\mu\nu}}$$  leading to  $$ T_{EH}^{\mu\nu} = -G_{\mu\nu} + \Lambda g_{\mu\nu} = -(R_{\mu\nu} - \frac{1}{2}g_{\mu\nu}R) + \Lambda g_{\mu\nu}. $$  But then, in the paragraph below Eq. (228) on page 62 of  paper, it is said that this quantity is not a physical quantity and that it is well known that for the gravitational field no (physical) energy-momentum tensor exists.  To me personally, this fact is rather surprising than well known. So can somebody explain to me (mathematically and/or "intuitively") why there is no energy-momentum tensor for the gravitational field? $\ker T\subset \ker S\Rightarrow S=rT$ when $S$ and $T$ are linear functionals When I run:  tex algorithms.dtx   for example, I get this message.    ! Undefined control sequence. l.34 \documentclass                    {ltxdoc} ?   Help? Do you ever center AND standardize variables in multiple regression? Do you ever center AND standardize variables in multiple regression? It seems as if standardization would automatically center variables...is this true?