I found this nice online book with exmples [url]http://www.byteofpython.info/[/url]

Member Avatar
Member Avatar
+0 forum 1

Hello, I'm trying to execute this simple code: [code] class Person: population = 0 def __init__(self, name): print 'Creating % s peron' % name self.name = name Person.population += 1 def __del__(self): print 'Destroying %s person' % self.name Person.population -= 1 prvi = Person('Asimi') drugi = Person('Mici') [/code] I'm using Wing IDE trial and here's what is output in debug mode: Creating Asimi peron Creating Mici peron Destroying Mici person Exception exceptions.AttributeError: "'NoneType' object has no attribute 'population'" in <bound method Person.__del__ of <__main__.Person instance at 0x00B29558>> ignored Destroying Asimi person Exception exceptions.AttributeError: "'NoneType' object has no attribute 'population'" in …

Member Avatar
Member Avatar
+0 forum 2

Hi, I've been trying to make a really simple word unscrambler, that takes a scrambled word, and then compares it to a txt file filled with words. The problem I'm getting, is that I'm trying to only read the first word of each line, and if it finds the word, then it prints out the entire line. So, my txt file kinda looks like this: [CODE]cart - art car tar bagel - age bag gel bike - [/CODE] If the user inputs "ikeb", then the program would only look at "cart", "bagel", and then "bike" before printing out "bike - …

Member Avatar
Member Avatar
+0 forum 3

Here's a cute little encipher/decipher program with a Tkinter GUI I wrote a while back. It's an implementation of a derivative of the Vigenere algorithm; the algorithm is taken from Laurence Smith's [U]Cryptography: The Science of Secret Writing[/U], Amazon link [URL=http://www.amazon.com/exec/obidos/tg/detail/-/048620247X/qid=1125004078/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-6170856-3267319?v=glance&s=books&n=507846]here[/URL]. It's a dated book (and the technique itself is very old), so don't expect any serious security from this - just something fun to think about. [CODE]# vigenere.py, a modification of the Vigenere ciphering program # Uses Tkinter import sys, string, tkMessageBox from Tkinter import * # -- The application class class Vigenere: # Initialize new instances of Vigenere …

Member Avatar
Member Avatar
+0 forum 2

Hello, I am new to Python and I am just starting to figure things out but this one has me stumped. I need to capture the exit code of my processes in order to track them in a database. I have all the other components working except this. In DOS I use: Echo %errorlevel% then post the value of %errorlevel% to the SQL table by calling a CF page and passing the value in the URL. Is there a way to calculate %errorlevel% with the exit code of the process in Python? I need Python to set %errorlevel% equal to …

Member Avatar
Member Avatar
+0 forum 1

Hello, I've downloaded PythonWin as a better IDE for writing Python code. I came across an interesting issue (as vegaseat pointed out) When I try to write this sentence in my native language "Ja sam

Member Avatar
Member Avatar
+0 forum 5

I want to read everything from a file using python. the one problem i am having (note: EVERYTHING from a file) is that python is returning an EOFError when i know that it's not the end of the file, is there any way to just read the damn thing till the computer crashes or at least untill the file i want to read from has been literaly sucked dry. basically is it possible to either skip an eof key and keep reading or specify my own. thanks alex

Member Avatar
Member Avatar
+0 forum 7

I'm completely new to python and really need help with this. I have written this basic cash fund program that allows a person to withdraw, deposit, and receive a balance from it. But now I need to now add email capabilities, by setting up a database (or list) of account holders' information such as email and other information. When a query is made by a user, they should enter a username or some other means of identification. When the query is accomplished, an email verification of the details should also be sent to the user. Please help! Here is my …

Member Avatar
Member Avatar
+0 forum 7

Hey there, i have a simple question about getting a script to do two things at once. like this. for i in range(100): print i time.sleep(.2) if i == 15: os.system('python /home/me/ipupdate.py') print 'done' when i run this, it stops at 15 and runs the script called out in the os.system line. i know it is supposed to do that. But, how could i get a script to do this without stopping the count (or delaying it unill the script called exits) I don' t have to run it this way, i can import it if necessary as a module. …

Member Avatar
Member Avatar
+0 forum 2

Hai Friends This is my first post to this forum. I am new to Python but I find its quite interesting. I have a problem with the folowing code... ########################## import telnetlib import sys HOST = "192.168.10.5" USER = "somename" PASSWORD = "somepassword" telnet = telnetlib.Telnet(HOST) telnet.read_until("login: ") telnet.write(USER + "\n") telnet.read_until("Password: ") telnet.write(PASSWORD + "\n") telnet.write("top -p 1 -n 1\n") telnet.write("exit\n") some_value = telnet.read_all() print some_value ############################# The problem is that, when I print 'some_value' I get " top: Unknown terminal "network" in $TERM ". But when I use other commands like 'ls -l' or 'df -h' it works …

