Skip to content

Tag: python

python re.sub newline multiline dotall

I have this CSV with the next lines written on it (please note the newline /n): I am trying to delete all that commas and putting the address one row up. Thus, on Python I am using this: As far as I know, re.multiline and re.dotall are necessary to fulfill /n needs. I am using re.compile because it is the

Python: Print a variable’s name and value?

When debugging, we often see print statements like these: How can write a function that will take a variable or name of a variable and print its name and value? I’m interested exclusively in debugging output, this won’t be incorporated into production code. Answer You can just use eval: Or more ge…

How to retrieve steam market price history?

I’m trying to get price history for items on steam market. I found a link that returns price history for a specific item (which is mentioned in almost every question about getting price history from market at this site). http://steamcommunity.com/market/pricehistory/?country=PT&currency=3&appid=…

BeautifulSoup – search by text inside a tag

Observe the following problem: For some reason, BeautifulSoup will not match the text, when the <i> tag is there as well. Finding the tag and showing its text produces Right. According to the Docs, soup uses the match function of the regular expression, not the search function. So I need to provide the …

How can I compare files quicker in Python?

Is there any way to make this script faster? I’m using one file to compare another file to print lines, if second column are equal. Input example (for both files): The command line below works equally for same purpose in bash: How can I improve this Python script? Answer If you store your lines in dicti…

PyCharm can’t find reference in PyGame __init__.py?

OK, I’m very new to coding, and I am just learning Python. I figured I would start with some basic Pygame exercises to try to have something to program. I’ve installed Python 3.4.3 and PyCharm. I also installed the Pygame executable “pygame-1.9.2a0-hg_5974ff8dae3c+.win32-py3.4.msi” from here: https://bitbucke…