Re: [Tutor] Problem using termcolor and colorama

2018-11-15 Thread Peter Otten
John Blower wrote:

> I try to create colour text by using these two  modules , only returns the
> colour code, no colour text. How to solve this problem.
> 
 import termcolor
 import colorama
 colorama.init()
 termcolor.cprint('Hello World','red')
> [31mHello World[0m

Start with one module. Does

>>> import colorama
>>> print(colorama.Fore.RED + "Hello" + colorama.Style.RESET_ALL)
Hello

print Hello in red?

If yes, how do

>>> colorama.Fore.RED + "Hello" + colorama.Style.RESET_ALL
'\x1b[31mHello\x1b[0m'

and

>>> termcolor.colored("Hello", "red")
'\x1b[31mHello\x1b[0m'

differ on your system?

If no, does

>>> from ctypes import windll
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name 'windll'

raise an exception on your system? This is expected on my (Linux) system, 
but on Windows it probably means that something went wrong.
The pypi page says

"""
I’ve personally only tested it on Windows XP (CMD, Console2), Ubuntu (gnome-
terminal, xterm), and OS X.
"""

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem using termcolor and colorama

2018-11-15 Thread Steven D'Aprano
On Thu, Nov 15, 2018 at 01:18:16PM +, John Blower wrote:
> I try to create colour text by using these two  modules , only returns the 
> colour code, no colour text.
> How to solve this problem.

Use a terminal that supports colour codes.

 
> >>> import termcolor
> >>> import colorama
> >>> colorama.init()
> >>> termcolor.cprint('Hello World','red')
> [31mHello World[0m

What platform are you using?

What terminal are you using?

What terminals does termcolor support?

What does the documentation for termcolor say?



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem using termcolor and colorama

2018-11-15 Thread David Rock

> On Nov 15, 2018, at 07:18, John Blower  wrote:
> 
> I try to create colour text by using these two  modules , only returns the 
> colour code, no colour text.
> How to solve this problem.
> 
 import termcolor
 import colorama
 colorama.init()
 termcolor.cprint('Hello World','red')
> [31mHello World[0m

I don’t know what those modules are, but based on the output, where you use 
them will matter.
Those are the correct ESC codes to print something in red, but your terminal 
needs to support displaying the colors.

If you are trying this in the python interpreter, try making a basic test 
script and run it instead to see if it works outside the interpreter 
environment.

I assume you are on Windows, too.  What OS and what version of Python are you 
using?

— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Problem using termcolor and colorama

2018-11-15 Thread John Blower
I try to create colour text by using these two  modules , only returns the 
colour code, no colour text.
How to solve this problem.

>>> import termcolor
>>> import colorama
>>> colorama.init()
>>> termcolor.cprint('Hello World','red')
[31mHello World[0m


Sent from Mail for Windows 10

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] python commandos

2018-11-15 Thread Avi Gross
Dev,

There are many ways to learn a programming language but a list of all
commands is not necessarily a good way. I suspect your real question is how
do you learn Python as either a beginner at this language or with little
knowledge of computers in general.

There are tons of books and classes both online and in the real world that
are a better way to start.

Python has a very short list of commands as in reserved words. Many are the
same or similar to other languages such as if/elif/else/while/for and so on.
What matters more is what they do and how they are used and the CONCEPTS
manipulated and even the philosophies involved in what commands are there
and even what commands are NOT there.

There are also lists of operators like + += / * >= and so on, some of which
are also reserved words in the first list like and/in/not. Again, what
matters is not the exact names but what they do and don't do.

There are tons of names for built-in functions but you can trivially replace
them or import literally tens of thousands or more other functions. There
are all kinds of objects, including the built in, with various names and
many have all kinds of internal parts with names you can access and
manipulate.

The answer to your question is that there are more names than your combined
vocabulary in all the human languages you speak but you don't need to know
them till you decide to use them.

If you want some simpler books or tutorials, many libraries (or book
sellers) let you search for key words like "Python". There are many free
sources including what you can find here:

https://www.python.org/

Specifically, you may want to look here:

https://www.python.org/doc/

If you got to this mailing list, you may already have been there. Make sure
you get educated especially in whatever version of Python you are using as
there are changes with each version with a serious disconnect between
version 3 and anything before.


-Original Message-
From: Tutor  On Behalf Of Dev
Pratap Singh
Sent: Wednesday, November 14, 2018 8:21 AM
To: tutor@python.org
Subject: [Tutor] Request to join subscriber list

Sir
I am really excited to learn about programming languages and as python
becoming very famous these days i just wanted a list of all commands of it.
Please if you are able to send it
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor