[Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Ben Vinger
Hello I want to create a dictionary (from SQL usernames) of the format: accounts = { ('psmit', '123456'): 'psmit', ('rmatt', 'mypass'): 'rmatt', } So I have: accounts = {} UserCursor.execute(sqlstr) rows = UserCursor.fetchall() UserConn.commit()

[Tutor] Build your own web server in three lines of code

2006-03-23 Thread Ben Vinger
The nice-looking, revamped Python web site states that you can do this, but does not go on to say how. Does anyone know? On an OT note, I've recently seen how it can be done in a shell script: http://www.debian-administration.org/articles/371 Ben _

Re: [Tutor] How to monitor streaming data from the internet via modem?

2006-03-09 Thread Ben Vinger
On 3/8/06, Alan Gauld <[EMAIL PROTECTED]> wrote: Ethereal is one well knownand powerful one, but there are others which may be simpler touse.   Yes, with Ethereal comes a command-line version called tethereal, which I've used within Python on both Windows and Linux.  It worked nicely for trafic a

Re: [Tutor] How can a function know where it was called from

2006-03-02 Thread Ben Vinger
Thanks to all who responded.  I ended up using  a sender parameter as suggested by Andre and Alan, as this was very simple to do.   Ben   ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] How can a function know where it was called from

2006-03-02 Thread Ben Vinger
Hello   I want myfunction in the pseudocode below return something different if it was called from indexfunction.   def indexfunction():    blah   def myfunction():   x = 'whatever'   if :  return x   else:  return + x +     Thanks Ben ___ Tuto

Re: [Tutor] python help

2006-02-08 Thread Ben Vinger
Why are these homework programming challenges so recognisable? It boils down to: Write a function that that uses X and Y techniques. The function may be hard and challenging to write but doesn't ever do anything interesting or anything that is useful and complete on its own. I realise teachers ha

[Tutor] Trapping a Dr Watson error

2006-02-02 Thread Ben Vinger
Hello I have a script based on: http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/Windows_NT_Eventlog.html It collects eventlogs data from many Windows servers. I know how to handle normal Python Tracebacks, but my script bombs out with a Dr Watson error when connecting to one particu

Re: [Tutor] mod_python and other web frameworks

2006-01-25 Thread Ben Vinger
--- Intercodes <[EMAIL PROTECTED]> wrote: > List: I am still open to suggestions. Being also keen to write better web apps in Python, I've spent a considerable amount of time reading about this (and it is indeed confusing), I've opted to try out something like Pylons or Turbogears. One thing I w

Re: [Tutor] passwords in scripts

2006-01-24 Thread Ben Vinger
Compiling is certainly helpful in my case, and I did not realise how simple it was until you explained it. I estimate that most of our MCSEs will not know about the strings command or attempt to look inside something like test.pyc for a password. As for users, I'll be amazed if they tried it. An

Re: [Tutor] passwords in scripts

2006-01-24 Thread Ben Vinger
--- Alan Gauld <[EMAIL PROTECTED]> wrote: > command line arguments? > > $ startapp -d mydb -l user/password & > > That way they are > 1) kept secret(especially if you turn shell history > off ;-) and > 2) can be changed every time you restart the server > app and > 3) you can have production a

Re: [Tutor] passwords in scripts

2006-01-23 Thread Ben Vinger
Hi Danny The Unix servers are ancient HP-UX ones. I doubt if an SSH implementation for them exists, but it is not worth my while trying to find out, because I will not be allowed to install anything on them (or even suggest it). So I access them using telnetlib: host = 'hpserver' user = 'backup

Re: [Tutor] passwords in scripts

2006-01-23 Thread Ben Vinger
; wrote: > 2006/1/21, Ben Vinger <[EMAIL PROTECTED]>: > > Hello > > > > I've written a couple of scripts that check log > files > > on our WIndows and Unix servers. These scripts > have > > plain text passwords in them, so anyone who can > acce

[Tutor] passwords in scripts

2006-01-21 Thread Ben Vinger
Hello I've written a couple of scripts that check log files on our WIndows and Unix servers. These scripts have plain text passwords in them, so anyone who can access the filesystem of the Windows server that runs the scripts can discover the passwords of the servers. Is there a way to hide/encry

Re: [Tutor] a class knowing its self

2006-01-21 Thread Ben Vinger
Yes, you are right, - Shuying Wang's suggestion fixed the immediate problem, but there is still someting wrong with my code - maybe I'll ask about it again later. --- Ewald Ertl <[EMAIL PROTECTED]> wrote: > > > Have a more precisely look at your code. > s.getName() does just return, what you h

[Tutor] a class knowing its self

2006-01-18 Thread Ben Vinger
Hello I've been reading about how a class has access to its own 'self', so I tried the following, but it is not working as I would expect: class Skill: def __init__(self): self.history = [] def setName(self, skill): self.name = skill def getName(self): return se

Re: [Tutor] extra characters in XML

2006-01-12 Thread Ben Vinger
Thanks - it was exactly as you said --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Most likely your XML file is 16-bit unicode, not > utf-8. When ascii text > is represented as unicode, every other byte will be > a null byte. That is > the extra character that shows up as a space or box > depen

Re: [Tutor] extra characters in XML

2006-01-11 Thread Ben Vinger
e large Unicode string. text = infile.read() # Close the file. infile.close() The same function is used to open a file for writing; just use "w" (write) or "a" (append) as the second argument. --- Ben Vinger <[EMAIL PROTECTED]> wrote: > Hello all > > I want

[Tutor] extra characters in XML

2006-01-11 Thread Ben Vinger
Hello all I want to do the following in an XML file: XFile = open(XmlFile,'r') for line in XFile.readlines(): if line.find('') > 0: print line However, it does not work due to extra characters that appear in the XML file. For example if I use the previous code without the if condition

Re: [Tutor] Website monitoring program.

2005-11-21 Thread Ben Vinger
Below is a program I found at http://starship.python.net/crew/neale/ (though it does not seem to be there anymore.) It uses a seperate file for the URLs --- Adisegna <[EMAIL PROTECTED]> wrote: > My question is how to use a loop to go through a > tuple of URLs. Please feel > free to suggest an ea

Re: [Tutor] hey i need some help here

2005-09-11 Thread Ben Vinger
It is almost certain that you are using MS Windows, and that Python is not in you "system path". If so, here's what to do: Add the top-level Python directory to your Windows "PATH". On Windows NT this is done with Control Panel/System/Environment. On Windows 2000 and Windows XP it is done with C

Re: [Tutor] PYTHON????

2005-09-01 Thread Ben Vinger
The Python interpreter already contain the code for multiplication, so you don't need to write it. You can just use it: x = raw_input('give the first number') y = raw_input('give the second number') print x, ' times ', y, ' is', int(x) * int( y) Or in the interactive interpreter you can just:

Re: [Tutor] Hy, I'm a n00b to Python, have some questions

2005-07-18 Thread Ben Vinger
--- Alex Nedelcu <[EMAIL PROTECTED]> wrote: > 4. What's the hottest web framework right now that > does not require an > application server (meaning that it runs on fastcgi) Take a look at Myghty - it seems pretty good - it is a Python rewrite of Perl::Mason (which Amazon.com is based on). Yo

Re: [Tutor] replaying

2005-07-18 Thread Ben Vinger
Mailman can be set up to reply to the forum, but people on this list prefer to live with pain! --- geon <[EMAIL PROTECTED]> wrote: > Hi, > > Seems to me as very unuseful thing in this phorum, > when I choose Replay > to any message, the field "to whom or Receiver" is > all the time not > tutor@

Re: [Tutor] (no subject). Ord and Chr query

2005-05-27 Thread Ben Vinger
--- John Carmona <[EMAIL PROTECTED]> wrote: > Ben I could not get your script working indentation? ___ Can't remember an address in your address book? Enter the first few letters and Address AutoComplete will automatic

Re: [Tutor] (no subject)

2005-05-26 Thread Ben Vinger
Or like this: for x in range (0,256): print ord(chr(x)), ': ', chr(x) (you could just print x, instead of ord(chr(x)), but then you would not be using ord) Ben --- Pujo Aji <[EMAIL PROTECTED]> wrote: > Actually you can do the same way: > > # Convert intAscii to charAscii > S = [chr

how to run a programm after you have typed in the commands (was Re: [Tutor] help (fwd))

2005-04-13 Thread Ben Vinger
It sounds like you've been using the Python interactive prompt such as IDLE. You can type the same Python statements you've used there into a text editor or Python IDE and save it. Let's say you have created a Python program/script called hello.py in a text editor and saved it. You can now open a

Re: [Tutor] os.popen doesn't give up

2004-12-02 Thread Ben Vinger
--- Ben Vinger <[EMAIL PROTECTED]> wrote: > --- Bob Gailer <[EMAIL PROTECTED]> wrote: > > Solutions: > > 2 - l = os.popen(r'snmpget -Os -c ' + > SNMPcommunity > > + ' -v2c -r 3 ' + IP + > > ' ' + counter, '