15,175 Topics

Member Avatar for
Member Avatar for TrustyTony

What this produces and why? >>> a = 2 >>> b = 5 >>> exec "print(a+b)" in dict(a=6, b=9)

Member Avatar for TrustyTony
1
183
Member Avatar for frivolous

hi, i made a music player it opens almost all the songs but while opening some songs it gives this error : A:/Chrome Downloads/Jhalla_Wallah_(Remix)_-_(MusicTub.Com).mp3 Error 277 for "open "A:Chrome DownloadsJhalla_Wallah_(Remix)_-_(MusicTub.Com).mp3" alias mp3_0.878022650438": A problem occurred in initializing MCI. Error 263 for "set mp3_0.878022650438 time format milliseconds": The specified device is …

Member Avatar for frivolous
0
5K
Member Avatar for zmjman08

Hi, I'm trying to take two text files, compare them, then output the matches into a new text file. I've read the thread started by the1last, but that's outputting differences, not matches. I just started learning about python a couple days ago, so I don't know anything about what syntax …

Member Avatar for santosh2430
0
14K
Member Avatar for HankReardon

Hello, Is there a Python tutor in this group who would be willing to help me with about 3 - lines of code. I have an assignment due on the 4th of July and am a little stuck. Thank You, HR

Member Avatar for TrustyTony
0
101
Member Avatar for HankReardon

Hello, I am having trouble writing a variable named UpperCaseSentence outside of a for loop in this particular code snippet. It runs fine while in the loop but not while out of the loop. Can anyone shed some light on this dilemma for me. Here is the code. Thank you …

Member Avatar for HankReardon
0
3K
Member Avatar for HTMLperson5

Is it possible to create a scripting language using Python? Interactive Shell is fine, just something which comes close to a scripting language? Which allows the user to script some sort of functionality? Maybe more that just a console like this: def main(): cmd = (raw_input('#>>')) if cmd=="do_stuff": print "Ok, …

Member Avatar for HTMLperson5
0
1K
Member Avatar for johndb

I have downloaded vpython and try to run one of the examples included with the program. [CODE]from visual import * floor = box(length=4, height=0.5, width=4, color=color.blue) ball = sphere(pos=(0,4,0), color=color.red) ball.velocity = vector(0,-1,0) dt = 0.01 while 1: rate(100) ball.pos = ball.pos + ball.velocity*dt if ball.y < 1: ball.velocity.y = …

Member Avatar for alex.avak
0
299
Member Avatar for vy_007

I have to write an application in python for image processing.I have made scripts of all the image editing options. Now I want to add GUI in it. I want a window where I can give the path of an image on which I want to perform the editing! At …

Member Avatar for TrustyTony
0
5K
Member Avatar for Acidz

Hi, People... I have a question about reading xls files in python then parsing it to sqlDatabase. The thing is, that the xls file(pricelist) we as a company use are ordered and it's pretty easy to sort that out. The problem comes with xls files from other companies. (We are …

Member Avatar for Acidz
0
353
Member Avatar for HTMLperson5

This is a program using the `urllib` module to find the (html/any client-side script) source code of any website which exists. Have fun!

Member Avatar for M.S.
0
169
Member Avatar for HTMLperson5

Hi guys, I am having a problem with the following code: #Health set here def win(): import time print "You win!" print "Thanks for playing" time.sleep(10) quit() def lose(): import time print "You lose!" print "Thanks for playing" time.sleep(10) quit() from random import randint pos_damage = randint(15,472) en_health = 1000 …

Member Avatar for HTMLperson5
0
271
Member Avatar for Testa

Hi all! Is my first post here and well, im very new with python (just aroun 10 days). I did the famous "Guess my number" game. (Python pick up a number and user must guess it). All right, i have not problems with this. But now im trying in the …

Member Avatar for Testa
0
213
Member Avatar for tarun123

hey if anyone knows how to open open window when we click on open option in menu bar of gui which is created by boa constructor.

0
158
Member Avatar for trishtren

Hey, Iv been looking around google for the past few days to find ways to embed python 3.2 into my c++ application. I however want interpeter to be compiled into my application, so i can merely distribute one exe file without relying on the user to install python. However the …

Member Avatar for TrustyTony
0
281
Member Avatar for efth

I recently left Python behind to pick up Java. In Python, a variable defined in a function could not be called outside of the function. But you could at least let the function return a value, which could be a variable defined in the function. When a variable is defined …

Member Avatar for jLocke
0
250
Member Avatar for werydude

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 …

Member Avatar for TrustyTony
0
513
Member Avatar for HTMLperson5

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?

Member Avatar for Gribouillis
0
328
Member Avatar for TrustyTony
Member Avatar for Ene Uran
0
205
Member Avatar for fatalaccidents

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 …

Member Avatar for TrustyTony
0
185
Member Avatar for mahela007

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 …

Member Avatar for Lucaci Andrew
0
11K
Member Avatar for KY_Fan

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 …

Member Avatar for KY_Fan
0
419
Member Avatar for hughesadam_87

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 …

Member Avatar for TrustyTony
0
120
Member Avatar for 4evrmrepylrning

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 …

Member Avatar for TrustyTony
0
210
Member Avatar for TrustyTony

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)

Member Avatar for snippsat
1
182
Member Avatar for chophouse

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 …

Member Avatar for chophouse
0
236
Member Avatar for TrustyTony

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. …

0
431
Member Avatar for prashanthmukund

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 …

Member Avatar for Lucaci Andrew
0
393
Member Avatar for hisan

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)

Member Avatar for hisan
0
511
Member Avatar for TrustyTony

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 …

0
639
Member Avatar for TrustyTony

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 …

Member Avatar for HiHe
0
295

The End.