Find roots of ill-conditioned polynomials

2005-09-10 Thread Raymond L. Buvel
If you are using the root finder in Numeric, and are having problems, check out the root finder in the ratfun module. My testing indicates that it will give the exact roots of a Wilkinson polynomial of degree 100. For more information see http://calcrpnpy.sourceforge.net/ratfun.html -- http://m

Re: 2.3 -> 2.4: long int too large to convert to int

2005-09-16 Thread Raymond L. Buvel
Grant Edwards wrote: > I give up, how do I make this not fail under 2.4? > > fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",0x1c,0x00,0x00)) > > I get an OverflowError: long int too large to convert to int > > ioctl() is expecting a 32-bit integer value, and 0xc0047a80 has > the hi

Re: newbie question on python 2.4 and tkinter

2005-02-19 Thread Raymond L. Buvel
David Joyner wrote: Hi: I'm trying to compile python 2.4 with tkinter. (I'm trying to write a gui interface which calls a program called GAP - I'm hoping to use subprocess, a python 2.4 module, since I was getting deadlocks using popen). The instructions at the python web site said basically to edi

Re: any Python equivalent of Math::Polynomial::Solve?

2005-02-26 Thread Raymond L. Buvel
Just wrote: SciPy indeed appear to contain a solver, but I'm currently stuck in trying to _get_ it for my platform (OSX). I'm definitely not going to install a Fortran compiler just to evaluate it (even though my name is not "Ilias" ;-). Also, SciPy is _huge_, so maybe a Python translation of

Re: any Python equivalent of Math::Polynomial::Solve?

2005-02-27 Thread Raymond L. Buvel
Alex Renelt wrote: Alex Renelt wrote: in addition: I'm writing a class for polynomial manipulation. The generalization of the above code is: definitions: 1.) p = array([a_0, a_i, ..., a_n]) represents your polynomial P(x) = \sum _{i=0} ^n a_i x^i 2.) deg(p) is its degree 3.) monic(p) makes P moni

Re: python -i (interactive environment)

2005-03-06 Thread Raymond L. Buvel
I posted the following a while back. I think this is what you are looking for. This can be done fairly easily by creating a module (lets call it interactive) with the following code in it. --- import sys,os def debug_exception(type, value, traceback): # Restore redirected standard I

yum repository

2005-03-14 Thread Donald L. Dietmeyer
What yum repository do you use to pick up python rpms? Don -- http://mail.python.org/mailman/listinfo/python-list

Pmw.ScrolledText

2004-12-07 Thread Donald L. Dietmeyer
I am attempting to put together a "dumb terminal" using a Pmw.ScrolledText to communicate via a serial port with a box that does the echoing of characters it receives. How can I stop the ScrolledText from echoing characters typed to it? Or lacking that, how can I know when a character has been ec

Re: A rational proposal

2004-12-18 Thread Raymond L. Buvel
Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/projects/gmpy)? That module already provides good performance. However, it d

Re: A rational proposal

2004-12-19 Thread Raymond L. Buvel
Alex Martelli wrote: Raymond L. Buvel <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/pr

[ANN] rpncalc-1.1 RPN Calculator For Python

2004-12-21 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Changes

Re: Ron Grossi: God is not a man

2005-04-28 Thread Donald L McDaniel
MC05 wrote: > "Donald L McDaniel" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> 4) I doubt seriously whether God plays a guitar, since guitars are >> made by men, for men. His Son could theoretically play a guitar. Perhaps >>

Re: Ron Grossi: God is not a man

2005-04-29 Thread Donald L McDaniel
MC05 wrote: > "sheltech" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> "MC05" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> >>> "Donald L McDaniel" <[EMAIL PROTECTED]&

Re: Ron Grossi: God is not a man

2005-04-29 Thread Donald L McDaniel
AKA wrote: > "Donald L McDaniel" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> MC05 wrote: >>> "sheltech" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >>>> >>>> "M

Re: Ron Grossi: God is not a man

2005-04-30 Thread Donald L McDaniel
Johnny Gentile wrote: > Donald - go away. Far away. Now. > And, for the last time (hopefully), stop crossposting to > rec.music.beatles. > Go sell crazy somewhere else. We're all stocked up. > > Donald L McDaniel wrote: >> AKA wrote: >>> "Donald L McD

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

