python – regex version of strip () – Ch. 7 Automate the boring stuff

Here is a practical exercise – Regex version of gang() $ – $

Write a function that takes a string and does the same thing as the
gang() chain method. If no other argument has gone beyond the
string to strip, the spacing characters will be removed from the
beginning and end of the chain. Otherwise, the specified characters
in the second argument of the function will be removed from the
chain.

I wrote the following code. Is there a better way to write it? All comments are highly appreciated.

import re

def regex_strip (s, chars = None):

if characters == none:
strip_left = re.compile (r & # 39; ^  s *)
strip_right = re.compile (r  s * $ & # 39;)

s = re.sub (strip_left, "", s)
s = re.sub (strip_right, "", s)
other:
strip_left = re.compile (r & # 39; ^[' + re.escape(chars) + r']* & # 39;)
strip_right = re.compile (r & # 39;[' + re.escape(chars) + r']* $ & # 39;)
s = re.sub (strip_left, "", s)
s = re.sub (strip_right, "", s)
results

Here is an example of an exit –

s = & # 39; * alphabetatheta * 4453 + - & # 39;
print (regex_strip (s, & # 39 ;. + - *))

>>> alphabetatheta * 4453   

python – Comma code – Ch. 4 Automate the boring thing

Your code is well constructed but could be much shorter using the .format () function.

str.format () is one of the string formatting methods in Python 3, which
allows multiple substitutions and formatting of values. This method allows
We concatenate elements in a string by positional formatting.

Your code can be shortened and concise in this way. Here's what your code might look like –

                def list_concatenator (your_list):

if it is not your list:
return "Your list is empty!"

elif len (your_list) == 1:
return str (your_list[0])

elif len (your_list) == 2:
returns "{0} and {1} & # 39;" format (your_signal[0], your_list[1])

other:
body = "," .join (map (str, your_list[:-1]))
returns "{0}, and {1} & # 39;" format (body, your_list[-1])

I used {0} and {1} so that the position arguments can be placed in the order of your choice. Although it is not necessary.

the .format() statements also take into account the comma Oxford, where the lists with two the elements do not have commas but lists with more than two elements are separated by commas.

OR

Another way to format in Python 3 is to use strings.

The idea behind f-strings is to simplify the string interpolation. To create a f-string, prefix the string with the letter "f". The string itself can be formatted in the same way as you would with str.format (). f-strings is a convenient and concise way to embed Python expressions in string literals for formatting.

Here is what your code would look like f-strings (Shorter) –

def list_concetenator (your_list):

if it is not your list:
return "Your list is empty!"

elif len (your_list) == 1:
return str (your_list[0])

elif len (your_list) == 2:
return "{your_site[0]} and {your_list[1]} "

other:
body = "," .join (map (str, a_list[:-1]))
return "{body}, and {your_list[-1]} "

Here are some examples of results –

your_list = ['item1', 'item2', 3, 'item4', 'item5', 'item6', 7, 'item8', 9]

print (list_concatenator (['item1', 'item2', 3, 'item4', 'item5', 'item6', 7, 'item8', 9]))

>>> <article1, article2, 3, article4, article5, article6, 7, article8 and 9 & # 39;

print (list_concatenator (['item1', 'item2', 3]))

>>> item1, item2 and 3 & # 39;

print (list_concatenator (['item1', 3]))

>>> item1 and 3 & # 39;

print (list_concatenator (['item1']))

>>> & # 39; item1 & # 39;

print (list_concatenator ([]))

>>> Your list is empty!

Overall, I think formatting was the main problem of your code.

I hope this helps you!

data – Displays 52 types of periodic searches without boring design

We publish about 52 different types of searches from time to time, some daily, others weekly, monthly, and so on. Our current vision is:

enter the description of the image here

So, as you can see, it sounds boring. Each link provides a file by click, and under each link is a date. There are several ideas, like showing a description of the latest research, which would be interesting. In addition, it might be interesting to display them as map elements like this:
https://getbootstrap.com/docs/4.0/components/card/

but if we have 52, the page will become very complicated …

How can we make this page appear as the least annoying way to display different types of searches for users without overwhelming them?

notifications – How to disable boring "brainstorming" for Whatsapp

After a recent update (Android 9.0), I noticed that notifications from Whatsapp Messenger appear in the same way as Facebook Messenger notifications – with a discussion head. It is a circle with the profile picture of the messenger, and by clicking on it, a small window appears with the message.

I preferred that this conversation head was never there, and I was able to see a preview of the message a few seconds just below the top of the screen when a message arrives. Is it possible to disable this feature? I've tried to disable contextual notifications, but this seems to be something totally different because the discussion heads continue to display.

How to make treadmills less boring?

What are you all doing? I find that doing mathematical formulas does the job! : wtf: D & # 39; AGREEMENT. well, I'm using a ski simulator. Well, some of these things have televisions connected with subtitles.

it's not boring how annoying [on hold]

I can not set up email or view it because I can not rest or change my passwordenter the description of the image here

it's not spam how fucking boring

I can not set up email or view it because I can not rest or change my passwordenter the description of the image here

usability – The user interface of the modal tabs is too boring

I show the customer data in a modal with 3 tabs. Each tab contains different data about a user and its related entities. The client must use modal and tabs here. However, I have tried my best to make the UI cool, but I can not get around this. Can you suggest improvements for correct use and typography? I am also looking for design suggestions.

Currently, when a user clicks on the details of this modal pop-up window:

1st modal screen

enter the description of the image here

enter the description of the image here

Then the user can navigate the tabs as shown below.

enter the description of the image here

usability – Modal Tabs UI is to Boring

I show the customer data in a modal with 3 tabs. Each tab contains different data about a user and its related entities. The client must use modal and tabs here. However, I have tried my best to make the UI cool, but I can not get around this. Can you suggest improvements for correct use and typography? I am also looking for design suggestions.

Currently, when a user clicks on the details of this modal pop-up window:

1st modal screen

enter the description of the image here

enter the description of the image here

Then the user can navigate the tabs as shown below.

enter the description of the image here

Complete the video of the user interface: https://www.useloom.com/share/3c2fb55d8c1a4d74a0c034a53503ee8a