Is there a difference between python

2020-04-05 Thread Malcolm Greene
Is there a difference between the following 2 ways to launch a console-less script under Windows? python

Simple Python github library to push/pull files?

2020-01-28 Thread Malcolm Greene
Any recommendations on a library providing a simple interface to Github for basic push/pull type of actions? I know there's a native GitHub RESTful API but wondering if anyone has placed a friendly Python wrapper on top of that interface? PyGithub supports a rich set of actions, but doesn't appe

Recommendation on best cross-platform encryption package

2020-01-22 Thread Malcolm Greene
Is the cryptography package still considered the "best" cross-platform package for encrypting sensitive data being stored in files on disk. Use case: JSON data files containing potentially confidential/PII data using something along the lines of AES256 encryption. Goal is to encrypt data in memo

Re: Python 3.6 on Windows - does a python3 alias get created by installation?

2019-10-09 Thread Malcolm Greene
Thanks Paul and Dan. @Paul: Yes, it *IS* a bit confusing . Your pip explanation hit the spot. @Dan: Yes, symlinks would be a good work around. Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Python 3.6 on Windows - does a python3 alias get created by installation?

2019-10-09 Thread Malcolm Greene
I'm jumping between Linux, Mac and Windows environments. On Linux and Mac we can invoke Python via python3 but on Windows it appears that only python works. Interestingly, Windows supports both pip and pip3 flavors. Am I missing something? And yes, I know I can manually create a python3 alias by

Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave, > I agree that a traditional INI file is the easiest way, especially since > Python supports them. So if I understand you, your apps look like this: Yes with the following nuance for our application sized scripts that require multiple configuration files. In this latter case, we place

Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave, > The plan for an app that I'm doing was to use SQLite for data and to hold the > preference settings as some apps do. The plan was changed last week to allow > the user to select the location of the data files (SQLite) rather than > putting it where the OS would dictate. Ok with tha

Re: Books for Python 3.7

2019-07-15 Thread Malcolm Greene
Python Cookbook; highly recommended. Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: pyodbc -> MS-SQL Server Named Instance ?

2019-07-02 Thread Malcolm Greene
You may need to update your ODBC driver from version 13 to 17.x. Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for tips and gotchas for working with Python 3.5 zipapp feature

2019-07-01 Thread Malcolm Greene
> I am exactly in the "pretty advanced usage": I want to create a zip that > embed numpy. In this case, I have to bundle the C extension. How can I do > that? 1. PyInstaller 2. PyOxide (new technology, may or may not support Numpy) Let us know how you make out. Malcolm -- https://mail.python

Re: change spacing to two instead of four with pep8 or flake8?

2019-06-29 Thread Malcolm Greene
> I've also taken to having my files auto-formatted with yapf on save ... @Cameron: Have you considered black at all and if so, what are your thoughts? Thanks, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: pip vs python -m pip?

2019-06-21 Thread Malcolm Greene
> From: Chris Angelico > Are you doing this in cmd.exe, powershell, bash, or some other shell? Same result via cmd.exe and PowerShell (ps1). > There are a LOT of ways that the Windows path can fail to pick up the correct > 'pip'. Normally activating a venv should let you use "pip" to mean the r

Re: How to force "python -m site" ENABLE_USER_SITE to false?

2019-06-21 Thread Malcolm Greene
> From: Ed Leafe > StackOverflow: > https://stackoverflow.com/questions/25584276/how-to-disable-site-enable-user-site-for-an-environment Thanks Ed! My takeaway from the above article and our path going forward is to explictly force ENABLE_USER_SITE to false via Python's "-s" switch. Malcolm --

Re: pip vs python -m pip?

2019-06-21 Thread Malcolm Greene
> you must be picking up pip from a different python install (or virtualenv) > than you are picking up python. > Check your %PATH% That was our first guess. Only one version of Python installed on the system (we install on an empty, freshly serviced pack Windows VM). Only one version of python*

How to force "python -m site" ENABLE_USER_SITE to false?

2019-06-21 Thread Malcolm Greene
Any suggestions on how one can force the "python -m site" ENABLE_USER_SITE value to false? Is it possible to globally force this setting - across all users - when installing a system wide version of Python ... or via a command line option when starting a Python session? Motivation: When ENABLE

