880 Posted Topics
Re: You have to use T not t self.timer = wx.[B]T[/B]imer(self) | |
Re: Maybe thumbnailCtrl is better for this. You can look at UltimateListCtrl. Fire up wxpython demo an take a look. [url]http://img691.imageshack.us/img691/8753/listctrl1.jpg[/url] | |
Re: [QUOTE]The question, how can I (if possible) replace all "value" with numbers in a quicker way then above?[/QUOTE] Yes you dont need to store data from file,just iterate over the file and do replace. And use [ICODE]with open()[/ICODE],then you dont need to close fileobject. This create a new file,this is … | |
Re: [QUOTE]Python has some extraordinarily intuitive features I'm noticing, it's almost...English. [/QUOTE] List comprehensions as Gribouillis use is a common way to write with python. [CODE]>>> l = ['a', 'b', 'c'] >>> a = [x for x in l if not 'a' in x] >>> a ['b', 'c'] >>> l ['a', … ![]() | |
Re: [B]python --version[/B] not python--version And as Gribouillis pointet out you can write [ICODE]python[/ICODE] in any path(cmd) and it will work. If environment variables(path) are ok. You should stick with 2.7 for now,you can have both installed. Most of stuff(tutorials/books/forum) out there is for python 2.x The diffrence 2 to 3. … | |
Re: As tony postet you have to use a paser. lxml is good,for me BeautifulSoup has alway been a favorit. lxml is more upp date and has more features. But BeautifulSoup is just one small file(easy to disbrute),and still dos a very good jobb. The advantages with lxml and BeautifulSoup is … | |
Re: This may help you,but this may not be an easy task for you if new to this and python. Files i get from code under is. [CODE]110702SRace01_B.rtf 110702SRace03_B.rtf 110702SRace04_B.rtf 110702SRace05_B.rtf 110702SRace06_B.rtf 110702SRace07_B.rtf 110702SRace08_B.rtf[/CODE] Files will be in folder you run script from. [CODE]from BeautifulSoup import BeautifulSoup import urllib2 from urllib … | |
Re: The problem here is not regex,because regex is the wrong tool when it comes to html/xml. [url]http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags[/url] So two good parser for python is lxml and BeautifulSoup. [CODE]from BeautifulSoup import BeautifulSoup html = '''\ <tr align="right"><td>3</td><td>Matthew</td><td>Brittany</td>''' soup = BeautifulSoup(html) tag = soup.findAll('td') print tag[2].string #Brittany [/CODE] | |
Re: Look at this post here i explain a little,and give a link to why regex is not the right tool for xml/html. [url]http://www.daniweb.com/software-development/python/threads/375186[/url] [CODE]from BeautifulSoup import BeautifulStoneSoup xml = '''\ <text> <p><s id="s1"><ng><w pws="yes" id="w1" p="CD">25</w> <w l="woman" pws="yes" id="w4" p="NNP" common="true" headn="yes">Woman</w></ng> <vg tense="past" voice="act" asp="simple" modal="no"><w l="create" pws="yes" … | |
Re: Counter() is a dictionary,then you can iterate over it with a for loop. [CODE]>>> l = ['162.10.2.1', '162.10.2.1', '162.10.2.1', '192.34.1.10', '172.11.2.9'] >>> l ['162.10.2.1', '162.10.2.1', '162.10.2.1', '192.34.1.10', '172.11.2.9'] >>> from collections import Counter >>> d = Counter(l) >>> d Counter({'162.10.2.1': 3, '172.11.2.9': 1, '192.34.1.10': 1}) >>> for k,v in sorted(d.iteritems()): … | |
Re: [QUOTE]well here is a thought[/QUOTE] Well here is an other thought,read the date of the thread [B]Feb 26th, 2006[/B] So maybe 5 years later NetByte now it,or have given up python years ago:confused: | |
Re: Use code tag next time you post. [CODE]import wx class duff(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,wx.ID_ANY,'Duffan Formula', size=(400,300)) #wx.ID_ANY self.panel = wx.Panel(self) #self.panel #self.panel on all g=wx.StaticText(self.panel,-1,"________________________________________________________",pos=(10,65)) z=wx.StaticText(self.panel,-1,"Welcome to Duffan Formula!!",pos=(10,10)) r=wx.StaticText(self.panel,-1,"Here you can discover the score of any girl you are looking for.",pos=(10,30)) q=wx.StaticText(self.panel,-1,"Use it, with Knowledge!",pos=(10,50)) a=wx.StaticText(self.panel,-1,"What`s her name?",pos=(10,110)) b=wx.StaticText(self.panel,-1,"What`s … | |
Re: One way. [CODE]>>> ip = "192.168.157.128" >>> ip = ip.split('.') >>> ' '.join((hex(int(i))[2:] for i in ip)) 'c0 a8 9d 80' >>> [/CODE] | |
Re: One way with regex. [CODE]import re with open('blah.txt') as f: for line in f: line = line.strip() result = re.findall(r'\d\.\d', line) print [float(i) for i in result] '''Output--> [2.6, 1.5] [2.7, 1.6] [2.8, 1.7] [2.9, 1.8] ''' [/CODE] | |
Re: There is no problem creating a GUI like that in python. The 3 big GUI-toolkit for python can all do that wxpython,PyQt,PyGTK. A good news is also that [URL="http://qt.nokia.com/products/"]QT[/URL],python has now [URL="http://www.pyside.org/"]Pyside[/URL](no licence problem for QT GUI framework in python) | |
Re: Try this,and use a simple script first where you not importing a lot of modules. So you are sure that py2exe work If you search this forum there are many post about how to use py2exe and cxfreeze. You can also look into gui2exe that work fine. [url]http://code.google.com/p/gui2exe/[/url] . [CODE]from … | |
Re: [QUOTE]is 'globals()' a namespace? and does a namespace work like a dictionary in the sense that you can add a key to a dictionary just by:[/QUOTE] Yes globals() are a namespace. A namespace is it`s just like dictionary. [CODE]*** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit … | |
Re: [QUOTE]how do I obtain inifo such as the name or the path of the folder,[/QUOTE] Maybe i dont understand you,if you give the path to the folder. Then you can store it in a variable and just print it out. [CODE]import os aFolder = 'C:/test/' print 'Top folder is %s' … | |
Re: Just a note,maybe meant to give more brainwork to call a list on range() that is returning a list. [CODE]>>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [/CODE] | |
Re: There is no problem all python 2.x books/tutorials will works for python 2.7. It dos not mattter if it`s python 2.4 - 2.5 - 2.6,code will run fine in python 2.7. New features for python 2.7 [url]http://docs.python.org/dev/whatsnew/2.7.html[/url] Only python 3 break backwardcompatibility. This post is a good start. [url]http://www.daniweb.com/software-development/python/threads/20774[/url] | |
Re: Why do you need this? Singel and dobbels quotes dos the same in python. [CODE]>>> s = "qwerty" >>> s 'qwerty' >>> print s qwerty >>> repr(s) "'qwerty'" >>> s = 'qwertys' >>> s 'qwertys' >>> repr(s) "'qwertys'" >>> print s qwertys >>> [/CODE] | |
Re: Maybe a little confusing that line from richieking. You should read link from tony because this i basic stuff you shold be able to figure out. [CODE]with open('your.txt') as f: for item in f: from_file = item.split(',') for line in from_file: print line[/CODE] | |
Re: Just a note that can help. New from python 2.7 is [ICODE]collections.Counter[/ICODE] [CODE] >>> from collections import Counter >>> l = ['j', 'a', 'n', 'k', 'o', 's', 'i', 'e', 'n', 'a', 'p', 'i', 'v', 'o'] >>> Counter(text) Counter({'a': 2, 'i': 2, 'o': 2, 'n': 2, 'e': 1, 'k': 1, 'j': … | |
Re: Look at [URL="http://doc.qt.nokia.com/4.7/qsettings.html"]Qsettings[/URL] if you want user to change and store settings in your UI. | |
Re: So a demo to the other way to install packages,easy_install is good to have and use. I use easy_install most of the time. I use same third party packages unidecode in this test. [url]http://pypi.python.org/pypi/Unidecode/0.04.1[/url] I download [B]Unidecode-0.04.1.tar.gz[/B] and pack it out,you pack it out to wherever you want. Then from … | |
Re: Tony has explain this,just a little more with code. [CODE]def something(): a = raw_input('>> ') return a print something()[/CODE] As you something() has the return value. [CODE] def something(): a = raw_input('>> ') return a a = something() #store it in variable a print a[/CODE] One important fact with functions … | |
Re: You have to run kode in same folder as 'newfile.txt' or you have to give correct path. [CODE]f = open('c:/somefolder/newfile.txt','r+')[/CODE] [QUOTE]I do not have a file there, but I thought you created a file with the same code?[/QUOTE] Or as tony mention [ICODE]read(r)[/ICODE] dos not create a new file only … | |
Re: Convert to string and use [B]len()[/B],is the most commen way. [CODE]>>> n = 123 >>> len(str(n)) 3 >>> [/CODE] If your user input is returning a string like [ICODE]raw_input()[/ICODE] in [B]python 2.x[/B] and [ICODE]input()[/ICODE] in [B]python 3.x[/B] you can use len(). Then convert to integer if needed. You can make … | |
Re: Two good parser are BeautifulSoup an lxml. Can you post a part of xml file and tell what info you want out. So maybe can i show a little about how to parse xml. | |
Re: I dont use Tkinter so much,wxpyhon is my favoritt gui-toolkit in python. You can look at this post here show sneekula and vega the use of tkinter listbox. [url]http://www.daniweb.com/forums/thread191210-2.html[/url] | |
Re: Python can handle very large integers well. [url]http://knauth.org/gsk/advice/alg-help/large-integers.php[/url] [url]http://www.daniweb.com/software-development/python/code/216587[/url] | |
Re: A little basic stuff about Class/OOP stuff that can be good to now. Remeber it`s not called a function but a [B]method[/B],when it belong to Class. [CODE]class Active(object): ''' Special method __init__() is called auto when you makeing a object(acts as Constructor)''' def __init__(self): self.players = [] self.goblins = [] … | |
Re: From CMD. [ICODE]easy_install pysnmp[/ICODE]. To do this you need to install [URL="http://pypi.python.org/pypi/setuptools"]Setuptools[/URL] Or as Gribouillis posted from CMD navigate to folder for unpack files and write[ICODE] python setup.py install [/ICODE] [CODE]>>> import pysnmp >>> dir(pysnmp) ['__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', 'majorVersionId', 'version'] >>> pysnmp.version (4, 1, 15) >>>[/CODE] | |
Re: look like it get and error on try to import numpy. Try. [ICODE]help('numpy')[/ICODE]. Try this. [CODE]try: help('modules') except Exception, e: print e[/CODE] Or [CODE] try: help('modules') except ImportError: pass[/CODE] To get it to continue after ImportError. Place for numpy [ICODE]C:\Python27\Lib\site-packages\numpy[/ICODE] So you have to delete this folder is reinstall. Remeber … | |
Re: [QUOTE]Very simply program but I can't get it to work. I know sure how to write the code.[/QUOTE] You have to post code,how do you think we can help you?. We are not mind readers. [QUOTE]but I can't get it to work.[/QUOTE] Python always give you [B]Traceback[/B] if something goes … | |
Re: As tony posted there is much info on this site. Take a look [URL="http://docs.python.org/library/"]The Python Standard Library[/URL] All this is build-in an you can import and use it. | |
Re: You have just paste code into IDLE(python shell),that dos not work. Do this [B]file->new window[/B] now copy code under and paste code into the new window you got. [CODE]print ("Game Over") input("Press the enter key to exit.")[/CODE] Save the file with [B].py extension[/B](somthing.py) Now you can press [B]F5 or Run … | |
Re: The "is" statement should only be used when you want to check if something is exactly and identical to None like "a is None" or "b is not None". For everything else you should use [B]==[/B] or [B]!=[/B]. There are some other use cases for "is", too. But in general … | |
Re: As postet over using site API can help. For webscraping are BeautifulSoup and lxml good parser. Just a quick example with BeautifulSoup,take out price of bean. [CODE] #Python 2.x from BeautifulSoup import BeautifulSoup import urllib2 url = urllib2.urlopen('http://beans.itcarlow.ie/prices.html') soup = BeautifulSoup(url) #print soup #site conteds tag = soup.find('strong') print tag … | |
Re: There is a bug with python 3.2 and command line output from [B]input()[/B] It put on a [B]'\r[/B]' character on [B]input()[/B] when run from command line. [url]http://bugs.python.org/issue11272[/url] This will be fix in in 3.3 (r88530) and 3.2 (r88531). Others versions are not affected. A temporay fix is to use [B]strip()[/B] … | |
Re: [QUOTE]in ruby everything is an object, unlike Python where the primitives are, well, primitive[/QUOTE] Maybe you should look thing up before you talk. [url]http://www.diveintopython.org/getting_to_know_python/everything_is_an_object.html[/url] [QUOTE]Everything in Python is an object, and almost everything has attributes and methods. All functions have a built-in attribute doc, which returns the doc string defined … | |
Re: [QUOTE]Hello. I have been trying to run a simple script in Windows 7 DOS using the python command[/QUOTE] Dont call it DOS because it`s a long time since windows had DOS. Windows 98 is the last version based on MS‑DOS. [QUOTE]Command Prompt is sometimes incorrectly referred to as "the DOS … | |
Re: Just a note collections Counter will always sort in descending count order. Here i also show [B]most_common()[/B],no we now that all word after 'it' has 1 as count. [CODE]from collections import Counter from string import punctuation text = """\ If you see a turn signal blinking on a car with … | |
Re: [QUOTE]but is there any python equivalent to the Java .jar files?[/QUOTE] Yes .py files. So think of this jar files will not work if not JRE (Java Runtime Environment) is installed. To make jar files you need JDK (Java Development Kit) Py files will not work if python is not … | |
Re: Wxpython do like very much,feel most pythonic. Robin Dunn the main developer dos a very good jobb with wxpython. Just look at wxpython maling list,the developers answer daily on question. Documation and tutorials is a lot more for wxpython than PyQt and PyGTK. Tkinter the build GUI-toolkit is ok,but the … | |
Re: I have seen someone else in a other forum had the same problem with python 3.2 Is correct when run from IDLE,and the problem is when run from command line. This is python bug tracker,if you want to look for or report a bug. [url]http://bugs.python.org/[/url] | |
Re: For stand alone application there are py2exe,cx_Freeze,PyInstaller. [URL="http://code.google.com/p/gui2exe/"]Gui2exe[/URL] is good with a Gui interface for all this installer. And finish it with a good installer like [URL="http://www.jrsoftware.org/isinfo.php"]inno-setup[/URL] You also have [URL="http://www.portablepython.com/"]Portable python[/URL] than can run python code without python installed. And as we know all linux distros and mac version … | |
Re: [QUOTE]1. input ask user for date 2. ouput add three weeks to the input[/QUOTE] Look at the [URL="http://docs.python.org/library/datetime.html"]datetime module[/URL] for this. [CODE]>>> import datetime >>> now = datetime.date(2011, 3, 5) >>> difference1 = datetime.timedelta(days=21) >>> print "3 weeks in the future is:", now + difference1 3 weeks in the future … | |
Re: [CODE]def myfunc(*args): return sum(args) print myfunc(10,10,1,10,10,10,10,10) #71[/CODE] | |
Re: What OS(operating system) do you us? For windows the brainless binary install(exe,msi) next,next...finish. List of diffent OS install at pygame site. [url]http://www.pygame.org/install.html[/url] |
The End.