15,181 Topics

Member Avatar for
Member Avatar for leegeorg07

i have this code: [ICODE]import webbrowser, random import os import os.path running = 1 DIR="C:/Documents and Settings/Owner/My Documents/georges poopy/main music/" music = filter(lambda x: x.lower().endswith("mp3"),os.listdir(DIR)) music = list(music) choice = int(raw_input("Press 1 to play a new song")) while running == 1: if choice == 1: song = random.choice(music) webbrowser.open(os.path.join(DIR,song)) choice …

Member Avatar for woooee
0
105
Member Avatar for lcc_551

Hi, I'm in first year computer science and could use some help on a program where I have to calculate the standard deviation from data on a txt file. Using some online help I've gotten somewhere but to be honest don't really know what's going on myself. The program is …

Member Avatar for jrcagle
0
185
Member Avatar for artmansoft

We have a Visual Basic script that communicates with an application through com. We like to translate it to Python and use win32com.client instead. We have everything working, except for the use of "Nothing" in the VB script for a couple of its function calls. What is the replacement of …

Member Avatar for jrcagle
0
1K
Member Avatar for Ene Uran

I am looking for a good example of the tarfile module, writing to and reading from an archive. Particularly the highly compressed filename.tar.bz2 format.

Member Avatar for BearofNH
0
152
Member Avatar for jmroach