pip vs python -m pip?

2019-06-21 Thread Malcolm Greene
64-bit Python 3.6.8 running on Windows with a virtual environment activated. "pip -v" reports 19.0.3 "python -m pip" reports 19.1.1 Is this behavior by design or a bug? My takeaway is that its better to run "python -m pip ..." vs "pip ..." when running pip related tasks. Thoughts? Malcolm --

What's the latest best practice on Python project directory layouts?

2019-06-14 Thread Malcolm Greene
I have a collection of command line scripts that share a collection of common modules. This code collection is for internal use and will run under a single version of Python 3.6+ and a single OS. My understanding of best practice is to organize this collection of Python files into a folder struc

Re: Block Ctrl+S while running Python script at Windows console?

2019-03-19 Thread Malcolm Greene
> This has nothing to do with Python does it? Isn't Python is just writing to > stdout and those write calls are blocking due because the terminal emulator > has stopped reading the other end of the > pipe/pty/queue/buffer/whatever-it's-called-in-windows? You're right. But I wasn't sure. I know

Re: Block Ctrl+S while running Python script at Windows console? (solved)

2019-03-18 Thread Malcolm Greene
Eryk, > Another common culprit is quick-edit mode, in which case a stray mouse click > can select text, even just a single character. The console pauses while text > is selected. MYSTERY SOLVED !! THANK YOU !! Apparently, while mouse clicking between windows, I was inadvertently selecting a c

Block Ctrl+S while running Python script at Windows console?

2019-03-18 Thread Malcolm Greene
I'm running some Python 3.6 scripts at the Windows 10/Windows Server 2016 console. In my every day workflow, I seem to be accidentally sending Ctrl+S keystrokes to some of console sessions, pausing my running scripts until I send another corresponding Ctrl+S to un-pause the affected scripts. My

Multiprocessing vs subprocess to run Python scripts in parallel

2019-03-12 Thread Malcolm Greene
Use case: I have a Python manager script that monitors several conditions (not just time based schedules) that needs to launch Python worker scripts to respond to the conditions it detects. Several of these worker scripts may end up running in parallel. There are no dependencies between individu

Convert Windows paths to Linux style paths

2019-03-12 Thread Malcolm Greene
Looking for best practice technique for converting Windows style paths to Linux paths. Is there an os function or pathlib method that I'm missing or is it some combination of replacing Windows path separators with Linux path separators plus some other platform specific logic? Thank you, Malcolm

Re: Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
[Reformatted as original post got mangled] Looking for advice on the best way to remove unused modules from a Python virtual environment. My setup is Python 3.6.6 running on macOS although I believe my use case is OS independent. Background: Long running project that, over the course of time, p

Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
Looking for advice on the best way to remove unused modules from a Python virtual environment. My setup is Python 3.6.6 running on macOS although I believe my use case is OS independent. Background: Long running project that, over the course of time, pip installed modules that are no longer used b

Normalizing path strings and separators in cross-platform unit test scripts

2019-01-07 Thread Malcolm Greene
Any recommendations on normalizing path strings in cross platform (Windows, Linux, macOS) for unit tests? Our goal is to normalize path strings to use forward slash separators so that we can consistently reference path strings in our unit tests in a cross platform way. Example: Under Windows we hav

Best practice for upgrading SQLite C library (DLL, SO, etc) that ships with Python

2019-01-05 Thread Malcolm Greene
I noticed that there's a rather big gap between the latest version of SQLite and the version of SQLite that ships with Python 3.6/3.7. Is there best practice advice for upgrading the SQLlite C library that ships with Python ... without causing havoc and mayhem on my system? Options Don't do it - th

Logging - have logger use caller's function name and line number

2018-12-29 Thread Malcolm Greene
I have a class method that adds additional context to many of the class's log messages. Rather than calling, for example, logger.info( 'message ...' ) I would like to call my_object.log( 'message ...' ) so that this additional context is managed in a single place. I'm actually doing that and its w

What Python related git pre-commit hooks are you using?

2018-11-18 Thread Malcolm Greene
Curious to learn what Python related git pre-commit hooks people are using? What hooks have you found useful and which hooks have you tried and abandoned? Appreciate any suggestions for those new to this process. Background: Window, macOS, and Linux dev environments, PyCharm professional edition I

Anyone running Python on MS Azure?

2018-11-09 Thread Malcolm Greene
Curious to hear if any of you are running Python scripts/apps on MS Azure cloud services? What services are you using and what has your experience been? Advice? Background: Customer migrating to Azure. I'm trying to get ahead of the curve regarding how Python-friendly the Azure platform is. Thanks

Verify pip's requirements.txt file at runtime?

2018-09-11 Thread Malcolm Greene
Is there a technique that would allow a script to verify its requirements.txt file before it runs? Use case: To detect unexpected changes to a script's runtime environment. Does the pip module expose any methods for this type of task? Thank you, Malcolm -- https://mail.python.org/mailman/listinfo/

logging module - how to include method's class name when using %(funcName)

2018-09-10 Thread Malcolm Greene
I'm using the Python logging module and looking for a way to include a method's class name when using %(funcName). Is this possible? When you have several related classes, just getting the function (method) name is not enough information to provide context on the code being executed. I'm outputting

Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread Malcolm Greene
Use case: Want to prevent 2+ instances of a script from running ... ideally in a cross platform manner. I've been researching this topic and am surprised how complicated this capability appears to be and how the diverse the solution set is. I've seen solutions ranging from using directories, named

Cross platform mutex to prevent script running more than instance?

2018-09-03 Thread Malcolm Greene
Use case: Want to prevent 2+ instances of a script from running ... ideally in a cross platform manner. I've been researching this topic and am surprised how complicated this capability appears to be and how the diverse the solution set is. I've seen solutions ranging from using directories, named

Re: Verifying the integrity/lineage of a file

2018-08-31 Thread Malcolm Greene
Thanks for the replies! I'm going to investigate the use of python-gnupg [1] which is a Python wrapper for the GPG command line utility. This library is based on gpg.py written by Andrew Kuchling. I'm all ears if f anyone has any alternative recommendations or python-gnupg tips to share. BTW:

bytes() or .encode() for encoding str's as bytes?

2018-08-31 Thread Malcolm Greene
Is there a benefit to using one of these techniques over the other? Is one approach more Pythonic and preferred over the other for style reasons? message = message.encode('UTF-8') message = bytes(message, 'UTF-8') Thank you, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Verifying the integrity/lineage of a file