Installation

2016-01-12 Thread Jansen, Ingram L
I can't download Python and I need it for class. Any suggestions? Ingram Jansen Banner ID: 830742998 -- https://mail.python.org/mailman/listinfo/python-list

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

Static caching property

2016-03-21 Thread Joseph L. Casale
With non static properties, you can use a decorator that overwrites the method on the instance with an attribute containing the methods return effectively caching it. What technique for a static property can be used to accomplish what the descriptor protocol does? I need to cache the results of a

Re: Static caching property

2016-03-21 Thread Joseph L. Casale
> I think Joseph is using "static" in the Java sense of being associated with > the class rather than an instance. (In Java, members of classes must be > known at compile-time.) Yup, so a single value on the class itself, not instance specific. > But what you can do is have the property refer to

Re: Static caching property

2016-03-21 Thread Joseph L. Casale
> One solution is to use descriptor protocol on the class, which means > using a metaclass. I'm not sure it's the best option, but it is an > option. I will look at that, I wonder if however I am not over complicating it: class Foo: _bar = None @property def expensive(self): i

RE: Static caching property

2016-03-22 Thread Joseph L. Casale
> If a method call on any instance defines the return value for > all instances, then this method likely should be a class method -- > and use a class attribute to store the result -- something like this: > > class C(object): > > _cache = {} > > @classmethod > def f(cls, ...): >

RE: Using map()

2014-11-16 Thread Joseph L. Casale
> I checked my modules with pylint and saw the following warning: > > W: 25,29: Used builtin function 'map' (bad-builtin) > > Why is the use of map() discouraged? > It' such a useful thing. The warning manifests from the opinion that a comprehension is more suitable. You can disable the warning or

ORM opinion

2014-12-04 Thread Joseph L. Casale
Begrudgingly, I need to migrate away from SQLAlchemy onto a package that has fast imports and very fast model build times. I have a less than ideal application that uses Python as a plugin interpreter which is not performant in this use case where its being invoked freshly several times per operat

RE: ORM opinion

2014-12-04 Thread Joseph L. Casale
> First recommendation: Less layers. Instead of SQLAlchemy, just import > sqlite3 and use it directly. You should be able to switch out "import > sqlite as db" for "import psycopg2 as db" or any other Python DB API > module, and still have most/all of the benefit of the extra layer, > without any e

RE: ORM opinion

2014-12-04 Thread Joseph L. Casale
> Anything listed here http://www.pythoncentral.io/sqlalchemy-vs-orms/ > you've not heard about? I found peewee easy to use although I've > clearly no idea if it suits your needs. There's only one way to find out :) Hi Mark, I found that article before posting and some of the guys here have alre

Argparse defaults

