text
stringlengths
226
34.5k
Scraping values from a webpage table Question: I want to create a python dictionary of color names to background color from this [color dictionary](http://people.csail.mit.edu/jaffer/Color/M.htm). What is the best way to access the color name strings and the background color hex values? I want to create a mapping for ...
How do I pull a recurring key from a JSON? Question: I'm new to python (and coding in general), I've gotten this far but I'm having trouble. I'm querying against a web service that returns a json file with information on every employee. I would like to pull just a couple of attributes for each employee, but I'm having ...
python: why am I not exiting while loop? Question: Can't find anything applicable to the problem I have here. If there is, please point me toward it. Anyway, as a new one to python, I can't understand why my output here keeps repeating indefinitely. from random import randint dollars = int(input("How...
How to add dynamically C function in embedded Python Question: I declare a C function as Python prototype static PyObject* MyFunction(PyObject* self, PyObject* args) { return Py_None ; } Now I want to add it into a dynamically loaded module PyObject *pymod = PyImport_...
Parsing NBA reference with python beautiful soup Question: So I'm trying to scrape out the miscellaneous stats table from this site <http://www.basketball-reference.com/leagues/NBA_2016.html> using python and beautiful soup. This is the basic code so far I just want to see if it is even reading the table but when I do ...
Writing pandas DataFrame to JSON in unicode Question: I'm trying to write a pandas DataFrame containing unicode to json, but the built in `.to_json` function escapes the characters. How do I fix this? Some sample code: import pandas as pd df=pd.DataFrame([['τ','a',1],['π','b',2]]) df.to_json('df...
How to create a prescription pill count like pain management facilities use? Question: I don't understand why this code won't work. I want to create some code to help me know exactly how many pills need to be taken back to pain management. If you don't take the right amount back, then you get kicked out of pain managem...
Google App Engine import error, for django.urls Question: I'm trying to learn Django, so I completed their multi-part tutorial (Python 2.7) and ran it locally. I got it working fine on my PC. I need the following import, in a views.py file: from django.urls import reverse When I upload it to GAE, it gives me the fol...
Reverse the list while creation Question: I have this code: def iterate_through_list_1(arr): lala = None for i in range(len(arr))[::-1]: lala = i def iterate_through_list_2(arr): lala = None for i in range(len(arr), 0, -1): lala = i L...
Nesting mpi calls with mpi4py Question: I am trying to use mpi4py to call a second instance of an mpi executable. I am getting the error: Open MPI does not support recursive calls of mpirun But I was under the impression that is exactly what Spawn is supposed to be able to handle - i.e. setting up...
Do AND, OR strings have special meaning in PLY? Question: When using PLY (<http://www.dabeaz.com/ply/>) I've noticed what seems to be a very strange problem: when I'm using tokens like `&` for conjunction, the program below works, but when I use `AND` in the same place, PLY claims syntax error. Program: ...
Python - separate duplicate objects into different list Question: So let say I have this class: class Spam(object): def __init__(self, a): self.a = a And now I have these objects: s1 = Spam((1, 1, 1, 4)) s2 = Spam((1, 2, 1, 4)) s3 = Spam((1, 2, 1...
Convert cURL command to post request to send notification to kaa server Question: I want to send a notification to kaa server. The below cURL command is working fine but I want to send POST request from my node.js server. Kindly help me in converting to post request. curl -v -S -u devuser:devuser123 -F...
Adding a dict as a value to another dict is overwriting the previous value Question: I have a piece of python code like below ( I am sorry that I couldn't paste my actual code because its very big) final_dict = {} default_dict = some_data for dict in list_of_dicts: # I am getting lis...
Can Django collectstatic overwrite old files? Question: In my deb postinst file: PYTHON=/usr/bin/python PYTHON_VERSION=`$PYTHON -c 'import sys; print sys.version[:3]'` SITE_PACKAGES=/opt/pkgs/mypackage/lib/python$PYTHON_VERSION/site-packages export PYTHONPATH=$SITE_PACKAGES echo "collect ...
Convert python cryptography EC key to OpenSSH format Question: I am looking to convert EC key generated using cryptography module to their respective OpenSSH strings. like ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAhANiNlmyHtBUgaPXG+CtCVK8mQxBUtDjX3/nqqPZAHhduAAAAIE/JNDqLTeq9WVa5XWyU2Y7NJXfV5...
Import data from xml file into two tables w/ foreign key at MySQL database Question: I need to load file of the following format into MySQL database. <item value="{$\emptyset $}"> <subitem value="(empty language)"></subitem> <subitem value="(empty set)"></subitem> </item> <item valu...
Using a DLL exported from D Question: I've created a simple encryption program in D, and I had the idea to make a DLL from it and try to import it to, for example, Python. I've could simply call my `main` function, becouse it dosn't need any params. But when I get to my encrytion method, **it uses dynamic-lenght`ubyte...
pyFFTW doesn't find libfftw3l.so while import Question: In my Raspbian system I have succesfully installed pyFFTW, but there is a problem while import package. import pyfftw File "/usr/local/lib/python3.4/dist-packages/pyfftw/__init__.py", line 16, in <module> from .pyfftw import ( I...
Process hangs if web browser crashes in selenium Question: I am using selenium + python, been using implicit waits and try/except code on python to catch errors. However I have been noticing that if the browser crashes (let's say the user closes the browser during the program's executing), my python program will hang, ...
How to add `colorbar` to `networkx` using a `seaborn` color palette? (Python 3) Question: I'm trying to add a `colorbar` to my `networkx` drawn `matplotlib ax` from the range of `1` (being the lightest) and `3` (being the darkest) [check out the line w/ `cmap` below]. I'm trying to combine a lot of `PyData` functionali...
Why does my Python XML parser break after the first file? Question: I am working on a Python (3) XML parser that should extract the text content of specific nodes from every xml file within a folder. Then, the script should write the collected data into a tab-separated text file. So far, all the functions seem to be wo...
How to connect a socket to another computer's socket through Internet Question: I recently have some difficulties to connect a socket to another computer's socket through Internet, an image is worth a thousand words: [![enter image description here](http://i.stack.imgur.com/9CseJ.png)](http://i.stack.imgur.com/9CseJ.p...
How do I ask the user if they want to play again and repeat the while loop? Question: Running on Python, this is an example of my code: import random comp = random.choice([1,2,3]) while True: user = input("Please enter 1, 2, or 3: ") if user == comp p...
python+pyspark: error on inner join with multiple column comparison in pyspark Question: Hi I have 2 dataframes to join #df1 name genre count satya drama 1 satya action 3 abc drame 2 abc comedy 2 def romance 1 #df2 name max_count...
SSH tunnel from Python is too slow to connect Question: I'm connecting to a remote SQL database over SSH. If I set up the SSH connection from the Linux command line (using `ssh-add my_private_key.key` and then `ssh user@mysite.co.uk`), it takes less than a second to connect. But if I do it from Python using [sshtunnel]...
can't define a udf inside pyspark project Question: I have a python project that uses pyspark and i am trying to define a udf function inside the spark project (not in my python project) specifically in spark\python\pyspark\ml\tuning.py but i get pickling problems. it can't load the udf. The code: from p...
Python Scraping - Unable to get required data from Flipkart Question: I was trying to scrape the customer reviews from Flipkart website. The following is the [link](https://www.flipkart.com/samsung- galaxy-j5-6-new-2016-edition-white-16-gb/product- reviews/itmegmrnzqjcpfg9?pid=MOBEG4XWJG7F9A6Z). The following was my co...
Python appending from previous for loop iteration Question: I have a very simple but annoying problem. I am reading in a list of files one by one whose names are stored in an ascii file ("file_input.txt") and performing calculations on them. My issue is that when I print out the result of the calculation ("print peak_w...
Hidden references to function arguments causing big memory usage? Question: **Edit:** Never mind, I was just being completely stupid. I came across code with recursion on smaller and smaller substrings, here's its essence plus my testing stuff: def f(s): if len(s) == 2**20: input('ch...
Value Error: x and y must have the same first dimension Question: Let me quickly brief you first, I am working with a .txt file with 5400 data points. Each is a 16 second average over a 24 hour period (24 hrs * 3600 s/hr = 86400...86400/16 = 5400). In short this is the average magnetic strength in the z direction for a...
Calling mpmath directly from C Question: I want to access mpmath's special functions from a C code. I know how to do it via an intermediate python script. For instance, in order to evaluate the hypergeometric function, the C program: #include <Python.h> void main (int argc, char *argv[]) { ...
Convert string type array to array Question: I have this: [s[8] = 5, s[4] = 3, s[19] = 2, s[17] = 8, s[16] = 8, s[2] = 8, s[9] = 7, s[1] = 2, s[3] = 9, s[15] = 7, s[11] = 0, s[10] = 9, ...
Modules and variable scopes Question: I'm not an expert at python, so bear with me while I try to understand the nuances of variable scopes. As a simple example that describes the problem I'm facing, say I have the following three files. The first file is outside_code.py. Due to certain restrictions I cannot modify t...
How can I repeatedly play a sound sample, allowing the next loop to overlap the previous Question: Not sure if this isn't a dupe, but the posts I found so far didn't solve my issue. * * * A while ago, I wrote a (music) [metronome for Ubuntu](http://askubuntu.com/a/814889/72216). The metronome is written in `python3/G...
Unable to mock class methods using unitest in python Question: module `a.ClassA`: class ClassA(): def __init__(self,callingString): print callingString def functionInClassA(self,val): return val module `b.ClassB`: from a.ClassA import Clas...
Grab retweeted status text in loop Question: I am using the python script tweepy to scrape Twitter data; the scraped data is output as a csv. The retweets are truncated. I am looking for suggestions on how I could modify the code below to grab the "retweeted_status.text" if the retweeted_status is "True". It seems that...
How can I make my python binary converter pass these tests Question: My python code is supposed to take decimal numbers from 0 to 255 as arguments and convert them to binary, return invalid when the parameter is less than 0 or greater than 255 def binary_converter(x): if (x < 0) or (x > 255): ...
Python multiprocessing lock strange behavior Question: I notice a behaviour in my code that I cannot explain. This is the code: import multiprocessing from collections import deque LOCK = multiprocessing.Lock() data = deque(['apple', 'orange', 'melon']) def f(*args): ...
Trying to create a crude send/receive through TCP in python Question: So far I can send files to my "fileserver" and retrieve files from there as well. But i can't do both at the same time. I have to comment out one of the other threads for them to work. As you will see in my code. SERVER CODE from sock...
Python dropbox - Opening spreadsheets Question: I was testing with the dropbox provided API for python..my target was to read a Spreadsheet in my dropbox without downloading it to my local storage. import dropbox dbx = dropbox.Dropbox('my-token') print dbx.users_get_current_account() fl = dbx...
How to calculate the values of a pandas DataFrame column depending on the results of a rolling function from another column Question: A very simple example just for understanding. **The goal is to calculate the values of a pandas DataFrame column depending on the results of a rolling function from another column.**...
Python: [Errno 2] No such file or directory Question: I want to open and read all csv file in a specific folder. I'm on OS X El Capitan version 10.11.6, and I'm using Python 2.7.10. I have the following function in phyton file: def open_csv_files(dir): for root,dirs,files in os.walk(dir): for...
Binding outputs of transformers in FeatureUnion Question: New to python and sklearn so apologies in advance. I have two transformers and I would like to gather the results in a `FeatureUnion (for a final modelling step at the end). This should be quite simple but FeatureUnion is stacking the outputs rather than providi...
Animated text funtion only working for certain strings Question: I am attempting to make a function that displays animated text in Python import sys def anitext(str): for char in str: sys.stdout.write(char) time.sleep(textspeed) print ("") This fu...
Python, scipy.optimize.curve_fit do not fit to a linear equation where the slope is known Question: I think I have a relatively simple problem but I have been trying now for a few hours without luck. I am trying to fit a linear function (linearf) or power-law function (plaw) where I already known the slope of these fun...
PyGobject error Question: #!/usr/bin/python # -*- coding: utf-8 -*- from gi.repository import Gtk class ourwindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="My Hello World Program") Gtk.Window.set_default_size(self, 400,325) Gtk.Window.set_position(self, Gtk.Windo...
How do I format a scientific number into decimal format in Python? Question: I'm having trouble trying to convert the results of my "def pricing(question)" function into decimal values instead of scientific. I tried converting the result to a string but that didn't work and I can't see anyway of formatting the pricex ...
Regex Search in Python: Exclude port 22 lines with ' line 22 ' Question: My current regex search in python looks for lines with `' 22 '`, but I would like to exclude lines that have `' line 22 '`. How could I express this in `Regex`? Would I be `'.*(^line) 22 .*$'` import re sshRegexString='.* 2...
youtube-dl python script postprocessing error: FFMPEG codecs aren't being recognized Question: My python script is trying to download youtube videos with youtube-dl.py. Works fine unless postprocessing is required. The code: import youtube_dl options = { 'format':'bestaudio/best', ...
Calculate run time of a given function python Question: I have created a function that takes in a another function as parameter and calculates the run time of that particular function. but when i run it, i can not seem to understand why this is not working . Does any one know why ? import time import...
How to calculate Variable Importance in SVM regression models Question: How do I calculate the variable importance of an [SVM](https://en.wikipedia.org/wiki/Support_vector_machine) regression model implemented in Python? At least, if an already-implemented function does not exist, I would like some hints how to calcul...
Using multiple levels of inheritance with sqlalchemy declarative base Question: I have many tables with identical columns. The difference is the table names themselves. I want to set up a inheritance chain to minimize code duplication. The following single layer inheritance works the way I want it to: fr...
Extracting a row from a table from a url Question: I want to download EPS value for all years (Under Annual Trends) from the below link. [http://www.bseindia.com/stock-share- price/stockreach_financials.aspx?scripcode=500180&expandable=0](http://www.bseindia.com/stock- share-price/stockreach_financials.aspx?scripcode=5...
Need help adding API PUT method to Python script Question: I am using the script below to collect inventory information from servers and send it to a product called Device42. The script currently works however one of the APIs that I'm trying to add uses PUT instead of POST. I'm not a programmer and just started using p...
Python: registering key presses and saving responses to an array or matrix Question: I am very new to Python, and I have been struggling with trying to find an answer to this question for a while now. I am using Python 3.5 to write an experiment script. I would like to write a script that loops through a number of tri...
Allow end-user to upload and execute javascript on server side Question: I'm studying javascript/nodeJS to develop ERP solution. I would like to allow ERP end-users to upload their own custom scripts, so they can interact with ERP scripts. Of course user scripts should implement pre-defined ERP API. For example this i...
python urlib in loop Question: my requirement is to read some page which has so many links available in order i have to stop at suppose at 4th link and i have to read and connect to the url at that particular link save the link contents in a list again the connected link has so many links and i have to connected to the...
Reading .dat file with fixed column width Question: The code I use in SAS Options symbolgen ps=10000; Data span_nonspan; INFILE 'C:\September 2016\SAMPLE.dat'; INPUT @1 XYZ $10. @11 ABC $7. @18 PM $3. run; Can anyon...
How to rectify this error? Question: python serve.py /usr/local/lib/python3.4/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead. .format(x=modname), ExtDeprecationWarning Traceback (most recent call last): Fi...
Python Turtle game, Check not working? Question: import turtle # Make the play screen wn = turtle.Screen() wn.bgcolor("red") # Make the play field mypen = turtle.Turtle() mypen.penup() mypen.setposition(-300,-300) mypen.pendown() mypen.pensize(5) for side in range(...
Having a compiling error with Python using PyCharm 4.0.5 Question: The reason for me asking the question here is that I did not find a solution elsewhere. I'm having the following error with my PyCharm 4.0.5 program while trying to run a Python script. It was working fine the one day and when I tried using it this afte...
Python Django Rest Post API without storage Question: I would like to create a web api with Python and the Django Rest framework. The tutorials that I have read so far incorporate models and serializers to process and store data. I was wondering if there's a simpler way to process data that is post-ed to my api and the...
Redirect error when trying to request a url with requests/urllib only in python Question: im trying to post data to a url in my server ... but im stuck in sending any request to that url (any url on that server ) here is one for example http://apimy.in/page/test the website is written in python3.4/...
Django app has a no ImportError: No module named 'django.core.context_processors' Question: Tried git pushing my app after tweaking it and got the following error. ImportError: No module named 'django.core.context_processors' this was not showing up in my heroku logs and my app works locally so I w...
Gantt Chart python machine scheduling Question: I'm having some bad time trying to plot a gantt chart from a data set with python. I have a set of machines that work on different tasks during a time period. I want to make a gantt chart that shows by the y axis the machines and x axis the time spent on each task. Each m...
Python and Tkinter root naming Question: I often see a GUI using root.mainloop() at the end. Near the top sometimes they put: root=tk.TK() and sometimes they just put: root=Tk() ## Do these two statements do something different? (examples below) from Tkinter import * class App: def __init__(se...
How can I join a list of characters into strings of 8? Question: I have a python list of chars and want to join them to create a list of strings of 8 elements each, eg: x = ['0','0','1','a','4','b','6','2','2','1','4','1','5','7','9','8'] result ['001a4b62', '21415798'] Answer...
Python program that sends txt file to email Question: I've recently created a python keylogger. The code is : import win32api import win32console import win32gui import pythoncom,pyHook win=win32console.GetConsoleWindow() win32gui.ShowWindow(win,0) def OnKeyboardEvent(ev...
Getting Column Headers from multiple html 'tbody' Question: I need to get the column headers from the second tbody in this url. <http://bepi.mpob.gov.my/index.php/statistics/price/daily.html> Specifically, i would like to see "september, october"... etc. I am getting the following error: runfile('C:/P...
asyncio: prevent task from being cancelled twice Question: Sometimes, my coroutine cleanup code includes some blocking parts (in the `asyncio` sense, i.e. they may yield). I try to design them carefully, so they don't block indefinitely. So "by contract", coroutine must never be interrupted once it's inside its cleanu...
How to take input from stdin, display something using curses and output to stdout? Question: I'm trying to make a python script that takes input from stdin, displays GUI in terminal using curses and then when user finishes interaction outputs the result to the stdout. Good example of this behaviour is [selecta](https:/...
From perl to python Question: I've got some code that I've translated from perl into python, but I am having a time trying to figure out this last part. my $bashcode=<<'__bash__'; . /opt/qip/etc/qiprc; . /opt/sybase/sybase.sh perl -mdata::dumper -e 'print dumper \%env'; __bash__ my $v...
Python Tkinter While Thread Question: Well i am a bit of newb at python, and i am getting hard to make a thread in Tkinter , as you all know using while in Tkinter makes it Not Responding and the script still running. def scheduler(): def wait(): schedule.run_pending() t...
PHP openssl AES in Python Question: I am working on a project where PHP is used for decrypt AES-256-CBC messages <?php class CryptService{ private static $encryptMethod = 'AES-256-CBC'; private $key; private $iv; public function __construct(){ $th...
GitPython "blame" does not give me all changed lines Question: I am using GitPython. Below I print the total number of lines changed in a specific commit: `f092795fe94ba727f7368b63d8eb1ecd39749fc4`: from git import Repo repo = Repo("C:/Users/shiro/Desktop/lucene-solr/") sum_lines = 0 ...
Itertools Chain on Nested List Question: I have two lists combined sequentially to create a nested list with python's map and zip funcionality; however, I wish to recreate this with itertools. Furthermore, I am trying to understand why itertools.chain is returning a flattened list when I insert two lists, but when I a...
python2.7 create array in loop Question: I would like to create a new variable in a loop with an index in which I write a 2d matrix of data. Something like this: import numpy DARK = [] a = [] for i in range(0,3): # create 3d numpy array d = numpy.array([[1, 2], [3, 4]]) ...
Altering dictionaries/keys in Python Question: I have ran the code below in Python to generate a list of words and their count from a text file. How would I go about filtering out words from my "frequency_list" variable that only have a count of 1? In addition, how would I export the print statement loop at the bottom...
What is the easiest way to get a list of the keywords in a string? Question: For example: str = 'abc{text}ghi{num}' I can then do print(str.format(text='def',num=5)) > abcdefghi5 I would like to do something like print(str.keywords) # function does not exist ...
Scrollspy Navbar jumping over tab? Question: <body data-spy="scroll" data-target=".navbar" data-offset="50"> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="...
How to resolve "_tkinter.TclError: unknown option"? Question: I am learning python tkinter but I have an error whenever I tried to compile it: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/spyderlib/ widgets/externalshell/sitecu...
Pretty print a JSON in Python 3.5 Question: I want to pretty print a JSON file, but popular solutions: [How to Python prettyprint a JSON file](http://stackoverflow.com/questions/12943819/how-to- python-prettyprint-a-json-file) dont work for me. Code: import json, os def load_data(filepath): ...
Calling class that initiates UI class in python Question: I have an issue while creating my small Python project. I am used to Java and this is still quite new to me. The problem is i create a UI class from QtCreator. Then convert it to `.py` and import to my project. I have a class that for now is considered `main` th...
How do I resolve builtins.ConnectionRefusedError error in attempting to send email using flask-mail Question: I am making a simple WebApp using Flask framework in python. It will take user inputs for email and name from my website ([www.anshulbansal.esy.es](http://www.anshulbansal.esy.es)) and will check if email exist...
Pyvmomi get folders name Question: I'm new to Python and Django and I need to list all my VMs. I used pyvmomi and Django but I can't get the folders name from VSphere, it shows a strange line. > VMware list > > 'vim.Folder:group-v207' > > 'vim.Folder:group-v3177' > > 'vim.Folder:group-v188' I have 3 folders on vSpher...
Airflow DB session not providing any environement vabiable Question: As an Airflow and Python newbie, even don't know if I'm asking the right question, but asking anyway. I've configured airflow on a CentOS system. Use remote MySql instance as the backend. In my code, need to get a number of Variables, the code looks l...
python add array of hours to datetime Question: import timedelta as td I have a date time and I want to add an array of hours to it. i.e. Date[0] datetime.datetime(2011, 1, 1, 0, 0) Date[0] + td(hours=9) datetime.datetime(2011, 1, 1, 9, 0) hrs = [1,2,3,4] Date[0] + td(hours...
python 27 - Creating and running instances of another script in parallel Question: I'm attempting to build a multiprocessing script that retrieves dicts of attributes from a MySQL table and then runs instances of my main script in **parallel** , using each dict retrieved from the MySQL table as an argument to each inst...
python3 How to select two elements on either side of a random element in a list? Question: I have finished this part of the code so far: wedding = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] from random import randrange random_index = randrange(0, len(wedding)) print('TV =', wedding[random_index]) ...
Problems with pd.read_csv Question: I have Anaconda 3 on Windows 10. I am using pd.read_csv() to load csv files but I get error messages. To begin with I tried `df = pd.read_csv('C:\direct_marketing.csv')` which worked and the file was imported. Then I tried `df = pd.read_csv('C:\tutorial.csv')` and I received the fol...
Display select Mysql query in python with output nice and readable Question: I need python script for display sql query with nice output and readable this not readable for heavy tables... cnx = mysql.connector.connect(user='root', password='*****', host='127.0.0.1', ...
Django Standalone Script Question: I am trying to access my Django (v1.10) app DB from another python script and having some trouble doing so. This is my file and folder structure: store store __init.py__ settings.py urls.py wsgi.py store_app __init.py__ ...
Apache poi multiline bullet point is working but not multiple paragaraph? Question: Generate word document using apache poi library bullet point is working but i trying multiple paragraph not working,i have pasted below, my java class code : package samplebuller; import java.io.FileInputStream;...
How do I execute multiple shell commands with a single python subprocess call? Question: Ideally it should be like a list of commands that I want to execute and execute all of them using a single subprocess call. I was able to do something similar by storing all the commands as a shell script and calling that script us...
Write hex code to text file from integer value in python Question: **Details: Ubuntu 14.04(LTS), Python(2.7)** I want to write hex code to a text file so I wrote this code: import numpy as np width = 28 height = 28 num = 10 info = np.array([num, width, height]).reshape(1,3)...
matplotlib 2D plot from x,y,z values Question: I am a Python beginner. I have a list of X values x_list = [-1,2,10,3] and I have a list of Y values y_list = [3,-3,4,7] I then have a Z value for each couple. Schematically, this works like that: X Y Z -1 ...
Python - Filename validation help needed Question: Bad Filename Example: `foo is-not_bar-3.mp4` What it should be: `foo_is_not_bar-3.mp4` I only want to keep a `-` for the last bit of the string if it is a digit followed by the extension. The closest I have gotten thus far is with the following code: fn...
Printing the current minute in a loop with python Question: I'm using python 3 and trying to create a script that runs constantly, and at some time, execute a specific code. The code i have so far, verifies the current minute, and if it's above a given minute, it print's a message, otherwise, it prints the current minu...
Error 3: Renaming files in python Question: Newbie Python question. I'm trying to rename files in a directory... the value of path is C:\tempdir\1\0cd3a8asdsdfasfasdsgvsdfc1.pdf while the value newfile is `C:\tempdir\1\newfilename.pdf` origfile = path newfile = path.split("\\"...