2018-08-31 Thread Malcolm Greene
I have use case where I need to distribute binary files to customers and want to provide a way for our customers to verify the "integrity/lineage" (I know there's a better description, but can't think of it) of these files, eg. to give them the confidence that the files in question are from me and

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Malcolm Greene
Thanks to everyone who contributed to this thread. Great feedback and suggestions! - Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-14 Thread Malcolm Greene
> You might try: > from getopt import getopt > or the (apparently newer): > from optparse import OptionParser Thanks Mike. My question was trying to make a distinction between Python options (flags that precede the script or module name) and arguments (the script specific values passed on the co

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-14 Thread Malcolm Greene
> If you run the script directly, by entering >script.py or clicking a script > icon or name in File Explorer, it runs python without python options *other > than those specified in environmental variables*. Understood. I thought there might have been a way to pass Python option values via a si

How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-14 Thread Malcolm Greene
When you run a script via "python3 script.py" you can include command line options like -b, -B, -O, -OO, etc between the "python3" interpreter reference and the script.py file, eg. "python3 -b -B -O -OO script.py". When you create a script that is executable directly, eg. script.py with execution b

Anyone using cloud based monitoring/logging services with Python logging module?

2018-07-26 Thread Malcolm Greene
Looking for feedback on anyone who's using a cloud based monitoring/logging service with Python's standard lib logging module, eg. services such as Datadog, Loggly, Papertrailapp, Scalyr, LogDNA, Logz.io, Logentries, Loggr, Logstats? Would appreciate hearing your experience, pros, cons, recommendat

Distributing Python virtual environments

2018-03-29 Thread Malcolm Greene
We're using virtual environments with Python 3.6. Since all our pip installed modules are in our environment's local site-packages folder, is the distribution of a virtual environment as simple as recursively zipping the environment's root folder and distributing that archive to another machine run

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
> Perhaps it doesn't need to be said, but just to be sure: don't use eval if > you don't trust the people writing the configuration file. They can do nearly > unlimited damage to your environment.  They are writing code that you are > running. Of course! Script and config file are running in a

Best practice for managing secrets (passwords, private keys) used by Python scripts running as daemons

2018-03-23 Thread Malcolm Greene
Looking for your suggestions on best practice techniques for managing secrets used by Python daemon scripts. Use case is Windows scripts running as NT Services, but interested in Linux options as well. Here's what we're considering 1. Storing secrets in environment vars 2. Storing secrets in confi

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
My original post reformatted for text mode: Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following tech

Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Malcolm Greene
Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following technique to expand these f-strings. Is there a bett

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Thank you Peter and Jussi - both your solutions were very helpful! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Wondering if there's a standard lib version of something like enumerate() that takes a max count value? Use case: When you want to enumerate through an iterable, but want to limit the number of iterations without introducing if-condition-break blocks in code. Something like: for counter, key in en

Best practice tips for sizing thread/process pools and concurrent futures max_workers?

2017-05-04 Thread Malcolm Greene
Looking for best practice tips on how to size thread/process pools or max workers with the concurrent futures module. Are there specific heuristics that can be applied or is this more a manual tuning process based on the run time behavior of a script and the nuances of one's environment? Are there

Elegant way to merge dicts without overwriting keys?

2017-05-04 Thread Malcolm Greene
I have a bunch of pickled dicts I would like to merge. I only want to merge unique keys but I want to track the keys that are duplicated across dicts. Is there a newer dict-like data structure that is fine tuned to that use case? Short of an optimized data structure, my plan is to convert dict keys

Re: Who still supports recent Python on shared hosting

2017-03-06 Thread Malcolm Greene
Another endorsement for Webfaction. -- https://mail.python.org/mailman/listinfo/python-list

Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-05 Thread Malcolm Greene
Looking for a quick way to calculate lines of code/comments in a collection of Python scripts. This isn't a LOC per day per developer type analysis - I'm looking for a metric to quickly judge the complexity of a set of scripts I'm inheriting. Thank you, Malcolm -- https://mail.python.org/mailman/

Re: Looking for tips and gotchas for working with Python 3.5 zipapp feature

2016-09-24 Thread Malcolm Greene
Hi Paul, > Just one further note, which may or may not be obvious. If your application > uses external dependencies from PyPI, you can bundle them with your > application using pip's --target option ... Cool stuff! To your question: None of what you've shared has been obvious to me :) Packagi

Re: Obtain the raw line of text read by CSVDictReader when reporting errors?

2016-09-22 Thread Malcolm Greene
Oscar/MRAB, > You could put something between the file and the reader ... Thank you both for your suggestions ... brilliant! You guys helped me solve my problem and gave me an excellent strategy for future scenarios. Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Obtain the raw line of text read by CSVDictReader when reporting errors?

2016-09-21 Thread Malcolm Greene
Looking for ideas on how I can obtain the raw line of text read by a CSVDictReader. I've reviewed the CSV DictReader documentation and there are no public attributes that expose this type of data. My use case is reporting malformed lines detected when my code validates the dict of data returned by

Re: Looking for tips and gotchas for working with Python 3.5 zipapp feature

2016-09-19 Thread Malcolm Greene
Hi Paul, WOW!:) I really appreciate the detailed response. You answered all my questions. I'm looking forward to testing out your pylaunch wrapper. Thank you very much! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Looking for tips and gotchas for working with Python 3.5 zipapp feature

2016-09-16 Thread Malcolm Greene
Looking for tips or edge case gotchas associated with using Python 3.5's new zipapp feature. For those of you wondering what this feature is, see the end of this post for a brief background [1]. Two questions in particular: 1. Are there any issues with deploying scripts that sit in sub- folder

Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Malcolm Greene
Thanks for your suggestions Chris and Terry. The answer I was looking for is the modulefinder module which is part of the standard lib. Works like a charm! Quote: This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script. modulefinder.py can a

Discover all non-standard library modules imported by a script

2016-09-16 Thread Malcolm Greene
Looking for suggestions on how, given a main script, discover all the non-standard library modules imported across all modules, eg. the modules that other modules import, etc. I'm not looking to discover dynamic imports or other edge cases, just the list modules loaded via "import " and "from impo

