-
Replied To a Post in Python Challenges
> This is a no-op :) Yes i can agree with that :) #multi_glob.py from glob import glob import os def multi_glob(path=None, *args): '''glob that can handle multiple file extensions … -
Replied To a Post in Python Challenges
I give it a try for fun. #multi_glob.py from glob import glob import os def multi_glob(path=None, *args): '''glob that can handle multiple file extensions option. #--- Usage ---# from multi_glob … -
Replied To a Post in How to sort two wxlistctrl
> Is wxPython still around? Yes still alive. Lastet officale oppdate is(25-Dec-2013) wxPython (classic) 3.0.0.0 It will soon be ready for Python 3,work is going on [Project Phoenix](http://wiki.wxpython.org/ProjectPhoenix) Work well … -
Replied To a Post in Parse large one line text file
One way. f_object = open('filename', 'rb') while True: chunk = f_object.read(180) if not chunk: break do_something_with(chunk) f_object.close() More modern an pythonic. from functools import partial with open('filename', 'rb') as f_object: … -
Replied To a Post in syntax error....?
Same after "d" missing comma. Learn to use string formatting. >>> a = 100 >>> difference = 'high' >>> print('The gap between {} and 1000000 is {}'.format(a, difference)) The gap … -
Replied To a Post in Returning only tags with certain siblings (Beautiful Soup)
> I was thinking that if a <title> has no corresponding <pos>, delete that title, but I don't know how to do that. Can anyone suggest a solution? Some hint … -
Began Watching Copy .dll files from System32 to folder
HI I need to copy .dll files in C:\Windows\system32\ which is found or match in my my_file.txt file to C:\tools folder. my code not work and need also to found … -
Replied To a Post in Copy .dll files from System32 to folder
Good effort Peter 18,the code dos what it shall. I would suggest some improvements. To strip off `\n` is better to use `strip()` >>> s = 'hello\n' >>> s.strip() 'hello' … -
Replied To a Post in Getting a Sum from reading a file
> Do I need to use .format? Maybe this help. >>> lst = ['$10.00', '$8.00', '$10.00', '$6.00', '$10.00', '$10.00'] >>> new_lst = [float(i.split('$')[1]) for i in lst] >>> new_lst [10.0, … -
Replied To a Post in Getting a Sum from reading a file
> Not sure if this will help me but....This is the file: This how the program writes the $10.00 too the file. > What to you want,sum up all number … -
Replied To a Post in Read and write words from an .XML or .CSV file to an .txt file
import os import xml.etree.ElementTree as ET tree = ET.parse("test.xml") root = tree.getroot() for element in root.iter('Path'): print os.path.basename(element.text) '''Output--> Riched32.dll napinsp.dll test.exe ''' Fix so "exe" not is in output. … -
Replied To a Post in Getting a Sum from reading a file
> and this is the file: Running fine for me in both my code example,and i run code in Python 3. #Python 3 totals = open('number.txt') #just copy,paste and save … -
Replied To a Post in Getting a Sum from reading a file
> I got this error: My `number.txt` is just a copy from your first post. $10.00 $10.00 $10.00 $10.00 $10.00 $10.00 > this is the code I used: You have … -
Replied To a Post in Read and write words from an .XML or .CSV file to an .txt file
You don't know that `print element.text` just was an example? A simple test and you should be able to figure very basic stuff like this out. You just use `os.path.basename(element.text)` … -
Replied To a Post in Getting a Sum from reading a file
> print [float(i.split('$')[1])#########for i in lst] > I got a syntax error where I put the ####### In Python 3 print is a function so you need (). #Python 3 … -
Replied To a Post in Read and write words from an .XML or .CSV file to an .txt file
Some hint,using a parser in standard library [ElementTree](https://docs.python.org/2/library/xml.etree.elementtree.html). Most of the time i use BeautifulSoup or lxml for parsing. import os import xml.etree.ElementTree as ET tree = ET.parse("test.xml") root = … -
Replied To a Post in Getting a Sum from reading a file
One way,you may need to break it up if list comprehension are something new. List comprehension is very common to use in Python. with open('number.txt') as f: lst = [i.strip() … -
Replied To a Post in Help with Python Threading Library with BeautifulSoup.
url is set to None,then you get this error message. >>> url = 'http://www.google.com' >>> url[0:4] 'http' >>> url = None >>> url[0:4] Traceback (most recent call last): File "<interactive … -
Replied To a Post in eliminate an element from list
>>> lst = [[1,2,3], [4,5,6]] >>> del lst[1] >>> lst [[1, 2, 3]] >>> lst = [[1,2,3], [4,5,6]] >>> lst.remove(lst[1]) >>> lst [[1, 2, 3]] >>> lst = [[1,2,3], [4,5,6]] … -
Replied To a Post in print a string backwards
`[::-1]` or `reversed()` >>> s = 'hello' >>> s[::-1].upper() 'OLLEH' >>> ''.join(reversed(s.upper())) 'OLLEH' -
Replied To a Post in Splitting words into a text file
> So it looks like it reads from all three files, but it includes the words with punctuation now? text is now a tuple. >>> s = 'Test.' >>> s1 … -
Replied To a Post in Splitting words into a text file
> How would I make it so that only words with 2 or more characters are put into that file? >>> s = 'hi this is a test' >>> s … -
Replied To a Post in Splitting words into a text file
There are some room for improvement in this code. In line 14 you are removing punctuation,then in line 20 you are testing for punctuation that's already removed. There is no … -
Replied To a Post in Simple Question about csv headers
Here is a differnt way,with a little change of good answer given by pyTony. Using `next()` to skip first line(header). def files_to_one(new_file, *files): with open(new_file, 'w') as fout: for f … -
Replied To a Post in How do i pair these up with a hint
> .I have not come across the curly brackets yet on this line of code New string formatting came out in Python 2.6 Gribouillis has much about it [here](http://www.daniweb.com/software-development/python/code/232375/string-formatting-specifications) A … -
Began Watching getting values from file records
python3 Hi I am trying to compare these two (strings) of numbers. There may not be a space inbetween the numbers in the file, but here its just for clearity. … -
Replied To a Post in getting values from file records
You can do this `print(t[0:3] in s)` read my post again. > You are checking if list ['16', '24', '30'] is in s and that is False. And see how … -
Replied To a Post in getting values from file records
Some hint. >>> s = ['06', '15', '26', '34', '36', '-', '16'] >>> t = ['16', '24', '30', '34', '43', '-', '20'] >>> s[0] '06' >>> t[0] '16' >>> s[0] … -
Replied To a Post in Give me suggestions for webserver UI for reservation software
Microframework like [Flask](http://flask.pocoo.org/) and [Bottle](http://bottlepy.org/docs/dev/index.html) would be fine for a task like this. There are many [14 Minimal Web Frameworks for Python](http://codecondo.com/14-minimal-web-frameworks-for-python/) > (mayby web2py) Would also be ok. > … -
Replied To a Post in Self Naming Varibles
> I need it for a code such as this: No that just stupid code. Explain better what you want do,then you get suggestions for better ways to solve it. -
Replied To a Post in Web scraping in Python
> . The given md5 hash isn't inside <strong> tags. Its simple plain text Even if it's in plain text,it's inside HTML on a website. Then using a parser is … -
Replied To a Post in Web scraping in Python
> And is there any other/better way to scrape particular data ? There is a better way,and HTML and regex is not the best way. Read bobince funny and good … -
Replied To a Post in how to import modules to main and excecute
Sorry but the code is not good at all. Now you have a while True loop start at line 14 with a lot of code in it. You have to … -
Replied To a Post in Confusion about Python's built in functions
> if we want to convert 'xyz' to uppercase, why dont we enter the argument inside the function Because `uppercase()` is a method that belong to string class and only … -
Replied To a Post in Another String to Variable Question
Good idèe bye slate to update objects namespace. You can also just work with dictionary if you need result `variable2 + variable3` wish is `30`. Herer a little compressed version. … -
Stopped Watching Another String to Variable Question
I appologize if this has been answered elsewhere but the terms I search for do not turn up a good fit. I am new to everything I am trying to … -
Began Watching Another String to Variable Question
I appologize if this has been answered elsewhere but the terms I search for do not turn up a good fit. I am new to everything I am trying to … -
Replied To a Post in Delete Key in dict if val = 0
That way is a little unpythonic way to do it rrashkin. d = {'Seven': 22, 'Six': 0, 'Three': 35, 'Two': 0, 'Four': 45, 'Five': 34, 'Eight': 0} for k,v in … -
Replied To a Post in Help with urllib
> returns the last line of that txt file and not the first (as I need). If you just need first line why make it more difficult than it is. … -
Replied To a Post in Python linux executable
[cx_Freeze ](http://cx-freeze.sourceforge.net/) works Python 2 and 3. [gui2exe](https://code.google.com/p/gui2exe/) for all installers into a GUI interface. As mention by Gribouillis on Linux it's ofen no problem to just give away `.py` … -
Replied To a Post in A quick question!
> Does this work for what you are asking? nichom your function is not `recursive` wish is the task here. Look at pyTony soultion. -
Replied To a Post in list index out of range?
One with [Requests](http://docs.python-requests.org/) So popular that it can be in standar libary in future,maybe in Python 3.4. When file is big as here(over 400mb) is a good choice to not … -
Replied To a Post in list index out of range?
Make a `list index out of range` error. >>> lst = [1,2,3] >>> lst[2] 3 >>> lst[3] Traceback (most recnt call last): File "<interactive input>", line 1, in <module> IndexError: … -
Replied To a Post in comparing domain name in two text files and print in to third one
You first post. http://www.daniweb.com/software-development/python/threads/470301/problem-in-copying-domain-name-from-one-notepad-to-another-using-regex You have postet more info about the task,but it still not as clear as it should be. You can try this. import re with open('1.txt') as … -
Replied To a Post in problem in copying domain name from one notepad to another using regex
It is better to use `re.finditer` when iterate over text and save to file. Look like this. import re data = '''\ line2 jdsbvbsf line3 <match name="item1" rhs="domain.com"></match> line4 <match … -
Replied To a Post in Whats wrong with my Regex code? Need simple text replacement
If you remove `re.IGNORECASE` look better? import re data = '''\ Amiloride-sensitive cation channel, ASIC3 (also called BNC1 or MDEG) which is an acid-sensitive (proton-gated)''' cleantext = re.sub(r'\(|\)|\[|\]', '' ,data) … -
Replied To a Post in Python gui advice for a snippet saver
> Hy I would like to know what python gui framework, I can use that will be compatible cross platform You can use most Python GUI framework as the work … -
Replied To a Post in Python or PHP? For web development
> but absolutelly no doubt that building web on PHP will be faster/easier, That is of course a lot bullshit for someone that use Python. I use Python for web … -
Replied To a Post in Using Python Arguments
Your code doesn't make sense as it are now. If you are gone use `sys.argv`,you know that means running script from command line and pass in argument from command line? …
The End.