1 (edited by ivan_soto 2018-02-17 05: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

Thumbs up

2

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.1: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

Thumbs up

3

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.

Thumbs up +1

4

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

Thumbs up

5

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

Thumbs up

6

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

You can follow me on twitter, @cartertemm

Thumbs up

7

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.

Thumbs up

8

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

Thumbs up

9

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

Thumbs up

10

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.

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up

11

@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

If you want to get in touch with me you can follow me on Twitter
have a nice day.
Paul

Thumbs up

12

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

I'm a cat! What's mine is mine, and what's yours is mine to :P XD

Thumbs up

13

oh I see

If you want to get in touch with me you can follow me on Twitter
have a nice day.
Paul

Thumbs up

14

What's the V3 way of doing things?

Orin

Thumbs up

15

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

Thumbs up

16

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.

Thumbs up

17 (edited by Jaseoffire 2018-02-18 20: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.

Thumbs up

18

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

Thumbs up

19

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.

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up

20

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.

Thumbs up

21

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.

Thumbs up

22

@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.

Thumbs up

23

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.

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up

24 (edited by gjp1311 2018-02-20 10: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

Thumbs up

25

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

Thumbs up