A Nice Python 3.7 Tip

Post Reply
kim
Posts: 182
Joined: Fri Jun 22, 2018 10:35 pm
Has thanked: 0
Been thanked: 2 times
Contact:

A Nice Python 3.7 Tip

Post by kim » Tue Feb 19, 2019 2:53 pm

#Python tip: As of 3.7, you can define a __getattr__ function in a module to trigger custom behaviors when a module variable is missing.

The function takes one argument, the variable name. It is triggered by modname.x access and doesn't affect global variable lookups.



john
Posts: 115
Joined: Wed Jun 13, 2018 9:36 am
Has thanked: 0
Been thanked: 1 time
Contact:

Re: A Nice Python 3.7 Tip

Post by john » Wed Feb 27, 2019 11:01 am

here's two more tips

1. #python 3.5 #tip merging two dictionaries into one:
a = {'a':1}
b = {'b':2}
c= {**a,**b}
c is now {'a':1,'b':2}
#coding #development #tech #programming #it

2. #python tip: The re.DEBUG flag lets you drill into how a regex is interpreted:

>>> re.compile(r'(ab|c|cd){2,4}e', re.DEBUG)

supriyala
Posts: 1
Joined: Tue Mar 05, 2019 11:21 am
Has thanked: 0
Been thanked: 0
Contact:

Re: A Nice Python 3.7 Tip

Post by supriyala » Tue Mar 05, 2019 11:23 am

Excellent tips. Thanks for sharing this post useful and valuable topic!

Savnisharma
Posts: 1
Joined: Mon May 27, 2019 8:58 am
Has thanked: 0
Been thanked: 0
Contact:

Re: A Nice Python 3.7 Tip

Post by Savnisharma » Mon May 27, 2019 9:01 am

Excellent post! I got valuable information here...Thanks for such an excellent informative post! Keep Up!

Kavyanjali579
Posts: 1
Joined: Thu Jun 06, 2019 9:33 am
Has thanked: 0
Been thanked: 0
Contact:

Re: A Nice Python 3.7 Tip

Post by Kavyanjali579 » Thu Jun 06, 2019 9:35 am

I agree with Savnisharma.

shreya
Posts: 1
Joined: Fri Aug 02, 2019 7:15 am
Has thanked: 0
Been thanked: 0
Contact:

Re: A Nice Python 3.7 Tip

Post by shreya » Fri Aug 02, 2019 7:27 am

great information

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest