text
stringlengths
200
200k
source
stringclasses
2 values
# How do I watch a file for changes using Python? ## Question I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from th...
stackoverflow-qa
# How do I watch a file for changes using Python? ## Question I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from th...
stackoverflow-qa
# How do I watch a file for changes using Python? ## Question I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from th...
stackoverflow-qa
# How do I watch a file for changes using Python? ## Question I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from th...
stackoverflow-qa
# How do I watch a file for changes using Python? ## Question I have a log file being written by another process which I want to watch for changes. Each time a change occurrs I'd like to read the new data in to do some processing on it. What's the best way to do this? I was hoping there'd be some sort of hook from th...
stackoverflow-qa
# What do I need to import to gain access to my models? ## Question I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved? ## Answer Import your setti...
stackoverflow-qa
# What do I need to import to gain access to my models? ## Question I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved? ## Answer If you use the sh...
stackoverflow-qa
# What do I need to import to gain access to my models? ## Question I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved? ## Answer This is what I ha...
stackoverflow-qa
# What do I need to import to gain access to my models? ## Question I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved? ## Answer The cleanest solu...
stackoverflow-qa
# Os.path : can you explain this behavior? ## Question I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me. I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubun...
stackoverflow-qa
# Os.path : can you explain this behavior? ## Question I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me. I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubun...
stackoverflow-qa
# Os.path : can you explain this behavior? ## Question I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me. I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubun...
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer I wrote this and the domain is gone but here's the guts.... Regardless of how my colleagues who really care about proper database design feel about UUID's...
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer See also the recipe for Backend-agnostic GUID Type in the SQLAlchemy documentation for column types. Tags: python, postgresql, orm, sqlalchemy, uuid
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer Unfortunately Backend-agnostic GUID Type from the SQLAlchemy documentation for column types does not seem to work for primary keys in SQLite database engin...
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer In case anyone is interested, I've been using Tom Willis answer, but found useful to add a string to uuid.UUID conversion in the process_bind_param method ...
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer Here is an approach based on the Backend agnostic GUID from the SQLAlchemy docs, but using a BINARY field to store the UUIDs in non-postgresql databases. ...
stackoverflow-qa
# How can I use UUIDs in SQLAlchemy? ## Question Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? ## Answer I've used the UUIDType from the SQLAlchemy-Utils package: http://sqlalchemy-utils.readthedocs.org/en/latest/data_types.html#module-sqlalchemy_utils.types.u...
stackoverflow-qa
# Is this the best way to get unique version of filename w/ Python? ## Question Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from bei...
stackoverflow-qa
# Is this the best way to get unique version of filename w/ Python? ## Question Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from bei...
stackoverflow-qa
# Is this the best way to get unique version of filename w/ Python? ## Question Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from bei...
stackoverflow-qa
# Is this the best way to get unique version of filename w/ Python? ## Question Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from bei...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer The double slash, //, is floor division: >>> 7//3 2 Tags: python, math, syntax, operators
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer // implements "floor division", regardless of your type. So 1.0/2.0 will give 0.5, but both 1/2, 1//2 ...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer In Python 3.0, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division,...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer Please refer The Problem with Integer Division for the reason for introducing the // operator to do in...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer As everyone has already answered, // is floor division. Why this is important is that // is unambiguo...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer It helps to clarify for the Python 2.x line, / is neither floor division nor true division. The curren...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer >>> print 5.0 / 2 2.5 >>> print 5.0 // 2 2.0 Tags: python, math, syntax, operators
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer The answer of the equation is rounded to the next smaller integer or float with .0 as decimal point. ...
stackoverflow-qa
# In Python, what is the difference between '/' and '//' when used for division? ## Question Is there a benefit to using one over the other? They both seem to return the same results. >>> 6/3 2 >>> 6//3 2 ## Answer / --> Floating point division // --> Floor division Lets see some examples in both python 2.7 and i...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# Framework/Language for new web 2.0 sites (2008 and 2009) ## Question I know I'll get a thousand "Depends on what you're trying to do" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now: It is now Octobe...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# How do I check out a file from perforce in python? ## Question I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to ...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# Regular expression to match start of filename and filename extension ## Question What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'? The regular expression should match any of the following: RunFoo.py RunBar.py Run42.py It shoul...
stackoverflow-qa
# MVC model structure in Python ## Question I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have: Model/__init__p.y should hold all Model class names so I can do a "from Model import User" ...
stackoverflow-qa
# MVC model structure in Python ## Question I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have: Model/__init__p.y should hold all Model class names so I can do a "from Model import User" ...
stackoverflow-qa
# MVC model structure in Python ## Question I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have: Model/__init__p.y should hold all Model class names so I can do a "from Model import User" ...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Updated to only delete files and to used the os.path.join() method suggested in the comments. If you also want to remove subdirecto...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer You might be better off using os.walk() for this. os.listdir() doesn't distinguish files from directories and you will quickly get...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Try the shutil module import shutil shutil.rmtree('/path/to/folder') Description: shutil.rmtree(path, ignore_errors=False, ...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Expanding on mhawke's answer this is what I've implemented. It removes all the content of a folder but not the folder itself. Teste...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer You can simply do this : import os import glob files = glob.glob('/YOUR/PATH/*') for f in files: os.remove(f) You can of co...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Using rmtree and recreating the folder could work, but I have run into errors when deleting and immediately recreating folders on n...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer This is the only answer so far, which: removes all symbolic links dead links links to directories links to files removes subdi...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer import os import shutil # Gather directory contents contents = [os.path.join(target_dir, i) for i in os.listdir(target_dir)] # It...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer I konw it's an old thread but I have found something interesting from the official site of python. Just for sharing another idea fo...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer I used to solve the problem this way: import shutil import os shutil.rmtree(dirpath) os.mkdir(dirpath) Tags: python, file, local...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer As a oneliner: import os # Python 2.7 map( os.unlink, (os.path.join( mydir,f) for f in os.listdir(mydir)) ) # Python 3+ list( ma...
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Yet Another Solution: import sh sh.rm(sh.glob('/path/to/folder/*')) Tags: python, file, local, delete-directory
stackoverflow-qa
# Delete Folder Contents in Python ## Question How can I delete the contents of a local folder in Python? The current project is for Windows but I would like to see *nix also. ## Answer Notes: in case someone down voted my answer, I have something to explain here. Everyone likes short 'n' simple answers. However, ...
stackoverflow-qa
# Extracting unique items from a list of mappings ## Question He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings {'id': id, 'url': url}. Some ids in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the follow...
stackoverflow-qa
# Extracting unique items from a list of mappings ## Question He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings {'id': id, 'url': url}. Some ids in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the follow...
stackoverflow-qa
# Extracting unique items from a list of mappings ## Question He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings {'id': id, 'url': url}. Some ids in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the follow...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# What is the best way to open a file for exclusive access in Python? ## Question What is the most elegant way to solve this: open a file for reading, but only if it is not already opened for writing open a file for writing, but only if it is not already opened for reading or writing The built-in functions work li...
stackoverflow-qa
# Python - How to use Conch to create a Virtual SSH server ## Question I'm looking at creating a server in python that I can run, and will work as an SSH server. This will then let different users login, and act as if they'd logged in normally, but only had access to one command. I want to do this so that I can have ...
stackoverflow-qa
# 'from X import a' versus 'import X; X.a' ## Question I've seen some Python programmers use the following style fairly consistently (we'll call it style 1): import some_module # Use some_module.some_identifier in various places. For support of this style, you can cite the "explicit is better than implicit" maxim. ...
stackoverflow-qa
# 'from X import a' versus 'import X; X.a' ## Question I've seen some Python programmers use the following style fairly consistently (we'll call it style 1): import some_module # Use some_module.some_identifier in various places. For support of this style, you can cite the "explicit is better than implicit" maxim. ...
stackoverflow-qa
# 'from X import a' versus 'import X; X.a' ## Question I've seen some Python programmers use the following style fairly consistently (we'll call it style 1): import some_module # Use some_module.some_identifier in various places. For support of this style, you can cite the "explicit is better than implicit" maxim. ...
stackoverflow-qa
# 'from X import a' versus 'import X; X.a' ## Question I've seen some Python programmers use the following style fairly consistently (we'll call it style 1): import some_module # Use some_module.some_identifier in various places. For support of this style, you can cite the "explicit is better than implicit" maxim. ...
stackoverflow-qa
# 'from X import a' versus 'import X; X.a' ## Question I've seen some Python programmers use the following style fairly consistently (we'll call it style 1): import some_module # Use some_module.some_identifier in various places. For support of this style, you can cite the "explicit is better than implicit" maxim. ...
stackoverflow-qa
# Splitting a semicolon-separated string to a dictionary, in Python ## Question I have a string that looks like this: "Name1=Value1;Name2=Value2;Name3=Value3" Is there a built-in class/function in Python that will take that string and construct a dictionary, as though I had done this: dict = { "Name1": "Value1...
stackoverflow-qa
# Splitting a semicolon-separated string to a dictionary, in Python ## Question I have a string that looks like this: "Name1=Value1;Name2=Value2;Name3=Value3" Is there a built-in class/function in Python that will take that string and construct a dictionary, as though I had done this: dict = { "Name1": "Value1...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Configuration file with list of key-value pairs in python ## Question I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would m...
stackoverflow-qa
# Base-2 (Binary) Representation Using Python ## Question Building on How Do You Express Binary Literals in Python, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like to replace it with a better algorit...
stackoverflow-qa
# Base-2 (Binary) Representation Using Python ## Question Building on How Do You Express Binary Literals in Python, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like to replace it with a better algorit...
stackoverflow-qa
# How to make parts of a website under SSL and the rest not? ## Question I need to create a cherrypy main page that has a login area. I want the login area to be secure, but the rest of the page should not be so. How can I do this in CherryPy? Ideally, any suggestions will be compatible with http://tools.cherrypy.o...
stackoverflow-qa
# How to make parts of a website under SSL and the rest not? ## Question I need to create a cherrypy main page that has a login area. I want the login area to be secure, but the rest of the page should not be so. How can I do this in CherryPy? Ideally, any suggestions will be compatible with http://tools.cherrypy.o...
stackoverflow-qa
# Counting array elements in Python ## Question How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string. ## Answer The method len() returns the number of elements in the lis...
stackoverflow-qa
# Counting array elements in Python ## Question How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string. ## Answer Or, myArray.__len__() if you want to be oopy; "len(myAr...
stackoverflow-qa
# Counting array elements in Python ## Question How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string. ## Answer len is a built-in function that calls the given container ...
stackoverflow-qa
# Counting array elements in Python ## Question How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string. ## Answer Before I saw this, I thought to myself, "I need to make a ...
stackoverflow-qa