text
stringlengths
226
34.5k
Insert csv file into SQL Server database: error with listdir? Question: I know it's bad to throw code here and ask for help to trouble shoot. This problem seems a little over my head. The code is supposed to loop through all the files and sub folders. I don't think there is any log error here. The problem is I ran int...
How to match two equal string with IF statement in python Question: My Python code: import re output = "your test contains errors" match2 = re.findall('(.* contains errors)',output) mat2 = "['your test contains errors'] " if match2 == mat2: print "PASS" In...
Debian No Module named numpy Question: I've installed Python Numpy on Debian using... > apt-get install python-numpy But when run the Python shell I get the following... Python 2.7.10 (default, Sep 9 2015, 20:21:51) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for mor...
Match text between two strings with regular expression Question: I would like to use a regular expression that matches any text between two strings: Part 1. Part 2. Part 3 then more text In this example, I would like to search for "Part 1" and "Part 3" and then get everything in between which would...
How to pass socket objects between two clients in any language C++, Python, Java, C Question: I have an idea like how basic communication between _client_ and _server_ is established. So serialize data streams can be passed between _client_ and _server_. But I want to know, how **_socket objects_** can be passed betwee...
splitting a file randomly in python Question: I have a input file word.txt.I am trying to splitting the file in 75%-25% randomly in python. def shuffle_split(infilename, outfilename1, outfilename2): from random import shuffle with open(infilename, 'r') as f: lines = f.rea...
Python unittest Mock patch object not methods Question: I am having trouble getting my head around unit testing with Mock in Python. I have a method `start_thing()` in a class I'd like to test: class ComplexClass: def __init__(self, lots, of, args): self.lots = lots .. ...
Python regular expression using the OR operator Question: I am trying to parse a large sample of text files with regular expressions (RE). I am trying to extract from these files the part of the text which contains _'vu'_ and ends with a newline _'\n'_. Patterns differ from one file to another, so I tried to look for ...
Splitting paragraph into sentences Question: I'm using the following Python code (which I found online a while ago) to split paragraphs into sentences. def splitParagraphIntoSentences(paragraph): import re sentenceEnders = re.compile(r""" # Split sentences on whitespace between them...
Python 2.7, Having problems with having iteration Question: from __future__ import print_function import random as rand def ex_game(): print('Instructions:','\n','Your job is to try to figure out a number of problems by your choosing and get the progress bar all GREEN, YELLOW means its there, ...
ANOVA syntax in RPy2 Question: First time using the RPy2 implementation in Python. Attempting to do an one- way ANOVA with two factors. It works in R on another machine, but Python does not like the syntax. Any thoughts are appreciated! from rpy2.robjects import aov huanova = aov(formula = df1['...
Recursive function returns redundant print statements Question: I have a simple python application that counts down from 10 to 0. I have it working except it prints a print message 10 times. Here is my code: `CountDown.py`: import sys import counter def main(): A = counter...
r.headers['Authorization'] in python2.7 class's __call__ function Question: I'm digging a little into requests/requests/auth.py file at master kennethreitz/requests on github. <https://github.com/kennethreitz/requests/blob/master/requests/auth.py> And I saw this code, class HTTPBasicAuth(AuthBase): ...
ImportRrror: no module named 'psycopg2' Question: I'm attempting to use PostgreSQL as my data base and I'm running into an issue when I try to start my server. Here's what I'm doing: * I have a virtual environment set up and activated * Django 1.8.4 is installed * psycopg2 2.5.2 is installed * wheel 0.24.0 is ...
Python - global Serial obj instance accessible from multiple modules Question: I have 5 different games written in python that run on a raspberry pi. Each game needs to pass data in and out to a controller using a serial connection. The games get called by some other code (written in nodeJS) that lets the user select a...
Issue with python 3.0 pexpect module Question: Here is the piece of base code which I wrote to do an automatic ssh to the linux, but every time it is getting into cases==0, which means it's thinking every time it's a "newkey"/ (yes/no): Please help me solving it. I am stuck at the basic level. #!/home/p...
python, plot planck curves looping through arrays Question: I try to get myself familiar with programming in python but have just started and struggling with the following problem. Maybe someone can give me a hint how to proceed or where I can look for a nice solution. I'd like to plot planck curves for 132 wavelength...
how to loop through list multiple times in Python Question: Can you loop through list (using range that has a step in it) over and over again until all the elements in the list are accessed by the loop? I have the following lists: result = [] list = ['ba', 'cb', 'dc', 'ed', 'gf', 'jh'] i want ...
Avoid shouldInterruptJavaScript in PySide QT4 - Python Question: I am using PySide '1.2.2' and trying to avoid the msgbox alerting a potential javascript error, since it is due to the site being sizeable. I am using this code from this other answer: [Override shouldInterruptJavaScript in QWebPage with PySide](http://s...
Python requests - how to add multiple own certificates Question: Is there a way to tell the requests lib to add multiple certificates like all .pem files from a specified folder? import requests, glob CERTIFICATES = glob('/certs/') url = '127.0.0.1:8080' requests.get(url, cert=CERTIFICATES) ...
Python PIL save Image in directory no override if the name is same Question: I am trying to make a backup copy of an image, because it will be resized often. I am asking for the path where the image is (Tkinter), then I am adding to the path and the image an "-original" and save it in the same directory where I got it ...
Access to Spark from Flask app Question: I wrote a simple Flask app to pass some data to Spark. The script works in IPython Notebook, but not when I try to run it in it's own server. I don't think that the Spark context is running within the script. How do I get Spark working in the following example? fr...
Rounding up to nearest 30 minutes in python Question: I have the following code below. I would like to roundup TIME to the nearest 30 minutes in the hour. For example: 12:00PM or 12:30PM and so on. EASTERN_NOW = timezone.localtime(timezone.now() + timedelta(minutes=30)) TIME = datetime.time(EAS...
How can I make this code more Pythonic - specifically, merging something into a function? Question: I know that this code would look a lot better if I made it so that checking the current prices against the open prices were in a function so I wouldn't have to re-write it for every stock I want to check, but I'm not sur...
Randomly fill a 3D grid according to a probability density function p(x,y,z) Question: **How can I fill a 3D grid in the order specified by a given probability density function?** Using python, I'd like to lay down points in a _random_ order, but according to some specified probability distribution over that region, w...
Sci-Kit Learn SGD Classifier problems predicting Question: I may not be able to find the help I need here, but I am hoping the smart coders of the internet can help me. I am attempting to use Python's Sci-Kit learn SGDClassifier to classify physical events. These physical events create an image of a track (black and wh...
Python's equivalent of Ruby's ||= Question: To check if a variable exist, and if exits, use the original value, other wise, use the new value assigned. In ruby, it's `var ||= var_new` How to write it in python? PS: I don't know the `name` of `||=`, I simply can't search it in Bing. Answer: I think there is some con...
convert json to xml without changing the order of parameters in python Question: I'm using Json2xml module for converting json format to xml format. But, while converting it changes the order of the parameters. How do I convert without changing the order of parameters? Here's my python code. from json2xm...
PUT not updating Pipedrive API (Python wrapper) Question: Here's a brief description of what I'm trying to do: * get a field's value * multiply that value by a constant * update the field with the adjusted value I am using a nice wrapper found here: <https://github.com/hiway/pipedrive-api> Here is my code: ...
Pickle errors with Python 3 Question: I'm converting some code from Python **2** to Python **3** , and I have hard time with a pickle problem! Here is a simple example of what I'm trying to do: class test(str): def __new__(self, value, a): return (str.__new__(self, va...
java.lang.NoClassDefFoundError when trying to instantiate class from jar Question: I did found quite a lot about this error, but somehow none of the suggested solutions resolved the problem. I am trying to use JNA bindings for libgphoto2 under Ubuntu in Eclipse (moderate experience with Java on Eclipse, none whatsoeve...
Selenium Webdriver / Beautifulsoup + Web Scraping + Error 416 Question: I'm doing web scraping using selenium webdriver in Python with [Proxy](http://www.us-proxy.org/). I want to browse more than 10k pages of single site using this scraping. **Issue** is using this proxy I'm able to send request for single time only...
No such file or directory webdriver_prefs.json when compiling to exe with cx_Freeze Question: I wrote an application using selenium firefox webdriver and compiled it with cx_Freeze. When I start my application I get an error: Traceback (most recent call last): File "c:\111\ui\__init__.py", line 27,...
using python 3.5 saving csv from url drops CR and LF Question: I'm using Python 3.5.0 to grab some census data. When I use my script it does retrieve the data from the url and saves it but the file that was saved can't be imported to SQL because it somehow dropped the {CR}{LF}. How can I get the file it saves able of b...
Copy and paste region of image in opencv? Question: I'm stuck at [this](http://opencv-python- tutroals.readthedocs.org/en/latest/py_tutorials/py_core/py_basic_ops/py_basic_ops.html#image- roi "this") tutorial where a ROI is pasted over another region of same image. Python trows a value error when I try something simila...
Python documentation equivalent for Perl's "perldoc" Question: ## Quick [perldoc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) overview: When writing a Perl module you can document it with [`POD`](http://perldoc.perl.org/perlpod.html) style documentation. Then to get an overview of how the module works yo...
Trees and path finding in Fortran Question: I am attempting to replicate some Python code in Fortran 90 to make it work within a larger Fortran project I am contributing to. Specifically, I am trying to convert some code that recursively identifies upstream paths in a binary tree, such as in the following example: ...
Python 2d Ball Collision Question: Here is what I have mustered up: from graphics import * from random import * from math import * class Ball(Circle): def **init**(self, win_width, win_high, point, r, vel1, vel2): Circle.**init**(self, point, r) ...
Trendline in Plotly Python Question: I am generating a plot in Python using Plotly, which shows data in a timeseries. I am using the following data from my SQLite database (as _dates_ and _lines_ below): [(u'2015-12-08 00:00:00',), (u'2015-11-06 00:00:00',), (u'2015-11-06 00:00:00',), (u'2015-10-07 00:00...
Differential Testing of GNUs Coreutils 'fmt' Utility Question: I am exploring various testing strategies (differential, regression, unit, etc...), and have been assigned the task of testing GNUs `Coreutils` _[`fmt`](http://www.gnu.org/software/coreutils/manual/html_node/fmt- invocation.html#fmt-invocation)_ utility. I ...
RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK Question: I'm using PyGTK for Python 2.7 in Ubuntu 14.04, but I get the following message: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK What could be the reason ? Answer: When does it trig...
Concurrency with shell scripts in failure-prone environments Question: Good morning all, I am trying to implement concurrency in a very specific environment, and keep getting stuck. Maybe you can help me. this is the situation: -I have N nodes that can read/write in a shared folder. -I want to execute an applicati...
Python-Modelica interface: Data Question: what is in your opinion the best way to get data (measure date for example) into modelica (dymola)? Is it possible, to import data from python to modelica (for example into a combi-time-table)? My idea would be as follows: 1. pre processing of measured data in python 2. lo...
Timeout a file download with Python urllib? Question: Python beginner here. I want to be able to timeout my download of a video file if the process takes longer than 500 seconds. import urllib try: urllib.urlretrieve ("http://www.videoURL.mp4", "filename.mp4") except Exception as e: ...
Python: Continuously check size of files being added to list, stop at size, zip list, continue Question: I am trying to loop through a directory, check the size of each file, and add the files to a list until they reach a certain size (2040 MB). At that point, I want to put the list into a zip archive, and then continu...
Making a vectorized numpy function behave like a ufunc Question: Let's suppose that we have a Python function that takes in Numpy arrays and returns another array: import numpy as np def f(x, y, method='p'): """Parameters: x (np.ndarray) , y (np.ndarray), method (str) Returns: n...
Merging two csv files where common column matches Question: I have a csv of users, and a csv of virtual machines, and i need to merge the users into their vms only where their id match. But all im getting is a huge file containing everything. file_names = ['vms.csv', 'users.csv'] o_data = ...
Jupyter / Ipython not displaying correctly in browser Question: I have installed Anaconda python 3.4 distribution for windows 64. This was a fresh install today of all components. I am super excited to start learning python. However, when I run 'ipython notebook' the browser page has formatting issues (see image in fir...
read numbers from a text file in python Question: I am trying to read a column of numbers from a text file that looks like this: some text and numbers..., then: q-pt= 1 0.000000 0.000000 0.000000 1.0000000000 1 -0.066408 0.0000000 2 ...
How to import a .profile into ipython's bash shell? Question: I like to run bash commands in ipython via ! however, my default path in the ipython bash (e.g. output from !$PATH) doesn't match up with $PATH from the system command line. I've already tried ! . ~/.profile but I get an error. Here is ...
secant line too long, trying not to use y limits Question: I'm currently trying to use python to teach myself the basics of calc, so please bare with me as I'm pretty beginner. I am using matplotlib pyplot to trace a function curve and then draw a secant line from two points I specify (p1 & p2). I think I have most o...
Summation of only consecutive values in a python array Question: I am new on python (and even programing!), so I will try to be as clear as I can to explain my question. For you guys it could be easy, but I have not found a satisfactory result on this yet. Here is the problem: I have an array with both negative and p...
How I do an animation that works with a set timer in python? Question: I am trying to do some animation that works with the timer. When the time finishes, the animation should finish at the same time. I was thinking on doing something like a battery bar in a cell phone. That's why I have a green rectangle in another wi...
How can I write a fits table into an output LDAC fits catalog using Python Question: I have an [LDAC](http://marvinweb.astro.uni- bonn.de/data_products/THELIWWW/LDAC/LDAC_concepts.html) fits catalog which in a Python code I need to add the elements of two arrays as two new columns to it. I open the original catalog i...
Code to do a "bit iterator" but with 3 states Question: I am wanting to do a counter that iterates over 3 states. I know how to do this for 2 states using the bit operator `i^=1`. I want to know if there is a way to do similiar but with three states? I realize I can just do: i = 0 while if(i...
Cassandra json2sstable and sstableloader reporting positive results, but no data change happening Question: I am fairly new to Cassandra - within the month, having come from a long SQL Server background. I have been tasked with stubbing out some Python to automate bulk loading of sstables. Enter sstableloader. Everythi...
why matplotlib give the error [<matplotlib.lines.Line2D object at 0x0392A9D0>]? Question: I am using python 2.7.9 on win8. When I tried to plot using matplotlib, the following error showed up: > from pylab import * > plot([1,2,3,4]) > > **[matplotlib.lines.Line2D object at 0x0392A9D0]** I tried the test code "pyth...
Clean way to read a null-terminated (C-style) string from a file? Question: I'm looking for a clean and simple way to read a null-terminated C string from a file or file-like object in Python. In a way that doesn't consume more input from the file than it needs, or pushes it back onto whatever file/buffer it works with...
python-3.x pickling creates empty file Question: I'm new to python, trying to store/retrieve some complex data structures into files, and am experimenting with pickling. The below example, however, keeps creating a blank file (nothing is stored there), and I run into an error in the second step. I've been googling arou...
Submitting offline forms using python Question: I am trying to extract information from my college website using python. Here is the link of the website. <http://studzone.psgtech.edu/CommonPage.aspx> I have the exam results page locally saved. I want to know how to submit data using the local file and get the resulti...
error while running any python-dependent commands/programs in terminal Question: I recently set up arch on my machine; installed python. `/usr/bin/python` was symlinked to `/usr/bin/python3` which itself is a symlink to `/usr/bin/python3.4`. Because, I use python2.7, I went ahead and linked `python` to `python2.7`. ...
Python syntax. Beautiful, right, short code Question: for item in listOfModels: if item[0] in perms: perms[item[0]][item[1]] = True else: perms[item[0]] = {item[1]: True} I often use code like this. Please tell me beautiful, short, right way to do same. (lib's, books,...
Python Tkinter Progressbar indeterminate on Toplevel while function running Question: I need a progressbar which should show that the programm is still running while a loop in a certain function is working, so all in all the issue is simple. I found some useful threads here but none helped me. I think I am missing a d...
Python pyqt4 access QTextEdit from function Question: I'm trying to write a notepad application, so far i have a gui without functionality. Every element of my gui is in separate function, and then is called in **init** method. For example in create_new_file(self) function I was trying to get text from QTextEdit .toPla...
Plain HTTP API call to Google Geocoding API fails with Python requests module Question: I'm inside a corporate proxy, so often I have SSL issues and have to fall back to plain HTTP (when it's not an issue involving sensitive data). Thus, I'm trying to geotag with [Google's Geocoding API](https://developers.google.com/m...
Celery beat not starting EOFError('Ran out of input') Question: Everything worked perfectly fine until: celery beat v3.1.18 (Cipater) is starting. __ - ... __ - _ Configuration -> . broker -> amqp://user:**@staging-api.user-app.com:5672// . loader -> celery.loaders....
python SyntaxError: invalid syntax on def Question: Can you help me with my code? It's a small part of it: # -*- coding: utf-8 -*- from sys import exit def inside(): print "Text." print "Text." ladder = raw_input("Text.\n> ") if...
Importing module item of subpackage from another subpackage Question: I have this project structure: root_package/ root_package/packA/ root_package/packA/__init__.py (empty) root_package/packA/moduleA.py root_package/packB/__init__.py (empty) root_package/packB/moduleB.py root_pac...
Maya - How to create python scripts with more than one file? Question: It's my first post here, please understand that I'm a beginner and that I'm learning "on-the-job". Can someone explain how can I import files from a different module in a Maya python script? I'm getting the following error: Error: Im...
mySQL within Python 2.7.9 Question: Arrghh... I am trying to use mySQL with Python. I have installed all the libraries for using mySQL, but keep getting the: "ImportError: No module named mysql.connector" for "import mysql.connector", "mysql", etc.. Here is my config: I have a RHEL server: > Red Hat Enterprise Linux...
Install Azure Python api on linux: importError: No module named storage.blob Question: I'm trying to use the Azure Python API. I followed these installation instructions <https://azure.microsoft.com/en-us/documentation/articles/python- how-to-install/> using pip install azure It had no issues. (I r...
GSUTIL traceback-Linux Mint Question: Im trying to install GSUTIL, after installation it gives the following output for every command, Traceback (most recent call last): File "/usr/local/bin/gsutil", line 5, in <module> from pkg_resources import load_entry_point File "/usr/lib/python2...
Django Related model cannot be resolved Question: I have two django/python applications one is running on Django 1.8 and Python 3.4 and the other is running on Django 1.8 and Python 2.7. These applications share a database and use a python package that houses several of the models that are shared between the two applic...
Calculate abs() value of input -- Python Question: I just started studying programming and now for a school assignment we have to make a program in Python that asks the user to input an integer and than calculates the absolute value of that. I know about the `abs` function. What i cant figure out is how to assign the u...
Python: Choose random line from file, then delete that line Question: I'm new to Python (in that I learned it through a CodeAcademy course) and could use some help with figuring this out. I have a file, 'TestingDeleteLines.txt', that's about 300 lines of text. Right now, I'm trying to get it to print me 10 random line...
Why does isinstance([1, 2, 3], List[str]) evaluate to true? Question: I was playing around a bit with the new type hinting / typing module with python3.5 trying to find a way to confirm if the hinted type is equal to the actual type of the variable and came across something that rather surprised me. >>> ...
Global variables in multiples functions in Python Question: i will try to explain my situation with examples: Im using global to declare a variable but this work only in a function, when i try to another sub function doesnt work. register.py def main(): alprint = input("Enter something: ") ...
org-babel: want all noweb block references to appear verbatim on export Question: Consider the following MVE in org-mode -- it contains my full question in detail. But, in summary, with some code blocks, some noweb references to other code blocks are substituted inline when I export the document, and, with other code b...
Python - How to find an item exists in a list (or sublist)? Question: For example my_list = [1, 2, 3, 4, [5, 6], [7, 8]] I want to find if 7 is in `my_list`.? The answer should be True, because it is part of the last sublist. Any ideas? Answer: If `mylist` was a list of only lists you could use `...
Python crawler: downloading HTML page Question: I want to crawl (gently) a website and download each HTML page that I crawl. To accomplish that I use the library requests. I already did my crawl-listing and I try to crawl them using urllib.open but without user-agent, I get an error message. So I choose to use requests...
Loading JSON object in Python using urllib.request and json modules Question: I am having problems making the modules 'json' and 'urllib.request' work together in a simple Python script test. Using Python 3.5 and here is the code: import json import urllib.request urlData = "http://api.openw...
Animating the path of a projectile in python Question: I am trying to animate the path of a projectile launched with an initial velocity at an initial angle. I attempted to modify the code found here: <http://matplotlib.org/examples/animation/simple_anim.html> My code looks like this: import numpy as np...
Python regex optional capture group or lastindex Question: I'm searching a file line by line for sections and sub sections using python. *** Section with no sub section *** Section with sub section *** *** Sub Section *** *** Another section Sections start with 0-2 spa...
NoneType in python Question: I was trying to get some rating data from [Tripadvisor](http://'http://www.tripadvisor.in/Hotels-g186338-London_England- Hotels.html') but as i was trying to fetch the data i was getting > 'NoneType' object is not subscriptable Can anybody help me figuring out where am i going wrong , sor...
What exactly does "iterable" mean in Python? Question: First I want to clarify, I'm NOT asking what is "iterator". This is how the term "iterable" is defined in Python's [doc](https://docs.python.org/3/glossary.html#term-iterable): > **iterable** > **An object capable of returning its members one at a time.** Exam...
Python Django Mezzanine Models Import Question: from django.db import models from mezzanine.pages.models import Page # The members of Page will be inherited by the Author model, such # as title, slug, etc. For authors we can use the title field to # store the author's name. For our model defin...
Python replacement for ez-ipupdate? Question: I want to update my dynamic dns entry from behind a NAT, which ez-ipupdate doesn't support. It uses the locally bound ip instead of the external ip address. My provider, easydns, only explicitly supports the ez-ipupdate solution on my platform, Linux. Instead of writing a...
Different results of CPU and GPU with Theano Question: I have the following piece of code: import theano import theano.tensor as T import numpy as np x = theano.shared(np.asarray([1, 2, 3], dtype=theano.config.floatX), borrow=True) y = T.cast(x, 'int32') print 'type of y: ', type...
Activiti vs Spring batch Question: I have got a use case to implement. It's basically a workflow kind of use case. Below is the requirements 1. Extract and import data from an external db to an internal db 2. Make this imported data into different formats and supply it to multiple external systems and invoke some...
Python - The fastest way to generate string of zeros Question: I need to generate some string of zeros for example: import sys MB = 1024 * 1024 cache = '' while sys.getsizeof(cache) <= 10 * MB: cache = cache + "0" and save it to the file, but I have the impression that this meth...
How do I get in python the maximum filesystem path length in unix? Question: In the code I maintain I run across: from ctypes.wintypes import MAX_PATH I would like to change it to something like: try: from ctypes.wintypes import MAX_PATH except ValueError: # raises on lin...
How to prevent vertical sizers from expanding their children all the way downwards in wxformbuilder Question: I'm trying to design a dash board in WX form builder for Python. I'm having trouble trying to figure out how to keep two horizontal sizers that are children to a vertical sizer from expanding far apart from eac...
Switching two elements in Python Question: Suppose I have a bunch of elements in a long list and I want to switch them around based on the output I get in random.randit(lo,hi) function. For instance, my list is L=[(1,hi), (1, bye), (1,nope), (1,yup), (2,hi), (2, bye), (2,nope), (2,yup), (3,hi), (3, bye),...
Selenium won't click a button with python? Question: please can someone help me with this, I can't get selenium to click a button with python. I'm on python 3.4 and using Firefox 42 the browser opens but that's all from selenium import webdriver from selenium.webdriver.common.keys import Keys ...
How to get the same result in book "Web Scraping with Python: Collecting Data from the Modern Web" Chapter 7 Data Normalization section Question: **Python version:** 2.7.10 **My code:** # -*- coding: utf-8 -*- from urllib2 import urlopen from bs4 import BeautifulSoup from collections im...
Python Multithreaded Messenger Simulation. Stuck on timerThread update. What do? Question: I have a piece of code that simulates a system of messengers (think post office or courier service) delivering letters in a multithreaded way. I want to add a way to manage my messengers "in the field" to increase the efficiency ...
parsing XML with namespace in python 3 gives no data Question: I have a XML with 3 namespaces. <?xml version="1.0" encoding="UTF-8"?> <cus:Customizations xmlns:cus="http://www.bea.com/wli/config/customizations" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xt="http://www.bea.com/wli/con...
Parallelize loop over numpy rows Question: I need to apply the same function onto every row in a numpy array and store the result again in a numpy array. # states will contain results of function applied to a row in array states = np.empty_like(array) for i, ar in enumerate(array): s...
replacing "with" statement in Python code Question: import json with open("login_data.txt", "r") as login_file: try: users = json.load(login_file) except: users = {} Recently, I'm doing a presentation for my code. However, my lecturer requires me to break down the ...
Regex in Python - Substring with single "re.sub" call Question: I am looking into the Regex function in Python. As part of this, I am trying to extract a substring from a string. For instance, assume I have the string: <place of birth="Stockholm"> Is there a way to extract Stockholm with a **singl...