Re: mocking for get method in requests

2019-03-26 Thread Toni Sissala
On 18.1.2019 19:16, Shakti Kumar wrote: Hello people, I noticed something weird (weird as per my current knowledge, though I know its subjective) today. Hi Kumar, mock_req.get('').return_value = 'Hello' Here you are calling mock_req -MagicMocks get-method with parameter '' and assigning

Re: mocking for get method in requests

2019-03-16 Thread George Fischhof
Shakti Kumar ezt írta (időpont: 2019. jan. 18., P, 18:18): > Hello people, > I noticed something weird (weird as per my current knowledge, though I know > its subjective) today. > > sample.py file > > -- > > import requests > def random_testing(): > out = requests.get('www.cisco.com') >

mocking for get method in requests

2019-01-18 Thread Shakti Kumar
Hello people, I noticed something weird (weird as per my current knowledge, though I know its subjective) today. sample.py file -- import requests def random_testing(): out = requests.get('www.cisco.com') a = out.json() return a testing.py file -- @patch(*’*sample.requests') def

Re: Simple question: how do I print output from .get() method

2018-05-30 Thread Rhodri James
On 30/05/18 06:51, Chris Angelico wrote: On Wed, May 30, 2018 at 3:44 PM, MrMagoo2018 wrote: Hello folks, imagine I have the code below and I am getting the "error" message when attempting to print() the output of 'sw_report'. Can you suggest which method I should use to retrieve this? Is

Re: Simple question: how do I print output from .get() method

2018-05-29 Thread Chris Angelico
On Wed, May 30, 2018 at 3:44 PM, MrMagoo2018 wrote: > Hello folks, imagine I have the code below and I am getting the "error" > message when attempting to print() the output of 'sw_report'. > Can you suggest which method I should use to retrieve this? Is that a > dictionary maybe? > > from

Simple question: how do I print output from .get() method

2018-05-29 Thread MrMagoo2018
Hello folks, imagine I have the code below and I am getting the "error" message when attempting to print() the output of 'sw_report'. Can you suggest which method I should use to retrieve this? Is that a dictionary maybe? from arista import arista m = arista() m.authenticate

[issue33651] Add get() method to sqlite3.Row class

2018-05-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > But I hear Raymond's point about all field being known, > and I think that's a good point… and I agree I don't > actually need .get(). > Feel free to close. Thanks for the quick replies. Okay, done. -- resolution:

[issue33651] Add get() method to sqlite3.Row class

2018-05-26 Thread Wilfredo Sanchez
Wilfredo Sanchez added the comment: Well, sequence and mapping are not mutually exclusive, and sqlite3.Row does allow mapping-style indexing, which is why I expected .get() to work. But I hear Raymond's point about all field being known, and I think that's a good

[issue33651] Add get() method to sqlite3.Row class

2018-05-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I have the same question. Do you have a concrete example where this can be useful? sqlite3.Row is not a mapping. It is a sequence. >>> import sqlite3 >>> import collections.abc >>> issubclass(sqlite3.Row,

[issue33651] Add get() method to sqlite3.Row class

2018-05-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: How is this needed? SQL queries return rows that are homogenous and with known fields. This is isn't like other dictionaries when you might not know in advance whether a given key is present. -- nosy: +rhettinger

[issue33651] Add get() method to sqlite3.Row class

2018-05-25 Thread Wilfredo Sanchez
New submission from Wilfredo Sanchez <wsanc...@wsanchez.net>: The sqlite3.Row class has mapping-like behavior but does not implement the get() method, so providing default values in code requires a bit of boilerplate that is not necessary with dictionaries. -- components: Librar

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-05-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for reminder Zackery. I forgot about that issue! -- ___ Python tracker ___

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-05-20 Thread Zackery Spytz
Zackery Spytz added the comment: There was already an open issue for this (#31868). -- nosy: +ZackerySpytz ___ Python tracker ___

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 1b27ec6e0b40f81bf276eefa6b5bdb773b2a8890 by Serhiy Storchaka in branch '3.6': [3.6] bpo-33383: Fix crash in get() of the dbm.ndbm database object. (GH-6630). (GH-6633)

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +6329 ___ Python tracker ___ ___

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset ee95feb69d937149bef3d245e87df1aef412b7fc by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7': [3.7] bpo-33383: Fix crash in get() of the dbm.ndbm database object. (GH-6630) (GH-6631)

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 2e38cc39330bd7f3003652869b644110a97a78d8 by Serhiy Storchaka in branch 'master': bpo-33383: Fix crash in get() of the dbm.ndbm database object. (#6630)

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread miss-islington
Change by miss-islington : -- pull_requests: +6327 ___ Python tracker ___

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +6326 stage: -> patch review ___ Python tracker ___

[issue33383] Crash in the get() method a single argument in dbm.ndbm

2018-04-29 Thread Serhiy Storchaka
New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>: Calling the get() method of the dbm.ndbm database object with only single argument causes a crash because the default value is set to NULL. The regression was introduce in 3.5. The proposed patch fixes the crash and add

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 634fe6a90e0c by Martin Panter in branch '3.4': Issue #24657: Prevent CGIRequestHandler from collapsing the URL query https://hg.python.org/cpython/rev/634fe6a90e0c New changeset ba1e3c112e42 by Martin Panter in branch '3.5': Issues #25232, #24657:

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset a4302005f9a2 by Martin Panter in branch '2.7': Issue #24657: Prevent CGIRequestHandler from collapsing the URL query https://hg.python.org/cpython/rev/a4302005f9a2 -- ___ Python tracker

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-03 Thread Martin Panter
Martin Panter added the comment: Thanks everyone for the reports and patches. There were a couple of subtle compatibility tweaks needed for the 3.4 and 2.7 branches, but I think I got them all. -- resolution: -> fixed status: open -> closed ___

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-03 Thread Martin Panter
Changes by Martin Panter : -- stage: commit review -> resolved ___ Python tracker ___

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-02 Thread Xiang Zhang
Xiang Zhang added the comment: Yes, there seems to still exist some defects not conforming to the specification. I would like to investigate it. Maybe I can propose a patch for it. -- ___ Python tracker

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-02 Thread Martin Panter
Changes by Martin Panter : -- assignee: -> martin.panter nosy: +berker.peksag stage: patch review -> commit review ___ Python tracker

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-10-01 Thread Martin Panter
Martin Panter added the comment: The patch looks like it will fix this particular bug without much negative impact. However there are plenty of other problems with this module’s URL handling, see Issue 14567. I think the translate_path(), _url_collapse_path(), is_cgi(), run_cgi(), etc

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-25 Thread Xiang Zhang
Xiang Zhang added the comment: The path with query component are unquoted entirely and then pass into _url_collapse_path. I think this behaviour is wrong and according to rfc3875 query component should be left encoded in QUERY_STRING. This patch seems to solve the problem. It passes the tests

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-25 Thread Martin Panter
Martin Panter added the comment: It would be good to have a regression test case for this one too. -- stage: needs patch -> patch review ___ Python tracker

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-25 Thread Xiang Zhang
Xiang Zhang added the comment: Add the testcase and use str.partition. -- Added file: http://bugs.python.org/file40585/cgihander.patch ___ Python tracker

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-23 Thread Xiang Zhang
Xiang Zhang added the comment: I think this is a bug. According to the rfcs, "/" is a reserved character in query component and continuous "/" in query component may be invalid and how to deal with it depends on the server. But encoded "/", %2F, acts as data and should be preserved. And

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-21 Thread takayuki
takayuki added the comment: This bug seems to remain in Python 3.5.0. How to reproduce: 1. Save the attached cgitest.py into cgi-bin directory and changed it to executable file by "chmod +x cgitest.py" 2. Run CGIHTTPRequestHandler [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux Type "help",

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-09-21 Thread Martin Panter
Martin Panter added the comment: Yes it also seems to apply to Python 3. Perhaps you forgot your test script, so I made my own. After running python3 -m http.server --cgi The response from the following URL has no double slashes to be seen:

[issue24657] CGIHTTPServer module discard continuous '/' letters from params given by GET method.

2015-07-17 Thread takayuki
letters even they are in the given parameters. -- components: Library (Lib) messages: 246877 nosy: takayuki priority: normal severity: normal status: open title: CGIHTTPServer module discard continuous '/' letters from params given by GET method. versions: Python 2.7

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-05-06 Thread Roundup Robot
Roundup Robot added the comment: New changeset a2928dd2fde4 by Richard Oudkerk in branch 'default': Correct issue number for c4f92b597074 in Misc/NEWS from #13813 to #13831 http://hg.python.org/cpython/rev/a2928dd2fde4 -- nosy: +python-dev ___ Python

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-05-06 Thread Richard Oudkerk
Changes by Richard Oudkerk shibt...@gmail.com: -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13831 ___

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-05-06 Thread Richard Oudkerk
Richard Oudkerk added the comment: The relevant changeset was c4f92b597074, but I wrote the wrong issue number in the commit message and Misc/NEWS. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13831

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-05-02 Thread Richard Oudkerk
Richard Oudkerk added the comment: Attached is a patch for 3.4 which uses the __cause__ hack to embed the remote traceback in the local traceback. It will not work for 2.x though. import multiprocessing, subprocess with multiprocessing.Pool() as p: p.apply(subprocess.Popen, (1,)) ...

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-04-25 Thread Richard Oudkerk
Richard Oudkerk added the comment: It might be possible to come up with a hack so that when the exception is unpickled in the main process it gets a secondary exception chained to it using __cause__ or __context__ whose stringification contains the stringification of the original traceback.

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-04-18 Thread Richard Oudkerk
Richard Oudkerk added the comment: Pickling an exception (assuming it works) does not capture the traceback. Doing so would be difficult/impossible since the traceback refers to a linked list of frames, and each frame has references to lots of other stuff like the code object, the global

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 65623d7dc76e by Giampaolo Rodola' in branch '3.3': Fix issue #17707: multiprocessing.Queue's get() method does not block for short timeouts. http://hg.python.org/cpython/rev/65623d7dc76e -- nosy: +python-dev

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 87882c96d138 by Giampaolo Rodola' in branch 'default': Fix issue #17707: multiprocessing.Queue's get() method does not block for short timeouts. http://hg.python.org/cpython/rev/87882c96d138

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-17 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- keywords: +3.2regression, 3.3regression resolution: - fixed status: open - closed versions: -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-04-17 Thread Paul Winkler
Changes by Paul Winkler pw_li...@slinkp.com: -- nosy: +slinkp ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13831 ___ ___ Python-bugs-list mailing

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2013-04-17 Thread Paul Winkler
Changes by Paul Winkler pw_li...@slinkp.com: -- versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13831 ___ ___ Python-bugs-list

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-16 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: I think I'll just stick with the original patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-16 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___ ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-15 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: Maybe I'm misinterpreting what you wrote but the test fails before the patch and succeeds after it so what's the point in adding multiple tests with different timeouts? Also, rathr than using an harcoded delta, we could maybe use a fudger factor, like

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-15 Thread Charles-François Natali
Charles-François Natali added the comment: Maybe I'm misinterpreting what you wrote but the test fails before the patch and succeeds after it so what's the point in adding multiple tests with different timeouts? Well, the test you added tests explicitely for a value 1s because this

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: Patch including a unittest is in attachment. -- keywords: +patch Added file: http://bugs.python.org/file29855/issue17707.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: Removed file: http://bugs.python.org/file29855/issue17707.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: Added file: http://bugs.python.org/file29856/issue17707.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Your test is much too strict (and I don't understand why you're using a Decimal). I think testing that the delta is greater or equal than 0.2 would be enough. -- nosy: +pitrou ___ Python tracker

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: Yeah, right. Too strict indeed. I'll get rid of the assertLessEqual statement. Here's why Decimal is necessary: import time time.time() - time.time() -9.5367431640625e-07 from decimal import Decimal Decimal(time.time()) - Decimal(time.time())

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't understand what you're worrying about here. This is just because of evaluation order: import itertools it = itertools.count() f = it.__next__ f() - f() -1 f() - f() -1 -- ___ Python tracker

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: Without using Decimal and without patching connections.py (hence q.get() returns immediately) the resulting delta is mismatched: == FAIL: test_timeout (__main__.WithProcessesTestQueue)

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Without using Decimal and without patching connections.py (hence q.get() returns immediately) the resulting delta is mismatched: Well, why are you surprised the test fails without the patch? -- ___ Python tracker

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: You're right, sorry. I got confused by the exponential notation in 9.107589721679688e-05. Updated patch is in attachment. -- Added file: http://bugs.python.org/file29857/issue17707.patch ___ Python tracker

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-14 Thread Charles-François Natali
Charles-François Natali added the comment: I think we should test multiple timeout values (e.g. 0.1, 0.5, 1 and 1.5): it'll take a little longer, but since the test suite didn't detect it, that's really lacking. Also, rathr than using an harcoded delta, we could maybe use a fudger factor, like

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Charles-François Natali
Charles-François Natali added the comment: Indeed, that's a regression introduced by fix for issue #10527. Just a rounding error: --- Lib/multiprocessing/connection.py.orig 2013-04-13 06:27:57.0 + +++ Lib/multiprocessing/connection.py 2013-04-13 06:25:23.0 + @@

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Charles-François Natali
Changes by Charles-François Natali cf.nat...@gmail.com: -- priority: normal - high ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___ ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +benjamin.peterson, georg.brandl, giampaolo.rodola, larry priority: high - release blocker stage: - patch review versions: +Python 2.7, Python 3.2, Python 3.4 ___ Python tracker

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Georg Brandl
Georg Brandl added the comment: Very good, regression #2 for 3.3.2. Keep them coming right now :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: My patch, my fault. I'm very sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___ ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Georg Brandl
Georg Brandl added the comment: Don't worry, mistakes happen. My message was actually positive: it's better to catch the problems now than two weeks after the regression fix release... -- ___ Python tracker rep...@bugs.python.org

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Charles-François Natali
Charles-François Natali added the comment: As they say, s*** happens (one of my first patches caused a regression with thread-local storage in multiple interpreters setup, so...) Note that it's a strong case for selectors inclusion (issue #16853) :-) BTW, this would probably need a test, and

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-13 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: Assigning to me. Will get back in 1 or 2 days. -- assignee: - giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-12 Thread Sultan Qasim
to multiprocessing's pipes brought about in solutions to issues #10527 or #16955. The multiprocessing Queue's get() method on Python 3.3.1 does not block on Linux when a timeout of 1 second or less is specified. I have not tested this on Windows or Mac OS X. Example Code: from multiprocessing

[issue17707] Multiprocessing queue get method does not block for short timeouts

2013-04-12 Thread Sultan Qasim
Changes by Sultan Qasim sultanqa...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17707 ___ ___ Python-bugs-list

[issue13831] get method of multiprocessing.pool.Async should return full traceback

2012-01-19 Thread Faheem Mitha
think of one. -- components: Library (Lib) messages: 151651 nosy: fmitha priority: normal severity: normal status: open title: get method of multiprocessing.pool.Async should return full traceback type: enhancement versions: Python 2.6 ___ Python

[issue8634] get method for dbm interface

2010-11-11 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: The other bug report adds the get method as part of MutableMapping compliance, so I’m closing this as a obsoleted. -- resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - Improve dbm modules

[issue8634] get method for dbm interface

2010-08-05 Thread Ray.Allen
Ray.Allen ysj@gmail.com added the comment: See issue9523. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8634 ___ ___ Python-bugs-list

[issue8634] get method for dbm interface

2010-08-02 Thread Ray.Allen
Ray.Allen ysj@gmail.com added the comment: +1 on generalize the dbm.gnu and gbm.ndbm, and also dbm.dumb. All of them should follow the Collections.MutableMapping ABC. I will work out a patch to fix this. -- nosy: +ysj.ray ___ Python tracker

[issue8634] get method for dbm interface

2010-08-02 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8634 ___ ___ Python-bugs-list mailing

[issue8634] get method for dbm interface

2010-08-01 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: dbm.ndbm already has get(). dbm.gnu is missing it. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8634 ___

[issue8634] get method for dbm interface

2010-08-01 Thread Benjamin VENELLE
Benjamin VENELLE kai...@gmail.com added the comment: Yes I know, that's why get() should be a standard dbm's method like __getitem__() and __setitem__(). So, defining it in all classes which implements dbm interface would be a good enhancement. --

[issue8634] [PATCH] get method for dbm interface

2010-05-06 Thread Benjamin VENELLE
New submission from Benjamin VENELLE kai...@gmail.com: I'm suggesting to add the dict's 'get' method to dbm interface. So that, it would be easier to manage 'key not found' issues. B. Venelle. -- components: Library (Lib) messages: 105130 nosy: Kain94 priority: normal severity: normal

[issue8634] get method for dbm interface

2010-05-06 Thread Brian Curtin
Changes by Brian Curtin cur...@acm.org: -- title: [PATCH] get method for dbm interface - get method for dbm interface versions: -Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8634

Re: get method

2008-12-30 Thread Roel Schroeven
James Mills schreef: Ross, the others have informed you that you are not actually incrementing the count. I'll assume you've fixed your function now :) ... I want to show you a far simpler way to do this which takes advantage of Python's list comprehensions and mappings (which are really

Re: get method

2008-12-30 Thread James Mills
On Tue, Dec 30, 2008 at 7:10 PM, Roel Schroeven rschroev_nospam...@fastmail.fm wrote: Hm, you just changed an O(n) algorithm to an O(n**2) algorithm. No big deal for short strings, but try your solution on a string with length 1 and see the difference. On my computer the O(n) version takes

Re: get method

2008-12-30 Thread MRAB
James Mills wrote: On Tue, Dec 30, 2008 at 7:10 PM, Roel Schroeven rschroev_nospam...@fastmail.fm wrote: Hm, you just changed an O(n) algorithm to an O(n**2) algorithm. No big deal for short strings, but try your solution on a string with length 1 and see the difference. On my computer the

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 9:15 AM, MRAB goo...@mrabarnett.plus.com wrote: (snip) A while back I posted a Python implementation of 'bag' (also called a multiset). The code would then become something like: What complexity is this ? cheers James --

Re: get method

2008-12-30 Thread John Machin
On Dec 31, 10:58 am, James Mills prolo...@shortcircuit.net.au wrote: On Wed, Dec 31, 2008 at 9:15 AM, MRAB goo...@mrabarnett.plus.com wrote: (snip) A while back I posted a Python implementation of 'bag' (also called a multiset). The code would then become something like: What complexity

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:22 AM, John Machin sjmac...@lexicon.net wrote: (snip) The crawl through the shrubbery looking for evidence approach stumbles on the actual code: Yes I found his implementation soon after :) Not bad actually... I wonder why bag() isn't shipped with the std lib -

Re: get method

2008-12-30 Thread Steven D'Aprano
On Wed, 31 Dec 2008 10:29:14 +1000, James Mills wrote: On Wed, Dec 31, 2008 at 10:22 AM, John Machin sjmac...@lexicon.net wrote: (snip) The crawl through the shrubbery looking for evidence approach stumbles on the actual code: Yes I found his implementation soon after :) Not bad

Re: get method

2008-12-30 Thread MRAB
James Mills wrote: On Wed, Dec 31, 2008 at 10:22 AM, John Machin sjmac...@lexicon.net wrote: (snip) The crawl through the shrubbery looking for evidence approach stumbles on the actual code: Yes I found his implementation soon after :) Not bad actually... I wonder why bag() isn't shipped

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:49 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: What set module? Sorry I must have meant the collections module :) Adding a multi-set or bag class to the collections module would be a good idea though. Perhaps you should put in a feature request?

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:54 AM, MRAB goo...@mrabarnett.plus.com wrote: Occasionally someone posts here wanting to count items and solutions involving dict or defaultdict are suggested, and I think that a 'bag' class would be useful. The 'set' class was introduced first in a module, but it