So this should be a really easy one, but i've spent a few hours searching and can't find anything that explicitly states how to do this. All i want to do is see the column names for a particular table. I created the tables like: [CODE=python] con = sqlite3.connect( ":memory:" …

Member Avatar for weisburd
0
23K
Member Avatar for eyewirejets

Python 2.6.1: How would I write a user input validation statement scores < 0 or scores > 100 print error message and ask for input again? Where would I place it, in the below code? [CODE] num_test = raw_input("How many test would you like to average? ") scores = [] …

Member Avatar for sneekula
0
136
Member Avatar for lakhan.p

Hi, I m trying to open a file in read mode , my program is below ... #!/usr/bin/python print "------" file = open("C:\Lakhan\Pytonpro\file.txt", "r") print file file.close() but it shows following error ------ Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 165, in RunScript exec f in __main__.__dict__ File "C:\Documents and …

Member Avatar for lakhan.p
0
198
Member Avatar for mccraig

Hey all, I'm curious to know if there's a tkFileDialog that allows a person to browse for a folder, and in the pop-up "Browse for Folder" window, also have the option to "Make a new folder". I need to have this functionality, but when I use askdirectory() there is only …

Member Avatar for leegeorg07
0
1K
Member Avatar for amit1_x

I am new to Python, I have been asked to write a script to display the time difference. I get these times using shell scripts and are stored in some variables H1 and H2. I was wondering if i could use datetime.datetime in Python to calculate the difference the below …

Member Avatar for BearofNH
0
159
Member Avatar for eyewirejets

When I run my program, I get the word None as output for a line. I don't have a print statement that contains that word. When I debug no errors found. Any ideas what it can be?

Member Avatar for eyewirejets
0
92
Member Avatar for starzstar

Hi, I have a nested dictionary like the following how do I loop through such dictionary ,Basically I am looking to get the value of key "name" from the following dictionary Any help is appreciated, [{'resource': ['{"metadata": {"type": "directory", "size": "8"}, "name": "default", "links": {"link": ["{\\"href\\": \\"https://my.server.comdefault\\", \\"rel\\": \\"self\\"}", "{\\"href\\": …

Member Avatar for starzstar
0
118
Member Avatar for tobycatlin

Hello everybody, I am after a little help using python to read in data from a binary file. This is what i got so far: [CODE] import struct infile = "friday.bin" FH = open(infile, 'rb') line = FH.read(32) data= struct.unpack("<H", line[0:2]) print data [/CODE] Which produces an output: 38288 I …

Member Avatar for NarendraRoy
0
4K
Member Avatar for orangie

I would really appreciate a help to this problem: Let's say x = Class() x.name = 'the_name' x.value = 10 if you were only give the 'the_name' how do you get the instance ref, x to get x.value

Member Avatar for paddy3118
0
115
Member Avatar for rajasekhar1242

hi, i am trying to develop a database application. i am using python as front end and mysql as back end. But now i am getting some problem as "INTERNAL SERVER ERROR" while i am running my application on MAC OS x. #!/usr/bin/python import os import cgi from cgi import …

Member Avatar for rajasekhar1242
0
152
Member Avatar for gyu

hi i need help figuring out how to get my program to calculate standard deviation. this is what i've done so far: [QUOTE]import math import sys lines = sys.stdin.readlines() sample_number = 0 time_seconds = 0 time_list = [] for line in lines: time = line.split('\t') f2 = time[1].strip('\n') if time[0]!= …

Member Avatar for vegaseat
0
82
Member Avatar for mruane

Can you tell me where this unassigned global is...I looked everywhere but cannot find it. [code=python] global gold gold = 0 global a_gold_a a_gold_a = 15 global a_gold_b a_gold_b = 15 global a_gold_c a_gold_c = 20 global room1_done room1_done = 0 def prompt_main(): global a_gold_a, a_gold_b, a_gold_c, room1_done x = …

Member Avatar for vegaseat
0
90
Member Avatar for chebude

I want to read a file and convert the columns to rows. A 1 2 3 4 5 6 7 8 9 10 B 11 12 13 14 15 16 17 18 19 20 C 21 22 23 24 25 26 27 28 29 30 want them to be like …

Member Avatar for BearofNH
0
96
Member Avatar for TheOneElectroni

Hello everybody, I’m experimenting with PyQt, trying to learn it, and I’m a bit stuck with Signals and Slots. I don’t usually like just to repeat the examples you find in tutorials and guides because I think it’s more useful for learning to experiment concepts by yourself. Tutorials usually teach …

Member Avatar for TheOneElectroni
0
324
Member Avatar for vinoth_python

Hi, I'm doing python studies to write test automation scripts. As a part of that I want a script which should identify the NAT type of my network.. Please help me out in this regard... Thx.

Member Avatar for vinoth_python
0
101
Member Avatar for omni504

I'm not really sure if this is the right place or not for my questions, since i'm a complete noob when it comes to python and all. But its a real simple question, and help would be appreciated. I've been reading "Python for Software Design: How to Think Like a …

Member Avatar for omni504
0
152
Member Avatar for marcux

Hi all! I have made my GUI in Glade 3 with a couple of windows. When I click a button a window should show: [CODE]my_window.show()[/CODE] That works fine. If I close my window with: [CODE]my_window.hide()[/CODE] The next time I show the window it works fine, but if I close my …

0
86
Member Avatar for strobon

can someone pointing me how to get a command in checkbutton1 be executed after user check it and hit ok button?.for example: in the attached picture, if user check the 'open terminal button' and hit execute,the program open terminal window.

Member Avatar for strobon
0
129
Member Avatar for ITBarbie

I am writing a script (a full-fledged program, actually) in PYTHON (version 2.5; the current version is 3.0 but there are some performance problems -- 3.0 is slower than 2.5; go figure). The program allows a user to open a file in WORD. I have tested this program on an …

Member Avatar for leegeorg07
0
99
Member Avatar for 4pennies

Hello, a bit new to python here and would appreciate some help. I am writing a simple encoder to a raw_input(turn to numerical ascii and then applying some numbers to it). I was able to get the encoding right but when i try to do a outfile only the first …

Member Avatar for 4pennies
0
94
Member Avatar for drew7py

I am looking for some pointers on how to format float numbers in a numpy array. This code selects lines from an array, and I want the output to look better so I can import into excel. infile looks like this: 1074 CL 006 2004 A8LGPUYE 10 TY 2 S0111P …

Member Avatar for drew7py
0
111
Member Avatar for iLikeSunshine

Traceback (most recent call last): File "...\Hello Python\src\main\__init__.py", line 7, in <module> redBench.accomodate(harold) [B]TypeError: unbound method accomodate() must be called with bench instance as first argument (got man instance instead)[/B] Here is the code: [I]__init__py[/I] [CODE]import man_cl import bench_cl harold = man_cl.man("harold") redBench = bench_cl.bench [B]redBench.accomodate(harold)[/B][/CODE] [I]man_cl.py[/I] [CODE]class man: def …

Member Avatar for iLikeSunshine
0
72
Member Avatar for Rejinacm

When i used a global variable in my supplement file and imported it in a top-level file i got AttributeError.Why? eg: file1.py global i i =10 file2.py import file1 print 'i in file1 %d' %file1.i Aso,i was not able to use file1.i when i used from ie; from file1 import …

Member Avatar for Lardmeister
0
70
Member Avatar for istib

Dear all, I've been struggling with an issue whilst scraping a site that has both roman and arabic (and asian characters too, it seems). I want to extract those entries that are English, hence that don't contain foreign letters. I've been reading into some Unicode guides but can't get my …

0
42
Member Avatar for icu222much

I am trying to find a way to control the amount my variable 'i' increments by so I decided to include the code 'i = i + 1' within the for loop. My idea was that as my loop would run, it would print the 'i' values '1, 3, 5, …

Member Avatar for icu222much
0
203
Member Avatar for breatheasier

Hi, I'm making a program in VPython to simulate the motion of particles. It's fairly simple in theory but I'm having some problems with my lists of particles. What I'm trying to do is make sure that the particles do not overlap, and regenerate a position if they do overlap. …

Member Avatar for BearofNH
0
153

The End.