• Member Avatar for snippsat
    snippsat

    Replied To a Post in Using Memoization Instead of Recursion

    You have been told before to before to watch your coding style. Stop using `global`. There is a also build module that solve this in Python 3. from functools import …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Launching a Calculator

    You use [subprocess](https://docs.python.org/3/library/subprocess.html) module. import subprocess calc_program = "path_to_program" subprocess.call([clac_program])
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in seperating input number in thousands

    Use [string formatting](https://mkaz.com/2012/10/10/python-string-format/) >>> value = 1000000000000 >>> n = "{:,}".format(value) >>> print(n) 1,000,000,000,000 >>> #Back to float >>> float(n.translate(None, ',')) 1000000000000.0
  • Member Avatar for snippsat
    snippsat

    Edited PyCon 2015

    It's started (: Find some videos that are interesting,feel free to post link or discuses it here. I was looking most forward to David Beazley talks. Live coding with Concurrency …
  • Member Avatar for snippsat
    snippsat

    Created PyCon 2015

    It's started (: Find some videos that are interesting,feel free to post link or discuses it here. I was looking most forward to David Beazley talks. Live coding with Concurrency …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Point in Polyhedron

    >because my anaconda distribution doesn't seem to have linprog (?) You can use `pip install` or `conda install`(Scripts folder) to get new stuff into Anaconda. For this is best to …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in "Hello World" Fun

    Making hello world movie with great [MoivePy](https://zulko.github.io/moviepy/index.html) Results can be seen [here](https://www.dropbox.com/sh/t3vxb8xald56fh6/AABZ78-mls7INL3zNCtmUYRAa?dl=0) This make a 10 sec long videoclip showing hello world,using codec H264. import moviepy.editor as moviepy hello_world = …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in python get drive letter / mount point

    [psutil](https://pypi.python.org/pypi/psutil/#downloads) is good. Here a run on my windows and Mint(VirtualBox) >>> import psutil >>> psutil.disk_partitions() [sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'), sdiskpart(device='D:\\', mountpoint='D:\\', fstype='', opts='cdrom'), sdiskpart(device='E:\\', mountpoint='E:\\', fstype='NTFS', opts='rw,fixed'), sdiskpart(device='F:\\', mountpoint='F:\\', …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Reading from a website

    Here are the diffrent ways, and also what i would call the prefered way these day with [Requests](http://docs.python-requests.org/en/latest/#). Python 2: from urllib2 import urlopen page_source = urlopen("http://python.org").read() print page_source Python …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in slide puzzle game

    To make some futher i improvement's. All code is now in functions, explanation is moved into function so it work as doc-string(then it's possible to use `help()` on functions). I …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in how to print every word starts with "A" in a urlpage

    >print link['title'] what is title? The alt of the <img> tag? Have you looked at Firebug or Chrome DevTools? Links i gave you in [post](https://www.daniweb.com/software-development/python/threads/492470/cant-send-this-list-from-terminal-to-txt-filedrop-each-index-into-new-line). Then is easy to so …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in need help for finding special NAMES in a url page (homework)

    David W it's about time to learn string formatting :) Splitting up with `,` and `+ something +` is not so nice. print('"{}".istitle() is {}'.format(item, item.istitle())) [Python String Format Cookbook](https://mkaz.com/2012/10/10/python-string-format/) …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in how to print every word starts with "A" in a urlpage

    >So now i want my script to find every word that start with "A" in that url page >and print it for me. Then i should find a way to …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to print only the content of all <li> tags from a url page?

    >he's gone too far=D Yes of course,to make it great humoristic read. Regex can be ok to use some times,like you only need a singel text/value. Both [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#a-regular-expression) and [lxml](http://lxml.de/xpathxslt.html#regular-expressions-in-xpath) …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to print only the content of all <li> tags from a url page?

    >Use regular expressions Click Here No no no just to make it clear :) Have to post this [link](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) again. Use a parser Beautifulsoup or lxml. from bs4 import BeautifulSoup …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in why the output doesn't contain all that URL links?

    >so why it didn't print the url of each website into output?! Because this is a dynamic site using JavaScript,jQuery.... The problem is that JavaScript get evaluatet by DOM in …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Trouble sorting dictionary into highest to lowest

    Change last part to this. lst = [] for k in d: high = int(max(d[k])) lst.append((k, high)) score_lst = sorted(lst, key=lambda tup: tup[1], reverse=True) for name,score in score_lst: print('{} {}'.format(name, …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in cant send this list from terminal to txt file/drop each index into new line

    Use the new [bs4](http://www.crummy.com/software/BeautifulSoup/bs4/doc/),do not call old BeautifulSoup. Do not use `read()`,BeautifulSoup detect encoding and convert to Unicode. As mention you need take out `href attributes`, and you most learn …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in send a printed text from terminal into a text file

    As Andrae posted,but need to close file object. f = open('url.txt', 'w') #Opens the file to write text f.write(url) #Writes the file to the opened text file f.close() Or the …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Remove commas in list replacing them with spaces

    >>> answer = ('7', 'Q', '5', 'H', '9', '4', '3', '8', 'L') >>> print(' '.join(answer)) 7 Q 5 H 9 4 3 8 L >>> help(''.join) Help on built-in function …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in "Hello World" Fun

    Hello world on the wall? This is a rewite of some code i did for a "99 bottles of beer" challenge. Use Google image API and take out some random …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Python; using a loop to write numbers to a text. Using a loop to read them

    Don't call both function main,use name that make sense. import random def generate_numbers(): one = 1 thirteen = 13 subtract = 1 number_gen = open('numbers.txt', 'w') for number in range(one,thirteen,subtract): …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to open and play mp3 file in python?

    Look's like you need [Avbin](http://avbin.github.io/AVbin/Home/Home.html) An other option is to use your favorite player. import subprocess # pick an external mp3 player you have sound_program = "path to player" # …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to print letters randomaticly

    Here is a big hint. >>> import random >>> s = 'i am a programmer' >>> ''.join(random.sample(s, len(s))) 'm mraep mriago ra' >>> #no whitespace >>> s_1 = ''.join(s.split()) >>> …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How can i creat e text file to use as a database in python

    >With jason >ValueError: Expecting property name enclosed in double quotes >is a royal pain, if you want to save string objects! Can you give an example? No problem in me …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Edited Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Created Database for lazy people(Dataset)

    A look at [Dataset](http://dataset.readthedocs.org/en/latest/) and easy and Pythonic way to create a database. Other candidates in this categorie,i will mention [pyDAL](https://github.com/web2py/pydal) and [Peewee](https://peewee.readthedocs.org/en/latest/). I did some test of Dataset in …
  • Member Avatar for snippsat
    snippsat

    Gave Reputation to Gribouillis in count of substrings. append method

    Ok, so here is a new standard lib candidate import re def overcount(S, sub, start=0, end=None): """overcount(S, sub[, start[, end]]) -> int Return the number of overlapping occurences of substring …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in count of substrings. append method

    >for sses in assesses, it output me 1 instead 2! What is the secret? In your first post you dont't have "assesses" and "sses" test. `str.count()` don't count overlapping occurrences. …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in count of substrings. append method

    >can I make?: I think it should fine,i have not read your assignment yet. Here a test run. #Python 3.4.2 >>> text = input('Enter some text: ') Enter some text: …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How can i creat e text file to use as a database in python

    >@snippsat I like the concept, although being based on top of sqlalchemy may >have a performance cost for dataset. Yes,i agree there may be some performance cost, but for many …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How can i creat e text file to use as a database in python

    A test with [dataset](http://dataset.readthedocs.org/en/latest/index.html),database as simple as it get. So here i have a player list that i store in a Sqlite(comes with Python) database. import dataset player_lst = [ …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in count of substrings. append method

    >>> text = "trans panamanian bananas" >>> text.count('an') 6 -- >>> import re >>> len(re.findall(r'an', text)) 6
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Regex (Newbie trouble) re

    >this is the HTML line which returns as soup - I'm after the 1.41 only - which >I hope to return as valueTable Using `.next_sibling` can be better. from bs4 …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in python timer

    You should use [after](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/universal.html) Tkinter is running an infinite loop(the event loop). When you use a while loop and time sleep,then this can lock up(block GUI). That's why all GUI …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Regex (Newbie trouble) re

    >the "Price Book or class="yfnc_tabledata1" is in the return respData which is >the source code downloaded from yahoo.ca. Ok i understand,it's just that i cant find it if search through …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in Regex (Newbie trouble) re

    Cant find what you search in respData. Do post also post your import. import urllib.request, urllib.parse This is the adress,you get data from. >>> resp.geturl() 'https://ca.finance.yahoo.com/lookup?s=basics' Do you find `Price …
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in PIL and matplotlib for Linux

    Pillow fork dos more than just bugfix of orginal PIL. It now comes with [new stuff and serval improvements](http://blog.uploadcare.com/post/106828637418/pillow-2-7-extended-release-notes). So it can be smart to get Pillow instead of PIL.
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to merge two binary files

    >Is it possible we have both code in the one?For future GUI. That should not be a problem,if i understand you right.
  • Member Avatar for snippsat
    snippsat

    Replied To a Post in How to merge two binary files

    You can not open 2 exe in binary mode,and try to merge these into 1 file. `exe` are standalone programs,that has to be open separately. Here a demo of what …

The End.