hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
115 stars 62 forks source link

Some problems about return 'None' #153

Open MindyZHAOMinzhu opened 5 years ago

MindyZHAOMinzhu commented 5 years ago

Troubleshooting

使用list.remove之后return出来结果是None

Describe your environment

屏幕快照 2019-07-18 下午9 49 32 屏幕快照 2019-07-18 下午9 50 06
hupili commented 5 years ago

@MindyZHAOMinzhu , you can use help(list.remove) to check the documentation. In short, this function is an "in-place" function, i.e. the operation is done in the original place referenced by the variable. In contrast, another type is call CoW (copy-on-write), i.e. the operation is done on a copy of the original data. So original data is kept intact when things are done. One CoW example is str.replace. Please try it out.

This is good question. We'll orgainise it into FAQ.

hupili commented 5 years ago

A bit note: