761 Posted Topics
Re: I'm not sure if tkinter has changed in py30 and above but shouldn't you be using [icode]awin.destroy[/icode] ? | |
Re: [QUOTE=mathijs;474400]i came up with this to print the field [code=python] list = [["-","-","-"],["-","-","-"],["-","-","-"]] def printschema(): for x in list: print x[0],x[1],x[2] printschema() o - - - - x - - - lijst[1][1]="o" printschema() o - - - o x - - - [/code] i put it into a list to … | |
![]() | Re: [QUOTE=sravan953;929262]open the Sound Recorder, but how do I make it to [I]start recording[/I]?[/QUOTE] That's not the kind of thing that subprocess was intended for. That kind of behavior is more akin to win32 hooks. Subprocess can manipulate std input but not buttons on a GUI. As sneekula said, if the … |
Re: [QUOTE=dezza;912231]Can you define this method? I am not sure I understand what you mean.[/QUOTE] Binary read is simply opening the file under the [B]mode[/B] 'read' plus 'binary'. Read up on the built-in [ICODE]open[/ICODE] method [URL="http://docs.python.org/library/functions.html#open"]here[/URL], and the answer will reveal itself. | |
Re: [QUOTE=jephthah;882066]but isnt 7 just a watered down Vista? i dont' know anyone who's especially excited about 7.[/QUOTE] No, it's a fixed Vista. I'm genuinely excited about 7. I had the beta and now am running the RC1 on my home desktop. It's fantastically amazing and is what Vista [I]should[/I] have … | |
Re: [QUOTE=Your_mum;928498][code]AdressBook = ['Eve', 'Bob', 'Mike', 'Tom', 'Jane'] for x in AdressBook: print x, '\n' f = open('C:\Documents and Settings\Henry\My Documents\Python_Stuff\Letter.txt', 'r+') for a in AdressBook: x = AdressBook.index(0) for i in f: print i % (x) AdressBook.pop(0) [/code]Confuzzled...[/QUOTE] I'm confuzzled by your code. Do you know what [ICODE]list.index(x)[/ICODE] does? It … | |
Re: This isn't builtin, but my first hit on a google search for 'python list frequency' was [URL="http://snippets.dzone.com/posts/show/1629"]this[/URL]: [code=python] >>> alist = [ '1', '1', '2', '1', '3', '4', '1', '3'] >>> [(a, alist.count(a)) for a in set(alist)] [/code] | |
Re: The line is static, it's not dynamic! What you can do is capture the resize event and simply adjust the width of the static line to the width of the window using something like getsize(). | |
![]() | Re: Refer to [URL="http://docs.python.org/library/subprocess.html#subprocess.call"]documentation here[/URL]. The first argument contains your arguments for the process itself so it needs to be a single element (list, tuple, etc). The remainder of parameters get passed to the Popen init function. [URL="http://docs.python.org/library/subprocess.html#subprocess.Popen"]Refer here [/URL]to the remainder of items you can pass using **kwargs. |
Re: Using your example string, we can separate at the whitespace using split(), and then locate the index of "welcome" using index(). Finally slicing the list by the result of index() + 1 will give us "to". Using it for finding a row of text x lines further should be a … | |
Re: Firstly, you can use glob to get a list containing the name of each directory that starts with td like such: [icode]dirs = glob.glob(td.*)[/icode] You can find the [URL="http://docs.python.org/library/glob.html#module-glob"]documentation about glob here[/URL]. Next, you'll want to iterate over the list that glob returns by doing something along the lines of … | |
Re: sys.argv provides you the string representation of cmd line params. 'True' and 'False' are both strings, and if a string has any content in it at all, the boolean representation is True. You should simply change your condition to [icode]if test.lower() == 'true':[/icode] HTH | |
Re: The important note about the above solution is that when calling SMTP() zachabesh initializes it to connect to gmail's smtp server ([icode]smtplib.SMTP("smtp.gmail.com", 0)[/icode]). Python's smtplib relies on you having access to an existing smtp server or else it cannot work. Alternately, you can initialize SMTP in the way that you … | |
Re: As I interpret your package structure, your import should go something like this: [code=python] from package.subpackage1.baseclass import BaseClass class ClassA(BaseClass): pass [/code] | |
Re: All I can tell is that your expect strings never get found. So you would be better to figure out how to do this on the command line, and then replicate those actions using pexpect (since pexpect basically spoofs you performing the same commands (sendline) and waiting for certain responses … | |
Re: [QUOTE=shoemoodoshaloo;874126] How would you guys put that in laymen's terms? [icode]if not line.strip()[/icode][/QUOTE] I would translate it to: [icode]if empty line:[/icode] I guess. Here's an example, basically this code is relying on the fact that Python considers an empty string, or [icode]''[/icode] to be a False, while a non-empty string … | |
Re: [QUOTE=Norbert X;819059]Keep getting an error about the tnls: [/QUOTE] Your indentation is off... starting with tnls on line 114 and again at 133 going down. | |
Re: [QUOTE=computerfreak;873434]I can do that on the x-axis. ... I want it to be even along the x axis too, but I can't think of a way to do that [/QUOTE] Can you give more detail? Are you using a graphics toolkit? What type of interface are we talking here? | |
Re: [QUOTE=Davide Davin;915494]my problem is the content class because i can't pass self to this class imust pass parent but is not corret can somone help me[/QUOTE] Please clarify your question. What's "not correct" | |
Re: [QUOTE=jimmy legend;918932]The tut's on the internet are a little complex.[/QUOTE] In that case threading is likely too complex for you. There's plenty of examples of threading on this site, if you'd take the time to search this particular forum. Also "open up 2 urls" is rather vague. You want to … | |
Re: [QUOTE=princessotes;916804]thank s for the code. I have tried this but i keep getting the following error maxval=int(data[0]) ValueError: invalid literal for int() with base 10: '-0.0539723' However when i use float() instead, it works. Do you understand this error.[/QUOTE] '-0.0539723' is not a valid integer since it is not a … | |
Re: [QUOTE=denniskhor;916508]i use pywinauto, so will be like tat... ur answer din point to my question...[/QUOTE] Your grammar is atrocious, therefore your question makes no sense. It is unlikely that anyone will be willing or able to answer it in its current form. I suggest revising your question and asking in … | |
Re: Maybe as a sanity check print out the contents of [icode]ffmpeg_line[/icode] before calling the subprocess to make sure you've actually constructed the proper system call. Also, the shared computer... is it a different platform? What is the purpose of that setup? I could imagine if you were running a script … | |
Re: The file [icode]Otickers.txt[/icode] is not in the working directory. Try printing the output of [icode]os.listdir('.')[/icode] to see what actually is in the directory, along with [icode]os.getcwd()[/icode] to see which directory you're actually working in. also, a major flaw in your code is that any exception caught within your try block … | |
Re: This belongs in the Hardware/Software -> Networking forum... If you know how to use ssh to create tunnels go that route. If you don't know how to do that, search google for the numerous guides that exist. | |
Re: [QUOTE=SpiritGeek;915502] [CODE=python]class Validate_Numeric ( wx . PyValidator ): def __init__ ( Self ): wx . PyValidator . __init__ ( Self ) def Clone ( Self ): return Validate_Numeric () def On_Text_Change ( Self, Event ): TextCtrl = Self . GetWindow () Text = TextCtrl . GetValue () if Text . … | |
Re: Define "memory error". How about pasting your traceback. | |
I feel like I'm losing my mind... I uninstalled wxPython this morning and was going to reinstall with the latest version as I'm having peculiar problems with UliPad that I just downloaded yesterday. Well after uninstalling the wx package and docs & demos I went to the wxPython page and … | |
Re: [QUOTE=wildgoose;906877]That will work as well. But close file then reopen it with the create upon open or you will merely be overwriting the existing file and have debris from the previous file at the end![/QUOTE] What wildgoose is trying to say here is make sure you open your new file … | |
Re: Here's how to open a file for reading and iterate over it: [code=python] f = open(my_file) for line in file: # Do something to each line f.close() [/code] Here's how to split a string : [code=python] >>> my_text = "Here'ssomeTExt WithSomeMoreOver Here and then some more" >>> my_text.split() ["Here'ssomeTExt", 'WithSomeMoreOver', … | |
Re: Many DELL versions of BIOS have a "backdoor" password to bypass this in MFG or troubleshooting environments. This backdoor password is Dell (or DELL). Give those a shot. | |
Re: What is your question exactly? [code=python] Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print 'Rash\xf4mon' Rashômon >>> [/code] | |
Re: I think this is what you're looking for: [code=python] urllib.urlretrieve(url_of_file, destination_on_local_filesystem) [/code] Note this could vary depending on what version of Python you have. This is from 2.5... Other versions of python can use something like: [code=python]urllib.request.urlretrieve(url, local_file_name)[/code] | |
Re: [QUOTE=kes_ee;905234][CODE=perl]$str = HelloWorld; $str =~ s/[A-Z]/_$&/g; $str =~ s/^_//; $str = uc($str); print "$str";[/CODE][/QUOTE] This one's a little closer to your perl method: [code=python] import re text = re.sub(r'([A-Z]+)',lambda x:'_'+x.group(0).lower(),'HelloPythonWorld') text = re.sub(r'^_', r'', text) print text.upper()[/code] | |
Re: [QUOTE=evstevemd;905237]what editor do you use? Get ulipad [url]http://code.google.com/p/ulipad/[/url][/QUOTE] How long have you known about this? And why haven't you told us until now?! | |
Re: Use sum [code=python] def test(): number = input("Number: ") return sum([count*20 for count in range(1, number+1)]) [/code] | |
Re: I think you'll probably need to make use of eval in this case: [code=python] >>> myLengths = [3, 8, 5] >>> for eachLength in myLengths: ... print eval("'%0" + str(eachLength) + "d' % 2") ... 002 00000002 00002 >>> [/code] Unless you're willing to split your above code into two … | |
Re: How pitifully sad and pathetic of a cyborg name: J.L.M. - Journeying Lifelike Machine I have no purpose but to wander and appear lifelike? :( Haha, but this one's not too bad: J.I.M.M.Y. - Journeying Intelligent Machine Manufactured for Yelling Who would manufacture a machine just to yell? | |
Re: Running a script via [icode]python my_python.py cmd1 cmd2 cmd3[/icode] on the command line would produce the following argv structure: [code=python] import sys print sys.argv # Output: # ['my_python.py', 'cmd1', 'cmd2', 'cmd3'] [/code] HTH | |
Re: A simple, straightforward method would be to iterate over both files simultaneously and write their values into the output file with a tab separating them like so: [code=python] file1 = open( file_name1 ) file2 = open( file_name2 ) out_file = open( out_file_name, 'w' ) while 1: line1 = file1.readline() line2 … | |
Re: Perhaps you should uninstall the cx_Oracle module and reinstall it, as it probably looks for the location of the current Oracle installation during setup. Make sure all references to the old 9i version are removed, including registry entries and all directories. | |
Re: [QUOTE=iliketacos;903227] [code=python] def recordcomment(post): f=open('C:/commentlog.txt', 'a') f.write(post) f.write("\n") f.close() [/code][/QUOTE] It seems to me that you're trying to use the [ICODE]file.write()[/ICODE] method in the same manner as [ICODE]print[/ICODE]. correct me if I'm wrong, but you want a blank line (new line character [ICODE]\n[/ICODE]) in between each comment in the comments … | |
Re: [QUOTE=sillyboy;782510]why is this in the python forum?[/QUOTE] Because he thinks we'll do his homework for him. ![]() | |
Re: No, you're not using global variables correctly. Here's the correct way to use a global variable: [code=python] # This is the global scope my_var = 'Hi' def my_function( input ): # This is inside the function's scope global my_var # This pulls my_var into the scope of the function [/code] … | |
Re: You'll need to be more clear. Define "the cookie bit". How about pasting your traceback. | |
![]() | Re: You can use the HTML capabilities of wxPython and simply design the GUI... look into the docs and demos for examples of HTML usage ![]() |
![]() | Re: [QUOTE=sravan953;902113]Any more ideas on how I can shorten it?[/QUOTE] How about using slicing: [CODE=python]site_list= ['C', ':', '\', 'D', 'o', 'c', 'u', 'm', 'e', 'n', 't', 's', ' ', 'a', 'n', 'd', ' ', 'S', 'e', 't', 't', 'i', 'n', 'g', 's', '\', 'S', 'r', 'a', 'v', 'a', 'n', '\', 'M', … ![]() |
Re: > First of all, you don't have to do int(input()) because input() returns a number anyway. > > And you should start with better explaining the rest of the problem I think he's using python 3... That being said, we don't give homework help to those that don't show effort. … | |
Re: And also [URL="http://diveintopython.org"]diveintopython.org[/URL] | |
Re: Refer [URL="http://docs.python.org/tutorial/modules.html#packages"]here[/URL] for details on how to make a "Package" taking advantage of __init__.py files... should get you going |
The End.