2015-01-04 Thread Joseph L. Casale
Does a facility exist to add an argument with a default being a function that leverages the final parsed Namespace? For example: group = parser.add_argument_group(' some_group ') group.add_argument( '--some_group', nargs='*', type=str ) group.add_argument(

Hashed lookups for tabular data

2015-01-19 Thread Joseph L. Casale
I have some tabular data for example 3 tuples that I need to build a container for where lookups into any one of the three fields are O(1). Does something in the base library exist, or if not is there an efficient implementation of such a container that has been implemented before I give it a go?

Re: Hashed lookups for tabular data

2015-01-19 Thread Joseph L. Casale
> So presumably your data's small enough to fit into memory, right? If > it isn't, going back to the database every time would be the best > option. But if it is, can you simply keep three dictionaries in sync? Hi Chris, Yeah the data can fit in memory and hence the desire to avoid a trip here. >

Re: Hashed lookups for tabular data

2015-01-19 Thread Joseph L. Casale
> The IDs of the objects prove that they're actually all the same > object. The memory requirement for this is just what the dictionaries > themselves require; their keys and values are all shared with other > usage. Chris, I would have never imagined that, much appreciated for that! jlc -- http

Re: Hashed lookups for tabular data

2015-01-19 Thread Joseph L. Casale
> Why not take a look at pandas as see if there's anything there you could > use? Excellent docs here http://pandas.pydata.org/pandas-docs/stable/ > and the mailing list is available at gmane.comp.python.pydata amongst > other places. Mark, Actually it was the first thing that came to mind. I did

Re: Hashed lookups for tabular data

2015-01-19 Thread Joseph L. Casale
> If you want an sql-like interface, you can simply create an in-memory > sqlite3 database. > > import sqlite3 > db = sqlite3.Connection(':memory:') > > You can create indexes as you need, and query using SQL. Later, if you > find the data getting too big to fit in memory, you can switch to us

Unitest mock issue

2014-02-14 Thread Joseph L. Casale
I am trying to patch a method of a class thats proving to be less than trivial. The module I am writing a test for, ModuleA imports another ModuleB and instantiates a class from this. Problem is, ModuleA incorporates multiprocessing queues and I suspect I am missing the patch as the object in ques

Descriptor type hinting

2014-02-27 Thread Joseph L. Casale
How does one satisfy a lint/type checker with the return value of a class method decorated with a descriptor? It returns a dict, and I want the type hinting to suggest this versus the str|unknown its defaults to. Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list

RE: Descriptor type hinting

2014-02-27 Thread Joseph L. Casale
> Surely the answer will depend on the linter you are using. Care to tell > us, or shall we guess? Hey Steven, I am using PyCharm, I have to admit I feel silly on this one. I had a buried assignment that overrode the inferred type. It wasn't until a fresh set of eyes confirmed something was awry

asyncio question

2014-03-13 Thread Joseph L. Casale
I have a portion of code I need to speed up, there are 3 api calls to an external system where the first enumerates a large collection of objects I then loop through and perform two additional api calls each. The first call is instant, the second and third per object are very slow. Currently aft

RE: writing reading from a csv or txt file

2014-03-30 Thread Joseph L. Casale
> Hi I have 3 csv files with a list of 5 items in each. > rainfall in mm, duration time,time of day,wind speed, date. > I am trying to compare the files. cutting out items in list list. ie:- > first file (rainfall2012.csv)rainfall, duration,time of day,wind speed,date. > first file (rainfall2013.cs

Soap list and soap users on this list

2014-04-17 Thread Joseph L. Casale
Seems the soap list is a little quiet and the moderator is mia regardless. Are there many soap users on this list familiar with Spyne or does anyone know the most optimal place to post such questions? Thanks! jlc -- https://mail.python.org/mailman/listinfo/python-list

RE: Soap list and soap users on this list

2014-04-17 Thread Joseph L. Casale
> Is your question > regarding anything at all Python, or are you just looking for helpful > nerds? :) Hi Chris, Thanks for responding. I've been looking at Spyne to produce a service that can accept a request formatted as follows: http://..."; xmlns:xsi=http:/..." xmlns:xsd="http://...";>

RE: Soap list and soap users on this list

2014-04-17 Thread Joseph L. Casale
>Read first. > > >You can try : > > > http://spyne.io/docs/2.10/ > > > https://pythonhosted.org/Soapbox/ Thanks Marcus, I assure you I have been reading but missed soapbox, I'll keep hacking away, thanks for the pointer. jlc -- https://mail.python.org/mailman/listinfo/python-list

RE: Executing pl/sql script File in python without sqlclient

2014-04-25 Thread Joseph L. Casale
> Is there a way to execute pl/sql Script files through Python without > sqlclient. https://code.google.com/p/pypyodbc/ might work for you... > i have checked cx_oracle and i guess it requires oracle client, so is there a > way to execute without oracle client. Right, as the name implies it us

RE: Soap list and soap users on this list

2014-04-28 Thread Joseph L. Casale
> https://gist.github.com/plq/11384113 > > Unfortunately, you need the latest Spyne from > https://github.com/arskom/spyne, this doesn't work with 2.10 > > 2.11 is due around end of may, beginning of june. > > Ping back if you got any other questions. Burak, Thanks a ton! I've just pulled this

RE: Designing a network in Python

2014-04-30 Thread Joseph L. Casale
> I have managed to read most of the important data in the xml onto lists. > Now, I have two lists, Source and Destination and I'd like to create > bi-directional > links between them. > And moreover, I'd like to assign some kind of a bandwidth capacity to the > links and > similarly, storage an

RE: Designing a network in Python

2014-04-30 Thread Joseph L. Casale
> I don't know how to do that stuff in python. Basically, I'm trying to pull > certain data from the > xml file like the node-name, source, destination and the capacity. Since, I > am done with that > part, I now want to have a link between source and destination and assign > capacity to it. I

Exception problem with module

2014-05-13 Thread Joseph L. Casale
I am working with a module that I am seeing some odd behavior. A module.foo builds a custom exception, module.foo.MyError, its done right afaict. Another module, module.bar imports this and calls bar.__setattr__('a_new_name', MyError). Now, not in all but in some cases when I catch a_new_name,

RE: Exception problem with module

2014-05-13 Thread Joseph L. Casale
> Best would be to print out what's in a_new_name to see if it really is > what you think it is. If you think it is what you think it is, have a > look at its __mro__ (method resolution order, it's an attribute of > every class), to see what it's really inheriting. That should show you > what's hap

RE: Exception problem with module

2014-05-14 Thread Joseph L. Casale
> I see that you've solved your immediate problem, but you shouldn't call > __setattr__ directly. That should actually be written > > setattr(bar, 'a_new_name', MyError) > > But really, since bar is (apparently) a module, and it is *bar itself* > setting the attribute, the better way is > > a

Re: Problem building 3.5 on Windows

2014-05-17 Thread Joseph L. Casale
Mark, Excuse the format of this post, stuck on the road only with an iPhone but in the event it helps, http://blog.vrplumber.com/b/2014/02/12/step-2-get-amd64-compatible-vs-2010/ may be useful. Jlc -- https://mail.python.org/mailman/listinfo/python-list

RE: Exception problem with module

2014-05-19 Thread Joseph L. Casale
>> Well I am not sure what advantage this has for the user, not my code as >> I don't advocate the import to begin with it, its fine spelled as it was >> from where it was... > > The advantage for the user is: /snip Hey Steven, Sorry for the late reply (travelling). My comment wasn't clear, I wa

RE: compiled cx_freeze

2014-05-25 Thread Joseph L. Casale
> Anyone knows where to get a compiled cx_freeze that has already has this > patch? http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze -- https://mail.python.org/mailman/listinfo/python-list

RE: compiled cx_freeze

2014-05-25 Thread Joseph L. Casale
> Unfortunately, this is buggy too. Here is a test output from a compiled > console exe created with the above version of cx freeze: Let Christoph know, he is very responsive and extremely helpful. -- https://mail.python.org/mailman/listinfo/python-list

Best practice for connections and cursors

2013-08-01 Thread Joseph L. Casale
I posted this to the sqlite list but I suspect there are more C oriented users on that list than Python, hopefully someone here can shed some light on this one. I have created a python module that I import within several other modules that simply opens a connection to an sqlite file and defines s

Logging help

2013-08-01 Thread Joseph L. Casale
I have a couple handlers applied to a logger for a file and console destination. Default levels have been set for each, INFO+ to console and anything to file. How does one prevent logging.exception from going to a specific handler when it falls within the desired levels? Thanks, jlc -- http://ma

RE: Best practice for connections and cursors

2013-08-02 Thread Joseph L. Casale
>Speaking to the OP: personally, I don't like the approach of putting data >access methods at the module level to >begin with. I'd rather use a class. >Just because it makes sense to have a singleton connection now doesn't mean it >>will always make sense as your application grows. >In fact,

RE: Logging help

2013-08-04 Thread Joseph L. Casale
>Oh hai - as I was reading the documentation, look what I found: > >http://docs.python.org/2/library/logging.html#filter > >Methinks that should do exactly what you want. Hi Wayne, I was too hasty when I looked at filters as I didn't think they could do what I wanted. Turns out a logging object se

RE: [argparse] mutually exclusive group with 2 sets of options

