2018-02-17 06:33:55 (edited by ivan_soto 2018-02-17 06:34:34)

Hi there,
so very recently I decided to just finally move on and try something new. I want to do other things besides games etc, and I need to learn a better programming language than BGT. So...from a bgt user, what are some tips or resources to learn python. BGT is so simple that its hard to move away from, but it needs to be done. It is clear that it's done and it probably won't ever be updated again.

Ivan M. Soto.
Feel free to check out my work and services.
http://ims-productions.com

2018-02-17 08:42:11

Well the first step would be to download Python [here]. Some good books to start off with would be [A Byte of Python] and [How to Think Like a Computer Scientist], although you can find a bunch more [here].

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2018-02-17 09:34:47

Python is a good choice because it's syntax is even easier than BGT. Everything is an object and everything is dynamic, so it's not required to declare data types.
When I've started learning Python, which was somewhere in late 2009., I found a book called "A byte of Python". That introduced me to the Python world. Later on if you wish to expand your Python knowledge, read the book called "Dive into Python".
My suggestion is go with Python 3, it's the future. Python2 has unicode issues that I faced many times while developing software with Python, and you will sooner or later have to deal with these issues. Python3 is unicode by default, which is something to expect from a programming language nowadays, since almost nobody now is using Windows 9X or ME where ANSI was a standard.
You can use wxPython for making GUIs. Sighted developers on the Internet constantly recommend PyQT saying that it's the best, and may be it really is, however it has accessibility issues. BTW, I don't like to use the term The Best too much, big_smile.
For communicating with screen readers, you have two options, the one is called Tolk and another one is called Accessible Output. However, the repository where accessible output is hosted seams to be currently down, so Tolk is the only good option right now. I'm combining Tolk with Pyttsx3, which is another python library for SAPI support.
For 3D audio, you can use libaudioverse. For making games you have Pygame or Pyglet as a choice.
For networking, you can use Twisted.
And, for converting your Python script into executable, you have Py2Exe, CXFreeze or PyInstaller. I like PyInstaller, because generating exe is simple as writing pyinstaller with additional commandline options. I was using Py2Exe before, but it wasn't updated since 2014.
And, most of Python libraries can be easily installed, updated or removed by using pip on command line e.g., pip install wxpython, pip install libaudioverse, pip install pygame, pip install pyinstaller.

2018-02-17 13:03:32

I'm confused on that. I tryed entiring the pip command but nothing happens. Where do I type this? Very confused on where this goes...

Ivan M. Soto.
Feel free to check out my work and services.
http://ims-productions.com

2018-02-17 13:08:53

Hi,
Open command prompt by typing cmd in the run dialogue box and pressing enter. Now type pip install pygame pyinstaller libaudioverse. That was an example... This way you can install your libraries automatically. If this is not working, use the cd command to navigate to the scripts folder of where your python is installed (for example, cd c:\python36\scripts) and run the pip command as shown above.
Regards,
Amit

There once was a moviestar icon.
Who prefered to sleep with the light on.
They learnt how to code, devices sure glowed,
and lit the night using python.

2018-02-17 16:17:39

make sure pip is in your path, and if its not, add it.

go to the run dialog, type SystemPropertiesAdvanced, click environment variables, tab down to the system variables list, find path, click edit.
Go to the end of this text. Now you'll have to add the path of pip, assuming your using py3 this is c:\Python36\scripts\pip.exe
note: ; (semicolon) is used as the delimiter here, so the end should look like c:\some\random\thing;c:\Python36\scripts\pip.exe
HTH

2018-02-17 23:44:33

Oh. Thank goodness. I'm getting really tired of BGT and my antivirus having a civil war on my computer, so hopefully seeing more developers migrating away from it might solve most of those issues. Probably not all of them because antivirus software is...well...odd, but still. I'd also add don't neglect the documentation on the website, and poking around Stack Overflow and google. While python is not my favorite language as it lacks several of the nice time saving syntax found in C family languages, I won't deny that it is not too difficult to learn.

I have a website now.
"C: God's Programming Language
C++: The object-oriented programming language of a pagan deity" -- The Red Book
"There, but for the grace of God go I"

2018-02-18 00:23:24

