880 Posted Topics

Member Avatar for [O3]

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 …

Member Avatar for vegaseat
0
138
Member Avatar for snfitz

[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]

Member Avatar for snippsat
0
243
Member Avatar for Purnima12

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 …

Member Avatar for snippsat
0
605
Member Avatar for Cyproz

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]

Member Avatar for vegaseat
0
120
Member Avatar for Stev0

[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 …

Member Avatar for Stev0
0
143
Member Avatar for baki100

Look at [URL="http://code.google.com/p/gui2exe/"]Gui2exe[/URL] to. Dos not create console default.

Member Avatar for baki100
0
984
Member Avatar for soUPERMan

[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 …

Member Avatar for soUPERMan
0
178
Member Avatar for heValbo

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 …

Member Avatar for Gribouillis
0
119
Member Avatar for 1988asso

[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]

Member Avatar for vegaseat
0
117
Member Avatar for AnnetteM

[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. …

Member Avatar for AnnetteM
0
1K
Member Avatar for letlet_pogs

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 …

Member Avatar for letlet_pogs
0
127
Member Avatar for A_Dubbs

[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.

Member Avatar for snippsat
0
752
Member Avatar for yoni0505

[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 …

Member Avatar for snippsat
0
140
Member Avatar for conord

[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

Member Avatar for woooee
0
143
Member Avatar for Noliving
Member Avatar for lyndon enero
0
91
Member Avatar for ssmokincamaro

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]

Member Avatar for snippsat
0
146
Member Avatar for richardtreier
Member Avatar for snippsat
0
81
Member Avatar for rehber344

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]

Member Avatar for snippsat
0
107
Member Avatar for Purnima12

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]

Member Avatar for Gribouillis
1
2K
Member Avatar for jtbcswiss

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 …

Member Avatar for Gribouillis
0
473
Member Avatar for Hawkeye Python

[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 …

Member Avatar for snippsat
0
120
Member Avatar for Hawkeye Python

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 …

Member Avatar for The_Kernel
0
175
Member Avatar for Hawkeye Python

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]

Member Avatar for Hawkeye Python
0
4K
Member Avatar for sindhujavenkat

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): …

Member Avatar for sindhujavenkat
0
142
Member Avatar for vamsicoolman

[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> …

Member Avatar for vamsicoolman
0
13K
Member Avatar for persianprez

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.

Member Avatar for snippsat
0
189
Member Avatar for Stefano Mtangoo

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, …

Member Avatar for Stefano Mtangoo
0
104
Member Avatar for supanoob

You shold look better there are many post about this. here is one just postet. [url]http://www.daniweb.com/forums/thread256661.html[/url]

Member Avatar for Stefano Mtangoo
0
114
Member Avatar for supanoob

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 …

Member Avatar for Stefano Mtangoo
-3
109
Member Avatar for Tech B

[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]

Member Avatar for snippsat
0
2K
Member Avatar for funfullson

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 …

Member Avatar for vegaseat
0
106
Member Avatar for PixelHead777

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 …

Member Avatar for Ene Uran
0
157
Member Avatar for liamchou

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, …

Member Avatar for liamchou
-2
86
Member Avatar for rehber344

You can use py-unrar2. [url]http://code.google.com/p/py-unrar2/wiki/QuickTutorial[/url]

Member Avatar for WaltP
0
108
Member Avatar for mahela007

[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 …

Member Avatar for mahela007
0
285
Member Avatar for adam4u

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?

Member Avatar for HiHe
-3
171
Member Avatar for rehber344

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 …

Member Avatar for rehber344
-1
153
Member Avatar for anishakaul

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?

Member Avatar for anishakaul
0
3K
Member Avatar for d8m9

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 …

Member Avatar for snippsat
0
139
Member Avatar for evilweasel_47

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]

Member Avatar for woooee
0
109
Member Avatar for mahela007

[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 …

Member Avatar for Stefano Mtangoo
0
196
Member Avatar for A_Dubbs

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]

Member Avatar for Ene Uran
0
1K
Member Avatar for deonis

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 …

Member Avatar for deonis
0
138
Member Avatar for gangster88

[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) …

Member Avatar for gangster88
0
84
Member Avatar for shrikant.rails

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]

Member Avatar for shrikant.rails
0
142
Member Avatar for Tech B

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 …

Member Avatar for Tech B
0
2K
Member Avatar for zrin

[CODE]>>> Input = '55' >>> type(Input) <type 'str'> >>> n = int(Input) >>> n 55 >>> type(n) <type 'int'>[/CODE]

Member Avatar for zrin
0
112
Member Avatar for Dokino

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 …

Member Avatar for Dokino
0
130
Member Avatar for letlet_pogs

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 …

Member Avatar for sneekula
0
113
Member Avatar for lewashby

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]

Member Avatar for sneekula
0
74

The End.