473,544 Members | 1,946 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.
9
27,918
thread by: shing | last post Mar 21 '07 by: ghostdog74
I saw another thread about this, but it said this: import msvcrt msvcrt.getch() I can't quite seem to get that working on my python... >>> import msvcrt >>> msvcrt.getch()
13
27,937
thread by: Chaim Krause | last post Nov 4 '08 by: bearophileHUGS
I am unable to figure out why the first two statements work as I expect them to and the next two do not. Namely, the first two spit the sentence into its component words, while the latter two return the whole sentence entact. import string from string import whitespace mytext = "The quick brown fox jumped over the lazy dog.\n" print...
13
27,954
thread by: Michal | last post Dec 6 '05 by: The new guy
Hello, is there any way how to detect string encoding in Python? I need to proccess several files. Each of them could be encoded in different charset (iso-8859-2, cp1250, etc). I want to detect it, and encode it to utf-8 (with string function encode). Thank you for any answer Regards Michal
852
27,956
thread by: Mark Tarver | last post Mar 15 '07 by: John J. Lee
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for my general education. Mark
36
28,054
thread by: Riccardo Rossi | last post Jul 18 '05 by: Alex Martelli
Hi all! How does Python pass arguments to a function? By value or by reference? Thanks, Riccardo Rossi.
4
28,066
Thekid
thread by: Thekid | last post Dec 11 '08 by: bvdet
Hi, I know I need to use PIL, but how would I count all of the red pixels in a given image? The image is simply a vertical red line on a black background. import PIL im = image.open("mypic.jpg") im.getdata()
11
28,108
thread by: placid | last post Feb 15 '07 by: placid
Hi all, Is it possible to be able to do the following in Python? class Test: def __init__(self): pass def puts(self, str): print str
6
28,128
thread by: pythondummy | last post Apr 14 '10 by: bvdet
just wondering how to replace a space (' ') in a string to a dot ('.') so far i have this... def add_dots(game): for row in game: for char in row: if char == ' ':
3
28,214
thread by: Johny | last post Sep 30 '07 by: Fuzzyman
Is it possible to unload a module after I've imported it. I have the main program from which I import several smaller programs. Some of these uses timeoutsocket module. But one of the smaller program can not work with the timeoutsocket module, so I must unload the timeoutsocket module, execute the program and then reload timeoutsocket...
2
28,254
Avatar19
thread by: Avatar19 | last post Apr 10 '10 by: Avatar19
List1 = while True: A = raw_input() if A: A = A.split(" ") List1.append(A) else: break print List1
14
28,274
thread by: erikcw | last post May 28 '07 by: Ben Finney
Hi, I'm trying to turn o list of objects into a dictionary using a list comprehension. Something like entries = {} = d.id] for d in links]
4
28,281
thread by: Achim Domma | last post Jul 18 '05 by: Piet van Oostrum
Hi, I read some text from a utf-8 encoded text file like this: text = codecs.open('example.txt','r','utf8').read() If I pass this text to a COM object, I can see that there is still the BOM in the file, which marks the file as utf-8. Simply removing the first character in the string is not ok, because the BOM is optional. So I tried...
2
28,413
thread by: Georgy Pruss | last post Jul 18 '05 by: Georgy Pruss
Hi all, How can I call a function which is in a Windows DLL? For example, import win32api lib_hnd = win32api.LoadLibrary( "user32.dll" ) if lib_hnd: fn_addr = win32api.GetProcAddress( lib_hnd, "MessageBeep" ) # returns int(2010532466) if fn_addr: # Here I'd like to call fn_addr. In C it would be plain fn_addr()
5
28,423
thread by: Lad | last post Aug 7 '06 by: John Machin
Hello, what is the best /easest way how to get number of hours and minutes from a timedelta object? Let's say we have aa=datetime.datetime(2006, 7, 29, 16, 13, 56, 609000) bb=datetime.datetime(2006, 8, 3, 17, 59, 36, 46000) so c=bb-aa will be datetime.timedelta(5, 6339, 437000)
3
28,426
thread by: zxo102 | last post Aug 9 '05 by: Stuart Corrie
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not figure it out. Here is my sample code: import win32com.client xl=win32com.client.Dispatch("Excel.Application") xl.Visible=1 wb =...
9
28,433
thread by: Bo Yang | last post Feb 27 '06 by: Méta-MCI
Hi, I know in java , we can use class.ForName("classname") to get an instance of the class 'classname' from a string , in python , how do I do that ? Thanks in advance !
8
28,461
thread by: sam | last post Sep 21 '06 by: Tuomas
hey everybody, this is my first time posting here. i'm pretty new to python and programming in general (as you'll soon work out for yourselves...) i'm trying to code a version of a selection sort and the heart of the code is as follows (no_lines is simply the number of items to be sorted, read out of an input file): for j in range(0,...
19
28,541
thread by: beliavsky | last post Sep 20 '06 by: Duncan Booth
I think I read a suggestion somewhere to wrap the code where a Python script starts in a main() function, so one has def main(): print "hi" main() instead of
9
28,622
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)...
4
28,682
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?
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,
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...
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,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,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

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.