Re: Dynamically import specific names from a module vs importing full module

2016-08-23 Thread Malcolm Greene
Ned and Random832, Ned: Thank you - your example answered my question. Random832: Thank you for the reminder about "from import " still importing the module. Yes, I had forgotten that behavior. Best, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Malcolm Greene
Python 3.5: Is there a way to dynamically import specific names from a module vs importing the full module? By dynamic I mean via some form of importlib machinery, eg. I'm looking for the dynamic "from import " equivalent of "import "'s importlib.import_module. Thank you, Malcolm -- https://mai

Advice on optimizing a Python data driven rules engine

2016-08-11 Thread Malcolm Greene
Background: I'm building a rules engine for transforming rows of data being returned by csv DictReader, eg. each row of data is a dict of column name to value mappings. My rules are a list of rule objects whose attributes get referenced by rule specific methods. Each rule has an associated meth

Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-04 Thread Malcolm Greene
Wow!!! A huge thank you to all who replied to this thread! Chris: You gave me some ideas I will apply in the future. MRAB: Thanks for exposing me to the extended attributes of the UnicodeError object (e.start, e.end, e.object). Mike: Cool example! I like how _cleanlines() recursively calls itse

Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-04 Thread Malcolm Greene
Hi Chris, Thanks for your suggestions. I would like to capture the specific bad codes *before* they get replaced. So if a line of text has 10 bad codes (each one raising UnicodeError), I would like to track each exception's bad code but still return a valid decode line when finished. My goal is

Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-04 Thread Malcolm Greene
I'm processing a lot of dirty CSV files and would like to track the bad codes that are raising UnicodeErrors. I'm struggling how to figure out what the exact codes are so I can track them, them remove them, and then repeat the decoding process for the current line until the line has been fully deco

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
> You could use win_unicode_console enabled in sitecustomize or usercustomize. > https://pypi.python.org/pypi/win_unicode_console The pypi link you shared has an excellent summary of the issues associated when working Unicode from the Windows terminal. Thank you Eryk. Malcolm -- https://mail.py

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Chris, > Don't forget that the print function can simply be shadowed. I did forget! Another excellent option. Thank you! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Thank you Random832 and Peter - excellent ideas. My use case was diagnostic output being (temporarily) output to stdout via debug related print statements. The output is for debugging only and not meant for production. I was looking for a solution that would allow me to output to the console with

print() function with encoding= and errors= parameters?

2016-08-03 Thread Malcolm Greene
Looking for a way to use the Python 3 print() function with encoding and errors parameters. Are there any concerns with closing and re-opening sys.stdout so sys.stdout has a specific encoding and errors behavior? Would this break other standard libraries that depend on sys.stdout being configured

Re: logging: getLogger() or getLogger(__name__)?

2016-07-28 Thread Malcolm Greene
Thank you Laurent! - Original message - From: Laurent Pointal With __name__ you will have one logger per source file (module), with corresponding filtering possibilities, and organized hierarchically as are packages (logging use . to built its loggers hierarchy). Without __name__, y

Re: Behavior of tempfile temp files when scripts killed, interpreter crashes, server crashes?

2016-07-28 Thread Malcolm Greene
Hi Eryk, Awesome! Thank you very much for your detailed answer!! Malcolm Linux has the O_TMPFILE open() flag [1]. This creates an anonymous file that gets automatically deleted when the last open file descriptor is closed. If the file isn't opened O_EXCL, then you can make it permanent by linki

Behavior of tempfile temp files when scripts killed, interpreter crashes, server crashes?

2016-07-27 Thread Malcolm Greene
Can someone share their OS specific experience in working with tempfile generated temp files under these conditions? 1. Script killed by another process 2. Interpreter crashes 3. Server crashes (sudden loss of power) 4. Other application termination conditions ??? I'm curious which scenarios re

logging: getLogger() or getLogger(__name__)?

2016-07-27 Thread Malcolm Greene
I've read that best practice for logging is to place the following line at the top of all modules: logger = getLogger(__name__) I'm curious why the following technique wouldn't be a better choice: logger = getLogger() Are there scenarios that favor one style over another? Thank you, Malco

