Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; ';-)': 0.03; 'yet.': 0.04; 'python3': 0.07; 'bash': 0.09; 'collier': 0.09; 'emulate': 0.09; 'launchpad': 0.09; 'lookup': 0.09; 'parsed': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'systems.': 0.12; ':-d': 0.16; 'boolean': 0.16; 'char,': 0.16; 'command,': 0.16; 'fancy': 0.16; 'guessing': 0.16; 'python3.': 0.16; 'tags.': 0.16; 'username.': 0.16; 'wrote:': 0.18; 'skip:p 40': 0.19; 'written': 0.21; '>>>': 0.22; 'cc:addr:gmail.com': 0.22; 'coding': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'char': 0.24; 'subject:Code': 0.24; 'unix/linux': 0.24; 'together.': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'host': 0.29; 'skip:p 30': 0.29; 'am,': 0.29; 'unix': 0.29; 'xml': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'posting': 0.31; 'run': 0.32; 'linux': 0.33; 'url:python': 0.33; 'fri,': 0.33; 'programmers': 0.33; 'style': 0.33; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'version': 0.36; 'data,': 0.36; 'ram': 0.36; 'var': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'two': 0.37; 'clear': 0.37; 'awesome': 0.38; 'pm,': 0.38; 'skip:p 20': 0.39; 'users': 0.40; 'url:mail': 0.40; 'easy': 0.60; 'most': 0.60; 'tell': 0.60; 'skip:o 30': 0.61; 'tips': 0.61; 'url:u': 0.61; 'browser': 0.61; 'you.': 0.62; 'making': 0.63; 'email addr:gmail.com': 0.63; 'more': 0.64; 'total': 0.65; 'skip:1 20': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'url:0': 0.67; 'person,': 0.68; 'skip:r 30': 0.69; 'jul': 0.74; 'special': 0.74; 'skip:$ 10': 0.81; 'url:gif': 0.82; 'url:images': 0.83; 'functions:': 0.84; 'hate': 0.91; 'joel': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=AiNLdrRZ/xnphW/k4aHf1naJqQioy2PXtIuaFPg3OMs=; b=fAsRtYie50+zFu9cJP4VHRY7ePm+A06IsuyTt5bP/WTK8r87MbM4DWjSUz4ZX4ohuP azqhQjpQJahwND4deqGznkLd7F9BaZDLr2byVRLtQqehwvgSdWkeTV110cHquUJf7F+8 0ya+idx3ouyBZq/7lD2uY//w/S9RWM4jLANBFbZLhg3WmEsz+DxOMYcFX2VJxrZyjjc5 tHs7/LVeQnhloW69CJjSLhG65c/w3QcKYS9RaAnWw1kTYatRiOqE22/qMsp6AQ8is6zu AaIkBXWb9RX0EyW8k086VksHIoituHECt886rp1T78kr2KtA19pAH7yRJVlJ9/332bwm c0MA== MIME-Version: 1.0 X-Received: by 10.49.15.130 with SMTP id x2mr20846483qec.47.1374292029255; Fri, 19 Jul 2013 20:47:09 -0700 (PDT) In-Reply-To: References: <51E9445B.30509@Gmail.com> Date: Fri, 19 Jul 2013 23:47:09 -0400 Subject: Re: Share Code Tips From: David Hutto To: Joel Goldstick Content-Type: multipart/alternative; boundary=047d7bd7579e38b8a404e1e94c37 Cc: Python Mailing List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 282 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374292038 news.xs4all.nl 15868 [2001:888:2000:d::a6]:42656 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50944 --047d7bd7579e38b8a404e1e94c37 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable And also don't forget special char, or that it can bbe var char, or char in the DB lookup in boolean with the username. On Fri, Jul 19, 2013 at 11:43 PM, David Hutto wrote= : > Just use an explanatory user tip that states it should be case sensitive, > just like with most sites, or apps. > > > On Fri, Jul 19, 2013 at 10:21 AM, Joel Goldstick > wrote: > >> >> >> >> On Fri, Jul 19, 2013 at 9:51 AM, Devyn Collier Johnson < >> devyncjohnson@gmail.com> wrote: >> >>> Aloha Python Users! >>> >>> I have some coding tips and interesting functions that I want to share >>> with all of you. I want to give other programmers ideas and inspiration= . It >>> is all Python3; most of it should work in Python2. I am a Unix/Linux >>> person, so some of these will only work on Unix systems. Sorry Microsuc= k >>> users :-D ;-) >>> >>> All of the below Python3 code came from Neobot v0.8dev. I host an >>> artificial intelligence program on Launchpad (LP Username: >>> devyncjohnson-d). I have not released my Python version yet. The curren= t >>> version of Neobot (v0.7a) is written in BASH and Python3. >>> >>> To emulate the Linux shell's date command, use this Python >>> >>> function def DATE(): print(time.strftime("%a %B %d %H:%M:%S %Z %Y")) >>> >>> Want an easy way to clear the terminal screen? Then try this: >>> >>> def clr(): os.system(['clear','cls'][os.**name =3D=3D >>> 'nt']) >>> >>> Here are two Linux-only functions: >>> >>> def GETRAM(): print(linecache.getline('/**proc/meminfo', >>> 1).replace('MemTotal:', '').strip()) #Get Total RAM in kilobytes# >>> def KDE_VERSION(): print(subprocess.getoutput('**kded4 --version | awk >>> -F: \'NR =3D=3D 2 {print $2}\'').strip()) ##Get KDE version## >>> >>> Need a case-insensitive if-statement? Check this out: >>> >>> if 'YOUR_STRING'.lower() in SOMEVAR.lower(): >>> >>> Have a Python XML browser and want to add awesome tags? This code would >>> see if the code to be parsed contains chess tags. If so, then they are >>> replaced with chess symbols. I know, many people hate trolls, but troll= s >>> are my best friends. Try this: >>> >>> if '>> re.sub('', '=E2=99=94', PTRNPRS, flags=3Dre.I); DATA= =3D >>> re.sub('', '=E2=99=95', DATA, flags=3Dre.I); DATA = =3D >>> re.sub(''**, '=E2=99=96', DATA, flags=3Dre.I); DAT= A =3D >>> re.sub(''**, '=E2=99=97', DATA, flags=3Dre.I); DAT= A =3D >>> re.sub(''**, '=E2=99=98', DATA, flags=3Dre.I); DAT= A =3D >>> re.sub('', '=E2=99=99', DATA, flags=3Dre.I); DATA = =3D >>> re.sub('', '=E2=99=9A', DATA, flags=3Dre.I); DATA = =3D >>> re.sub('', '=E2=99=9B', DATA, flags=3Dre.I); DATA = =3D >>> re.sub(''**, '=E2=99=9C', DATA, flags=3Dre.I); DAT= A =3D >>> re.sub(''**, '=E2=99=9D', DATA, flags=3Dre.I); DAT= A =3D >>> re.sub(''**, '=E2=99=9E', DATA, flags=3Dre.I); PTR= NPRS =3D >>> re.sub('', '=E2=99=9F', DATA, flags=3Dre.I) >>> >>> For those of you making scripts to be run in a terminal, try this for a >>> fancy terminal prompt: >>> >>> INPUTTEMP =3D input('User =E2=89=BB=E2=89=BB=E2=89=BB') >>> >>> >>> I may share more code later. Tell me what you think of my coding style >>> and tips. >>> >>> >>> Mahalo, >>> >>> Devyn Collier Johnson >>> DevynCJohnson@Gmail.com >>> -- >>> http://mail.python.org/**mailman/listinfo/python-list >>> >> >> I'm guessing you may be posting with html. So all your code runs >> together. >> >> -- >> Joel Goldstick >> http://joelgoldstick.com >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > --=20 Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* --047d7bd7579e38b8a404e1e94c37 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
And also don't forget special char, or that it can bbe= var char, or char in the DB lookup in boolean with the username.
=


