15,181 Topics
| |
This is part of another script, too long for here, but isolating this part, my dilemma is that this works when manually invoked from IDLE, but not when run as a cron job. from datetime import datetime import os # check to see if a log file exists, make one … | |
Here you see how one could use recursion together with generators for (inefficient) permutations generator. It is kind of interesting to know how one can do it recursively (of course there exist many ways). Anyway this snippet demonstrates how you can use recursive generator call to feed a for statement. … | |
I am a newbie to python. I am just working on a program to count number of letters in each words of a sentence. That includes punctuation too. If the sentence is "This is it!" my program should give "4 2 3". First I thought I can convert this string … | |
below is mycode though i have set keepalive, socket connection gets closed after sometime. sb_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM,socket.SOL_TCP) sb_sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) sb_sock.connect((msg_host, host_port)) reg_msg="REG 0000 "+finder_id+"\r" sb_sock.send(reg_msg) | |
I googled little around for correct way to not reinventing of the wheel for expression evaluation (even I had done some simple evaluation check for my [Tkinter calculator snippet](http://www.daniweb.com/software-development/python/code/282548/simple-calculator) earlier). After getting totally upset with [this example](http://www.bestcode.com/html/evaluate_math_expressions_pyth.html), I made this with some struggles with `__builtins__` globals parameter of eval. First … | |
I am trying to write safyfied evaluator class, and get unexpected `__builtins__` added to dictionary after evaluation. Can somebody explain why/how it happens? import math def echo(n): print n return n def nothing(n): return n debug = nothing class MathParser(object): ''' Mathematical Expression Evaluator class. call evaluate() function that will … | |
Hi ALL, I am completely new to python and when i was playing with a while loop in the Python SHELL the code works but when I then put it into a file and saved and then tried to run it I got the error "NameError: name 'b' is not … | |
Inspired by some C and C++ threads regarding finding a specific pattern in a file. | |
When working whith large data files, it may be desirable to output a sequence of bytes by large chunks. This snippet defines a file adapter class to handle this transparently. Writing bytes to an ChunkedOutputFile will automatically write the underlying file object by fixed length chunks. | |
I am self teaching myself python and I have hit a question that I can't seem to figure out dealing with raw_input. This is the code that is confusing me: print "How tall are you?", height = raw_input() print "So, you're %r tall ." % (height) I input my height … | |
Hello, I need your help with something (again): I need to control two text widgets with one scrollbar and, thanks to this website, I found some code to do it using listboxes (here: [url]http://www.daniweb.com/forums/post940371.html#post940371[/url]). I modified it, and it now works with text widgets and pyton 2.x. The problem is: … | |
>I need to take a list of files and remove a '.2' from a line in each file. I then need to rewrite the file without the '.2'. Using the code below I am >able to take a single file and do exactly what i need to but when trying … | |
Hello everybody. I want to make sure about something: If I install ActivePython 3.2 as root on Linux, will it delete the distro's default Python (2.6)? I also installed Python 3.1 a long time ago, so I have Distro's Python 2.6, the official Python 3.1 and want to add this … | |
Hello again. Here are the details: * My litle scripts work perfectly in my virtual Windows XP (I'm using virtualbox if that matters) as long as they are non-compiled .py or .pyw files * After compiling them, I double click on them and a DOS window comes out, then dissapears … | |
Hello. I am trying to create a module containing many little functions useful for linguistics. So far everything works right, but I have a question: is it a problem if a function within a module calls another function within the same module? I mean, I have a function that performs … | |
Hi, this is, let's say, the second part of this thread: [url]http://www.daniweb.com/forums/thread291657.html[/url] I have managed to control two widgets with one scrollbar, but now I have realized that, althought the widgets can be controlled individually via the mouse wheel or the keyboard, I sometimes need individual controls for each widget. … | |
sample_json1={{ "globalControlId": 72, "value": 0, "controlId": 2 }, { "globalControlId": 77, "value": 3, "controlId": 7 } } sample_json2={ { "globalControlId": 77, "value": 3, "controlId": 7 }, { "globalControlId": 72, "value": 0, "controlId": 2 } } | |
Trying to convert the following block of perl to python for($row = 0, $mytype = 500; $row < $filearray_count; $row++) { if ($_ eq $filearray[$row][0]) { $mytype = $filearray[$row][1]; print "$row, $mytype, $_ \n"; break; And here is the python attempt. I'm not sure if I'm dealing with $mytype = … | |
**PLEASE HELP ASAP!!! I need help completing this by tomorrow afternoon!!! Can anybody write this for me???????? ** Chemin de Fer is a French card game. You will be creating a simulation of this card game. In Chemin de Fer, cards have the following values: aces are worth 1, cards … | |
Hi, I'm new to python, although I have experience with other programming languages. I installed python and downloaded packages, which all work fine. But now I downloaded Obspy, and it can't find the modules. For example, if I type: from obspy.core import read, it gives an error stating that there … | |
Hello! I am new to Python, and I want to learn it. I have just installed Python 2.7.3 And Visual Python Tkinter IDE for Ver 2.6-2.7-3.1 (BETA) –Version: 2.0.12.2524. I was looking into some the Tutorial and follow the first example to code. Here begun my issues. First Step: I … | |
I'm new to python, so kindly bare with me my query is that how can we get the static strings from the dialog boxes of windows and paste those strings to a notepad or a clipboard file. e.g. if a take the Run Dialog box of Windows all the Strings … | |
Hello to everyone! This is my first post here, I hope you can help me. I'm making a class work in python and I'm a little lost: I have to use classes to represent monomials and polynomials, and the classes should contain methods to add, substract, multiply and divide them. … | |
I made a program that outputs a large amount of individual data files that I want to create images for. I created a python script that loops through all of the files, but for some odd reason it crashes after doing 17 images. It is always 17 images, and the … | |
Sometimes we want to tackle some problem specifying properties of sequence of numbers consisting the integer. Then it is usefull to have function to join many integers to make a long integer. Most efficient way for tight loops is to stay in integers domain and not go through the string … | |
Finding efficiently primes, whose begining numbers are also primes. See the thread http://www.daniweb.com/software-development/cpp/threads/425821/prime-number-c in C++ forum for discussion on topic. | |
Hello, I've found quite a few answers on this site. I was a network admin, however these days you have to wear multiple hats and as such I'm learning Python at work and my main source for answers when stuck is of course, the net. So here is my problem. … | |
i made a music player with a playlist but the songs in playlist are not playable because only the name of song is going in playlist not a complete mp3 file. can you tell me how to handle this problem?? here is my code from Tkinter import * import mp3play … | |
I have no idea where to start with this, a few pointers and a kick in the right direction would be much appreciated. I run a radio station. All our music is in folders representing music styles. From time to time I want to print out a complete library. Printing … | |
Hi ! I have books.txt and it contain 20 books with author,the books.txt look like so.. Mark Lutz/learning python James payane/Beginning Python Noah gift/Python for Unix and Linux System Administration If user search for book it just print book and author if user search for author print (“you cannot search … |
The End.