15,190 Topics
![]() | |
Hi. I'm a python noob who codes for fun, so please only critize me if you're trying to help. I'm on python 2.7 and built this code for fun. (dont ask what the questions are mean. its private info) Start = True while Start: print "Would you like to play … | |
![]() | Well, in python I was planning to do something like this: >> echo text text >> But I just cant find a way to do it! I know that for user input i will use `input()`, but how do I get it to echo the text specified? |
Do not miss http://www.daniweb.com/community-center/geeks-lounge/threads/424660/code-snippet-contest | |
Hey guys, I am a non-root user on a linux machine and I'm working with mpi4py. I have an alias set to my python-2.7 that has all of the modules that I loaded into it. So if I type 'python' and then 'from mpi4py import MPI' everything is fine. The … | |
Is it possible to keep writing the output of a program on the same line instead of moving to a new line every time? The output should be written over the preceding output. An example would be a kind of counter... say a number that counts from 1 to 10 … | |
This class just keeps getting worse. My next lab he had us do is this, **"Write a program that computes the intersection of a circle with a horizontal line and displays the information textually and graphically".** He gave us absolutely no help or anything to do this. He just said … | |
Hi, If I have a list of strings, it's easy to output them using .join(). For example: mylist=['hi', 'there', 'girls'] myout='\t'.join(mylist) What I want to know is if there is a builtin python method that acts like join, except it automatically converts ints and floats to strings without giving a … | |
I have this: import re subs = [] def subcons(data): match = re.search(r'(<[a-z]{3})', data) if match: subs.append(match.group(0)) data = data.replace(match.group(0), '') subcons(data) else: print data return data, subs input = 'ABC <uvw <xyz some random data' e, f = subcons(input) print e print f The print statement in the else … | |
Do you get content of oper right before trying it out? oper = ['plus', 'minus', 'times'] oper.extend('divide') How about do you know what happens when you run this? Big bang? ;) print('a' 'b' 'c') And this is same, isn't it`? c = 'c' print('a' 'b' c) | |
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 … |
The End.