Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8308

Re: python 3 constant

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 <rosuav@gmail.com>
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 <eszp4cvoh5fb.dlg@localhost.localdomain>
References <927fca1e-ca72-4d33-965c-70b812b83d50@glegroupsg2000goo.googlegroups.com> <mailman.301.1308777491.1164.python-list@python.org> <192j4fjo2gskg$.dlg@localhost.localdomain> <87y60tnhaa.fsf@benfinney.id.au> <eszp4cvoh5fb.dlg@localhost.localdomain>
Date Fri, 24 Jun 2011 01:29:38 +1000
Subject Re: python 3 constant
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.325.1308842981.1164.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, Jun 23, 2011 at 9:58 PM, Waldek M. <wm@localhost.localdomain> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

python 3 constant sidRo <slacky2005@gmail.com> - 2011-06-22 11:54 -0700
  Re: python 3 constant Noah Hall <enalicho@gmail.com> - 2011-06-22 22:17 +0100
    Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-23 08:40 +0200
      Re: python 3 constant Ben Finney <ben+python@benfinney.id.au> - 2011-06-23 17:22 +1000
        Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-23 13:58 +0200
          Re: python 3 constant Ben Finney <ben+python@benfinney.id.au> - 2011-06-23 23:04 +1000
            Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-25 12:42 +0200
          Re: python 3 constant Chris Angelico <rosuav@gmail.com> - 2011-06-24 01:29 +1000
            Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-23 21:56 +0200
              Re: python 3 constant Chris Angelico <rosuav@gmail.com> - 2011-06-24 08:00 +1000
                Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-25 12:50 +0200
                Re: python 3 constant Chris Angelico <rosuav@gmail.com> - 2011-06-25 20:59 +1000
                Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-25 13:24 +0200
              Re: python 3 constant alex23 <wuwei23@gmail.com> - 2011-06-23 20:04 -0700
                Re: python 3 constant "Waldek M." <wm@localhost.localdomain> - 2011-06-25 12:44 +0200

csiph-web