880 Posted Topics
Re: From a editor is the way most off us do it. Pyscripter er god for windows. [url]http://code.google.com/p/pyscripter/[/url] Linux is SPE er bra. sudo apt-get install spe For IDLE. Fil->new window Write your code and run it(F5) You need to read a little this to basic,and everyone should at lest figurer … | |
Re: [CODE]>>> num = raw_input("Enter a number: ") >>> l = [] >>> for item in range(int(num)): ... a = int(raw_input('Enter: ')) ... l.append(a) ... >>> l [5, 6, 3, 4, 7] >>> [/CODE] | |
Re: Always use 4 space for indentations [URL="http://www.python.org/dev/peps/pep-0008/"]PEP 8[/URL] Here is a little help on how to trow more than one dice. [CODE]import random possible = [2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 30, 34, 50, 100] dice_number = int(raw_input('How many dice would you like … | |
Re: To check for a valid email adress regular expression is a god tool. [CODE]import re mail_input = raw_input("Enter your email: ") if re.match(r"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b\Z", mail_input, re.IGNORECASE): print ("That is a valid email") else: print ("That email is not valid") [/CODE] | |
Re: [QUOTE]I'm an information security professional who's decided to teach myself python[/QUOTE] Yes a good choice. I put together something that may in direction you describe. [CODE]import re text = '''\ A fast and friendly dog. email1@dot.net myetest@online.no My car is red. han445@net.com ''' find_email = re.findall(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b',text,re.IGNORECASE) print 'Text has %d … | |
Re: Look at [URL="http://code.google.com/p/gui2exe/"]Gui2exe[/URL] to. Dos not create console default. | |
![]() | Re: [QUOTE]costAd() <-- dead code after the return statement :)[/QUOTE] No you dont give function an argument. [ICODE]def costAd(numChar):[/ICODE] Then you most always pass an argument when calling the function. Your error message is pretty clear. [QUOTE]TypeError: costAd() takes exactly 1 argument (0 given)[/QUOTE] Look at vega code. [ICODE]costAd(20) [/ICODE] If … ![]() |
Re: Hei fra norge. This is an almost impossible task without a good libary. I did a translation program a while ago where i use google translate API and wxpython as gui. Its work fine,still only in norwegian. Shall write gui fronend in englishs to. Did this a fun projects.you can … | |
Re: [CODE]import wx class HorizontalToolbar(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(240, 200)) toolbar = self.CreateToolBar(wx.TB_HORIZONTAL) toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('1ico.ico')) toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('2ico.ico')) toolbar.Realize() self.Centre() self.Show(True) def OnExit(self, event): self.Close() app = wx.App() HorizontalToolbar(None, -1, 'horizontal toolbar') app.MainLoop()[/CODE] | |
Re: [QUOTE]It just gave a message at the bottom of the gray PythonWin frame right where it says,"running the code file..." or something similar to that[/QUOTE] Get a better editor than PythonWin. [URL="http://code.google.com/p/pyscripter/"]Pyscripter[/URL] is good. Paste your kode inn,and you se a red line mark under line 7 for your code. … | |
Re: You dont need to use [ICODE];[/ICODE] in python. First we breake it down in python IDLE. [CODE] IDLE 2.6.4 >>> exp = "1+2" >>> exp '1+2' >>> string1 = exp.split("+") >>> string1 ['1', '2'] >>> print "Operator 1 is : " , op1 Operator 1 is : Traceback (most recent … | |
Re: [url]http://code.google.com/p/gui2exe/[/url] Start with [ICODE]python <your path> GUI2Exe.py[/ICODE] choose your wxpython script. Set Optimize 2 | Compressed 3 | Bundle Files 3 Complie-->finish test your program. | |
![]() | Re: [QUOTE]oh and I know how to use google btw, maybe even better then you do...[/QUOTE] Then you should know that urllib2 has been integrated into urllib in python 3. [url]http://www.python.org/dev/peps/pep-3108/#urllib-package[/url] [url]http://diveintopython3.org/porting-code-to-python-3-with-2to3.html#urllib[/url] Most of us use python 2.x,because we need 3 party moduls like wxpython,Twisted,dangjo,py2exe...and so on. No problem to have … |
Re: [QUOTE]absolute and relative paths. [/QUOTE] Rember to use \\ or /(windows) \ count as a new line. So as an example. c:/tmp/163282.xml or c:\\tmp\\163282.xml | |
Re: For help you have to post your code,we can not guess how your code are set up. | |
Re: You can look at this,for taking out values. [CODE]l = [] for i in open('your.txt'): l.append(i[0:2]) print l l1 = l[0] print l1 '''Out--> ['10', '12', '4,'] 10 '''[/CODE] | |
Re: Try [URL="http://code.google.com/p/gui2exe/"]Gui2exe[/URL] | |
Re: Just wonder what you want to do. If you just want to ping,this is an easy solution. [CODE]import os os.system("ping " + '192.168.2.1') #Extern adress import os os.system("ping " + 'www.goolge.com') [/CODE] | |
Re: Krstevski read this again. [QUOTE]and several other trivial programs in Python 3.1,[/QUOTE] Raw_input has been removed in python 3.x(input in python 3.x dos the same as raw_input in python 2.x) So Purnima12 use input with Krstevski soultion. For dates there is a build datetime module to look at. [url]http://www.daniweb.com/code/snippet216493.html[/url] [url]http://www.daniweb.com/code/snippet216475.html[/url] | |
Re: A general rule is that use regular expression on html is not god at all. If you want to read why is a bad idèe. [url]http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags[/url] [URL="http://www.crummy.com/software/BeautifulSoup/"]BeautifulSoup[/URL] and [URL="http://codespeak.net/lxml/"]lxml[/URL] are god tool for this. To get bettter help give us a sample off the html. And be very correct what … | |
Re: [QUOTE]In some other languages the content of the file (1000) would be a numeric value, not a string. Thanks [/QUOTE] In many other lanuages you need to declare vaiables. In python there is no need for this,but off course datatypes is always there. C++ int age; age = 30 Python … | |
Re: How dos your money.txt look? Change to this [ICODE]money = int(money) - Bet[/ICODE]. Type check [ICODE]print type(money)[/ICODE]. [ICODE]print type(Bet)[/ICODE] Your desgin could be better, a long funtion that only ends(no loop) Try to make a main function that has meny and question then that function call the bet function. Betting … | |
Re: Use this[ICODE] f = open('C:/teste.txt', 'w')[/ICODE]. Or this [ICODE] f = open('C:\\teste.txt', 'w') [/ICODE]. [ICODE]\ [/ICODE] count as newline [ICODE]\\ [/ICODE]== Backslash (\) In windows i always use this [ICODE]c:/[/ICODE]. [url]http://docs.python.org/reference/lexical_analysis.html#string-literals[/url] | |
Re: Look at this post for learning PyQt,i like wxpython better as many her on daniweb. [url]http://www.daniweb.com/forums/thread191210.html[/url] There are license problem with PyQt. [QUOTE]How can I add the vcontents in a tabbed view? [/QUOTE] You can use Qtabwidget. [url]http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtabwidget.html[/url] [CODE]import os, sys from PyQt4 import QtGui, QtCore class MainWindow(QtGui.QWidget): def __init__(self): … | |
Re: [CODE]import BeautifulSoup as bs html = """\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Test JSON </TITLE> <script language="JavaScript"> function checkJSON() { try { var v = eval(TextJSON.value); var OK='OK' document.write("OK"); } catch (ex) { document.write("Error:"+ex); } TextJSON.focus(); } </script> </HEAD> <BODY > <table width="100%" border="0"> <tr> … | |
Re: Why most of can use free with tool like [URL="http://www.jrsoftware.org/isinfo.php"]Inno setup[/URL] And for exe [URL="http://code.google.com/p/gui2exe/"]Gui2exe make it easy[/URL] I also use UPX to compress dll,exe,pyd. | |
Re: Dirdialog may be what you are looking for. [CODE]import wx class MyFrame(wx.Frame): '''Info abot class | Doc string''' def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) self.SetBackgroundColour('light blue') self.panel = wx.Panel(self) b = wx.Button(self.panel,-1,"Create and Show a DirDialog", (50,50)) self.Bind(wx.EVT_BUTTON, self.OnButton, b) def OnButton(self, evt): dlg = wx.DirDialog(self, … | |
Re: You shold look better there are many post about this. here is one just postet. [url]http://www.daniweb.com/forums/thread256661.html[/url] | |
Re: There are very good reason why board like this should have registration and log in. Board want serious user and not alot off spam. Enough off that and back to your question. Wxpython is great for more advance GUI look. Look at this post. [url]http://www.daniweb.com/forums/thread252780.html[/url] Wxpython has a demo where … | |
Re: [QUOTE]I did more reading into the setup problem. Seems I need to include a dll that isn't pulled automatically from Python2.6 and above[/QUOTE] Read this. [url]http://www.daniweb.com/forums/thread256661.html[/url] | |
Re: From command line. [CODE]C:\>python -m timeit "for i in xrange(100): pass" 1000000 loops, best of 3: 1.77 usec per loop #Are tuple faster than list? C:\>python -m timeit (1,2,3,4) 10000000 loops, best of 3: 0.0226 usec per loop C:\>python -m timeit [1,2,3,4] 10000000 loops, best of 3: 0.194 usec per … | |
Re: In first post. [QUOTE]After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on a project you are interested in.[/QUOTE] That means that you have to know python good. You can … | |
Re: You have to explain better. Give an correct example how it shoul look(input and output) Eksp. This lines in sample--a, i will have in sample--b. Sample--b is a new file or sample--b is in same file. Sample--A CHIP FRAME_4X, $ (1, 4HTFRR2-0A-00, AD=0.005, SF=0.5) ROWS 38500/76200 Output. Sample--B CHIP FRAME_4X, … | |
Re: You can use py-unrar2. [url]http://code.google.com/p/py-unrar2/wiki/QuickTutorial[/url] | |
Re: [CODE]>>> import time >>> dir(time) ['__doc__', '__name__', '__package__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'strptime', 'struct_time', 'time', 'timezone', 'tzname'] >>> help(time.sleep) Help on built-in function sleep in module time: sleep(...) sleep(seconds) Delay execution for a given number of seconds. The argument may be a floating … | |
Re: Read this. [url]http://www.daniweb.com/forums/announcement114-2.html[/url] [QUOTE]I didn't understand on what you trying to say, but I'm leaving this problem for "professionals people" [/QUOTE] Yes leave your homework to "professionals people". Do you see how stupid that look? | |
Re: Use 4 space for indentations(and nothing else ever) What is you data input? Not sure what you are trying do do. Here something you can look at. [CODE]>>> import sys >>> help(sys.getsizeof) Help on built-in function getsizeof in module sys: getsizeof(...) getsizeof(object, default) -> int Return the size of object … | |
Re: This question is very unclear. Python code and html is text and png is an image format. So you can not convert this code to and image format off course. Are you trying to make a fake png file with html and python code? | |
Re: So first you do something like this. [CODE] html = '''\ <HEADLINE text="This is headline 1"> <PARAGRAPH file="path to the file.txt">''' l = [] for item in html.split('\n'): if item.startswith('<HEADLINE'): l.append(item.split('"')[1]) ll = ''.join(l) print ll '''Out--> This is headline 1 ''' [/CODE] And then you want that text to … | |
Re: See if this help make your code shoter and clearer. Ask if somethis is unclear. [CODE]l = [] for i in open('dna.txt'): if i.split()[1] == '1': l.append(i.strip().rstrip('1')) print l '''Out ['AAAAAGATAAGCTAATTAAGCTACTGGGTT ', 'AAAAAGGGGGCTCACAGGGGAGGGGTAT '] '''[/CODE] | |
Re: [CODE]>>> import datetime >>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo'] >>> #Use method date and timedelta >>> print datetime.date.today() 2010-01-11 >>> >>> #Find now days since 1 Jan 1901 >>> one_day = datetime.timedelta(days=1) >>> long_time_ago = datetime.date(1901, 1, 01) >>> print to_day - long_time_ago … | |
Re: Not possible to help you if you dont post the code. Look at this. [url]http://wxpython.webs.com/tutorial5.htm[/url] Install wxpython demo. I have made put files in folder named c:\demo. To start [ICODE]python c:\demo\demo\demo.py[/ICODE] | |
Re: For loop will only iterate one time over the list and not find duplicated words. You can use text.find() method in a while loop. This will iterate over all word in the text, when all search word are found text.find() will return -1. Example. [CODE]text = """\ Hi,i have a … | |
Re: [QUOTE] i dnt knw if my code is even right.. plz help[/QUOTE] No is far from right,this you should know if you try to run it. Look at this one more time,to you think this will run? [CODE]if: finish=no[/CODE] [CODE]print " student(s) got 0 marks student(s) got 1 marks student(s) … | |
Re: And dont mix indentation now you have 8 spaces and 2 spaces. Always use 4 spaces. Look at [URL="http://www.python.org/dev/peps/pep-0008/"]PEP 8[/URL] | |
Re: Two module comes in mind. Python Win32 Extensions. [url]http://python.net/crew/skippy/win32/Downloads.html[/url] Tim Golden's excellent WMI. [url]http://tgolden.sc.sabren.com/python/wmi/index.html[/url] WMI has an excellent way of looking at many hardware settings, but has limited support for changing many of them. Try pypi to see if someone has make somthing for this. [url]http://pypi.python.org/pypi[/url] Maybe better to find … | |
Re: [CODE]>>> Input = '55' >>> type(Input) <type 'str'> >>> n = int(Input) >>> n 55 >>> type(n) <type 'int'>[/CODE] | |
Re: There are several problem with your code. Function within a function you dont use it in code like this as vegaseat poinet out. You `break` out to nothing. This line will not work `print "Wrong Input , x"` in exception handling because off **x** I rewrite to show a better … | |
Re: Dont use [ICODE];[/ICODE]in python. [CODE]output = "The number is: " num = 12 print '%s%d' % (output,num) ''' The number is: 12 ''' [/CODE] [CODE]output = "The number is: " num = 12 output+=num print output[/CODE] Error message is pretty clear. [ICODE]TypeError: cannot concatenate 'str' and 'int' objects[/ICODE] [CODE]>>> output … | |
Re: Dictionary has keys() and values() You dont show all code. [CODE]Example. >>> tanks = {'tiger': 'a55', 'trunk': 'f77'} >>> for tank in tanks.values(): print tank a55 f77 >>> for tank in tanks.keys(): print tank tiger trunk #-------- >>> dir(tanks) #this show methods under dictionary [/CODE] |
The End.