Case insensitive dict

2013-05-21 Thread Joseph L. Casale
I was doing some work with the ldap module and required a ci dict that was case insensitive but case preserving. It turned out the cidict class they implemented was broken with respect to pop, it is inherited and not re implemented to work. Before I set about re-inventing the wheel, anyone know o

Ldap module and base64 oncoding

2013-05-24 Thread Joseph L. Casale
I have some data I am working with that is not being interpreted as a string requiring base64 encoding when sent to the ldif module for output. The base64 string parsed is ZGV0XDMzMTB3YmJccGc= and the raw string is det\3310wbb\pg. I'll admit my understanding of the handling requirements of non a

RE: Ldap module and base64 oncoding

2013-05-25 Thread Joseph L. Casale
> Can you give an example of the code you have? I actually just overrode the regex used by the method in the LDIFWriter class to be far more broad about what it interprets as a safe string. I really need to properly handle reading, manipulating and writing non ascii data to solve this... Shame

RE: authentication with python-ldap

2013-05-25 Thread Joseph L. Casale
> I have been doing the same thing and I tried to use java for testing the > credentials and they are correct. It works perfectly with java. > I really don´t know what we´re doing wrong. > > > You are accessing a protected operation of the LDAP server > and it (the server) rejects it due to invali

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
> I'm not sure what exactly you're asking for. > Especially "is not being interpreted as a string requiring base64 encoding" is > written without giving the right context. > > So I'm just guessing that this might be the usual misunderstandings with use > of base64 in LDIF. Read more about when LDI

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
Hi Michael, > Processing LDIF is one thing, doing LDAP operations another. > > LDIF itself is meant to be ASCII-clean. But each attribute value can carry any > byte sequence (e.g. attribute 'jpegPhoto'). There's no further processing by > module LDIF - it simply returns byte sequences. > > The a

RE: Ldap module and base64 oncoding

2013-05-27 Thread Joseph L. Casale
> Note that all modules in python-ldap up to 2.4.10 including module 'ldif' > expect raw byte strings to be passed as arguments. It seems to me you're > passing a Unicode object in the entry dictionary which will fail in case an > attribute value contains NON-ASCII chars. Yup, I was. > python-lda

Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyone currently doing this with Python 2.7 in windows

RE: Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
> You leave out an awful amount of detail. I have no idea what ST is, so > I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not su

Popen in Python3

2013-06-19 Thread Joseph L. Casale
I am trying to invoke a binary that requires dll's in two places all of which are included in the path env variable in windows. When running this binary with popen it can not find either, passing env=os.environ to open made no difference. Anyone know what might cause this or how to work around thi

Decorator help

2013-07-03 Thread Joseph L. Casale
I have a set of methods which take args that I decorate twice, def wrapped(func): def wrap(*args, **kwargs): try: val = func(*args, **kwargs) # some work except BaseException as error: log.exception(error) return [] return wra

RE: Decorator help

2013-07-03 Thread Joseph L. Casale
>> If you don't want to do that, you'd need to use introspection of a >> remarkably hacky sort. If you want that, well, it'll take a mo. > > After some effort I'm pretty confident that the hacky way is impossible. Hah, I fired it in PyCharm's debugger and spent a wack time myself, thanks for the c

RE: Decorator help

2013-07-04 Thread Joseph L. Casale
>Well, technically it's > >func.func_closure[0].cell_contents.__name__ > >but of course you cannot know that for the general case. Hah, I admit I lacked perseverance in looking at this in PyCharms debugger as I missed that. Much appreciated! jlc -- http://mail.python.org/mailman/listinfo/python

List comp help

2013-07-14 Thread Joseph L. Casale
I have a dict of lists. I need to create a list of 2 tuples, where each tuple is a key from the dict with one of the keys list items. my_dict = { 'key_a': ['val_a', 'val_b'], 'key_b': ['val_c'], 'key_c': [] } [(k, x) for k, v in my_dict.items() for x in v] This works, but I need to t