2013-08-05 Thread Joseph L. Casale
> You can probably do something similar using sub commands > (http://docs.python.org/2/library/argparse.html#sub-commands). The problem here is that argparse does not pass the subparser into the parsed args and shared args between subparsers need to be declared each time. Come execution time, when

RE: [argparse] mutually exclusive group with 2 sets of options

2013-08-05 Thread Joseph L. Casale
> I think you are looking for exclusive groups: > > http://docs.python.org/2.7/library/argparse.html#argparse.add_mutually_excl > usive_group No. That links first doc line in that method shows the very point we are all discussing: "Create a mutually exclusive group. argparse will make sure that

RE: Running a command line program and reading the result as it runs

2013-08-23 Thread Joseph L. Casale
> >> I'm using Python 2.7 under Windows and am trying to run a command line > >> program and process the programs output as it is running. A number of > >> web searches have indicated that the following code would work. > >> > >> import subprocess > >> > >> p = subprocess.Popen("D:\Python\Python27\

sqlite issue in 2.7.5

2013-09-02 Thread Joseph L. Casale
I have been battling an issue hopefully someone here has insight with. I have a database with a few tables I perform a query against with some joins against columns collated with NOCASE that leverage = comparisons. Running the query on the database opened in sqlitestudio returns the results in un

RE: sqlite issue in 2.7.5

2013-09-09 Thread Joseph L. Casale
> This pragma speeds up most processes 10-20 times (yes 10-20): > pragma synchronous=OFF > > See the SQLITE documentation for an explanation. > I've found no problems with this setting. Aside from database integrity and consistency? :) I have that one set to OFF as my case mandates data processing

Barcode printing

2013-09-29 Thread Joseph L. Casale
I need to convert a proprietary MS Access based printing solution into something I can maintain. Seems there is plenty available for generating barcodes in Python, so for the persons who have been down this road I was hoping to get a pointer or two. I need to create some type of output, preferab

RE: Barcode printing

2013-09-30 Thread Joseph L. Casale
>If that's a bit heavyweight (and confusing; it's not all free software, >since some of it is under non-free license terms), there are other >options. > >pyBarcode http://pythonhosted.org/pyBarcode/> says it's a >pure-Python library that takes a barcode type and the value, and >generates an SVG of

Logging timezones

2013-10-26 Thread Joseph L. Casale
The default converter attribute uses localtime, but often under windows when I add an additional logger, create a new file handler and set a formatter the time switches to utc. Obviously redefining a new converter class does nothing as the default is what I wanted to start with, localtime. Anyon

RE: Using "with open(filename, 'ab'):" and calling code only if the file is new?

2013-10-29 Thread Joseph L. Casale
> with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as > output: > fieldnames = (...) > csv_writer = DictWriter(output, filednames) > # Call csv_writer.writeheader() if file is new. > csv_writer.writerows(my_dict) > > I'm wondering what's the

RE: Using "with open(filename, 'ab'):" and calling code only if the file is new?

2013-10-29 Thread Joseph L. Casale
> Like Victor says, that opens him up to race conditions. Slim chance, it's no more possible than it happening in the time try/except takes to recover an alternative procedure. with open('in_file') as in_file, open('out_file', 'ab') as outfile_file: if os.path.getsize('out_file'): pri

RE: Compiling Python 3.3.2 on CentOS 6.4 - unable to find compiled OpenSSL?

2013-11-04 Thread Joseph L. Casale
> Any thoughts on what we're doing wrong? Building them yourself:) Try iuscommunity.org for prebuilt packages... -- https://mail.python.org/mailman/listinfo/python-list

Callbacks with concurrent.futures

2015-03-12 Thread Joseph L. Casale
I have a ProcessPoolExecutor for which I am attaching multiple callbacks. As this must be process based and not thread based, I don't have the luxury communication between threads. Without a queue, does something inherent exist in concurrent futures that allows me to accumulate some data from the f

Re: Callbacks with concurrent.futures

2015-03-12 Thread Joseph L. Casale
> ProcessPoolExecutor is built on the multiprocessing module, so I > expect you should be able to use multiprocessing.Queue or > multiprocessing.Pipe in place of threading.Queue. Hi Ian, Yeah I am using a Manager.Queue as the method polling the queue is itself in a process. I just wondered if the

Module load times

2015-08-13 Thread Joseph L. Casale
I have an auto generated module that provides functions exported from a c dll. Its rather large and we are considering some dynamic code generation and caching, however before I embark on that I want to test import times. As the module is all auto generated through XSL, things like __all__ are not

Re: Module load times

2015-08-13 Thread Joseph L. Casale
Hi Stefan, > How is the DLL binding implemented? Using "ctypes"? Or something else? It is through ctypes. > Obviously, instantiating a large ctypes wrapper will take some time. A > binary module would certainly be quicker here, both in terms of import time > and execution time. Since you're gene

