15,175 Topics
| |
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 … | |
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 … | |
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 … | |
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? | |
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\\": … | |
| 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 … |
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 | |
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 … | |
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]!= … | |
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 = … | |
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 … | |
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 … | |
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. | |
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 … | |
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 … | |
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. | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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, … | |
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. … | |
How can we in python change the number of elements in a line to the next, this is, for example... We have the following txt file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 And we want a program which the output … | |
Given a list of integers, generate the list of the corresponding floats. | |
i need help understanding how to fix my code (But please no explicit answers, I really need to understand.) I need to create a program (I'm using IDLE) that will count the number of characters in a given sentence WITHOUT counting spaces. So far I have: [CODE] S = raw_input("Enter … | |
I start learning about python, so i read the tutorial: they show this: >>> x = int(raw_input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' ... … | |
I am trying to write a python script that can take a word from one file and transfer it to a specific location in another file. for example, lets say i have a file called hb15b.txt and it includes the following: MODIFY-USER 2671, "hb15b01", " UGz9", 1, How can i … | |
For the second year running Python has been selected as the Language of the Year by Linux users: [code] Linux Users' Programming Languages of the Year 2008 PHP 115 13.36% Perl 72 8.36% Python 226 26.25% Ruby 46 5.34% C 114 13.24% C++ 129 14.98% Java 106 12.31% Lisp 9 … |
The End.