Using pydal for standalone scripts
I am looking into creating a database abstraction library using pydal and mysql as the engine. I noticed that I have to specify a 'folder' with the connection string to tell pydal where to save "table files". So I'll have hundreds of different databases and install this library on many machines. Do I need to standardize a place for these files and make sure that directory exists on every machine that uses the library? It seems rather cumbersome. I mean, couldn't pydal have just put this information into the database in its own private table? Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
On 3/15/24 02:30, Loris Bennett wrote: Hi, I am initialising an object via the following: def __init__(self, config): self.connection = None self.source_name = config['source_name'] self.server_host = config['server_host'] However, with a view to asking forgiveness rather than permission, is there some simple way just to assign the dictionary elements which do in fact exist to self-variables? class Foo(): def __init__(self, config): for key, val in config.iteritems(): setattr(self, key, val) f = Foo({'cat': 'dog'}) print(f.cat) (outputs 'dog') -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
I should mention that I wanted to answer your question, but I wouldn't actually do this. I'd rather opt for your self.config = config solution. The config options should have their own namespace. I don't mind at all referencing foo.config['option'], or you could make foo.config an object by itself so you can do foo.config.option. You'd fill it's attributes in the same way I suggested for your main object. -- https://mail.python.org/mailman/listinfo/python-list
python repl vi mode line editing not working.
Kubuntu 24.04. sinewave:toby ~(1)> cat .inputrc set editing-mode vi set keymap vi sinewave:toby ~(1)> cat .editrc bind -v bind \\t rl_complete sinewave:toby ~(1)> python Python 2.7.18 (default, Jul 8 2024, 12:49:12) [GCC 13.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. 1 1 2 2 ^[k I see the literal 'escape' character + 'k', when it should let me edit previous commands. I did have to compile my own python because I'm using 2.7 on this machine. Thanks for any help. Toby -- https://mail.python.org/mailman/listinfo/python-list
Problem using mysql library
sinewave:toby ~(1)> python Python 2.7.18 (default, Jul 8 2024, 12:49:12) [GCC 13.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. import MySQLdb Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 23, in (version_info, _mysql.version_info)) ImportError: this is MySQLdb version (1, 2, 5, 'final', 1), but _mysql is version (1, 4, 6, 'final', 0) I Googled this a lot, and saw many people with the same problem, but couldn't find an answer that helped. Thanks! Toby -- https://mail.python.org/mailman/listinfo/python-list
Re: python repl vi mode line editing not working.
For this to work, the Python implementation should use the same readline library as your shell, I guess. It works in python3, so I guess my problem is that I'm compiling python (I think kubuntu dropped python2), but I don't see any relevant options in the configure help. -- https://mail.python.org/mailman/listinfo/python-list
Re: python repl vi mode line editing not working.
I see the literal 'escape' character + 'k', when it should let me edit previous commands. I did have to compile my own python because I'm using 2.7 on this machine. I figured it out. I needed to apt install libreadline-dev. -- https://mail.python.org/mailman/listinfo/python-list
python3 package import difference?
I have an old library from 20 some years ago for use with python2, that is structured like this: rcs ├── dbi │ ├── __init__.py │ ├── dbi.py │ └── regos.py └── __init__.py -- *empty* the __init__.py file under 'rcs' is empty. The one under rcs.dbi contains: from dbi import * from regos import * With python2, I'd go: import rcs.dbi then I'd have access to stuff in regos.py as: rcs.dbi.feature() (Where 'feature' is defined in regos.py) When I do the same import with python3, I get: Traceback (most recent call last): File "/home/toby/me", line 1, in import rcs.dbi File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in from dbi import * ModuleNotFoundError: No module named 'dbi' What's changed, and how do I fix it? Thanks! -- https://mail.python.org/mailman/listinfo/python-list