Re: Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Malcolm Greene
Hi Jussi, You answered my questions - thank you! Malcolm > 1. The signature for glob.glob() is "glob.glob(pathname, *, >recursive=False)". What is the meaning of the 2nd parameter listed >with an asterisk? It's not a parameter. It's special syntax to indicate that the remaining paramete

Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

2016-07-26 Thread Malcolm Greene
In reading Python 3.5.1's glob.glob documentation[1] I'm puzzled by the following: 1. The signature for glob.glob() is "glob.glob(pathname, *, recursive=False)". What is the meaning of the 2nd parameter listed with an asterisk? 2. Is there a technique for using glob.glob() to recognize fi

Re: Possible to capture cgitb style output in a try/except section?

2016-07-26 Thread Malcolm Greene
Hi Steven and Peter, Steven: Interestingly (oddly???) enough, the output captured by hooking the cgitb handler on my system appears to be shorter than the default cgitb output. You can see this yourself via this tiny script: import cgitb cgitb.enable(format='text') x = 1/0 The solution I came up

Possible to capture cgitb style output in a try/except section?

2016-07-26 Thread Malcolm Greene
Is there a way to capture cgitb's extensive output in an except clause so that cgitb's detailed traceback output can be logged *and* the except section can handle the exception so the script can continue running? My read of the cgitb documentation leads me to believe that the only way I can get c

Re: Caller's module name, function/method name and line number for output to logging

2016-07-26 Thread Malcolm Greene
Hi Peter, > Fine! Then you can avoid the evil hack I came up with many moons ago: > https://mail.python.org/pipermail/python-list/2010-March/570941.html Evil? Damn evil! Love it! Thank you, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: Caller's module name, function/method name and line number for output to logging

2016-07-25 Thread Malcolm Greene
Hi Terry, >> Is there a technique for accessing a function's *CALLER* module name, >> function/method name and line number so that this information can be > Look in the inspect module for the inspect stack function. Note that > when you call the function, it needs to look 2 levels up. Perfect!

Caller's module name, function/method name and line number for output to logging

2016-07-25 Thread Malcolm Greene
Is there a technique for accessing a function's *CALLER* module name, function/method name and line number so that this information can be passed to a logging library's logger? I have a routine that detects an error condition, but I want to report the error's context relative to the caller, not the

Re: Dynamically call methods where method is known by address vs name

2016-07-22 Thread Malcolm Greene
Hi Michael, > Out[3]: 'HELLO' > In [4]: g = str.upper > In [5]: g(s) > Out[5]: 'HELLO' That's perfect! My mistake was trying to use the method returned by ''.upper vs. str.upper. Thank you, Malcolm   -- https://mail.python.org/mailman/listinfo/python-list

Dynamically call methods where method is known by address vs name

2016-07-22 Thread Malcolm Greene
I know I can do the following: >>> s = 'lower' >>> getattr(s, 'upper')() 'LOWER' But how could I do the same if I had the method 'address' (better name???) vs. method name? >>> upper_method = s.upper How do I combine this upper_method with string s to execute the method and return 'LOWER'?

Re: Algorithm for sequencing a collection of dependent equations

2016-07-22 Thread Malcolm Greene
Hi Tim, > I think that what you're looking for is a topological sort BINGO! That's *exactly* what I was searching for. Thank you very much, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Algorithm for sequencing a collection of dependent equations

2016-07-22 Thread Malcolm Greene
We're working on a DSL (domain specific language) that we translate into a list of tokenized expressions. My challenge is to figure out how to sequence evaluation of these expressions so that we evaluate these expressions in the proper order given that expressions have dependencies on other express

Re: Max size of Python source code and compiled equivalent

2016-07-21 Thread Malcolm Greene
> Heh, great question, and I'm curious too! But one place to get a bit more > info is the standard library. > > rosuav@sikorsky:~/cpython/Lib$ find -name \*.py|xargs ls -lS|head > -rw-r--r-- 1 rosuav rosuav 624122 Jul 17 17:38 ./pydoc_data/topics.py Brilliant! :) Thanks Chris! Malcolm -- http

Max size of Python source code and compiled equivalent