get method

2008-12-29 Thread Ross
I am teaching myself Python by going through Allen Downing's Think Python. I have come across what should be a simple exercise, but I am not getting the correct answer. Here's the exercise: Given: def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1

Re: get method

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 17:00:31 -0800, Ross wrote: Here's my code: def histogram(s): d = dict() for c in s: d[c]= d.get(c,0) return d This code returns a dictionary of all the letters to any string s I give it but each corresponding value is incorrectly

Re: get method

2008-12-29 Thread Scott David Daniels
Ross wrote: ... Use get to write histogram more concisely. You should be able to eliminate the if statement. def histogram(s): d = dict() for c in s: d[c]= d.get(c,0) return d This code returns a dictionary of all the letters to any string s I give it

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:00 AM, Ross ross.j...@gmail.com wrote: I am teaching myself Python by going through Allen Downing's Think Python. I have come across what should be a simple exercise, but I am not getting the correct answer. Here's the exercise: Given: def histogram(s): d =

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:32 AM, James Mills prolo...@shortcircuit.net.au wrote: Ross, the others have informed you that you are not actually incrementing the count. I'll assume you've fixed your function now :) ... I want to show you a far simpler way to do this which takes advantage of

Re: get method

2008-12-29 Thread Ross
On Dec 29, 8:07 pm, Scott David Daniels scott.dani...@acm.org wrote: Ross wrote: ... Use get to write histogram more concisely. You should be able to eliminate the if statement. def histogram(s):    d = dict()    for c in s:            d[c]= d.get(c,0)    return d This code

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:38 AM, Ross ross.j...@gmail.com wrote: I realize the code isn't counting, but how am I to do this without using an if statement as the problem instructs? I just gave you a hint :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:43 AM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Dec 30, 2008 at 11:38 AM, Ross ross.j...@gmail.com wrote: I realize the code isn't counting, but how am I to do this without using an if statement as the problem instructs? I just gave you a hint :)

Re: get method

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 17:38:36 -0800, Ross wrote: On Dec 29, 8:07 pm, Scott David Daniels scott.dani...@acm.org wrote: Ross wrote: ... Use get to write histogram more concisely. You should be able to eliminate the if statement. def histogram(s):    d = dict()    for c in s:          

Re: get method

2008-12-29 Thread Aaron Brady
On Dec 29, 8:02 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Mon, 29 Dec 2008 17:38:36 -0800, Ross wrote: On Dec 29, 8:07 pm, Scott David Daniels scott.dani...@acm.org wrote: Ross wrote: ... Use get to write histogram more concisely. You should be able to

Re: Why does list have no 'get' method?

2008-02-11 Thread grflanagan
On Feb 8, 4:24 pm, [EMAIL PROTECTED] wrote: val = BETTER foo THAN bar ;-) Cobol-strikes-back-ly yours, George I use a ETL language/tool that actually has a function for this kind of thing: NulltoValue(value,defaultValue) it returns defaultValue if value is null otherwise

  1   2   >