RE: List comp help

2013-07-14 Thread Joseph L. Casale
> Yeah, it's remarkably easy too! Try this: > > [(k, x) for k, v in my_dict.items() for x in v or [None]] > > An empty list counts as false, so the 'or' will then take the second option, > and iterate over the one-item list with > > None in it. Right, I overlooked that! Much appreciated, jlc --

sqlite3 version lacks instr

2013-07-28 Thread Joseph L. Casale
I have some queries that utilize instr wrapped by substr but the old version shipped in 2.7.5 doesn't have instr support. Has anyone encountered this and utilized other existing functions within the shipped 3.6.21 sqlite version to accomplish this? Thanks, jlc -- http://mail.python.org/mailman/l

RE: sqlite3 version lacks instr

2013-07-28 Thread Joseph L. Casale
> Has anyone encountered this and utilized other existing functions > within the shipped 3.6.21 sqlite version to accomplish this? Sorry guys, forgot about create_function... -- http://mail.python.org/mailman/listinfo/python-list

Robust regex

2012-11-19 Thread Joseph L. Casale
Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(

RE: Robust regex

2012-11-19 Thread Joseph L. Casale
> Regexes may be overkill here. A simple string split might be better: Yup, and much more robust as I was looking for. Thanks everyone! jlc -- http://mail.python.org/mailman/listinfo/python-list

Dict comprehension help

2012-12-05 Thread Joseph L. Casale
I get a list of dicts as output from a source I need to then extract various dicts out of. I can easily extract the dict of choice based on it containing a key with a certain value using list comp but I was hoping to use dict comp so the output was not contained within a list. reduce(lambda x,y:

RE: Dict comprehension help

2012-12-05 Thread Joseph L. Casale
> {k: v for d in my_list if d['key'] == value for (k, v) in d.items()} Ugh, had part of that backwards:) Nice! > However, since you say that all dicts have a unique value for > z['key'], you should never need to actually merge two dicts, correct? > In that case, why not just use a plain for loop

RE: Dict comprehension help

2012-12-06 Thread Joseph L. Casale
>You could put the loop into a helper function, but if you are looping >through the same my_list more than once why not build a lookup table > >my_dict = {d["key"]: d for d in my_list} > >and then find the required dict with > >my_dict[value] I suppose, what I failed to clarify was that for each l

Creating an iterator in a class

2012-12-27 Thread Joseph L. Casale
I am writing a class to provide a db backed configuration for an application. In my programs code, I import the class and pass the ODBC params to the class for its __init__ to instantiate a connection. I would like to create a function to generically access a table and provide an iterator. How do

RE: Creating an iterator in a class

2012-12-27 Thread Joseph L. Casale
>Have the method yield instead of returning: Thanks, that was simple, I was hung up on implementing magic methods. Thanks for the pointers guys! jlc -- http://mail.python.org/mailman/listinfo/python-list

RE: Creating an iterator in a class

2012-12-27 Thread Joseph L. Casale
> It's probably best if you use separate cursors anyway. Say you have > two methods with a shared cursor: > > def iter_table_a(self): > self.cursor.execute("SELECT * FROM TABLE_A") > yield from self.cursor > > def iter_table_b(self): > self.cursor.execute("SELECT *

Function Parameters

2012-12-27 Thread Joseph L. Casale
When you use optional named arguments in a function, how do you deal with with the incorrect assignment when only some args are supplied? If I do something like: def my_func(self, **kwargs): then handle the test cases with: if not kwargs.get('some_key'): raise SyntaxError or:

RE: Function Parameters

2012-12-27 Thread Joseph L. Casale
> Don't use kwargs for this. List out the arguments in the function > spec and give the optional ones reasonable defaults. > I only use kwargs myself when the set of possible arguments is dynamic > or unknown. Gotch ya, but when the inputs to some keywords are similar, if the function is called

Numpy outlier removal

2013-01-06 Thread Joseph L. Casale
I have a dataset that consists of a dict with text descriptions and values that are integers. If required, I collect the values into a list and create a numpy array running it through a simple routine: data[abs(data - mean(data)) < m * std(data)] where m is the number of std deviations to includ

RE: Numpy outlier removal

2013-01-06 Thread Joseph L. Casale
>Assuming your data and the dictionary are keyed by a common set of keys:  > >for key in descriptions: >    if abs(data[key] - mean(data)) >= m * std(data): >        del data[key] >        del descriptions[key] Heh, yeah sometimes the obvious is too simple to see. I used a dict comp to rebuild

RE: Numpy outlier removal

2013-01-07 Thread Joseph L. Casale
> In other words: this approach for detecting outliers is nothing more than  > a very rough, and very bad, heuristic, and should be avoided. Heh, very true but the results will only be used for conversational purposes. I am making an assumption that the data is normally distributed and I do expec

Dict comp help

2013-01-24 Thread Joseph L. Casale
Hi, Slightly different take on an old problem, I have a list of dicts, I need to build one dict from this based on two values from each dict in the list. Each of the dicts in the list have similar key names, but values of course differ. [{'a': 'xx', 'b': 'yy', 'c': 'zz'},  {'a': 'dd', 'b': 'ee'

RE: Dict comp help

2013-01-24 Thread Joseph L. Casale
> >>> data = [{'a': 'xx', 'b': 'yy', 'c': 'zz'},  {'a': 'dd', 'b': 'ee', 'c':  > >>> 'ff'}]  > >>> {d["a"]: d["c"] for d in data} > {'xx': 'zz', 'dd': 'ff'} Priceless, That is exactly what I needed, for which I certainly over complicated! Thanks everyone! jlc -- http://mail.python.org/mailman/

Overriding property types on instances from a library

2021-02-20 Thread Joseph L. Casale
I have some code that makes use of the typing module. This code creates several instances of objects it creates from a library that has some issues. For example, I have multiple list comps that iterate properties of those instance and the type checker fails with: Expected type 'collections.It

RE: How to implement logging for an imported module?

2021-03-07 Thread Joseph L. Casale
> I couldn't find any information on how to implement logging in a library that > doesn't know the name of the application that uses it. How is that done? Hello, That's not how it works, it is the opposite. You need to know the name of its logger, and since you imported it, you do. Logging is hi

Script profiling details

2022-01-10 Thread Joseph L. Casale
I am trying to track down a slow script startup time. I have executed the script using `python -m cProfile -o profile /path/script.py` and read through the results, but the largest culprit only shows various built-ins. I expected this given the implementation, but I was hoping to get some finer de

RE: Script profiling details

2022-01-11 Thread Joseph L. Casale
> You might try `py-spy`. That worked well, I started trying to get more data from the profile output with the stats module but didn't quite get there. Thank you everyone, jlc -- https://mail.python.org/mailman/listinfo/python-list

MySQL connector issue

2016-10-23 Thread Joseph L. Casale
I have some code that I am testing on Windows without c extensions which runs on a RHEL server with c extensions. In a simplified test case as follows: connection = mysql.connector.connect(...) cursor = connection.cursor(cursor_class=MySQLCursorDict) while True: cursor.execute('SELECT foo,biz

RE: MySQL connector issue

2016-10-23 Thread Joseph L. Casale
> Perhaps you simplified too much, but changes between the select and the > update could be lost. I think you need at least three states: > > 1 mark rows where baz is null (by setting baz to some value other than NULL > or 42, 24, say: set baz = 24 where baz is NULL) > 2 show marked rows (select

RE: MySQL connector issue

2016-10-23 Thread Joseph L. Casale
> Interesting. Generally, I allocate cursors exactly at the same time as I open > transactions; > not sure if this works with the mysql connector, but with psycopg2 > (PostgreSQL), my code looks like this: > > with conn, conn.cursor() as cur: > cur.execute(...) > ... = cur.fetchall() > >

thread local storage

2016-10-26 Thread Joseph L. Casale
Looks like the shipped implementation doesn't give access to all the discrete copies of tls for us in a case where a context manager needs to perform any cleanup. Does something exists where I can leverage this feature or do I need to roll my own? Thanks, jlc -- https://mail.python.org/mailman

RE: reactiveX vs Async

2017-01-11 Thread Joseph L. Casale
> Try these links on for size: > > https://msdn.microsoft.com/en-us/library/hh242982(v=vs.103).aspx which links > to > https://msdn.microsoft.com/en-us/library/hh242983(v=vs.103).aspx near the end. These two SO threads have a variation of pretty good explanations: http://stackoverflow.com/questi

RE: reactiveX vs Async

2017-01-11 Thread Joseph L. Casale
>> There is the recent flurry around the new async additions to python > > I meant to add: “… which I dont pretend to understand…” Try these links on for size: https://msdn.microsoft.com/en-us/library/hh242982(v=vs.103).aspx which links to https://msdn.microsoft.com/en-us/library/hh242983(v=vs.10

RE: reactiveX vs Async

2017-01-11 Thread Joseph L. Casale
> Thanks Joseph > Trouble is there is stew of technologies/languages… > (meta)-stewed with more abstract concepts, eg push vs pull, > Enumerable-Observable > duality, continuous vs discrete time > The last causing its own share of confusion with “functional reactive > programming” (FRP) meaning s

RE: reactiveX vs Async

2017-01-11 Thread Joseph L. Casale
> One more question: Do you know if (and how much) of these things would work > in Linux/C# (ie mono)? Mono, I forgot what that is when .net core debuted:) Looks like the .net Rx guys have a port, https://github.com/Reactive-Extensions/Rx.NET/issues/148 A package for .net core is up on nuget.

RE: reactiveX vs Async

2017-01-11 Thread Joseph L. Casale
> So you are saying that nuget-ing .Net core would be a workable pre-requisite > for > Rx on mono? Microsoft open sourced .net a while ago. With that came the movement to bring .net to other platforms. https://en.wikipedia.org/wiki/.NET_Framework#.NET_Core As its currently being heavily develop

RE: Can not run the Python software

2017-01-13 Thread Joseph L. Casale
> Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello > World" program and got the following message: > "Process finished with exit code 1073741515 (0xC135)" > I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, > x64-based processor). If you track

RE: Can not run the Python software

2017-01-13 Thread Joseph L. Casale
> And this is coming up a lot. This is something that should already be > on all supported versions of Windows if Windows updates are done, right? No, it's not an update. You install the runtime *if* you need it. > but maybe it's time that the > Python installer bundles the redistributable inst

RE: multiprocessing.Process call blocks other processes from running

2017-01-14 Thread Joseph L. Casale
> while True: >for client in clients: > stats = ThreadStats() > stats.start() > p = Process(target=getWhispererLogsDirSize, args=(client,queue,)) > jobs.append(p) > p.start() > p.join() You start one client then join before starting the next... Start them all an

RE: Sockets: IPPROTO_IP not supported

2017-01-16 Thread Joseph L. Casale
> Trying to sniff Ethernet packets, I do this: > >s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP) > > but it results in this: > > $ sudo python3 sniff_survey.py > Traceback (most recent call last): > File "sniff_survey.py", line 118, in > s = socket

RE: What are your opinions on .NET Core vs Python?

2017-01-29 Thread Joseph L. Casale
> .NET is a library that can be used from many languages, including Python. No. .NET Core (what the OP asked about which is not .NET) is a cross-platform framework. Obviously Python and .NET differ in runtime semantics with respect to the original source code, however they are now roughly equiva

RE: What are your opinions on .NET Core vs Python?

2017-01-29 Thread Joseph L. Casale
> What .NET APIs are anticipated to be released that aren't on the > official CLI list now: > https://en.wikipedia.org/wiki/List_of_CLI_languages#Current_Languages, > and/or, are .NET supported languages expected to expand beyond the CLI > list? I think this (and the last point) misinterprets the

RE: What are your opinions on .NET Core vs Python?

2017-01-30 Thread Joseph L. Casale
> What do you mean by "both platforms"? Python scripts already run on > three major operating systems (Win/Lin/Mac) and a good number of > less-popular OSes; a well-written Python script will run in four major > Pythons (CPython, PyPy, Jython, IronPython) and a number of others; > and all manner of

RE: What are your opinions on .NET Core vs Python?

2017-01-30 Thread Joseph L. Casale
> Python still has my heart, but .NET Core tempts me. One great thing of > coding in C# would be no GIL. Seriously, check out the benchmarks at https://github.com/aspnet/benchmarks. I think aside from the obvious, you'll find the Razor engine and the overall library to be a pleasure to work with

RE: What are your opinions on .NET Core vs Python?

2017-01-30 Thread Joseph L. Casale
> C# hardly seems any better than Java to me as far as a language goes. Which sounds pretty good to me, they are both high performance, mature and rich languages. > Being forced into working with classes even when they are not > appropriate is jarring. And 100% irrelevant, it doesn't prevent you

Context manager on method call from class

2018-03-15 Thread Joseph L. Casale
I have a class which implements a context manager, its __init__ has a signature and the __enter__ returns an instance of the class. Along with several methods which implement functionality on the instance, I have one method which itself must open a context manager against a call on an instance att

Re: Context manager on method call from class

2018-03-15 Thread Joseph L. Casale
From: Python-list on behalf of Rob Gaddi Sent: Thursday, March 15, 2018 12:47 PM To: python-list@python.org Subject: Re: Context manager on method call from class   > from contextlib import contextmanager. > > Then you just use the @contextmanager decorator on a function, have it > set up,

RE: issues when buidling python3.* on centos 7

2018-03-26 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of joseph pareti Sent: Sunday, March 25, 2018 10:15 AM To: python-list@python.org Subject: issues when buidling python3.* on centos 7 > The following may give a clue because of inconsistent python versions: > > [joepareti54@xxx ~]$ python -V

Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in character_class))) I would use that in a re.sub to collapse and replace all but

RE: Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of MRAB Sent: Friday, April 13, 2018 12:05 PM To: python-list@python.org Subject: Re: Python regex pattern from array of hex chars > Use re.escape: > > regex = re.compile('[^{}]+'.format(re.escape(''.join(c for c in > character_class Br

Re: Instance variables question

2018-04-16 Thread Joseph L. Casale
From: Python-list on behalf of Irv Kalb Sent: Monday, April 16, 2018 10:03 AM To: python-list@python.org Subject: Instance variables question   > class PartyAnimal(): >     x = 0 > >     def party(self): >     self.x = self.x + 1 >     print('So far', self.x) Your not accessing the

RE: Issue with python365.chm on window 7

2018-04-24 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of Brian Gibbemeyer Sent: Tuesday, April 24, 2018 11:01 AM To: Ethan Furman Cc: python-list@python.org Subject: Re: Issue with python365.chm on window 7 > The file at > https://www.python.org/ftp/python/3.6.4/python364.chm > > Loads up into

RE: Issue with python365.chm on window 7

2018-04-24 Thread Joseph L. Casale
From: Brian Gibbemeyer Sent: Tuesday, April 24, 2018 12:36 PM To: Joseph L. Casale Cc: python-list@python.org Subject: RE: Issue with python365.chm on window 7 > I right clicked on the file, no option to unblock. Sorry, choose properties, then unblock. -- https://mail.python.org/mail

RE: lxml namespace as an attribute

2018-08-15 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of Skip Montanaro Sent: Wednesday, August 15, 2018 3:26 PM To: Python Subject: lxml namespace as an attribute > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top

Serializing complex objects

2018-09-21 Thread Joseph L. Casale
I need to serialize a deep graph only for the purposes of visualizing it to observe primitive data types on properties throughout the hierarchy. In my scenario, I cannot attach a debugger to the process which would be most useful. Using json is not the easiest as I need to chase endless custom seri

RE: Serializing complex objects

2018-09-21 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of Rhodri James Sent: Friday, September 21, 2018 11:39 AM To: python-list@python.org Subject: Re: Serializing complex objects > Depending on what exactly your situation is, you may be able to use the > pickle module (in the standard library)

Ctypes c_void_p overflow

2016-05-05 Thread Joseph L. Casale
I have CDLL function I use to get a pointer, several other functions happily accept this pointer which is really a long when passed to ctypes.c_void_p. However, only one with same type def in the prototype overflows. Docs suggest c_void_p takes an int but that is not what the first call returns,

RE: Ctypes c_void_p overflow

2016-05-05 Thread Joseph L. Casale
> I generally avoid c_void_p because its lenient from_param method > (called to convert arguments) doesn't provide much type safety. If a > bug causes an incorrect argument to be passed, I prefer getting an > immediate ctypes.ArgumentError rather than a segfault or data > corruption. For example, w

argparse and subparsers

2016-06-26 Thread Joseph L. Casale
I have some code where sys.argv is sliced up and manually fed to discrete argparse instances each with a single subparser. The reason the discrete parsers all having a single subparser was to make handling the input simpler, the first arg in the slice could be left in. This has become unmaintai

RE: argparse and subparsers

2016-06-27 Thread Joseph L. Casale
> Not sure if this fits the bill, or makes sense here, but I came cross > "docopt" which touts itself as a "Command-line interface description > language". I used it in a project and it seems to be pretty easy to use > as well as elegant. It stores the arguments & values as a dictionary, > keyed by

RE: SOAP and Zeep

2016-07-29 Thread Joseph L. Casale
> Or any other libraries that can be recommended? I'd recommend Spyne, code and docs are good, but more importantly the lead dev is responsive and very helpful. Can't speak highly enough about him... http://spyne.io/ hth, jlc -- https://mail.python.org/mailman/listinfo/python-list

RE: asyncio Question

2019-03-15 Thread Joseph L. Casale
> -Original Message- > From: Python-list bounces+jcasale=activenetwerx@python.org> On Behalf Of Simon > Connah > Sent: Thursday, March 14, 2019 3:03 AM > To: Python > Subject: asyncio Question > > Hi, > > Hopefully this isn't a stupid question. For the record I am using Python > 3.7

Type hinting

2019-04-08 Thread Joseph L. Casale
Hi, Is it possible to associate combinations of types for a given signature, for example: T = TypeVar('T', Foo, Bar, Baz) S = TypeVar('S', FooState, BarState, BazState) closure = 'populated dynamically' def foo(factory: Callable[[List[T], str], None], state: S) -> List[T]: results = []

Class initialization with multiple inheritance

2019-07-15 Thread Joseph L. Casale
I am trying to find explicit documentation on the initialization logic for a Base class when multiple exist. For the example in the documentation at https://docs.python.org/3/tutorial/classes.html#multiple-inheritance, if Base1 and Base2 both themselves inherited from the same base class, only Base

RE: Class initialization with multiple inheritance

2019-07-20 Thread Joseph L. Casale
-Original Message- From: Barry Scott Sent: Tuesday, July 16, 2019 11:53 AM To: Joseph L. Casale Cc: python-list@python.org Subject: Re: Class initialization with multiple inheritance > And here is the MRO for LeftAndRight. > > >>> import m > LeftAndRight.__ini

policy based variable composition

2020-04-03 Thread Joseph L. Casale
I am looking to replace a home built solution which allows a program to derive a series of variable values through configuration or policy. The existing facility allows dependences so one of the requested variables can depend on another, they are ordered and computed. It also allows callbacks so c

Constructing mime image attachment

2020-05-28 Thread Joseph L. Casale
I have some json encoded input for nodemailer (https://nodemailer.com/message/embedded-images) where the path key is a string value which contains the base64 encoded data such as: { html: 'Embedded image: ', attachments: [{ filename: 'image.png', path: 'data:image/png;bas

RE: Python Client Rest API Invocation - POST with empty body - Invalid character found in method name [{}POST]. HTTP method names must be tokens

2020-11-20 Thread Joseph L. Casale
> Invalid character found in method name [{}POST]. HTTP method names must be > tokens. /snip > I could see in from wireshark dumps it looked like - {}POST > HTTP/1.1 The error message and your own debugging indicate the error. Your method *name* is {}POST, you have somehow included two brac

RE: setuptools issue

2020-12-17 Thread Joseph L. Casale
> Installed on this Slackware-14.2/x86_64 workstation with python-3.9.1 are: > python-setuptools-22.0.5-x86_64-1 I just ran into this recently, I don't recall the actual source but it was the version of setuptools having been so old. Your version is from Jun 3, 2016... Update it, that was what w

pexpect with kadmin

2020-12-22 Thread Joseph L. Casale
Anyone ever used pexpect with tooling like kadmin and have insight into how to manage interacting with it? After setting up debug logging, I was able to adjust the expect usage to get the input and output logs to at least appear correct when setting a password for a principal, however even with a

RE: pexpect with kadmin

2020-12-23 Thread Joseph L. Casale
> If you have windows 10 can you use Windows Subsystem for Linux (WSL) > to install one of the Linux distros and use that? Interesting idea, sadly I am too far past the deadline on this to go through the red tape needed to get that in place. Thanks, jlc -- https://mail.python.org/mailman/listi

asyncio cancellation pattern

2020-12-28 Thread Joseph L. Casale
I've started writing some asyncio code in lieu of using threads and managing concurrency and primitives manually. Having spent a lot of time using c#'s async implementation, I am struggling to see an elegant pattern for implementing cancellation. With the necessity for the loop (that of which I un

Data structure question

2013-11-17 Thread Joseph L. Casale
I have a need for a script to hold several tuples with three values, two text strings and a lambda. I need to index the tuple based on either of the two strings. Normally a database would be ideal but for a self-contained script that's a bit much. Before I re-invent the wheel, are there any built-

RE: Data structure question

2013-11-17 Thread Joseph L. Casale
> Not entirely sure I understand you, can you post an example? > > If what you mean is that you need to locate the function (lambda) when > you know its corresponding strings, a dict will suit you just fine. > Either maintain two dicts for the two separate strings (eg if they're > "name" and "loca

RE: Data structure question

2013-11-17 Thread Joseph L. Casale
> How about two dictionaries, each containing the same tuples for > values? If you create a tuple first, then add it to both dicts, you > won't have any space-wasting duplicates. Thanks guys. -- https://mail.python.org/mailman/listinfo/python-list

Formatting text in a table with reportlab

2013-12-12 Thread Joseph L. Casale
I sent off a msg to the reportlab list but didn't find an answer, hoping someone here might have come across this... I am generating a table to hold text oriented by the specification of the label it gets printed on. I need to compress the vertical size of the table a little more but the larger te

Unit tests and coverage

2013-12-28 Thread Joseph L. Casale
I have a script that accepts cmdline arguments and receives input via stdin. I have a unit test for it that uses Popen to setup an environment, pass the args and provide the stdin. Problem is obviously this does nothing for providing coverage. Given the above specifics, anyone know of a way to wor

RE: Unit tests and coverage

2013-12-28 Thread Joseph L. Casale
> So, back to my original question; what do you mean by "providing > coverage"? Hi Roy, I meant touch every line, such as what https://pypi.python.org/pypi/coverage measures. As the script is being invoked with Popen, I lose that luxury and only gain the assertions tests but that of course doesn'

RE: Unit tests and coverage

2013-12-29 Thread Joseph L. Casale
> As the script is being invoked with Popen, I lose that luxury and only gain > the assertions tests but that of course doesn't show me untested branches. Should have read the docs more thoroughly, works quite nice. jlc -- https://mail.python.org/mailman/listinfo/python-list

Argparse class method based instantiation

2014-01-02 Thread Joseph L. Casale
I have an Python3 argparse implementation that is invoked as a method from an imported class within a users script __main__. When argparse is setup in __main__ instead, all the help switches produce help then exit. When a help switch is passed based on the above implementation, they are ignored

Implementing append within a descriptor

2014-01-20 Thread Joseph L. Casale
I have a caching non data descriptor that stores values in the implementing class instances __dict__. Something like: class Descriptor: def __init__(self, func, name=None, doc=None): self.__name__ = name or func.__name__ self.__module__ = func.__module__ self.__doc__

RE: Implementing append within a descriptor

2014-01-21 Thread Joseph L. Casale
> You're going to have to subclass list if you want to intercept its > methods. As I see it, there are two ways you could do that: when it's > set, or when it's retrieved. I'd be inclined to do it in __set__, but > either could work. In theory, you could make it practically invisible > - just check

RE: SQLite + FTS (full text search)

2014-01-23 Thread Joseph L. Casale
> But on Windows when I use the official Python 3.3 32-bit binary from > www.python.org this is not enabled. For an unobtrusive way [1] to gain this, see apsw. For what it's worth, I prefer this package over the built in module. Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.16

Documenting descriptors

2014-01-28 Thread Joseph L. Casale
I am documenting a few classes with Sphinx that utilize methods decorated with custom descriptors. These properties return data when called and Sphinx is content with a :returns: and :rtype: markup in the properties doc string. They also accept input, but parameter (not really applicable) nor var

Logging from a multiprocess application

2014-02-06 Thread Joseph L. Casale
I have a module that has one operation that benefits greatly from being multiprocessed. Its a console based module and as such I have a stream handler and filter associated to the console, obviously the mp based instances need special handling, so I have been experimenting with a socket server i

RE: Logging from a multiprocess application

2014-02-06 Thread Joseph L. Casale
> Maybe check out logstash (http://logstash.net/). That looks pretty slick, I am constrained to using something provided by the packaged modules in this scenario. I think I have it pretty close except for the fact that the LogRecordStreamHandler from the cookbook excepts when the sending proces

Subclassing tuple and introspection

2015-12-02 Thread Joseph L. Casale
I need to return a collection of various types, since python doesn't have the terse facility of extension methods like C#, subclassing tuple and adding a method seems like a terse way to accommodate this. However, if the method returns one element of the collection, how can one enable introspectio

Re: Subclassing tuple and introspection

2015-12-02 Thread Joseph L. Casale
> If you're not already familiar with collections.namedtuple, have a > look at it, as it sounds like just naming the fields may be all that > you need. You can also subclass it further to add methods if desired. Yeah, all the types in these collections are named tuples... The collection itself isn

Passing data across callbacks in ThreadPoolExecutor

2016-02-16 Thread Joseph L. Casale
What is the pattern for chaining execution of tasks with ThreadPoolExecutor? Callbacks is not an adequate facility as each task I have will generate new output. Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list

Re: Passing data across callbacks in ThreadPoolExecutor

2016-02-18 Thread Joseph L. Casale
On Thur, Feb 17, 2016 at 9:24 AM, Ian Kelly wrote: >> What is the pattern for chaining execution of tasks with ThreadPoolExecutor? >> Callbacks is not an adequate facility as each task I have will generate new >> output. > > Can you specify in more detail what your use case is? > > If you don't m

Re: Passing data across callbacks in ThreadPoolExecutor

2016-02-19 Thread Joseph L. Casale
> It's still not clear to me specifically what you're trying to do. It > would really help if you would describe the problem in more detail. > Here's what I think you're trying to do: > > 1) Submit a task to a ThreadPoolExecutor and get back a future. > > 2) When the task is complete, submit anot

  1   2   >