473,543 Members | 4,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Forum

Python programming language - Ask questions about python interpreter, control flow, data structures, modules errors, classes, standard library, gui, databases, unit testing, object oriented, structured programming and more.
6
30,011
thread by: silverburgh.meryl | last post Feb 19 '07 by: Martin Blume
Hi, I have a function called 'test' defined in A.py. How can I call that function test in my another file B.py? Thank you.
1
29,988
thread by: tshravan | last post Mar 24 '08 by: jlm699
Hello All, I am newbie to python. I was trying to use a=zeros(5) in python shell, but it is throwing the following exception in the shell Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'zeros' is not defined
12
29,949
thread by: wocosc | last post Mar 6 '07 by: bartonc
Hey, I have a problem. I was presented a problem where I need to open a file and then copy and rename it. We are still using really basic commands, but I am pretty lost with this. I know how to open a file and get python to read it. Any help would be great.
5
29,770
thread by: runsun | last post May 19 '07 by: bartonc
Read from an existing file, then output a file with the same name but an extension: file = raw_input ('Enter the filename:\n') fileout = open ('file.out', 'w') However, when I enter a filename like "test", it gives the output file as "file.out" instead of "test.out".
7
29,768
thread by: 23rnj3mn32sdjqw | last post May 6 '09 by: IceMan85
Hi, It should be simple - but I am trying to find the difference between two datetimes as an integer in seconds. Using pywin32 build 212, python 2.5, Windows XP Pro, MySQL 5.0. import time import datetime def date4string(string): return datetime.date(*time.strptime(string, "%Y-%m-%d %H:%M:%S"))
2
29,731
thread by: learnerofpython | last post Nov 15 '10 by: David Hall
hi! What wud be the python equivalent of the C statement while(some condition); (i.e no statement gets executed) any ideas.please let me know
4
29,550
thread by: yinglcs | last post Mar 19 '06 by: Steve Holden
I check the documentation here, but it does not say how to check if a directory is exist in python? http://docs.python.org/lib/os-file-dir.html And why mkdir fails if the directory already exists? Thank you.
2
29,493
thread by: Liu Kun, SLC ICM (BJ) | last post Jul 18 '05 by: Daniel Dittmar
Hello, I want to use a method from _xxx_yyy.pyd, but I can not use import to load this file, how to use .pyd in python interpreter? Best Regards Liu Kun
30
29,469
thread by: bdsatish | last post Jun 27 '08 by: Lie
The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As expected my_round(2.5) = 2 # Not 3, which is an odd num I'm interested in rounding numbers of the form "x.5" depending upon whether x is odd...
3
29,423
thread by: Peter Moscatt | last post Jul 19 '05 by: Brian Beck
I am wanting to return the system date using the following: date.today() How would I then convert this to a string ? Pete
4
29,399
thread by: sophie_newbie | last post Oct 18 '07 by: Paul Hankin
Hi, in my program i need to call a couple of functions that do some stuff but they always print their output on screen. But I don't want them to print anything on the screen. Is there any way I can disable it from doing this, like redirect the output to somewhere else? But later on in the program i then need to print other stuff so i'd need...
12
29,328
thread by: NareshKonda | last post Feb 17 '23 by: Vanisha
Right from data development to web development, Python has become the most famous and an important open source programming language used in today’s scenarios. In many IT forums, it is discussed that if you want to find the most used colors in a picture, you use Python, if you want to develop a web app then you use Python if you want to automate...
3
29,278
thread by: william hoskins | last post Feb 7 '11 by: william hoskins
Hey everyone, I am fairly new to python, and I was working on a google app engine project for a class, and this error came up. I wasn't sure why, because right above it I have the same object type right above it, and when I take the filter off the other, it works fine, I just can't do that or it screws everything up def LoginBar(): user =...
9
29,208
thread by: wordsender | last post Jul 18 '05 by: Abhijit Soman
Hey guys, I can't figure this one out, why is this simple script giving me problems? logfile=file(r'test.txt','w') logfile.write('datetime') test=logfile.readlines() When I run it I get the error message:
5
29,200
thread by: Peter Watkins | last post May 26 '07 by: bartonc
I'd like to convert a little endian hex string: '00020000020000FC' to a number. I was going to use struct.unpack('>q', theString) but this is meant for a string where the bytes in the string correspond to bytes in the number. I think that something like the opposite of the hex() function would work perfect as long as it supported...
35
29,189
thread by: erikwickstrom | last post Oct 11 '06 by: MonkeeSage
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. import shutil, os, sys
3
29,146
thread by: Bouzy | last post Nov 5 '08 by: markus314
I have a list of words and am trying to replace all the numbers in my list with whitespace. for word in words: numbers = re.search('+', word) word = clearup(word) if word in dictionary: pass else: print word
5
29,145
thread by: bkunjitam | last post Dec 1 '06 by: bartonc
Hi, My programme has a text box where in user enters the ip address. I need to validate the IP (like no space allowed in the entry, the numerals should not exceed 255, not more than 3 dots allowed overall, no consecutive dots allowed etc.,.). How do i go about the same? Is there any built in function for the same? thanks, Badri
4
28,987
thread by: Bryan | last post Jul 29 '05 by: Peter Hansen
Quick question: Why does os._exit called from a Python Timer kill the whole process while sys.exit does not? On Suse. Bryan
2
28,978
thread by: Boris Mok | last post Oct 1 '07 by: Duncan Booth
Hi all, I'm doing a function which needs return an arrary -- or more specially a dictionary data type. I have a sample like this def AFC(): v = 1 return v
4
28,940
thread by: Stef Mientki | last post May 31 '07 by: stef
hello, after 4 months playing around with Python, and I still have troubles with egg files. Sometimes it works, sometimes it doesn't. If I google on "python egg", I get lost of links, which contains huge pages of information, and I'm totally scared off.
2
28,929
thread by: Gordon Airporte | last post Jul 27 '05 by: Gordon Airporte
I'm trying to get my canvas to resize to fill its frame within a window, but I can't figure out how to handle the callback data from the window's <Configure> properly. It has very strange behavior - resizing randomly or growing by itself, shrinking to 0. The following works passably but jumps around at random if you move the window and goes...
16
28,700
thread by: Davy | last post Nov 7 '07 by: Wildemar Wildenburger
Hi all, We know that list cannot be used as key of dictionary. So, how to work around it? For example, there is random list like l=. Any suggestions are welcome! Best regards,
4
28,681
thread by: JustSomeGuy | last post Nov 25 '05 by: bonono
Hi I'm writing a python application on my windows box and I want to draw a simple triangle on the screen... How can I do this. Am I going to have to use tcl/tk?
9
28,621
thread by: Maciej Sobczak | last post Jul 18 '05 by: Roger Binns
Hi, I have a string. This string is to be used as a path for a new file. I would like to check if this string *could be* a valid file name, *before* I try to create the file itself. In other words, I would like to know whether some string violates the underlying OS's policies (or maybe some more restriced policies, but portable)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.