Hi.
Both python 2 and 3 both have pip now, you just need to edit the systems variables. Pip won't respond in command prompt unless you do this. Python's syntax is very simple, especially for making small utilities and things like that.
You should take a look at the documentation, then read something like dive into python or one of those.
Hth.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

2018-02-18 06:06:37

Hi,
At post number 7,, excuse me please, but what kind of c/c++ syntax are you talking about? I know some c++ and what I've always seen that a c++ programmer is always bigger compared to a python program. And python is so simple too. To support this, look some python below.
a=5
b=10
a,b=b,a
what the above code did is that it swapped the values those two variables, a and b contained. Imagine doing this in c/c++ or BGT. To do this you will need a third variable.
Regards,
Amit

There once was a moviestar icon.
Who prefered to sleep with the light on.
They learnt how to code, devices sure glowed,
and lit the night using python.

2018-02-18 07:13:26

a= (b) ? c : d;
switch (e) {
case f : g(); break;
case h : i(); break;
}
And then there are c-style macros.
Python is supremely simpler overall, but I do need the terniary operation far more often than swapping.
Yeah, Python eventually added its own version (which is annoying to port, since it puts the arguments in a different order), but it's not as quick as a=(b)?c:d;
But that's all I can think of that python does less conveniently. ... Well, that and the lack of smart string concatenation.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-02-18 11:23:35

@post 10:
smart string concatenation? I think this is pretty smart smile
name = "paul"
surname = "iyobo"
print "hi %s, %s" % (name, surname)
or maybe I totally missunderstood what you were saying

Paul

2018-02-18 15:11:31

that %s stuff is the old way of doing things, you don't do that in python 3

Facts with Tom MacDonald, Adam Calhoun, and Dax
End racism
End division
Become united

2018-02-18 15:34:02

oh I see

Paul

2018-02-18 17:51:34

What's the V3 way of doing things?

2018-02-18 18:40:11

Hi,
Actually the %s thing is still valid in python 3 as I just checked it out. IF you don't want to use it then you can use the power feature introduced in python, called f strings or formated strings. like this:
name="amit"
print(f"hi {name{!")
As you can see this is much more simpler than that %S or other methods to do this.
Regards,
Amit

There once was a moviestar icon.
Who prefered to sleep with the light on.
They learnt how to code, devices sure glowed,
and lit the night using python.

2018-02-18 19:56:55

so the book says not to use notepad. Is there any other edetors that you'd suggest? I don't want to go try a random one in case of it not being accessible.

2018-02-18 21:02:25 (edited by Jaseoffire 2018-02-18 21:05:57)

Yeah, I was mainly talking about the conditional stuff like switch case statements and the ternary operator. Python's constant if/elif/else blocks feel repetative to type. In C/C++ (Which admittedly is beginning to put this language back in my good graces over Java) is the preprocessor which allows for macros and that sort of thing. Plus, more as a personal preference, I prefer the braces to the forced tabbing system. In C/C++/Java, if I forget a tab somewhere, the compiler and or program is not going to yell at me about it. Not to say anyone that I might be working with on a project won't mind you, but I'd rather have them angry at me when it would be a simple correction requiring little trouble of retesting stuff. I can write the program as I wish and if it works, I know it isn't a blocking issue because I forgot a tab somewhere. If it's a nice enough IDE, a lot of the brace stuff is handled for me as well. Celebrating your existence, Eclipse.

I have a website now.
"C: God's Programming Language
C++: The object-oriented programming language of a pagan deity" -- The Red Book
"There, but for the grace of God go I"

2018-02-18 22:39:47

Hi Amerikranian.
Goodness, I am tired of hearing stupid stuff like this! Yes you can use notepad to write python programs no problem. I've seen this in many python tutorials, "Don't use notepad, it's very bad!" If it's easier for you to use notepad then go ahead. You can still run scripts with the command prompt if you really want to later. Just keep in mind that the books are wrong about things sometimes.
Hth.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

2018-02-19 00:34:38

Yeah. I find that, while IDEs reduce some of the work, they make up for it with clutter and navigation and gah just let me write the code in a text editor, read the compilation results, and test the thing. Notepad + the command prompt is generally sufficient, but Python.exe launches a useful terminal, also.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-02-19 02:06:38

