Re: ewby on programming need some tips and tricks

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 7 Dec 2008 19:41:39 +0200

From: "Nick Stockton" <nstockton@xxxxxxxxx>
"""
In perl you can write the entire program in a single line. You can even
write the program in the command line. Can you do that with python?
"""

Yes you can do boath with python.

Can you give an example?
Here is a very simple example of a command line that downloads the first
page of Google and prints the title of that page:

perl -MLWP::Simple -e "$p=get('http://www.google.com/');
($t)=$p=~/<title>(.+?)<\/title>/gsi; print $t;"

It would be very interesting, especially for those who like python to see
how it could be done with python, and I would be also very interested,
because it could convince me easier that python has real advantages.

You asked:
"""
In perl you can split an expression on more lines and it will work. Can
you do the same thing with python?
"""

yes you can do that with python.

Can you give an example?

Here is a simple math operation that is easy to understand in perl, of
course very exagerated to see how flexible are some languages:

my
$
variable
=
1
+
2
;

print
$
variable
;

This will print of course "3".


You stated:
"""
In perl you can indent the code with more or less spaces, whatever you
like, or you can not indent the code at all. But you can't do that with
python.
"""

in python you can indent the code with more or less spaces as well even
just one space as long as you indent.  I tend to use four spaces as for
me, anything more is to many and anything less is to few.

I think you didn't understand what I said.
In python you should keep a consistent indenting and if you indent a line
with a space, you should indent all other lines in the same block with a
space, because if it happends to indent them with 2 or more spaces, the
program won't be very happy.

Also in another message you asked:
"""
If python wouldn't have this issue of indentation, it wouldn't need
workarounds for making it a little bit friendlier.
So I don't understand what you don't like when I said that python is less
friendly for the blind than other languages.
"""

Because most languages and programs in general for that matter to one
extent or another can be a little unfriendly and require workarounds.  I
mentioned visual studio in my last message.  Do you think it would be very
accessible with out the screen reader scripts for it?  The screen reader
scripts and learning all the hotkeys for them are probably even bigger
workarounds then adding a couple commented braces in python code.  I don't
use VS so someone else will have to confirm that but I do define screen
reader scripts as

Yes of course you are right. That's one of the reasons I don't use Visual
Studio too much. :-)

workarounds.  Now lets say you use the console to compile and you get some
output that scrolls off the screen.  As far as I know it's quite hard for
a blind user to use the cmd scrollback buffer and so What do you do?  You
pipe the output to a text file and read it with a text editor or pipe it
directly to a program for reading even though it might be a bit
inconvenient to do. Pipes are workarounds too.

Yes pipes are workarounds too, because you need to make an effort each time
you need to do the pipes.
But I have defined a shortcut in TextPad to run a certain program with the
current program as a parameter, so if I want to compile the program I am
currently developing, I just press the hot key I defined, then press enter,
or I could also add some command line parameters before pressing enter.
But this is not special to perl or other languages, because I can use the
same technique with python, or ruby, or C#, or Java...

And the result from STDERR or STDOUT will be printed as another common document window, which would be very accessible no matter if it has 3 lines or 100 MB.

Octavian

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: