Teaching Python

2011-04-19 Thread Passiday
Hello,

I am planning to teach Python to a group of high school students, who have 
in-depth interest in programming, hacking etc.

I am looking for some good material, what I could use as a basic guide when 
preparing the classes plan for the course - website or book, what would roll 
out the topic methodologically gradually. The target audience is someone who 
knows most basics of the programming, but doesn't mind being reminded about 
them now and then.

Thanks for any suggestions!

Passiday
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Teaching Python

2011-04-19 Thread Passiday
Of course, I meant the "tinkering, playing with, etc." meaning. That would be 
quite strange to look for an advice "how to break the Pentagon's systems" in 
public forum :)  And while I plan to tell them about the "practical 
programming" (ie, typical tasks what they would be doing when hired), I think 
the school is still that wonderful time when can afford to do something just 
for the fun of it. Who knows what will come out of it, when they know how to 
join several programs together via clever scripting, build some circuit board 
to handle some household appliances, and set up a webcam for the world to 
control that. I see them as potential geniuses rather than potential data entry 
operators with programmer skills.

I think Python is a very important language to learn - both easy and advanced, 
with very wide support in different platforms, with loads of great applications 
that can be scripted by it, and great community support.

I am aware, of course, that the web is full with tutorials, etc. It's the sheer 
abundance of material what made me post the question, an attempt to narrow the 
scope down. The book Dive into Python seems like good solution, I think I'll 
give it a shot.

Passiday
-- 
http://mail.python.org/mailman/listinfo/python-list


MIDI message sending and receiving, MID file manipulation

2011-04-25 Thread Passiday
Hello,

I'd like to experiment with Python, connecting my Linux PC with MIDI
device (standard synthesiser keyboard).

I am pretty new to the Python world, so the questions that crop up, I
assume, could be pretty basic to someone who had spent some time with
it.

So, here comes:
1) Is everything what could be done with Python in some IDE (Eclipse
for me), can be accomplished in the interactive console? I mean,
perhaps Python could be used just as programming language and compiled
in binary code, thus allowing access to some binary libraries what
might not be accessible from within the interpreter.
2) Is there a way how to run Python script in event-driven mode, ie,
run the script, it registers some function as keyboard event handler,
and then calls that function whenever I press any key. Is such
behaviour possible in the interactive mode? Since I want to test the
MIDI message exchange, having a function sitting on the timer event is
what I'll need for playback, and an event that is triggered by
incoming MIDI message for recording.
3) Of course, I need some Python module to actually get this MIDI
communication happen. Sending and receiving MIDI messages to and from
my MIDI device.
4) As for manipulating the MIDI files in Python, I have searched up
this: http://www.mxm.dk/products/public/pythonmidi  However, this lib
doesn't try to provide actual communication with MIDI device.
-- 
http://mail.python.org/mailman/listinfo/python-list


Suggested coding style

2011-09-24 Thread Passiday
Hello,

I have started to code random stuff in Python only recently, still
lots to learn. So please bear with me if my question sounds like rant.

I have been coding in many other languages, most of the time it was
Java and C#. I don't like the function mess of PHP (ie, loads and
loads of functions without any namespaces etc), but I'd like to think
that Python is different.

In my brief coding experience I have stumbled upon Python zfill(width)
method, and I thought, really, do you have to include such a narrow-
purpose method in the basic method set? Perhaps there are more such
methods that are nice when you need them, but then again, you don't
put all the possible methods in the standard set.

Perhaps there is reason such method is in the basic library, and my
complaints are unbased? Or, perhaps the language is on course to bloat
out and get filled with tens and hundreds of special-purpose methods
that render the language structure chaotic?

Passiday
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggested coding style

2011-09-29 Thread Passiday
Oh, my. Who could expect this topic would iterate to some whining about 
religion (please don't respond on this remark of mine).

Here's a summary of what I take from this longwinded thread:
Read the Zen of Pthon for some fun: http://www.python.org/dev/peps/pep-0020
Read the PEP-8 for some good guidelines: http://www.python.org/dev/peps/pep-0008

My topic was "Suggested coding style" because I hoped there is some common 
understanding which of the ancient methods/functions are so not where they 
should be that the use of them should be depreciated. I can fully understand 
that when the language evolves, it might implement some ugly methods. Perhaps 
it was some quick itching need to format some numbers that drove some antique 
Python programmer so mad that he decided this belongs to the string class, 
instead of some number/date/string formatting class that attempts to build on 
existing well established standards. And so, the str.zfill() was born. But I'd 
expect that there exists some leadership who are brave enough to admit some bad 
decisions and lead the people by announcing that using certain methods is "bad 
style". No need to take them out of the implementation, that might unnecessary 
break some code in obscure places. However, guiding programmers for better 
coding practice and avoid ugly bloating of nice scripting lang
 uage should be considered a holy (please don't rant on use of this word) 
mission.

Passiday
-- 
http://mail.python.org/mailman/listinfo/python-list


(don't bash me too hard) Python interpreter in JavaScript

2011-11-15 Thread Passiday
Hello,

I am looking for a way how to bring Python interpreter to JavaScript, in order 
to provide a web-based application with python scripting capabilities. The app 
would have basic IDE for writing and debugging the python code, but the 
interpretation, of course, would be done in JavaScript. I'd like to avoid any 
client-server transactions, so all the interpretation should take place on the 
client side. The purpose of all this would be to create educational platform 
for learning the programming in python.

I hoped somebody already had done something like this, but I couldn't google up 
anything. I've found some crazy project emulating PC in JavaScript (and even 
running Linux on top of it), but not a python interpreter.

Of course, I could take the python source and brutally recode it in JavaScript, 
but that seems like awful lot of work to do. Any ideas how I should proceed 
with this project?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-15 Thread Passiday
Thanks Carl, this looks like a good base to start from.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-15 Thread Passiday
Of course, I am aware of this. But the file system can be emulated, and certain 
networking can be mediated via the server, too. But for starts, I don't plan to 
go beyond the basic file operations, if at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Can't get Apache2 tp process py (Ubuntu 11.10)

2011-12-15 Thread Passiday
Hello,

Sorry if this is not exactly appropriate forum where to ask Apache question, 
but I though't here would some Apache-experienced people probably hang out.

Well, I can't get my Apache2 to process Python *.py files. I checked numerous 
tutorials how to enable it, and did the install steps:

- Installed the libapache2-mod-python package
- Added the following lines to the  section of  
/etc/apache2/sites-available/default file:
  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On

I made this simple test.py file:

def index(req):
  return "Test successful";

When I request the file, ie, [url]http://localhost/test.py[/url], I get the 
download prompt, and the Python script is just downloaded, not processed.

The error log /var/log/apache2 shows these lines that kind of confirm that the 
module is loaded:

[Thu Dec 15 15:12:38 2011] [notice] mod_python: Creating 8 session mutexes 
based on 150 max processes and 0 max threads.
[Thu Dec 15 15:12:38 2011] [notice] mod_python: using mutex_directory /tmp 
[Thu Dec 15 15:12:38 2011] [notice] Apache/2.2.20 (Ubuntu) 
PHP/5.3.6-13ubuntu3.3 with Suhosin-Patch mod_python/3.3.1 Python/2.7.2+ 
configured -- resuming normal operations

As one can see, there are no any errors that would tell there's something wrong 
happening.

Any ideas what installation step did I do wrong or skipped?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't get Apache2 tp process py (Ubuntu 11.10)

2011-12-15 Thread Passiday
Ok, figured this out by myself. There was an apache config conflict, and the 
config without mod_python enabled took over the config with mod_python enabled.
-- 
http://mail.python.org/mailman/listinfo/python-list