Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'languages,': 0.03; 'python.': 0.04; 'python': 0.08; '#define': 0.09; 'wrong,': 0.09; 'received:209.85.214.174': 0.13; 'received:mail- iw0-f174.google.com': 0.13; 'subject:python': 0.14; 'wrote:': 0.15; 'constants': 0.16; 'cpp': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handy': 0.16; 'pm,': 0.16; 'header:In-Reply-To:1': 0.22; 'code': 0.24; "python's": 0.25; '(the': 0.28; 'received:209.85.214': 0.28; 'message- id:@mail.gmail.com': 0.28; 'thu,': 0.28; 'yet': 0.30; 'it.': 0.33; 'entry': 0.33; 'to:addr:python-list': 0.34; "can't": 0.34; 'things': 0.35; 'reference': 0.35; 'assuming': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'something': 0.38; 'subject:: ': 0.38; 'run': 0.39; 'first.': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'might': 0.40; 'your': 0.61; 'jun': 0.67; 'concept': 0.73; 'opinion.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=GhmZ0rklD/3ZxL/cpmj25en05KPj0/AO5tG43coVP7E=; b=queh6CJ6AKWy2N5RCtqdPstym96a2HogIjaYpUiEBAAA0QNBE21ylSGnv3jr47h9pC AriLtpBMyQ7Qb6IM9w6uAlGIrLNbA9pgl29pSS5ksBuCjIJehY49fKzpbT8WKrAWh2K7 O/PypSkgLmhjzKEIoruGdec6+Nlcoe/0mqYGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=sDAjjEmI38gddhW7YnbaKDhzqfluLdn/FzzzIzmi2aVczhcvJ+znIvix22efEzOAYZ vQO1IhasuHOR4T9wSopBnioSA2iQoc9KQEdqjNGLP180y6n845MHfcF3Ava5Owatp6pB LdaLl21pKUPQ1VUK+LR0UmyCN4j0nzmxrSl0E= MIME-Version: 1.0 In-Reply-To: References: <927fca1e-ca72-4d33-965c-70b812b83d50@glegroupsg2000goo.googlegroups.com> <192j4fjo2gskg$.dlg@localhost.localdomain> <87y60tnhaa.fsf@benfinney.id.au> Date: Fri, 24 Jun 2011 01:29:38 +1000 Subject: Re: python 3 constant From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308842982 news.xs4all.nl 14142 [::ffff:82.94.164.166]:46479 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8308 On Thu, Jun 23, 2011 at 9:58 PM, Waldek M. wrote: > Of course, it is just my personal opinion. It might be not pythonic, > I may be wrong, yet - concept of constants is not something new and > if other languages, like C/C++/Java/Perl/ (bash even) have them, > I can't see the reason not to have them in Python. > You can have them in Python. Just run your code through cpp (the C preprocessor) first. Voila! It's handy for other things too. Don't like Python's lack of "then" and "end if"? #define then : #define end(x) lst=[1,2,3] if lst then do_stuff end(if) You can even make functions that take reference arguments! #define inc(x) x=x+1 i=3 inc(i) print("i = ",i) j=4 inc(i+j) print("i + j = ",i+j This is an excellent technique, and I heartily recommend it. Assuming you're writing an entry for the International Obfuscated Python Code Contest, that is. ChrisA