Re: WHY it compains about the missing argument is WHAT i don't understand
Νίκος Βέργος writes: > plugin = bottle_pymysql.Plugin( dbuser='user', dbpass='pass', > dbname='counters', dictrows=False ) > app.install(plugin) > > ... > ... > > @app.route( '/' ) > @auth_basic( counters.is_authenticated_user ) > def listall( pymydb ): This declares `listall` to have one mandatory positional argument "pymydb". > But when i try to load the app's URL like http://superhost.gr/clientele as > you can see i get this error: > > > Exception: > TypeError("listall() missing 1 required positional argument: 'pymydb'",) > Traceback: > Traceback (most recent call last): > File "/usr/lib/python3.6/site-packages/bottle.py", line 862, in _handle > return route.call(**args) > File "/usr/lib/python3.6/site-packages/bottle.py", line 1740, in wrapper > rv = callback(*a, **ka) > File "/usr/lib/python3.6/site-packages/bottle.py", line 2690, in wrapper > return func(*a, **ka) > TypeError: listall() missing 1 required positional argument: 'pymydb' This error indicates that `listall` is called by the `bottle` function wrapper without positional argument. > listall() is `/` route's callback function and i never inside my script i > call listall( pymydb ). > Why it compains about the missing argument is WHAT i don't understand. Your definition of `listall` does not match the expectations of `bottle` with regard to this function. Reread the corresponding documentation and adapt your `listall`. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On 09Oct2019 16:50, DL Neil wrote: Another option might be to add a symlink* from the application's directory to wherever you've downloaded and expanded the GitHub .zip archive. I do this. A current project is using Spectra's ds3 Python library. The project itself has a directory for the additional source code beyond what comes from the venv, and that directory is in the sys.path. In the directory is a symlink to the specific vendor checkout of the ds3 library: ds3 -> ../../vendor/spectra/ds3_python3_sdk/ds3 So the project tree has: vendor/spectra/ds3_python3_sdk/ds3 where the vendor library is kept (from their github repo) and: lib/python containing the above symlink and the non-venv additional libraries (i.e. the project's own Python code as a package). The ./lib/python path in in sys.path (from the environment's $PYTHONPATH). So the symlink thing is not unreasonable at all. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On 9/10/19 4:34 PM, jf...@ms4.hinet.net wrote: jf...@ms4.hinet.net於 2019年10月8日星期二 UTC+8上午10時45分36秒寫道: For example: from my-dir import test I know it can be solved by renaming, but any alternative? --Jach Maybe another (better?) solution is: import sys sys.path.append(r'my-dir') import test Another option might be to add a symlink* from the application's directory to wherever you've downloaded and expanded the GitHub .zip archive. * Linux terminology, other OpSys may use different. Both are somewhat unattractive (IMHO). -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
jf...@ms4.hinet.net於 2019年10月8日星期二 UTC+8上午10時45分36秒寫道: > For example: > from my-dir import test > > I know it can be solved by renaming, but any alternative? > > --Jach Maybe another (better?) solution is: import sys sys.path.append(r'my-dir') import test --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On Wed, Oct 9, 2019 at 12:56 PM DL Neil via Python-list wrote: > > On 9/10/19 2:46 PM, Chris Angelico wrote: > > On Wed, Oct 9, 2019 at 12:36 PM DL Neil via Python-list > > wrote: > ... > > > (Or just using pip to install directly from GitHub, although not > > everyone knows that that's possible.) > > Come on, you just knew I was going to ask how... > https://pip.pypa.io/en/stable/reference/pip_install/#git It should be as easy as: pip install git+https://github.com/USER/REPO There are lots of other options if you need them (eg "@branchname") but if you just want to grab the latest unversioned code, it should be that simple. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On 9/10/19 2:46 PM, Chris Angelico wrote: On Wed, Oct 9, 2019 at 12:36 PM DL Neil via Python-list wrote: ... (Or just using pip to install directly from GitHub, although not everyone knows that that's possible.) Come on, you just knew I was going to ask how... -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On Wed, Oct 9, 2019 at 12:36 PM DL Neil via Python-list wrote: > > On 9/10/19 2:12 PM, jf...@ms4.hinet.net wrote: > > dieter於 2019年10月8日星期二 UTC+8下午1時33分20秒寫道: > >> jf...@ms4.hinet.net writes: > >>> ... > >>> But most of the download from Github has a directory named '-master' > >>> which causes a trouble sometimes. > >> > >> Those are likely not meant to be imported directly. > >> > >> Typically, you have a "setup" step which installs (in some way) > >> a "distribution". This step usually ensures that you can use > >> "normal" Python import syntax to access all associated packages. > >> > >> The "setup" step is typically performed with > >> "python setup.py develop" or "python setup.py install" -- > >> with the "distribution" providing the "setup.py". > > > > Yes, I understand the normal procedure on using a package, but it's not > > always the case. > > I'm curious - if this is the correct way to do things, and the original > author intends the package/module for you to download, why does (s)he > choose to follow an non-Pythonic naming convention? > > Does this say something about the author? > - something about his/her abilities in Python? > - the Python-friendliness (or otherwise) of GitHub? (cf PyPi) > It looks like the OP asked GitHub for a zip download instead of doing what would be far more generally common: cloning the repository. (Or just using pip to install directly from GitHub, although not everyone knows that that's possible.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
On 9/10/19 2:12 PM, jf...@ms4.hinet.net wrote: dieter於 2019年10月8日星期二 UTC+8下午1時33分20秒寫道: jf...@ms4.hinet.net writes: ... But most of the download from Github has a directory named '-master' which causes a trouble sometimes. Those are likely not meant to be imported directly. Typically, you have a "setup" step which installs (in some way) a "distribution". This step usually ensures that you can use "normal" Python import syntax to access all associated packages. The "setup" step is typically performed with "python setup.py develop" or "python setup.py install" -- with the "distribution" providing the "setup.py". Yes, I understand the normal procedure on using a package, but it's not always the case. I'm curious - if this is the correct way to do things, and the original author intends the package/module for you to download, why does (s)he choose to follow an non-Pythonic naming convention? Does this say something about the author? - something about his/her abilities in Python? - the Python-friendliness (or otherwise) of GitHub? (cf PyPi) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
[RELEASE] Python 2.7.17 release candidate 1
The first release candidate of Python 2.7.17 is now available for download and testing. Python 2.7.17 includes 80 fixes over Python 2.7.16. Downloads may be found on python.org: https://www.python.org/downloads/release/python-2717rc1/ Read the full changelog at: https://raw.githubusercontent.com/python/cpython/1c7b14197b10924e2efc1e6c99c720958be1f681/Misc/NEWS.d/2.7.17rc1.rst As always with prereleases, please test your applications and libraries and report bugs to: https://bugs.python.org/ A final release is scheduled to follow in 12 days. PEP 373, the Python 2.7 release schedule, calls for 2.7.17 to be the penultimate bug fix release of the Python 2.7 series. Time for Python 2 is running low! Regards, Benjamin 2.7 release manager -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle '-' in the 'from' part in a "from import" statement?
dieter於 2019年10月8日星期二 UTC+8下午1時33分20秒寫道: > jf...@ms4.hinet.net writes: > > ... > > But most of the download from Github has a directory named '-master' > > which causes a trouble sometimes. > > Those are likely not meant to be imported directly. > > Typically, you have a "setup" step which installs (in some way) > a "distribution". This step usually ensures that you can use > "normal" Python import syntax to access all associated packages. > > The "setup" step is typically performed with > "python setup.py develop" or "python setup.py install" -- > with the "distribution" providing the "setup.py". Yes, I understand the normal procedure on using a package, but it's not always the case. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: Get __name__ in C extension module
> On 7 Oct 2019, at 00:44, Ian Pilcher wrote: > > On 10/6/19 12:55 PM, Barry Scott wrote: >> Then the answer to your question is simple. Do it in python and passt >> logger into the C++ module. > > Funny thing, that's exactly where I started this journey. I couldn't > figure out how to get the logging.Logger type object, so that I could > use a "O!" format string unit. This led me to read a bit more about > the logging framework, which led me to the advice to get loggers by > name, rather than passing them around, etc., etc. In PyCXX I never need to use the "O!" stuff. I write something like this (untested): // function in foo module Py::Object function( const Py::Tuple &args, const Py::Dict &kws ) { Py::Object logger( args[0] ); Py::Tuple log_args( 1 ); args[0] = Py::String( "log message" ); logger.callMemberFunction( "info", log_args ); return Py::None(); } I'd call from Python something like: import foo import logging logger = logging.getLogger(__name__) foo.function( logger ) > >> Next I would never code directly against the C API. Its a pain to use >> and get right, get the ref counts wrong and you get memory leaks of >> worse crash python. > > Well, I like driving cars with manual transmissions, so ... Understood. Barry > > -- > > Ian Pilcher arequip...@gmail.com > "I grew up before Mark Zuckerberg invented friendship" > > -- https://mail.python.org/mailman/listinfo/python-list
WHY it compains about the missing argument is WHAT i don't understand
plugin = bottle_pymysql.Plugin( dbuser='user', dbpass='pass', dbname='counters', dictrows=False ) app.install(plugin) ... ... @app.route( '/' ) @auth_basic( counters.is_authenticated_user ) def listall( pymydb ): But when i try to load the app's URL like http://superhost.gr/clientele as you can see i get this error: Exception: TypeError("listall() missing 1 required positional argument: 'pymydb'",) Traceback: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib/python3.6/site-packages/bottle.py", line 2690, in wrapper return func(*a, **ka) TypeError: listall() missing 1 required positional argument: 'pymydb' listall() is `/` route's callback function and i never inside my script i call listall( pymydb ). Why it compains about the missing argument is WHAT i don't understand. -- https://mail.python.org/mailman/listinfo/python-list
Re: python -m pip install and pip install
Cameron Simpson 于2019年10月8日周二 下午12:25写道: > > On 08Oct2019 02:49, Hongyi Zhao wrote: > >On Tue, 08 Oct 2019 06:28:05 +0530, Pankaj Jangid wrote: > >> A very good use-case is when you have both, python2 and python3 > >> installed. > >> python2 -m pip install mod > >> python3 -m pip install mod > >> will install the package in the corresponding PYTHONPATH. > >> > > > >If so, why not just: > >pip2 install mod > >and using: > >pip3 install mod > > Because of the slight disconnect between "pip2" and "python2", etc. Do > you _know_ they both use the same Python install? With "pythonX -m pip" > you're using the same python executable which will be accessing what you > just installed. I use pyenv + pip, which will do the trick. > > It isn't a deal breaker, but preferred: one less moving part. > > Cheers, > Cameron Simpson -- Hongsheng Zhao Institute of Semiconductors, Chinese Academy of Sciences GnuPG DSA: 0xD108493 -- https://mail.python.org/mailman/listinfo/python-list
Re: Access violation in Python garbage collector (visit_decref) - how to debug?
On Tue, Oct 8, 2019 at 7:27 AM dieter wrote: > Geoff Bache writes: > > Yes, this is hard, that's why I'm here :) > > > > I've enabled the equivalent tools to valgrind in Visual Studio, and tried > > setting PYTHONMALLOC=debug, but neither of those seem to be showing > > anything either. I don't really know what else to try in this direction. > > It likely is too hard to be solved remotely (in this list). > > On the contrary, MRAB just solved it :) Thanks for your replies. /Geoff -- https://mail.python.org/mailman/listinfo/python-list
Re: python -m pip install and pip install
Hongyi Zhao 于2019年10月8日周二 下午4:53写道: > > Cameron Simpson 于2019年10月8日周二 下午12:25写道: > > > > On 08Oct2019 02:49, Hongyi Zhao wrote: > > >On Tue, 08 Oct 2019 06:28:05 +0530, Pankaj Jangid wrote: > > >> A very good use-case is when you have both, python2 and python3 > > >> installed. > > >> python2 -m pip install mod > > >> python3 -m pip install mod > > >> will install the package in the corresponding PYTHONPATH. > > >> > > > > > >If so, why not just: > > >pip2 install mod > > >and using: > > >pip3 install mod > > > > Because of the slight disconnect between "pip2" and "python2", etc. Do > > you _know_ they both use the same Python install? With "pythonX -m pip" > > you're using the same python executable which will be accessing what you > > just installed. > > I use pyenv + pip, which will do the trick. And nowadays, the pyenv + vurtualenv + pip + pipenv is the suggested env management method for python. In this way, the pipenv will solve the version dependence of the underlying tool chain and corresponding used packages/modules. > > > > > It isn't a deal breaker, but preferred: one less moving part. > > > > Cheers, > > Cameron Simpson > > > > -- > Hongsheng Zhao > Institute of Semiconductors, Chinese Academy of Sciences > GnuPG DSA: 0xD108493 -- Hongsheng Zhao Institute of Semiconductors, Chinese Academy of Sciences GnuPG DSA: 0xD108493 -- https://mail.python.org/mailman/listinfo/python-list
Re: Access violation in Python garbage collector (visit_decref) - how to debug?
Thankyou!!! That was it. Saved me a lot of time debugging no doubt and potential nasty problems at customer sites etc. I must admit I had just pattern-matched with these functions but had no idea that some of them stole references. I still don't really understand why, the docs say it is a "common idiom", but not common enough to be familiar to me and tricky to be inconsistent. But now I know, and the crash is gone :) Regards and many thanks again, /Geoff On Mon, Oct 7, 2019 at 7:32 PM MRAB wrote: > On 2019-10-07 08:04, Geoff Bache wrote: > > It's possible. Our embedding code is fairly simple and we've tried to > > encapsulate all the DECREFing in resource objects, i.e. that do DECREF > > in their destructor when they go out of scope. We hoped this would > > minimise this sort of problem. > > The C++ calling code essentially tries to call progwrapper.prog with a > > dictionary as arguments, and looks like > > > > GilStateHolder pyStateHolder; > > PyRefHolder module(PyImport_ImportModule("progwrapper")); > > > > if (module._ref) > > { > > PyXRefHolder func(PyObject_GetAttrString(module._ref, "prog")); > > PyXRefHolder pyArgs(PyTuple_New(1)); > > PyXRefHolder pyDict(convertDictForPython(dictIn)); > > PyTuple_SetItem(pyArgs._ref, 0, pyDict._ref); > > |Do you DECREF pyDict._ref later on? I ask because PyTuple_SetItem > steals a reference.| > > |Many other functions that "store" an object, such as PyList_Append, > INCREF to retain the stored object, but PyTuple_SetItem doesn't.| > > || > > > PyRefHolder pyRet(PyObject_CallObject(func._ref, pyArgs._ref)); > > > > if (pyRet._ref != NULL) > > { > > addPythonValuesToDict(pyRet._ref, theDict); > > ... > > > > where GilStateHolder, PyRefHolder etc are such resource objects as > > described above, wrapping round the PyObject pointers etc. > > > > [snip] > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Would you be interested in this Python open source project?
You might just consider working with the BuildBot project to add support for lighter weight build workers. Re-Re-Re-inventing the wheel is almost always wasted effort. On Tue, Oct 8, 2019 at 8:33 AM Rhodri James wrote: > On 08/10/2019 11:22, Simon Connah wrote: > > I'm posting this message as a way to gauge interest in the project and > > to see if it is worth moving forward with. There are probably hundreds > > of CI/CD tools out there and many more general devops tools but what I > > want to build is a CI/CD tool that ONLY supports Python 3.6 or greater > > and only runs on one Linux distribution (my preference is Ubuntu). This > > way configuration would be much more simple than the vast majority of > > devops tools which try to support every programming language that is > > popular (or so it seems) on many different Linux distributions and even > > Windows and macOS. > > > > My theory is that if you limit the devops tool to a very limited > > subsection of the available options the system will be easier to > > configure for users, more stable, easier to patch bugs in and generally > > just be a better all around things for Python developers. > > > > I'd love to hear some feedback on the idea. > > > > I think your reasoning is sound. I probably wouldn't make a lot of use > of it, but I live in Embedded Systems land where it's notoriously hard > to do CI off the target silicon. Other people living in more tractable > problem spaces will probably be more enthusiastic. > > -- > Rhodri James *-* Kynesim Ltd > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Would you be interested in this Python open source project?
On 08/10/2019 11:22, Simon Connah wrote: I'm posting this message as a way to gauge interest in the project and to see if it is worth moving forward with. There are probably hundreds of CI/CD tools out there and many more general devops tools but what I want to build is a CI/CD tool that ONLY supports Python 3.6 or greater and only runs on one Linux distribution (my preference is Ubuntu). This way configuration would be much more simple than the vast majority of devops tools which try to support every programming language that is popular (or so it seems) on many different Linux distributions and even Windows and macOS. My theory is that if you limit the devops tool to a very limited subsection of the available options the system will be easier to configure for users, more stable, easier to patch bugs in and generally just be a better all around things for Python developers. I'd love to hear some feedback on the idea. I think your reasoning is sound. I probably wouldn't make a lot of use of it, but I live in Embedded Systems land where it's notoriously hard to do CI off the target silicon. Other people living in more tractable problem spaces will probably be more enthusiastic. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Would you be interested in this Python open source project?
I'm posting this message as a way to gauge interest in the project and to see if it is worth moving forward with. There are probably hundreds of CI/CD tools out there and many more general devops tools but what I want to build is a CI/CD tool that ONLY supports Python 3.6 or greater and only runs on one Linux distribution (my preference is Ubuntu). This way configuration would be much more simple than the vast majority of devops tools which try to support every programming language that is popular (or so it seems) on many different Linux distributions and even Windows and macOS. My theory is that if you limit the devops tool to a very limited subsection of the available options the system will be easier to configure for users, more stable, easier to patch bugs in and generally just be a better all around things for Python developers. I'd love to hear some feedback on the idea. -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange tab completion oddity with enums?
Piet van Oostrum wrote: > Chris Angelico writes: > >> I'm not sure what's going on here, and it's probably not actually >> enum-specific, but that's where I saw it. >> >> If you create a plain class and have an attribute with an annotation, >> you can see that: >> > class Foo: >> ... spam: "ham" = 1 >> ... > Foo.__a >> Foo.__abstractmethods__ Foo.__annotations__ > Foo.__annotations__ >> {'spam': 'ham'} > > Also strange: > > It shows Foo.__abstractmethods__ but there is no such attribute. > What's going on? > Foo.__abstractmethods__ > Traceback (most recent call last): > File "", line 1, in > AttributeError: __abstractmethods__ An AttributeError doesn't generally doesn't mean that the attribute doesn't exist. Consider: >>> class Foo: ... @property ... def bar(self): raise AttributeError ... >>> foo = Foo() >>> "bar" in dir(foo) True >>> foo.bar Traceback (most recent call last): File "", line 1, in File "", line 3, in bar AttributeError So __abstractmethods__ might be a property of Foo's metaclass (type). Let's see: >>> type.__dict__["__abstractmethods__"] >>> type.__dict__["__abstractmethods__"].__get__(Foo) Traceback (most recent call last): File "", line 1, in AttributeError: __abstractmethods__ -- https://mail.python.org/mailman/listinfo/python-list