93 lines
2.1 KiB
Plaintext
93 lines
2.1 KiB
Plaintext
From: ivanlan at callware.com (Ivan Van Laningham)
|
|
Date: Thu, 22 Apr 1999 21:58:00 GMT
|
|
Subject: Emulating C++ coding style
|
|
References: <371F8FB7.92CE674F@pk.highway.ne.jp>
|
|
Message-ID: <371F9B68.5071C282@callware.com>
|
|
Content-Length: 1830
|
|
X-UID: 897
|
|
|
|
Hi Thooney and all the other Pythonistas out there--
|
|
|
|
Thooney Millennier wrote:
|
|
>
|
|
> Hello Everyone!
|
|
>
|
|
> I usually use C++ ,so I want to make programs like
|
|
> I do using C++.
|
|
> I don't figure out how to implement the followings
|
|
> by Python.
|
|
> If you know any solutions,Please Help!
|
|
>
|
|
> 1. #define statements
|
|
> e.g. #define __PYTHON_INCLUDED__
|
|
> #define PYPROC(ARG) printf("%s",ARG)
|
|
>
|
|
|
|
__PYTHON_INCLUDED__ = 1
|
|
|
|
(Although that's probably not what you really mean to do.)
|
|
|
|
def PYPROC(arg):
|
|
print arg
|
|
|
|
> 2. stream class
|
|
> e.g. cout << "hello python."<<endl;
|
|
>
|
|
|
|
print "hello python"
|
|
|
|
--or--
|
|
|
|
sys.stdout.write("hello python")
|
|
|
|
|
|
> 3. const variables
|
|
> e.g. const int NOCHAGE=1;
|
|
>
|
|
|
|
Can't be done. Any sufficiently determined Pythonista can change
|
|
anything she wants to.
|
|
|
|
But, you can do this to keep your edges inside a specific file--
|
|
|
|
_NOCHANGE = 1
|
|
|
|
Any variable beginning with an underscore has module-specific scope.
|
|
|
|
> 4. access to class's members using "::"
|
|
> e.g. some_class::static_value
|
|
> e.g. some_class::static_func(x)
|
|
>
|
|
|
|
print some_class.static_value
|
|
t = some_class.static_func(x)
|
|
|
|
See, there's no real concept of a ``static'' member, or of ``private''
|
|
members in Python classes. All methods and members of all classes are
|
|
public. That's a good thing.
|
|
|
|
> Thanks for reading.
|
|
>
|
|
> Thooney Millennier.
|
|
|
|
You should investigate the tutorial at http://www.python.org
|
|
|
|
It's really very good, and with your C++ experience you will have no
|
|
trouble at all.
|
|
|
|
<arigato-to-another-newbie>-ly y'rs,
|
|
Ivan
|
|
----------------------------------------------
|
|
Ivan Van Laningham
|
|
Callware Technologies, Inc.
|
|
ivanlan at callware.com
|
|
http://www.pauahtun.org
|
|
See also:
|
|
http://www.foretec.com/python/workshops/1998-11/proceedings.html
|
|
Army Signal Corps: Cu Chi, Class of '70
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
|