text
stringlengths
226
34.5k
Python Class Inheritance, __init__ and cls Question: The desired output of the code is that I have a class variable Team.stuff which has one entry holding the b instance, and the Player.stuff variable should be empty. Instead I get an error... class Player: stuff=[] def __init__(self): ...
Extracting values only from the value of excel row recived using xlrd -python Question: This problem is specific wrt using xlrd package in python I got row of excel which is in form of list but each item is integer value; type:value this is not string. The row is save by; import xlrd book = xlrd...
Make Python's Interactive Interpreter Class Print Evaluated Expressions Question: When you use the Python Interactive Interpreter, you can enter an expression, say `1+1` and it'll print the value. If you write `1+1` in a script, it will not print anything, which makes perfect sense. However, when you create a subclass...
sqlite and python filter results Question: I have a python function to do query from sqlite. as the following: def Query(X, Y, Z): where X, Y & Z are the columns of the database. so for example when Query(1, 2, 3) it will go to the sqlite as follows: <code>SELECT...
python unittest.TestCase.assertEquals() on complex data structures Question: I'm unit testing a function that returns a _very_ complex data structure (dict of lists of lists of sets etc.). I validated the output manually, and now I want to make sure it doesn't change without me noticing. Right now I have: ...
log a variable name and value Question: I am looking for a way to quickly print a variable name and value while rapidly developing/debugging a small python script on a unix command line/ssh session. It seems like a very common requirement and it seems wasteful (on keystrokes and time/energy) to duplicate the variable_...
How do you convert a python time.struct_time object into a ISO string? Question: I have a Python object: time.struct_time(tm_year=2013, tm_mon=10, tm_mday=11, tm_hour=11, tm_min=57, tm_sec=12, tm_wday=4, tm_yday=284, tm_isdst=0) And I need to get an [ISO string](http://www.w3.org/TR/NOTE-datetime):...
f2py with Intel Fortran compiler Question: I am trying to use f2py to interface my python programs with my Fortran modules. I am on a Win7 platform. I use latest Anaconda 64 (1.7) as a Python+NumPy stack. My Fortran compiler is the latest Intel Fortran compiler 64 (version 14.0.0.103 Build 20130728). I have been ex...
Flask-Migrate not creating tables Question: I have the following models in file `listpull/models.py`: from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer, db.Fore...
Printing a Yearly Calendar Question: I am trying to print a yearly calendar with python and I have hit a wall. I am getting the days of the month printed, but I am not sure how to make the output jump to a new line after 7 days. I am using a for loop to print the days of the month. I need the numbers to go to a new l...
matplotlib savefig bbox_inches = 'tight' does not ignore invisible axes Question: When you set bbox_inches = 'tight' in Matplotlib's savefig() function, it tries to find the tightest bounding box that encapsulates all the content in your figure window. Unfortunately, the tightest bounding box appears to include invisib...
html post values addition in bottle application Question: I was trying to add two html form values transferred via post in a python bottle application. Unfortunately it is just concatenating. I tried to convert the inputs to int but then i get" Unhandled Exception Error".... This is my code from bottle i...
How do I change my Content-Transfer-Encoding header in Python? Question: This is my code right now: from email.MIMEText import MIMEText body = "helloworld" msg = MIMEText(body, 'plain') msg['Subject']= subject msg['From'] = from_field['name'] + ' <'+from_field['email']+'>' msg['Dat...
Python disable while iterating Question: So I am creating a data structure that is based on storage and memory. Lets say I have the following method: def __store(self): #stores information into self.__memory list now what I want to do is, if this function is called inside a loop, I want it ...
importing python modules - ImageChops Question: I'm looking for a good way to analyze image similarity, using python. I'm NOT looking for a way to establish whether two images are identical. I'm just looking for a way to establish the similarity between two images (e.g., if two images are very similar they could be giv...
Python Printing the String Result Question: import operator def mkEntry(file1): results = [] for line in file1: lst = line.rstrip().split(",") lst[2] = int(lst[2]) results.append(lst) return print(sorted(results, key=operator.itemgetter(1,2))) ...
Sequential pattern matching algorithm in Python Question: I find myself in this situation that I need to implement an algorithm for sequential pattern matching in Python. Can't find any working library/snippet on the internet after searching for hours. problem definition: implement a function sequential_pattern_match...
Displaying an amount of objects on to the screen and positioning Question: I am following this tutorial: <http://www.raywenderlich.com/24252/beginning- game-programming-for-teens-with-python#comments> And I am trying to reduce the amount of badgers drawn to the screen from the part where the badgers are drawn. It looks...
Project Euler getting smallest multiple in python Question: I am doing problem five in Project Euler: "2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?" I have co...
Multi-threaded websocket server on Python Question: Please help me to improve this code: import base64 import hashlib import threading import socket class WebSocketServer: def __init__(self, host, port, limit, **kwargs): """ Initialize websoc...
Splines in pythonOCC Question: This question is about how to use splines in general in pythonOCC, There are two part to this question. Have found out that I can create a spline by array = [] array.append(gp_Pnt2d (0,0)) array.append(gp_Pnt2d (1,2)) array.append(gp_Pnt2d (2,3)) array.appe...
Blender ImportError: cannot import name Question: I am really almost giving up on trying to create an import-export module addon to Blender 2.68 and it seems that it is an insurmountable python problem (Blender uses python 3.3). I see plenty of questions in stackoverflow on this topic but none of them answers my proble...
Embed Plotly graph into a webpage with Bottle Question: Hi i am using plotly to generate graphs using Python, Bottle. However, this returns me a url. Like: https://plot.ly/~abhishek.mitra.963/1 I want to paste the entire graph into my webpage instead of providing a link. Is this possible? My code ...
OpenGL Pyglet "Error: global name 'texture' not defined" Question: The error is on line 5: glBindTexture(texture.target, texture.id) 1. import pyglet 2. from pyglet.gl import * 3. class CustomGroup(pyglet.graphics.Group): 4. def set_state(self): 5. glEnable(texture.target) 6...
django-cms refusing to publish a specific page in production - where should I start debugging? Question: I have a small problem in my production cms. One of the pages (There are about 50) is refusing to be published. I mean: if I click on "publish" in the admin interface or use the method publish_page I am not getting ...
Reverse for '' with arguments '(1L,)' and keyword arguments '{}' not found Question: I'm new to Django and faced with next problem: when I turn on the appropriate link I get next error: `NoReverseMatch at /tutorial/` `Reverse for 'tutorial.views.section_tutorial' with arguments '(1L,)' and keyword arguments '{}' not ...
Django "__init__() keywords must be strings" error while running "runserver" Question: I just set up virtualenv to start django project. I installed everything fine. when I issue "python manage.py runserver" it spits out this error. I tried all kind of django runserver error through out and no one seems to have this. A...
Pythonic way of writing a library function which accepts multiple types? Question: If, as a simplified example, I am writing a library to help people model populations I might have a class such as: class Population: def __init__(self, t0, initial, growth): self.t0 = t0, se...
Homework: need to check the time performance of the loop, computer heats Question: I typed this code in python and my computer really heats and doesn't print anything! however when I assigned `num = 2**10` it did. How can I calculate approx. how long will it take for an average computer to run this code? the code is: ...
Cython: overloaded constructor initialization using raw pointer Question: I'm trying to wrap two C++ classes: Cluster and ClusterTree. ClusterTree has a method get_current_cluster() that instantiates a Cluster object, and returns a reference to it. ClusterTree owns the Cluster object, and manages its creation and delet...
python: Open file from zip without temporary extracting it Question: How can I open files from a zip archive without extracting them first? I'm using pygame. To save disk space, I have all the images zipped up. Is it possible to load a given image directly from the zip file? For example: `pygame.image.load('zipFile/im...
How to replace characters that have already been printed in a previous line Question: I am trying to make a game similar to [this](http://candies.aniwey.net/) in Python (3.3.2 on Windows). I think that most of the programming is fairly basic and so it will be easy for me as beginner. What I can't understand is how to h...
Redirect text from editor directly to python script Question: is there a way to open text editor like vim or gedit from python script and then redirect typed text from text editor back directly to python script so I could save it in database? Something like git commit command which opens external text editor and on exi...
How to read a config file using python Question: I have a config file `abc.txt` which looks somewhat like: path1 = "D:\test1\first" path2 = "D:\test2\second" path3 = "D:\test2\third" I want to read these paths from the `abc.txt` to use it in my program to avoid hard coding. Answer: In ord...
Python: get OS language Question: What is a way to get current Windows (or OSX) Locale id on Python 2.x. I want to get an int (or str) which tells what language in OS is active. Is possible without using WinAPI? Answer: This is the documentation related to the **[locale](http://www.python.org/doc//current/library/lo...
SyntaxError: Invalid Syntax PLEASE help me Question: Hey guys I am trying to learn Python Through an online book here: <http://learnpythonthehardway.org/book/ex1.html> However, I am trying to run a program to make it say stuff (I am trying to use Windows Power Shell like it suggested) and I keep getting an error Prog...
cannot resolve AttributeError: 'module' object has no attribute 'calcKappa' Question: I'm completely new to python. Now i'm using Enthought canopy (python 2.7.3). I know this question has been asked a million times before and i can imagine you all are tired of this question but it has been bugging me all day. ...
How do Python's any and all functions work? Question: I'm trying to understand how the `any()` and `all()` Python built-in functions work. I'm trying to compare the tuples so that if any value is different then it will return `True` and if they are all the same it will return `False`. How are they working in this case...
Detecting collision when rotating Question: I have a chain of squares represented in pygame. I have some code that lets me rotate parts of the chain, as follows. #!/usr/bin/python import pygame def draw(square): (x,y) = square pygame.draw.rect(screen, black, (100+x*20,100+y*2...
how to parse time stamps in Python from PyPI packages (eg. 12-Oct-2010 06:40) Question: I'm wondering if there is a straightforward way to do this, since PyPI is the Python packaging authority, it seems like parsing these time stamps (into the epoch time perhaps) should then be handled in Python somewhat easily, but it...
File is not creating in python when unicode present in the file name Question: I need to store HTML file as text files. In the same name of web tittle. something went wrong with my code so that it is not creating file in side the directory. I have directory permission to write. I am using Ubuntu 12.04LTS Directory `/h...
Easy_install and pip broke: pkg_resources.DistributionNotFound: distribute==0.6.36 Question: I was tried to upgrade pip with `pip install --upgrade pip` on OSX and pip and easy_install both dont work. When running pip Traceback (most recent call last): File "/usr/local/bin/pip", line 5, in <module...
get all link site in source html (python) Question: I want get all link in one web page ,this function only one link but need get all link ! of course i know need The One Ring true but i don't know use i need get all link def get_next_target(page): start_link = page.find('<a href=') start_quote ...
Chinese Restaurant Process implementation in Python Question: I have wrote a code in Python for CRP problem. The problem itself can be found here: <http://cog.brown.edu/~mj/classes/cg168/slides/ChineseRestaurants.pdf> And to give a short description of it: Suppose we want to assign people entering to a restaurants to ...
Sample of Server to Server authentication using OAuth 2.0 with Google API's Question: This is a follow-up question for [this question](http://stackoverflow.com/questions/19391252/how-to-obtain-a-private- key-for-a-legacy-google-app-engine-project): I have successfully created a private key and have read the various pa...
Send by ref/by ptr in python? Question: i need help-i try to send value to method like in c++ by ref/by ptr how can i do it? to exmple: def test(x): x=3 x=2 test(x) print(x) In this case x a local variable in test method and will not change the "original" X so how ...
function calls in python (pygame) Question: im trying to split my code into functions and i want to input my own values for x and y. so the character can move from the inputed values. When i try to do this from the function call, nothing happens. Any suggestions? import pygame, sys from pygame.local...
Python 3.3 pyqtgraph can't plot points Question: Is it me, or is it impossible to plot points (scatterplot) in pyqtgraph using Python 3.3? I have quite big data*, and find matplotlib way too slow, so I would like to give this a try: 1) `pyqtgraph.plot([1],[1])` shows nothing in the plot. 2) `pyqtgraph.plot([1,2,3,4]...
Generating Pivot Tables in Python - Pandas? Numpy? Xlrd? from csv Question: I have been searching for hours, literally the entire day on how to generate a pivot table in Python. I am very new to python so please bear with me. What I want is to take a csv file, extract the first column and generate a pivot table using ...
How to install external packages into Canopy? Question: I am new to python and Canopy. I have searched for the possible solutions online, including the support forum of Enthought Canopy, but failed to solve my problem by following the instructions under other similar questions. I use Mac OS, and wanted to install exte...
Print output to file on python Question: I have two python files. My test.py import td.py file witch i found internet. Td.py file looking signals from TelldusCenter program. Now if i run test.py file it shows me signals what i get from TelldusCenter app and output is something like: "Door - ON" Now i like to print tha...
Python: fast iteration through file Question: I need to iterate through two files many million times, counting the number of appearances of word pairs throughout the files. (in order to build contingency table of two words to calculate Fisher's Exact Test score) I'm currently using from itertools import...
AttributeError: '_BoundedSemaphore' object has no attribute 'acuire' Question: I am learning python, and learning through a book called Violent Python, I am on a section which involves making a brute force SSH script. I am having problems with an error, and cannot figure out the problem or the fix. the code: ...
Is there a python http-client which automatically performs authentication for several auth types? Question: I am currently using urllib2 or curl to perform authentication to different Trac, Jira, Twiki and Media Wiki sites to request information like the users that are active. Now depending on the settings on the spec...
BeautifulSoup - why is it printing file path and not the content Question: I am trying to understand how BeautifulSoup works. Note that I am really new to Python so I am probably missing something out. I open a Python terminal and write this: from bs4 import BeautifulSoup import re ytchannel = '...
Python data structure for sorted key-value pairs Question: I have a (fixed) set of keys for which I store a value. I often look up the value for a key and increment or decrement it. A typical dict usage. x = {'a': 1, 'b': 4, 'c': 3} x['a'] += 1 Additionally however, just as often as incrementin...
Running tests for third-party Django app results in "ImportError: No module named urls" Question: I've installed a not-yet-open sourced third-party Django app using pip and now I'm implementing unit tests for it. However, whenever I try running the unit tests, it results in the following traceback for each test case: ...
Submitting jobs using python Question: I am trying to submit a job in a cluster in our institute using python scripts. compile_cmd = 'ifort -openmp ran_numbers.f90 ' + fname \ + ' ompscmf.f90 -o scmf.o' subprocess.Popen(compile_cmd, shell=True) Popen('qsub launcher',...
Using SELECT LAST() with pyodbc and MSACCESS sometimes returns same value Question: I have a strange problem that Im having trouble both duplicating and solving. Im using the pyodbc library in Python to access a MS Access 2007 database. The script is basically just importing a csv file into Access plus a few other tri...
capture Python script output Question: I have written very small script and try to capture output of the script. I have written multiple time similar way but never had issue. Could I have input. I think I am doing very silly mistake numpy_temp = """ import numpy import sys a, b, c = numpy.pol...
Trimmed Mean with Percentage Limit in Python? Question: I am trying to calculate the **trimmed mean** , which excludes the outliers, of an array. I found there is a module called [`scipy.stats.tmean`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tmean.html#scipy.stats.tmean), but it requires the use...
how to change the secs to the ISO time format? Question: How to change the secs to the ISO time format: for example: 28800 sec is the offset from the midnight? if successfully converted, the output should be 08:00:00 not 8:00:00. How could I do it in python? Thank you. Answer: Solution using timedelta to 'do the m...
ZeroMQ: have to sleep before send Question: I'm write a zeromq demo with Forwarder device (with pyzmq) Here are the codes(reference to <https://learning-0mq-with- pyzmq.readthedocs.org/en/latest/pyzmq/devices/forwarder.html> ): forwarder.py import zmq context = zmq.Context() frontend = con...
Efficient Cython for large matrix creation/manipulation Question: I have been trying to speed up a section of code that creates and manipulates a very large matrix of data (approx. 15,000 x 15,000; type double). For now, I don't think the size of the matrix is that important because I do not see speedup even for a smal...
Django - No module name site.urls Question: As [this other SO post shows](http://stackoverflow.com/questions/11216829/django-directory- structure), my Django 1.4 directory structure globally looks like: wsgi/ champis/ settings.py settings_deployment.py urls.py ...
Plot figure problems with python and matplotlib Question: I'm making an app that plots a figure after some processing. This is done after the user has introduced some values and pushes a button. However I don't get the figure plotted. Below there is a simplified code. This works fine if I plot directly the values of t ...
Python regex and using s/ in pattern Question: I have this regex pattern that when I use in vim works great: s/\.[A-Za-z0-9_]*\(IPROC\|IFIX\|IPTAT\)[A-Za-z_]*\([0-9][0-9]*\)[^0-9]*.*([A-Za-z0-9_]*\(IPROC\|IFIX\|IPTAT\)[A-Za-z_]*\([0-9][0-9]*\)[^0-9]*.*)/\3_\4 I am searching for things like `.jalsd...
How do I combine two files without overwriting any data in python? Question: I need to concatenate two files, one which contains a single number and the other which contains at least two rows of data. I have tried shutil.copyfile(file2,file1) and subprocess.call("cat " + file2 + " >> " + file1, shell=True), both things...
How to parse Ethernet Header of pcap file using Python? Question: I would like to decode the link-layer type and version of packets in a pcap file using Python. So, I have to parse pcap using Python. Here is my code. import dpkt import socket import sys f = open('filename') pcap = dp...
Sending Strings Queue to Clipboard in python Question: I am writing a program that runs in background and check's for file changes in a folder if any new Image file arrives into that folder it will read text from that Image with the help of tesseract OCR Engine.Images contains Adresses of Employees.python program split...
Run server alongside infinite loop in Python Question: I have the following code: #!/usr/bin/python import StringIO import subprocess import os import time from datetime import datetime from PIL import Image # Original code written by brainflakes and modified to exit ...
Representing graphs (data structure) in Python Question: How can one neatly represent a [graph](https://en.wikipedia.org/wiki/Graph_%28data_structure%29) in [Python](https://en.wikipedia.org/wiki/Python_\(programming_language\))? (Starting from scratch i.e. no libraries!) What data structure (e.g. dicts/tuples/dict(t...
WxPython widget missplaced after hide() & show() Question: I'm trying to build a GUI for a school project for Boolean expressions evaluation. This program takes a string as an input `A^B` and shows it's truth table in the GUI with a Grid widget. For some reasons (don't want to make this post too long) I need to Hide()...
Enthought Canopy - passing sys.argv from PySide Qt program Question: I've recently been looking at the Enthought distro of iPython. Today I decided to see if I could get some Qt GUI progs running and was successful after making minor changes. Simple example: import sys from PySide import QtGui # w...
How to avoid floating point errors? Question: I was trying to write a function to approximate square roots (I know there's the math module...I want to do it myself), and I was getting screwed over by the floating point arithmetic. How can you avoid that? def sqrt(num): root = 0.0 while ro...
python pattern identifier? regex? Question: So what I need is to identify the pattern " X" or "spaceCAPITAL" examples: string="Hello World, This is KZ" And the program would pick out: example_list = [W,T,K] Answer: >>> import re >>> strs = "Hello World, This is KZ" ...
Compiling and Executing Java file in python Question: how can I open an java file in python?, i've search over the net and found this: import os.path, subprocess from subprocess import STDOUT, PIPE def compile_java (java_file): subprocess.check_call(['javac', java_file]) def...
questions regarding Python namespaces and using import Question: I'm playing around with Python today and trying out creating my own modules. It seems I don't fully understand Python namespaces and I wonder if anyone could answer my questions about them. Here is an example of what I've done: I've created a module nam...
Load multiple dictionaries from a file Question: I have a file that looks like this: {"cid" : "160686859281645","name" : "","s" : "JBLU131116P00011000","e" : "OPRA","p" : "-","c" : "-","b" : "3.60","a" : "3.80","oi" : "0","vol" : "-","strike" : "11.00","expiry" : "Nov 16, 2013"}; {"cid" : "72101...
How to extract string between selected string in python Question: if i have a string like: str = 'Hello, <code>This is the string i want to extract</code>' Then how will i extract string that are between `<code>` and `</code>`, In above case the extract string is: 'This is the string...
Plot lines in different colors from color dictionary in Python Question: I'm trying to plot the path of 15 different storms on a map in 15 different colors. The color of the path should depend on the name of the storm. For example if the storm's name is AUDREY, the color of the storm's path should be red on the map. Co...
How to determine vCenter Server from a HostSystem object? Question: I am querying ESX hosts, some of which are managed by a vCenter server, and some are not. I want to find out the name of the vCenter server that manages this host, if it there is one. I'm using the Python psphere module, but all I want is the types of...
Incorrect value from dynamodb table description and scan count Question: I'm having a problem with dynamodb. I'm attempting to verify the data contained within, but scan seems to be only returning a subset of the data, here is the code I'm using with the python boto bindings #!/usr/bin/python #Check ...
isinstance(foo, types.GeneratorType) or inspect.isgenerator(foo)? Question: It seems that there are two ways in Python to test whether an object is a generator: import types isinstance(foo, types.GeneratorType) or: import inspect inspect.isgenerator(foo) In the spirit o...
Compress Python Object in Memory Question: Most tutorials on compressing a file in Python involve immediately writing that file to disk with no intervening compressed python object. I want to know how to pickle and then compress a python object in memory without ever writing to or reading from disk. Answer: I use thi...
how to istall opencv in EPD? Question: There is no opencv in EPD 7.3.1. My EPD path is like /usr/epd I have installed opencv using the method below the dashed line successfully . Now cv2.so and cv.py are made in the directory /usr/local/lib/python2.7/site- packages But since my default python is epd, there is a path...
Python urlopen error 404 directories Question: I have this code : from urllib.request import urlopen from bs4 import BeautifulSoup page = urlopen("http://www.doctoralia.com") soup = BeautifulSoup(page) myfile = open('data.txt','w') myfile.write(soup.prettify()) myfile.close()...
Virtual COM failing with pyserial/Linux, but working otherwise Question: I am using Virtual COM Port (VCP) example code from <http://blog.memsme.com/stm32f4-virtual-com-port-2/> on STM32F4 Discovery Board to have USB VCP. This code is originally by ST and used by many other people in their projects Communication with ...
Python Help. Code is going past if/Else Statement Question: The assignment is to write a code that can do triangles (find the perimeter, area, if it is an equilateral, right, etc.) I believe my code is on target, but it doesn't render an error like it should when the numbers don't form a triangle. Any help would be gr...
I need to load an excel file into python 2.7 using an interface Question: in order to do some operations with it but I would like to do it from an interface in order to select the file instead of just running a script with the name of the file, as the file name will change every day. Answer: You can use Tkinter `asko...
How to put appropriate line breaks in a string representing a mathematical expression that is 9000+ characters? Question: I have a many long strings (9000+ characters each) that represent mathematical expressions. I originally generate the expressions using sympy, a python symbolic algebra package. A truncated example ...
Error when installing Django using pythonbrew Question: I am currently facing an issue when trying to install Django using pythonbrew. My system is running ubuntu 12.04 (LTS) and I am following these instructions to get django running: <http://www.tangowithdjango.com/book/chapters/requirements.html#installing- softwa...
Python MySQL DB Question: I have 4 tables in a Mysql Db named Employee. The structure of the tables are as follows: Edetails(**_id,name,age_**) Edepartment(**_id,name,dept_**) Edesignation(**_id,name,desig_**) Esalary(**_id,name,basic,pf_**) id is the primary key in all the tables. My question is when a user gi...
Running python manage.py command from django with arguments Question: I have the command : ./manage.py dbbackup --clean --compress provided by the django-dbbackup app which performs a backup of my PostgreSQL database to Amazon S3. I am trying to run this command inside a django celery task run dail...
Good way to collect programmatically generated test suites in nose or pytest Question: Say I've got a test suite like this: class SafeTests(unittest.TestCase): # snip 20 test functions class BombTests(unittest.TestCase): # snip 10 different test cases I am currently doing t...
Output from sys.stdout in interactive mode Question: I tested sys.stdout.write in interactive mode; why do I get the 'extra' 1 and 2 suffixed to the numbers? If I run the code from a file I get the expected output (1234...) Python 3.3 on a Windows machine >>> import sys >>> for i in range(15): .....
Where does python argument unpacking fall into the order of operations? Question: <http://docs.python.org/2/reference/expressions.html#operator-precedence> My guess is that it falls into one of the buckets above dict lookups since func(*mydict[mykey]) does the dictionary lookup first. Is there a b...
Weakref and __slots__ Question: Consider the following code: from weakref import ref class Klass(object): # __slots__ = ['foo'] def __init__(self): self.foo = 'bar' k = Klass() r = ref(k) it works but when I uncomment the `__slots__` it breaks with ...
Logging error involving .conf+main.py modules Question: I think I'm missing something big and for the life of me, I can't figure it out. I have a `logging.conf` file that I am trying my main (say, `xyz.py`) file to read. But I am getting this weird error. I have the traceback below followed by the configuration file - ...
Python: string formatting and calling functions Question: So I'm running in to the string formatting error when trying to pass the arguments num1 and num2 to the function gcd. I'm not sure how to fix this. Please bear with me since I'm new to Python programming. Thanks! #!/usr/bin/python import sys ...