2016-07-21 Thread Malcolm Greene
We're writing a DSL parser that generates Python code. While the size of our generated code will be small (< 32K), I wanted to re-assure the rest of our team that there are no reasonable code size boundaries that we need to be concerned about. I've searched for Python documentation that covers max

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Malcolm Greene
Thank you Chris and Peter. The source file we're generating has one main function (go) with some supporting functions and classes as well. Will there be any problems referencing additional functions or classes defined in the source that gets passed to exec ... as long as references to those functi

Technique for safely reloading dynamically generated module

2016-07-21 Thread Malcolm Greene
We're designing a server application that parses a custom DSL (domain specific language) source file, generates a Python module with the associated logic, and runs the associated code. Since this is a server application, we need to reload the module after each regeneration. Is this process is simpl

Re: Validating Entry in tkinter

2011-07-25 Thread Malcolm Greene
Peter, > I think it doesn't matter whether you type in text, or insert it with Ctrl+V > or the middle mouse button. The validatecommand handler is always triggered. > I suspect achieving the same effect with Button/KeyPress handlers would > require significantly more work. Thank you! Malcolm -

Re: IMAP4_SSL, libgmail, GMail and corporate firewall/proxy

2011-02-16 Thread Malcolm Greene
Andrea, What type of result do you get trying port 993 ? Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet Another MySQL Problem

2010-05-28 Thread Malcolm Greene
Tim, > The underscore is a valid variable-name, idiomatically used for "I don't care > about this", often seen in places like tuple assignment: The underscore is also used as an alias for gettext.gettext or gettext.ugettext so you may want to use another variable-name. Malcolm -- http://mail.p

What license/copyright text to include and where to include it when selling a commercial Python based application?

2010-04-12 Thread Malcolm Greene
Looking for advice on what Python license and copyright text to include and where to include it when selling a commercial (Windows based) Python based application. By license text and copyrights I am refering to the text on this page: PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 http://www.python

Re: Strategy for determing difference between 2 very large dictionaries

2008-12-24 Thread Malcolm Greene
Hi Gabriel, > in Python 3.0 keys() behaves as iterkeys() in previous versions, so the above > code is supposed to be written in Python 2.x) I understand. Thank you. > note that dict comprehensions require Python 3.0 I'm relieved to know that I didn't miss that feature in my reading of Python's

Re: Strategy for determing difference between 2 very large dictionaries

2008-12-24 Thread Malcolm Greene
Hi Roger, By very large dictionary, I mean about 25M items per dictionary. Each item is a simple integer whose value will never exceed 2^15. I populate these dictionaries by parsing very large ASCII text files containing detailed manufacturing events. From each line in my log file I construct one

Re: Can you recommend a book?

2008-04-25 Thread Malcolm Greene
My two favorites: - Core Python Programming by Chun - Learning Python by Lutz Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Recommended "from __future__ import" options for Python 2.5.2?

2008-04-12 Thread Malcolm Greene
Is there any consensus on what "from __future__ import" options developers should be using in their Python 2.5.2 applications? Is there a consolidated list of "from __future__ import" options to choose from? Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Parsing locale specific dates, currency, numbers

2008-04-09 Thread Malcolm Greene
The locale module provides the ability to format dates, currency and numbers according to a specific locale. Is there a corresponding module for parsing locale's output to convert locale formatted dates, currency, and numbers back to their native data types on the basis of a specified locale? In

Tips for load balancing multiple Python apps on dual/quad core processors?

2008-04-07 Thread Malcolm Greene
I'm looking for tips on how to load balance running multiple Python applications in multi-CPU environments. My understanding is that Python applications and their threads are limited to a specific CPU. Background: I have a Python utility that processes email messages. I suspect there's a lot of id

Re: Python for Palm OS

2008-03-15 Thread Malcolm Greene
E-Lo, PalmPython http://c2.com/cgi/wiki?PalmPython I have no experience with Python for Palm OS's. This is just a reference from my personal notes. Malcolm -- http://mail.python.org/mailman/listinfo/python-list

wxPython/wxWidgets ok for production use ? (was Re: Quality assurance in Python projects containing C modules)

2008-03-10 Thread Malcolm Greene
Stefan, > My personal experience with wxPython has its ups and downs. Specifically when > it comes to crashes, I wouldn't bet my life on it. (but then, the OP I'm new to Python and getting ready to build a small client based application intended to run on Windows and Linux. I was planning on usi

  1   2   >