Member Avatar
Member Avatar
+0 forum 10

i have an interesting project at work going on. here is the challenge. i am using the serial module to read data from a serial input. it comes in as a hex. i need to make it a binary and compare it bit by bit to another byte. They have some weird way they set this up that i have to compare these things with AND. in other words, if bit 1 is 1 AND bit 1 is 1 then the real value is 1... long story short. is there a good way to compare bytes, bit by bit with …

Member Avatar
Member Avatar
+0 forum 4

Hello! I need some help... I parsed an xml file using the minidom.parse method, but when i printed the document object to the screen (using toxml() function), i noticed that the parser automatically replaced my " (inverted commas) chars into ' chars. for example : <Father_Tag> <Son_Tag title=' "Son" '> This is an "example </Son_Tag> </Father_Tag> turned out to be : <Father_Tag> <Son_Tag title=" &quot;Son&quot; "> This is an &quot;example </Son_Tag> </Father_Tag> as a result, the &quot; replaced the inverted commas (") that i added. this shit really messes up my program! can anyone help me?

Member Avatar
Member Avatar
+0 forum 4

Hi, I wonder if you can give me any advice how to learn Python. My plan is to read python tutorial in documentation from begining to the end, and then to get some book (learning Python, or Python in a nutshell). How long it will take (in average) to get comfortable with the language? I have a solid knowleadge of C and C++ and I see in Python documentation many reference to C, maybe Python is written in C? I'm really very new to this language and to interpreted language as well, so I don't really know what all thah …

Member Avatar
Member Avatar
+0 forum 3

Hello, I've just started to learn Python. I have two questions: 1. Is there any way to set up default folder for Python files (that Atest from introductionary example)? 2. can you suggest any good Python IDE (existing is OK, but I have a fealing that I'm working in ordinary colored Notepad? Thanks

Member Avatar
Member Avatar
+0 forum 5

I have a script that is called by a batch file. Whether or not the script completes successfully the batch file continues. I need to know the results of the script. Is there a way to open an IE session, and call a CF page that I can pass an exit code to in the URL? Also, how would I generate an exit code to pass? Thanks

Member Avatar
Member Avatar
+0 forum 1

I would like to write good code, it is so east to start writing crap. Is the following bad. lets say I have the following code [code] testvar = 5 def test(testvar): print testvar test(testvar)[/code] is it a bad practice to use the name of a variable or function in the definition of function, in particular for naming the parameter. This would seem useful to help document what is happening in your code(helps me remember). It does not seem to cause any problems

Member Avatar
Member Avatar
+0 forum 2

hi I have this source [code] env = {} env['SERVER_SOFTWARE'] = ''+self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname [/code] how I can print arrays in this format [code] [HTTP_GET_VARS] => Array ( [v1] => fsdfsdf [v2] => sdfsdf [v3] => sdfsd ) [_GET] => Array ( [v1] => fsdfsdf [v2] => sdfsdf [v3] => sdfsd ) [/code] with python [code] env['HTTP_GET_VARS''] = '' env['_GET'] = '' [/code] this is from web server and must works with php source where …

Member Avatar
Member Avatar
+0 forum 1

hi I have a problem with this source code [code] #fi, fo = os.popen2('c:/python24/python.exe C:/AppServ/webserver/www/index.pyw') #fi, fo = os.popen2('c:/Perl/bin/perl.exe C:/AppServ/webserver/www/wwwp.pl') fi, fo = os.popen2('c:/appserv/php/php.exe C:/AppServ/webserver/www/wphp.php') data = self.rfile.read(nbytes) fi.write(data) fi.close() shutil.copyfileobj(fo, self.wfile) sts = fo.close() [/code] when I try with python or perl it works but with php not. first it is Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive. and when I edit php.ini with cgi.force_redirect …

Member Avatar
Member Avatar
+0 forum 5

hi :) i have problem with opening ".py" files in my web server this is the source code: [code] import string,cgi,time from os import curdir, sep from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class MyHandler(BaseHTTPRequestHandler): def do_GET(self): try: if self.path.endswith(".html"): f = open(curdir + sep + self.path) #self.path /index.html self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() return if self.path.endswith(".py"): f = open(curdir + sep + self.path) self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() return if self.path.endswith(".sth"): #dynamic self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write("today " + str(time.localtime()[7])) self.wfile.write("year " + str(time.localtime()[0])) return return except IOError: self.send_error(404,'File Not Found: %s' % self.path) def do_POST(self): global rootnode try: …

Member Avatar
Member Avatar
+0 forum 2

Hello, I've just read thread why I should lear python and I must admit that I'm very interestwed to learn oppython myself. i have experience with C and C++ programming language. If I understood corectly Python is an interpreted language. What is advantage of interepreted languages (if there are any)? For example I write C++ code compile it, link it and then I can give or sell complete program (exe file). How to distribute interpreted language? Does that mean that I must share source code or what? I really don't have any experience with any interpreted language so, plase, do …

Member Avatar
Member Avatar
+0 forum 2

[FONT=Fixedsys]Hi it's me again, I want to know how to make a new directory containing my python script. Also, how do I make the new directory containing my python script into the current directory? Just for you to know, I installed the newest version of Python which is Python 2.4.1 msi for Windows XP PRO. Yea this is my first time programming and learning the basics. I'm just simply following this persons way of working with python, I guess. This will give you an idea of what I'm doing. Anyway, you can check it out at: [url]http://www.developer.com/lang/other/article.php/626311[/url] When you go …

Member Avatar
Member Avatar
+0 forum 1

Hey I'm a new member here. I just need some help. I need help with setting the path for python. I must set a path in Windows to the directory where the Python.exe is located so that I can execute Python script. I need to get the directory containing the file names python.exe to be listed in my system environment variable named "path." If you guys can give me a step by step procedure that'll be great. I need to set the path because I want to execute my script at the "Command Prompt" to see if I did it …

Member Avatar
Member Avatar
+0 forum 1

As I said before im new to python and stink at math(great combination huh?) Well I've looked at Thinking in Tkinter but I still don't fully understand the concept of classes. Could you provide any help\tutorials on this subject? Help Appreciated :cheesy:

Member Avatar
Member Avatar
+0 forum 7

Python Version: 2.1 Platform: HP Windows XP I am using Python scripts generated by ArcGIS/ModelBuilder in order to automate geoprocesses. Currently I am calling a series of scripts from a batch file that is called by the task scheduler. My problem is if there is an error the process stops, returns to the batch file and the next script starts. What I need to do is pass a result code to the batch file so I can tell if the script executed correctly. The scripts are independent and do not rely on the previous script but I still need to …

Member Avatar
Member Avatar
+0 forum 2

I wrote simple python program that rips, encodes, and gets song data from the cddb. I would like to give the user the option of customizing it to there taste. So I want to make a config file that I can store in /etc(linux fiel location). for example it would look like this config file [code] # if you would like to specify the location of you music directory uncomment the following #music_dir = '/home/shane/location/of/directory' # if you would like to permantey set the bitrate used please unmcooment the following #bit_rate = 192 [/code] is their a way to direct …

Member Avatar
Member Avatar
+0 forum 5

Ok new problem, I want to build off of a program I saw in a tutorial that has a "menu" and can calculate two different shapes. The two shapes are circle and rectangle. I've built it into a working order.(event bindings, buttons, area calculation programs) The program works all the way up to the done button(the button that begins calculation and prints it in a label) but when I click on the button it brings up a error message in the IDLE shell prompt that says that I can't do the following: This is a snippet of the script to …

Member Avatar
Member Avatar
+0 forum 9

Ok I've gotten py2exe because I have friends that want to test my programs, but they don't want to download the python program. Well I have tried to run the compiler out of MS-DOS and the Python version of MS-DOS. But every time I wind up with an error. I can't use the prompt for the life of me and I have no idea of any of the commands. :confused: A example or step by step would be [U]GREATLY[/U] appreciated. :cheesy: Running: Windows ME, Python 2.3

Member Avatar
Member Avatar
+0 forum 3

Hi all, Here's one that has me stumped. I'm trying to build a system shell with a Tkinter GUI in Python, and I can't figure out what to do with one of the widgets. Here's the program concept: I have two major widgets: a ScrolledText widget and an Entry widget. The purpose of the ScrolledText widget is to display the results (from STDOUT or STDERR) of what the user has typed. To that end, it is user-uneditable. The Entry widget contains both the prompt and the command line; when the application starts, this widget displays the prompt (which looks like …

Member Avatar
Member Avatar
+0 forum 4

Hey there, i have been writing python scripts for about 4 months now so i am still very new at programming. that said, i need to build a gui app to handle some data manipulation from a database, set points, etc... what i would like is the easiest to learn gui development method for python in linux. Dont need anything cross platform, just easy to learn but able to do things like plotting info on a graph. ok, so i have looked at Tkinter, glade2 and wxPython. i dont know, but i would like some opinions before i jump into …

Member Avatar
Member Avatar
+0 forum 4

Hey there, i have some python scripts that run with the cgi-module. all named whatever.py the thing is, firefox will open one that has a form on it, but not load the next one in line. it pops up a window that says what do you want me to do with this file? and i can open with, or download it. the other python programs work . i already did the chmod 755 on it, tried the chmod a+x, but just isn't doing anything. they work if rendered with IE - go figure. anyone ever see this ? thanks

Member Avatar
Member Avatar
+0 forum 2

The End.