[issue28612] str.translate needs a mapping example
Gaurav Tatke added the comment: Should a user be suggested to use str.translate() for the use case where user only wants to keep certain characters and strip off everything else? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28612> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28612] str.translate needs a mapping example
Gaurav Tatke added the comment: Hi, Pardon my ignorance, I am new to this but have below queries/thoughts - 1. Why would we say that adding new keys during lookup phase is an unpleasant side-effect? From what I understood by docs, one of the main reasons to use defaultdicts is to be able to insert a missing key and give a default value to it. 'defaultdict' doc itself suggest that doing this is cleaner and faster than using dict.setdefault(). 2. I believe defaultdict perfectly fits in this context of creating translation table for str.translate(). Even if we have very large string containing all characters from 4-5 languages, our defaultdict will still be comparatively small. It is easier to create a translation table using defaultdict when we have to strip most characters out of a string as in the example requested in the issue. Creating a translation table using str.maketrans() or by user defined function is tricky in this use case. 3. If argument for using defaultdict in this context is not convincing, shall I just give a patch, giving example of str.translate() using str.maketranse()? Regards, -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28612> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28612] str.translate needs a mapping example
Gaurav Tatke added the comment: Hi, I am new to Python and want to contribute. I am attaching a patch having required example of using defaultdict with translate. Please let me know if anything needs to be changed. I have tested the example and also the html doc in my local. Regards, Gaurav -- keywords: +patch nosy: +Gaurav Tatke Added file: http://bugs.python.org/file46072/translateexample_issue28612.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28612> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9004] datetime.utctimetuple() should not set tm_isdst flag to 0
Gaurav Tatke added the comment: Hi, I am new to python and would like to contribute. I find this issue easy so changed the documentation of datetime module. I tested it with sphinx. Attaching a patch. Please let me know if it is correct or needs changes. Appreciate it! Regards, Gaurav -- keywords: +patch nosy: +Gaurav Tatke Added file: http://bugs.python.org/file46050/timetuple_issue9004.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9004> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21150] Add quick links table to argparse docs
Gaurav Tatke added the comment: Hello All, I would like to help with this issue. I am a beginner. I am attaching a 'SampleOfSummaryTable.PNG' file which I think is one way of organizing summary table. I think if we put quick links of function parameters in summary table then it will make existing parameter quick links above detailed summary of each parameter as redundant. Please let me know if this is okay. -- nosy: +Gaurav Tatke Added file: http://bugs.python.org/file45972/SampleOfSummaryTable.PNG ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21150> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com