On Fri, Jul 1= 9, 2013 at 11:43 PM, David Hutto <dwightdhutto@gmail.com> wrote:
Just use = an explanatory user tip that states it should be case sensitive, just like = with most sites, or apps.


<= div>
On Fri, Jul 19, 2013 at 10:21 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote:



= On Fri, Jul 19, 2013 at 9:51 AM, Devyn Collier Johnson &l= t;devyncjohnso= n@gmail.com> wrote:
Aloha Python Users!

I have some coding tips and interesting functions that I want to share with= all of you. I want to give other programmers ideas and inspiration. It is = all Python3; most of it should work in Python2. I am a Unix/Linux person, s= o some of these will only work on Unix systems. Sorry Microsuck users :-D ;= -)

All of the below Python3 code came from Neobot v0.8dev. I host an artificia= l intelligence program on Launchpad (LP Username: devyncjohnson-d). I have = not released my Python version yet. The current version of Neobot (v0.7a) i= s written in BASH and Python3.

To emulate the Linux shell's date command, use this Python

function def DATE(): print(time.strftime("%a %B %d %H:%M:%S %Z %Y"= ;))

Want an easy way to clear the terminal screen? Then try this:

def clr(): os.system(['clear','cls'][os.name =3D=3D 'nt'])

Here are two Linux-only functions:

def GETRAM(): print(linecache.getline('/proc/meminfo', 1).re= place('MemTotal:', '').strip()) #Get Total RAM in kilobytes= #
def KDE_VERSION(): print(subprocess.getoutput('kded4 --version |= awk -F: \'NR =3D=3D 2 {print $2}\'').strip()) ##Get KDE versio= n##

Need a case-insensitive if-statement? Check this out:

if 'YOUR_STRING'.lower() in SOMEVAR.lower():

Have a Python XML browser and want to add awesome tags? This code would see= if the code to be parsed contains chess tags. If so, then they are replace= d with chess symbols. I know, many people hate trolls, but trolls are my be= st friends. Try this:

if '<chess_'.lower() in PTRNPRS.lower(): DATA =3D re.sub('&l= t;chess_white_king/>', '=E2=99=94', PTRNPRS, flags=3Dre.I); = DATA =3D re.sub('<chess_white_queen/>', '=E2=99=95', = DATA, flags=3Dre.I); DATA =3D re.sub('<chess_white_castle/>'<= u>, '=E2=99=96', DATA, flags=3Dre.I); DATA =3D re.sub('<= chess_white_bishop/>', '=E2=99=97', DATA, flags=3Dre.= I); DATA =3D re.sub('<chess_white_knight/>', '=E2= =99=98', DATA, flags=3Dre.I); DATA =3D re.sub('<chess_white_pawn= />', '=E2=99=99', DATA, flags=3Dre.I); DATA =3D re.sub('= <chess_black_king/>', '=E2=99=9A', DATA, flags=3Dre.I); D= ATA =3D re.sub('<chess_black_queen/>', '=E2=99=9B', D= ATA, flags=3Dre.I); DATA =3D re.sub('<chess_black_castle/>', '=E2=99=9C', DATA, flags=3Dre.I); DATA =3D re.sub('<c= hess_black_bishop/>', '=E2=99=9D', DATA, flags=3Dre.I= ); DATA =3D re.sub('<chess_black_knight/>', '=E2= =99=9E', DATA, flags=3Dre.I); PTRNPRS =3D re.sub('<chess_black_p= awn/>', '=E2=99=9F', DATA, flags=3Dre.I)

For those of you making scripts to be run in a terminal, try this for a fan= cy terminal prompt:

INPUTTEMP =3D input('User =E2=89=BB=E2=89=BB=E2=89=BB')


I may share more code later. Tell me what you think of my coding style and = tips.


Mahalo,

Devyn Collier Johnson
DevynCJohnson@Gmail.com
--
http://mail.python.org/mailman/listinfo/python-list

I'= ;m guessing you may be posting with html.=C2=A0 So all your code runs toget= her.

--

--
http://mail.python.org/mailman/listinfo/python-list




--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com<= /a>



--
Best Regards,
David Hutto
<= b>CEO:
http://www.hitwebdevelopment.com
--047d7bd7579e38b8a404e1e94c37--