I'm currently writing a large application and have written everything in notepad. I haven't used an IDE at all, unless you count the VC++ command-line developer tools as an 'IDE'. Also, the smart string concatenation that people are referring to is either of the following, if I'm following your wavelengths:
1. Printf-style formatting, i.e.:
printf ("%s %.3f\n", "Pi is equal to", 3.14159); // prints pi is equal to 3.141.
2. Boost.format-style syntax:
#include <boost/format.hpp>
#include <iostreams>
std::string s2 = boost::str(boost::format::format("%2% %1%") % 36 % 77 );
(Taken from http://www.boost.org/doc/libs/1_66_0/li … rmat.html; lots more examples there.)
(I admit, this method is a bit more clunky.)
There is, of course, the optional third way of doing things:
3. IOStreams-style formatting (setf/setw). Example at http://en.cppreference.com/w/cpp/io/ios_base/setf
There are probably a lot more ways of string concatenation. One other way is through stringstreams:
#include <sstream>
using namespace std;
stringstream ss;
ss << data;
ss << data << data << ...;
// Repeat until you've got all your data in the stringstream Or you can make a set of <<s until all the data is in.
// ss << data << data << ... << data;
// Get final string
string data = ss.str();

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2018-02-19 23:55:32

Well, honestly. Python's indentation is may be the only thing that may frustrate beginner users. However, Python is a piece of heaven comparing to some other languages where you get frustrated with null pointer exceptions, data conversions, not to mention that it's quite easy to forget to enclose braces when you have lots of nested blocks. I'm using Java at work, and I've realised how I miss Python, although I'm still using it for writing NVDA addons and some other private stuff. Python is far from perfect, because nothing in this world is perfect, but Python is very popular and saves your time a lot, at least from my experience. For me it's more important to get things done as soon as possible, than spending weeks of work on something that I can get in a single day. Life is too short for that.

2018-02-20 03:28:44

@Hrvoje, most of the issues you pointed out, like null pointer exceptions, can be gotten around easily. For example, in C++, you'd either use a library that *doesn't* use NULL or nullptr, or you'd do checks for them.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2018-02-20 03:59:22

You can get an equivalent to NPEs in Python, can't you? I mean, doesn't the exact same principal apply to trying to call a.f() if a is null or if a is None?
Basically, you can't expect that a function or method will never be called with invalid arguments, so the very first thing you should do is to confirm that the arguments are valid. A simple "if a is None : return False", or whatever the appropriate default is, or throwing an error, works well enough in most cases I encounter.
... Is it a style thing? Java has ludicrous style conventions, like making absolutely everything into classes, making new classes for extremely specific exceptions, overly verbose class names, package conventions that amount to a lot of wasted space... But those are just style conventions, and unless you're working with a package that has already gone too far down that rabit hole to be salvageable, you can basically treat Java like most C-style languages, just without a global context, right?
I basically gave up on Java when BGT and Python proved all around better for my purposes, so if some updates in the past 5 or so years have enforced the tedious clutter, then I missed it.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-02-20 11:16:45 (edited by gjp1311 2018-02-20 11:30:54)

Personally I'm very found of C# and the whole .NET environment. The language has the same learning curve as Java, though I think the ecosystem in .NET is easier to get around.
With this language you are able to use lambdas and functional programming concepts that Python has, without any trouble. And for what I'm seeing, this BGT seems like C and C++. I think the advantage of working with C# (And Java for that matter) is using managed code.
You won't be needing to worry about memory and pointers too much. You don't have pointers as in c and c++, but objects are references. It's easier for sure, but can be tricky sometimes.
I learned a bit of Python, but as I have worked my entire life with C-like languages, I found it very annoying to have to structure the code using only tabs and spaces. But I like very much the functional aspect of the language.

And as a plus, Visual Studio Community is very accessible.
https://www.reddit.com/r/programming/co … o_2017_to/
https://youtu.be/iWXebEeGwn0

2018-02-20 18:23:36

There still are pointers in c++. While it is encouraged to pass things as reference or const reference, pointers are still okay to use and perfectly acceptable in the language.

I don’t believe in fighting unnecessarily.  But if something is worth fighting for, then its always a fight worth winning.
check me out on Twitter and on GitHub