Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70694
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <akonsta@icloud.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'that?': 0.05; 'subject:Python': 0.06; 'assign': 0.07; 'responding': 0.07; 'variables': 0.07; 'arguments': 0.09; 'compact': 0.09; 'function,': 0.09; 'handful': 0.09; 'seemed': 0.09; 'stack,': 0.09; 'subject:2.7': 0.09; 'used.': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'dict': 0.16; 'dictionaries': 0.16; 'dictionary,': 0.16; 'dictionary.': 0.16; 'expression,': 0.16; 'message-id:@me.com': 0.16; 'received:mac.com': 0.16; 'redundant': 0.16; 'shorthand': 0.16; 'tuple': 0.16; 'unpack': 0.16; 'unpacking': 0.16; 'flexibility': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'passing': 0.19; 'seems': 0.21; 'code,': 0.22; 'preferred': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'decide': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'class.': 0.26; 'equivalent': 0.26; 'mention': 0.26; 'pass': 0.26; 'values': 0.27; 'function': 0.29; 'andrew': 0.30; 'returned': 0.30; 'especially': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'easier': 0.31; 'breaking': 0.31; 'allows': 0.31; 'class': 0.32; 'text': 0.33; 'url:python': 0.33; 'call.': 0.33; 'guess': 0.33; 'subject:from': 0.34; 'subject:with': 0.35; "can't": 0.35; 'advice': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'changing': 0.37; 'two': 0.37; 'implement': 0.38; '(i.e.,': 0.38; 'received:17': 0.38; 'pm,': 0.38; 'little': 0.38; 'url:mail': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'liked': 0.60; 'results.': 0.60; 'worry': 0.60; 'new': 0.61; 'simply': 0.61; 'more': 0.64; 'love': 0.65; 'great': 0.65; 'content-type:multipart/related': 0.67; 'natural': 0.68; 'of:': 0.68; 'goal': 0.75; 'yourself': 0.78; '2014,': 0.84; 'actually,': 0.84; 'batchelder': 0.84; 'header:In-reply-to:1': 0.84; 'try,': 0.84; 'responses': 0.93; 'ultimate': 0.93 |
| MIME-version | 1.0 |
| Content-Type | multipart/alternative; boundary="Boundary_(ID_eHafZk95FNkRyicCsnmgKg)" |
| To | Ned Batchelder <ned@nedbatchelder.com> |
| From | Andrew Konstantaras <akonsta@icloud.com> |
| Subject | Re: Help with changes in traceback stack from Python 2.7 to Python 3.x |
| Date | Mon, 28 Apr 2014 19:50:05 +0000 (GMT) |
| X-Mailer | iCloud MailClient14B.126622 MailServer14B.15638 |
| X-Originating-IP | [66.194.65.197] |
| In-reply-to | <ljmaiq$3f8$1@ger.gmane.org> |
| X-MANTSH | 1TEIXREEbG1oaGkdHB0lGUkdDRl5PWBoaHhEKTEMXGx0EGx8SBBscHwQdHhAbHho fGhEKWE0XSxEKbX4XGhEKTFkXGxobGxEKWUkXEQpZXhdobnkRCkNOF0sbHhpiTk1mHB9/XRl4c wcZeRsTHxpoHBEKWFwXGQQaBB0HTUsdEkhJHEwFGx0EGx8SBBscHwQdHhAbHhofGxEKXlkXYUZ sfWURCkxGF2hraxEKQ1oXGx0EGx8SBBscGwQTExEKQl4XGxEKRFgXGBEKREkXGxEKQkUXbB5YR XpfaEtYfGkRCkJOF2tFGlJQHkNcWVxoEQpCTBdtfB9fZFJHS2tpExEKQmwXb2B7e21mUn9kRkQ RCkJAF20TeGZHXk1TeGlOEQpwaBdnaQF4eFlcQU9gZhEKcGgXZUN8YXMee1sTQR8RCnBoF24bU kJscAVMZn1CEQpwaBdmUBxOekd+R0UTbBEKcGgXbhJtHEh6XmtmUn8RCnB/F2dgG1BGTgVsbEs dEQpwfxdjRUcbU1JDb2IZcxEKcF8XaExhGkZHbEdMU2gRCnBsF2h+Qh5eX2BtSXxkEQpwTBdkS RJ7SW4Yf11TUhEKcEMXZ3xoXUFhWR0cQ3IR |
| X-CLX-Spam | false |
| X-CLX-Score | 1011 |
| X-Proofpoint-Virus-Version | vendor=fsecure engine=2.50.10432:5.11.96,1.0.14,0.0.0000 definitions=2014-04-28_03:2014-04-28,2014-04-28,1970-01-01 signatures=0 |
| X-Proofpoint-Spam-Details | rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1404280309 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9559.1398718221.18130.python-list@python.org> (permalink) |
| Lines | 168 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1398718221 news.xs4all.nl 2935 [2001:888:2000:d::a6]:48552 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:70694 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Apr 28, 2014, at 12:36 PM, Ned Batchelder <ned@nedbatchelder.com> wrote: > On 4/27/14 5:51 PM, Andrew Konstantaras wrote: > > I guess I am missing something big as I am looking for a shorthand way > > of doing the following: > > > > dctA = dict(x=x, y=y, ... n=n) > > > > Yes, your makeDict(x, y) is a shorthand for dict(x=x, y=y), but there > are many things you can do with dict that you can't do with makeDict. > What is the makeDict equivalent of: > > dict(x=12, y=self.y, z=a+b) > > The code you have allows you more compact expression, but it brings > fragility and surprise. > > > This is, as I understand it a very natural way of using a dictionary. > > It seems that this syntax is unnecessarily redundant and hence my goal > > of writing something more compact. Perhaps the way I am doing it is a > > little unorthodox, but the ultimate use of a dictionary is, as I > > understand it, completely in line with how dictionaries were designed to > > be used. In my other code, I often use these dictionaries to pass > > arguments to functions and return results. It allows me great > > flexibility without breaking existing code. I pack a dictionary before > > passing and unpack when retrieving. > > Perhaps you want to create a class instead? If you find yourself > passing more than a handful of arguments to a function, and especially > more than a handful of values returned from a function, then a class > with methods might be a better way to combine state and behavior. > > Also, keep in mind that you can return a tuple from a function if you > want to return two or three values and assign them to names: > > x, y, z = compute_xyz() > > You mention unpacking your dictionary after the function call. How do > you do that? Isn't that a cumbersome and repetitive operation? One of the reasons I like using the dictionary over the tuple is that if I have a function that grows in functionality (i.e., I decide to return more data for new scenarios), I can just add the new object to the dictionary and I don't have to worry about changing the code every where else that used to call the function. Actually, that is one of the nice features of using a dictionary, I can check if the key is there and if it is pull it out. As I was dusting off this old code, I considered trying to implement this functionality through by creating a class. I never liked going through the stack, it seemed hacky, but I came to love using dictionaries as they have some great built in features. Again, thanks for the advice and I will focus on the class implementation. > > > > > I will give the locals approach a try, it seems a little more clumsy > > than simply passing the variables to the function. > > > > Thanks again for your input. > > > > ---Andrew > > BTW, it's a little easier to follow the threads of conversation if you > put your responses after the text you are responding to. This is known > as bottom-posting, and is preferred to top-posting as you did here. > > > -- > Ned Batchelder, http://nedbatchelder.com > > -- > https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Help with changes in traceback stack from Python 2.7 to Python 3.x Andrew Konstantaras <akonsta@icloud.com> - 2014-04-28 19:50 +0000
csiph-web