RE: Module load times

2015-08-13 Thread Joseph L. Casale
> Importing is not the same as instantiation. > > When you import a module, the code is only read from disk and instantiated > the first time. Then it is cached. Subsequent imports in the same Python > session use the cached version. I do mean imported, in the original design there were many ctype

return types from library api wrappers

2015-08-16 Thread Joseph L. Casale
What's the accepted practice for return types from a c based API Python wrapper? I have many methods which return generators which yield potentially many fields per iteration. In lower level languages we would yield a struct with readonly fields. The existing implementation returns a dict which I

RE: return types from library api wrappers

2015-08-17 Thread Joseph L. Casale
> Current practice is a NamedTuple for python code or the C equivalent. I > forget the C name, but I believe it is used by os.stat Hi Terry, Ok, that is what I will go with. Thanks for the confirmation, jlc -- https://mail.python.org/mailman/listinfo/python-list

Attaching to python process in alternate windows session

2015-08-26 Thread Joseph L. Casale
A while ago I stumbled on a workaround for this, but forgot. Anyone know the trick to accomplish this? Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list

Writing a module to abstract a REST api

2015-09-17 Thread Joseph L. Casale
I need to write a module to abstract the RabbitMQ HTTP REST api. Before I do this, I would like to see how other projects have done similar in the hopes I make something consistent and generic etc. Does anyone regularly work with a library that abstracts a REST API and can recommend it for review?

Re: Writing a module to abstract a REST api

2015-09-17 Thread Joseph L. Casale
> There is https://pypi.python.org/pypi/librabbitmq ? Hi Jon, That is the AMQP client that utilizes the c extensions, I am writing a module to interact with a plugin that exposes a REST API. So I am not really after anything AMQP specific, just a pointer to a project that abstracts anything with

Re: Writing a module to abstract a REST api

2015-09-17 Thread Joseph L. Casale
> If I understand you: > http://www.python-requests.org/en/latest/ > > is an example of what you are looking for? > > It's great. > > Also check out > http://cramer.io/2014/05/20/mocking-requests-with-responses/ > > if you need to mock requests. Hi Laura, The twitter samples Jon sent were good

Re: Writing a module to abstract a REST api

2015-09-18 Thread Joseph L. Casale
> Well, I would be interested in seeing such a module as well. > > Most modules and frameworks, I know, providing REST and interacting with > REST are more like traditional SOAP-like web services. You got your > functions which have a 1-to-1 correspondence with some resource URLs and > that's it.

Re: Writing a module to abstract a REST api

2015-09-18 Thread Joseph L. Casale
Hi Sven, >> The problem now comes from the following: >> >> # foo now contains a handle to the remote api. >> foo = InstanceOfApiWrapper() > > Is it necessary to have an instance of that API? Just curiosity here. Not always but often as the pattern here might rely on a handle to a c types based a

Modifying signature of ctor in class

2015-09-24 Thread Joseph L. Casale
I have a class factory where I dynamically add a constructor to the class output. The method is a closure and works just fine, however to accommodate the varied input its signature is (*args, **kwargs). While I modify the doc strings, the ctor sig is not optimal. Without building this a string an

Re: Modifying signature of ctor in class

2015-09-24 Thread Joseph L. Casale
> You can use the FunctionType class found in the types module (and its > friends) to create functions on the run. > And you can use the 'inspect' module to inspect existing functions, if you > need to base the new function on an existing one. Hi Gal, Seems the types module docs do not even have

Re: Modifying signature of ctor in class

2015-09-24 Thread Joseph L. Casale
> I don't think you can easily change the function's own definition, > other than by using eval (or equivalent shenanigans, like crafting > your own bytecode); but as of Python 3.something, the help() function > looks for a __wrapped__ attribute and will take function args from > that instead of th

Re: Modifying signature of ctor in class

2015-09-24 Thread Joseph L. Casale
> py> from inspect import Signature, Parameter > py> def foo(*args, **kwargs): pass > ... > py> foo.__signature__ = Signature([Parameter('x', > Parameter.POSITIONAL_OR_KEYWORD), Parameter('y', > Parameter.KEYWORD_ONLY)]) > py> help(foo) > Help on function foo in module __main__: > > foo(x, *, y)

<    1   2   3   4   5   6   7   >