Failure when filtering string list with re.match I'd like to filter a list of strings in python by using regex. In the following case, keeping only the files with a '.npy' extension.  The code that doesn't work:  import re  files = [ '/a/b/c/la_seg_x005_y003.png',           '/a/b/c/la_seg_x005_y003.npy',           '/a/b/c/la_seg_x004_y003.png',           '/a/b/c/la_seg_x004_y003.npy',           '/a/b/c/la_seg_x003_y003.png',           '/a/b/c/la_seg_x003_y003.npy', ]  regex = re.compile(r'_x\d+_y\d+\.npy')  selected_files = filter(regex.match, files) print(selected_files)   The same regex works for me in Ruby:  selected = files.select { |f| f =~ /_x\d+_y\d+\.npy/ }   What's wrong with the Python code?
What is the difference between re.search and re.match? What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it.
Tags in spoilers are always visible Errors "*ERROR* UVD not responding, trying to reset the VCPU!!!" How to vertically center content with variable height within a div? What is the best way to vertically center the content of a div when the height of the content is variable.  In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable height as well. Also, I would love a solution with no, or very little use of CSS hacks and/or non-semantic markup. How to see the full date on macOS Big Sur? How to initialize all members of an array to the same value? I have a large array in C (not C++ if that makes a difference). I want to initialize all members of the same value.  I could swear I once knew a simple way to do this. I could use memset() in my case, but isn't there a way to do this that is built right into the C syntax? View referrals from one part of my site to another in Google Analytics I have an online shop with a blog structured this way:   Shop: example.com Blog: example.com/blog   Both index have the same Google Analytic Code (UA). In the blog I write articles about some products with a link to the product page.  Now the problem is, I want to see stat on visits whose referral links have this pattern example.com/blog/*. primes whose difference is a multiple of $n$ Expected value of sums Suppose we draw cards out of a deck without replacement. How many cards do we expect to draw out before we get an ace? how to hard-bypass the input of a line driver with a switch? I would like to use  with a video.  With ffmpeg I can export some (.jpeg) images from a video. Can I convert a .jpeg into a valid .tiff or export directly .tiff images from the video with ffmpeg? I sometimes hear stories where people compare their feelings in winter in different places in the world.  It goes like     in city X the temperature was the same as in city Y, but the humidity made me feel much colder...   or      oh well, -20°C would be cold, but the humidity was low, so it felt OK   so it implies that humidity somehow makes it feel colder. I am talking about temperatures below freezing (-30...0°C).  Does this have any physical explanation, or is it some sort of ? How do I get a Realtek RTL8723BE wireless card to work? I have installed Ubuntu 15.04 on my laptop with RTL8723BE Wi-fi card. But it is always disconnecting from network. I have tried echo "options rtl8723be fwlps=N ips=N" | sudo tee /etc/modprobe.d/rtl8723be.conf but that didn't helped. What can I do to prevent the wifi from disconnecting? If I upgrade to kernel 4.X, will it help?  ~$ lspci -knn | grep Net -A2  09:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter [10ec:b723]     Subsystem: Hewlett-Packard Company Device [103c:2231]     Kernel driver in use: rtl8723be   ~$ rfkill list 0: hci0: Bluetooth     Soft blocked: yes     Hard blocked: no 1: phy0: Wireless LAN     Soft blocked: no     Hard blocked: no   ~$ ifconfig &amp;&amp; iwconfig &amp;&amp; route -n &amp;&amp; ping -c 1 google.com eth0      Link encap:Ethernet  HWaddr 38:63:bb:cd:4a:7e             UP BROADCAST MULTICAST  MTU:1500  Metric:1           RX packets:3 errors:0 dropped:0 overruns:0 frame:0           TX packets:53 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000            RX bytes:752 (752.0 B)  TX bytes:8445 (8.4 KB)  lo        Link encap:Local Loopback             inet addr:127.0.0.1  Mask:255.0.0.0           inet6 addr: ::1/128 Scope:Host           UP LOOPBACK RUNNING  MTU:65536  Metric:1           RX packets:3870 errors:0 dropped:0 overruns:0 frame:0           TX packets:3870 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0            RX bytes:314613 (314.6 KB)  TX bytes:314613 (314.6 KB)  wlan0     Link encap:Ethernet  HWaddr c0:38:96:6d:c4:83             inet addr:192.168.1.205  Bcast:192.168.1.255  Mask:255.255.255.0           inet6 addr: fe80::c238:96ff:fe6d:c483/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:15240 errors:0 dropped:0 overruns:0 frame:0           TX packets:14627 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000            RX bytes:14410285 (14.4 MB)  TX bytes:2192744 (2.1 MB)  eth0      no wireless extensions.  wlan0     IEEE 802.11bgn  ESSID:"DIR-615"             Mode:Managed  Frequency:2.437 GHz  Access Point: 00:90:4C:08:00:0D              Bit Rate=150 Mb/s   Tx-Power=20 dBm              Retry short limit:7   RTS thr=2347 B   Fragment thr:off           Power Management:off           Link Quality=70/70  Signal level=-22 dBm             Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0           Tx excessive retries:0  Invalid misc:186   Missed beacon:0  lo        no wireless extensions.  Kernel IP routing table Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 0.0.0.0         192.168.1.1     0.0.0.0         UG    400    0        0 wlan0 169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0 192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0 PING google.com.Dlink (172.26.136.19) 56(84) bytes of data. 64 bytes from 19.136.26.172.in-addr.arpa (172.26.136.19): icmp_seq=1 ttl=249 time=102 ms  --- google.com.Dlink ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 102.547/102.547/102.547/0.000 ms Make your own .sty files Sorry to start a subjective question, but want to understand "own.sty" file.  Other than all \usepackage{} what sort of other commands can be added to the makeyourown.sty file.  Can you include \let command, and \newcommands in it.   What sort of precaution / structure newbies should follow. Equivalent definitions for simple connectivity How to create animated GIFs of prototype mockups, like the ones on Dribbble? I'm sure you've seen Dribbblers upload animated mockups of their designs.   Here's an example:     I can create mockups on Photoshop and even apply simple Tween Animations to them but I can never get my GIFs to look like the example here.   What are Dribbblers using to create these animations?   Notice that the animations also include touch points and perfect motion. I would like to convert my Photoshop mockups to do the same.  How can I create an animated example of my mockups, similar to the ones created by Dribbblers? What canonical momenta are the "right" ones? I'm doing some classical field theory exercises with the Lagrangian $$\mathscr{L} = -\frac{1}{4}F_{\mu \nu}F^{\mu \nu}$$ where $F_{\mu \nu} = \partial_\mu A_\nu - \partial_\nu A_\mu$. To find the conjugate momenta $\pi^\mu_{\ \ \ \nu} = \partial \mathscr{L} / \partial(\partial_\mu A^\nu)$, I can use two methods.  First method: directly apply this to $\mathscr{L}$. We get a a factor of $2$ since there are two $F$'s, and another factor of $2$ since each $F$ contains two $\partial_\mu A_\nu$ terms, giving $$\pi^\mu_{\ \ \ \nu} = -F^\mu_{\ \ \ \nu}.$$  Second method: get $\mathscr{L}$ in terms of $A$ by expanding and integrating by parts, yielding $$\mathscr{L} = \frac{1}{2}(\partial_\mu A^\mu)^2 - \frac{1}{2}(\partial_\mu A^\nu)^2.$$ Differentiating this gets factors of $2$ and gives $$\pi^\mu_{\ \ \ \nu} = \partial_\rho A^\rho \delta^\mu_\nu - \partial^\mu A_\nu.$$  These two answers are different! (They do give the same equations of motion, at least.) I guess that means doing the integration by parts changed the canonical momenta.  Is this something I should be worried about? In particular, I have another exercise that wants me to show that one of the canonical momenta vanishes -- this isn't true for the ones I get from the second method! Plus, my stress-energy tensor is changed too. When a problem asks for "the" canonical momenta, am I forbidden from integrating by parts? I've got a development webserver on an Ubuntu box inside of VMWare Workstation 7.1.3. I'd like to run a web browser on a Windows machine (the host OS) for actually testing a web page I'm working on -- hard to run IE tests in Ubuntu :)  However, if I simply try to ping the IP given to the ubuntu VM (192.168.83.137) (or open it in my browser for that matter), it seems the host cannot communicate with the guest.  How do I allow the guest OS to communicate with the host when the guest is running in NAT mode? I'm trying to create a join/relate in QGIS where I have a shapefile of buildings and to that I would like to join a non-spatial table (.csv-file) containing people who work in each building. So I have multiple records in my table that I would like to be able to join to my single features in my shapefile. I can only run a join in QGIS where the first record is joined to the shapefile feature (ie building) but subsequent records get removed. Could someone let me know how to complete this join/relate in QGIS? Is there any difference between “which” and “that”? I need to write an article with APA citations. I have sample code that works fine with style=authoryear, but if I switch to style=apa I get the following error message:   Error Line 21 ! Undefined control sequence.&lt;argument&gt; \printdateextralabel   I'm using TexMaker with biber. I've gone through example after example and I can't figure out what's wrong. I suspected it was with TexMaker or MiKTeX, but I just uninstalled and reinstalled both programs and I'm having the same issue. The same error message always pops up with the line number after \printbibliography. I tried copying corrected MWE's from other questions (such as  answered by Alan Munn) and I get the same error.  I included a MWE and my .bib file (borrowed from another thread) below.  File MWE:  \documentclass[article,12pt,letterpaper]{apa6} \usepackage[american]{babel} \usepackage{csquotes} \usepackage[style=apa,natbib=true,backend=biber]{biblatex} \DeclareLanguageMapping{american}{american-apa}   \title{Annotated Bibliography 1} \author{Joe Smith} \affiliation{Spectacular University} \addbibresource{bib.bib}  \begin{document} \abstract{abstract goes here} \maketitle this is a test \cite{Kim1999188} \printbibliography \end{document}   bib:  @article{Kim1999188, title = "Absorption of water vapour into lithium bromide-based solutions with additives using a simple stagnant pool absorber ", journal = "International Journal of Refrigeration ", volume = "22", number = "3", pages = "188 - 193", year = "1999", note = "", issn = "0140-7007", doi = "10.1016/S0140-7007(98)00061-9", url = "http://www.sciencedirect.com/science/article/pii/S0140700798000619", author = "Jin-Soo Kim and Huen Lee and Sun Il Yu", keywords = "Absorption", keywords = "Water", keywords = "Lithium bromide", keywords = "Absorption", keywords = "Eau", keywords = "Bromure de lithium " }      Here is a link to my .