Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: Promoting Python Date: Tue, 05 Apr 2016 08:13:14 -0400 Organization: IISS Elusive Unicorn Lines: 156 Message-ID: References: <8297gblfu46c3p57sbu5i5h2lprsrl29u5@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de BQhVqbu6I+NjLlgyTAQYrgiBfImjyKwzFRSvFV6IkxpA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'subject:Python': 0.05; 'tries': 0.05; 'extent': 0.07; 'none)': 0.07; 'turtle': 0.07; 'url:msdn': 0.07; '(0,': 0.09; '(actually': 0.09; 'argument:': 0.09; 'blue': 0.09; 'determines': 0.09; 'extension,': 0.09; 'given,': 0.09; 'integral': 0.09; 'message- id:@4ax.com': 0.09; 'pixels': 0.09; 'portable': 0.09; 'porting': 0.09; 'python:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'underlying': 0.09; 'python': 0.10; '2.7': 0.13; 'output': 0.13; 'encoding': 0.15; '2016': 0.16; '252': 0.16; '255': 0.16; 'angle': 0.16; 'color.': 0.16; 'contexts,': 0.16; 'hex': 0.16; 'in-place': 0.16; 'inverse': 0.16; 'pithy': 0.16; 'positive,': 0.16; 'pythonwin': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'rem': 0.16; 'sign,': 0.16; 'switch.': 0.16; 'url:85)': 0.16; 'drawing': 0.18; 'integer': 0.18; 'shape': 0.18; 'url:home': 0.18; 'programmer': 0.18; 'shell': 0.18; 'language': 0.19; '>>>': 0.20; 'windows': 0.20; 'color,': 0.22; 'commands,': 0.22; 'libraries': 0.22; 'tkinter': 0.22; 'programming': 0.22; 'defined': 0.23; '(or': 0.23; 'sets': 0.23; 'import': 0.24; 'module': 0.25; 'install': 0.25; 'command': 0.26; 'installed': 0.26; 'header:X-Complaints-To:1': 0.26; 'compatible': 0.27; 'device': 0.28; 'interface': 0.29; '(it': 0.29; 'arc': 0.29; 'usable': 0.29; 'windows,': 0.29; 'print': 0.30; 'classes': 0.30; 'filled': 0.30; 'position.': 0.30; "i'd": 0.31; 'guess': 0.31; 'run': 0.33; 'changed': 0.33; 'url:python': 0.33; '-0700': 0.33; 'idle': 0.33; 'similar': 0.33; 'languages': 0.34; 'tue,': 0.34; 'next': 0.35; 'text': 0.35; 'clear': 0.35; 'direction': 0.35; 'displays': 0.35; 'false': 0.35; 'functions.': 0.35; 'something': 0.35; 'step': 0.36; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'basic': 0.36; 'framework': 0.36; 'url:library': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'received:org': 0.37; 'different': 0.63; 'within': 0.64; 'dont': 0.64; 'developed': 0.66; 'circle': 0.66; 'combining': 0.66; 'url:%28': 0.66; 'url:%29': 0.66; 'url:%1': 0.67; 'finally': 0.70; 'url:en-us': 0.72; '\xe2\x80\x93': 0.72; '100%': 0.72; 'pictures': 0.75; '250': 0.76; 'square': 0.76; '(once': 0.84; '2.5.': 0.84; '>if': 0.84; 'circle,': 0.84; 'extent.': 0.84; 'facing,': 0.84; 'fairness': 0.84; 'fill,': 0.84; 'kids.': 0.84; 'liberty': 0.84; 'moves': 0.84; 'pen,': 0.84; 'robotic': 0.84; 'colour': 0.91; 'dennis': 0.91; 'draws': 0.91; 'graphical': 0.91; 'grew': 0.91; 'received:108': 0.93; 'imagine': 0.96; 'hand,': 0.97 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-68-177-167.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <8297gblfu46c3p57sbu5i5h2lprsrl29u5@4ax.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:106511 On Tue, 5 Apr 2016 00:31:10 -0700 (PDT), Rustom Mody declaimed the following: >> Liberty Basic >> for n = 32 to 255: print n;chr$(n) : next n > >I grew up on BBC basic in 1984. Not used thereafter. > >Your first one is (I guess) this in python: > >>>> for i in range(32,127): >... print chr(i), >... > ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ > Not quite... >>> for i in range(32, 256): ... print i, chr(i) ... 32 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - ... Though characters 128-255 may depend on the computer encoding... PythonWin console gives: 244 ??5 ??6 ??7 ??8 ??9 ??0 ??1 ??2 ??3 ??4 ??5 ??> (actually -- it displays inverse video blue HEX values...) Windows command shell is something like 244 ( 245 ) 246 ÷ 247 ˜ 248 ° 249 · 250 · 251 v 252 n 253 ² 254 ¦ 255   >>> Though the first two are not parentheses, but make up an integral sign, 247 is a double-tilde, 251 is a square root. Apparently Forte Agent has a different encoding than the Windows command shell. >> >> REM BBC Basic >> FOR c = 1 TO 15 : COLOUR c >> PRINT "Color ";c >> NEXT c >> >> REM BBC Basic >> c = 0 >> FOR x = 80 TO 2000 STEP 96 >> GCOL c: CIRCLE FILL x,500,50 : c = c + 1 >> NEXT x > >If you tell us some more of what color, gcol etc do someone will likely show you >Though in all fairness I dont expect it to be as pithy as the BASIC Off hand, I'd guess "colour" sets text output color, "gcol" likely sets graphics color, and "circle fill" likely draws a filled circle in that color. For the OP: Very few languages have built-in graphics commands; which is why porting BASIC programs was so difficult. This means you have to import some graphical framework and use ITS command functions. Unfortunately, there are so many routes... If you are on Windows, and install the win32 python extension, you can make use of the native Win32 libraries to create device contexts, draw into them, etc. Be ready to drown in the less than clear MSDN documentation. For example, this might be the "circle fill" (once you've defined the context/window, pen, and brush https://msdn.microsoft.com/en-us/library/vs/alm/dd162510%28v=vs.85%29.aspx Or, since Python includes an interface to Tk, there is a "turtle graphics" module that may be usable (it will be more portable than Win32). >From the 2.7 help system ( https://docs.python.org/2/library/turtle.html or https://docs.python.org/3/library/turtle.html depending on version of Python installed): -=-=-=-=- Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966. Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an import turtle, give it the command turtle.forward(15), and it moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise. By combining together these and similar commands, intricate shapes and pictures can easily be drawn. The turtle module is an extended reimplementation of the same-named module from the Python standard distribution up to version Python 2.5. It tries to keep the merits of the old turtle module and to be (nearly) 100% compatible with it. This means in the first place to enable the learning programmer to use all the commands, classes and methods interactively when using the module from within IDLE run with the -n switch. The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support. -=-=-=-=- turtle.circle(radius, extent=None, steps=None) Parameters: radius – a number extent – a number (or None) steps – an integer (or None) Draw a circle with given radius. The center is radius units left of the turtle; extent – an angle – determines which part of the circle is drawn. If extent is not given, draw the entire circle. If extent is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if radius is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of extent. -=-=-=-=- turtle.fill(flag) Parameters: flag – True/False (or 1/0 respectively) Call fill(True) before drawing the shape you want to fill, and fill(False) when done. When used without argument: return fillstate (True if filling, False else). -=-=-=-=- -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/