Re: [Tutor] Why does loop duplicate?
On 16/12/15 19:37, Ken Hammer wrote: >... IDLE and Shell are Python 2.5.4 running on Windows 8.1. How exactly are you running this? Have you typed the code into a separate file using IDLE and then run it via the Run menu? Or are you importing the module at the >>> prompt? Or are you typing it into the interactive shell window? Or something else? The reason I ask is that I don't get repeats, so either you are running different code - possibly because of importing it and then changing it but not reimporting - or the way you run it is somehow causing the phenomenon. > prefixes = 'JKLMNOPQ' ###FAILS WITH REPEATS > suffix = 'ack' > suffixb= 'uack' > > for letter in prefixes: > if letter == "O": > print letter + suffixb > if letter == "Q": > print letter + suffixb > else: > print letter + suffix > -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Need to call a custom/magic method on calling of every Class methods
Hi Tutor, I am searching for any magic method/or any method that calls on every calling of the Class methods. for example: Class A(object): def one(self): return def two(self): return I need a method that prints which method is called in this class. I am aware of __call__() but this is called only once when the Class is called and decorators. This is need to placed on every method. c = A() c() # __call__ method is called. Is there any magic method that is auto called on every call of these Class Methods? Thanks, Sunil. G ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need to call a custom/magic method on calling of every Class methods
On Thu, Dec 17, 2015 at 05:18:26PM +0530, Sunil Tech wrote: > Hi Tutor, > > I am searching for any magic method/or any method that calls on every > calling of the Class methods. [...] > Is there any magic method that is auto called on every call of these Class > Methods? No, not really, but you can get *close* to what you want. You can't intercept *calling* the methods, but you can intercept the attribute lookup: class A(object): def __getattribute__(self, name): attr = super(A, self).__getattribute__(name) if callable(attr): print(name) return attr def one(self): return 1 def two(self): return 2 But beware that this will slow down all attribute access. This is possibly the simplest solution. Perhaps a better solution would be to create a custom Method descriptor, and then modify the class to use this descriptor instead of standard methods. But this is much more work. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need to call a custom/magic method on calling of every Class methods
Oh! Thank you so much Steven for the reply. On Thu, Dec 17, 2015 at 7:03 PM, Steven D'Aprano wrote: > On Thu, Dec 17, 2015 at 05:18:26PM +0530, Sunil Tech wrote: > > Hi Tutor, > > > > I am searching for any magic method/or any method that calls on every > > calling of the Class methods. > [...] > > Is there any magic method that is auto called on every call of these > Class > > Methods? > > No, not really, but you can get *close* to what you want. You can't > intercept *calling* the methods, but you can intercept the attribute > lookup: > > > class A(object): > def __getattribute__(self, name): > attr = super(A, self).__getattribute__(name) > if callable(attr): > print(name) > return attr > def one(self): > return 1 > def two(self): > return 2 > > > But beware that this will slow down all attribute access. > > This is possibly the simplest solution. Perhaps a better solution would > be to create a custom Method descriptor, and then modify the class to > use this descriptor instead of standard methods. But this is much > more work. > > > > -- > Steve > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Kivy Install
Hi, I don't know if this is the correct forum, I am new to Python and trying to install Kivy. I keep getting the following error message. Can you help? thanks, pete pip install --user Kivy Collecting Kivy Using cached Kivy-1.9.0.tar.gz Requirement already satisfied (use --upgrade to upgrade): Kivy-Garden==0.1.1 in c:\python27\lib\site-packages (from Kivy) Requirement already satisfied (use --upgrade to upgrade): requests in c:\python27\lib\site-packages (from Kivy-Garden==0.1.1->Kivy) Building wheels for collected packages: Kivy Running setup.py bdist_wheel for Kivy Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='C:\\Users\\edge\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\Kivy\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d c:\users\edge\appdata\local\temp\tmps896gmpip-wheel-: [INFO ] [Logger ] Record log in C:\Users\edge\.kivy\logs\kivy_15-12-17_35.txt [INFO ] [Kivy] v1.9.0 [INFO ] [Python ] v2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] Detected Cython version 0.21.2 Windows platform detected, force GLEW usage. Using this graphics system: OpenGL WARNING: A problem occured while running pkg-config --libs --cflags gstreamer-1.0 (code 1) 'pkg-config' is not recognized as an internal or external command, operable program or batch file. WARNING: A problem occured while running pkg-config --libs --cflags sdl2 SDL2_ttf SDL2_image SDL2_mixer (code 1) 'pkg-config' is not recognized as an internal or external command, operable program or batch file. running bdist_wheel running build running build_py creating build creating build\lib.win32-2.7 creating build\lib.win32-2.7\kivy copying kivy\animation.py -> build\lib.win32-2.7\kivy copying kivy\app.py -> build\lib.win32-2.7\kivy copying kivy\atlas.py -> build\lib.win32-2.7\kivy copying kivy\base.py -> build\lib.win32-2.7\kivy copying kivy\cache.py -> build\lib.win32-2.7\kivy copying kivy\clock.py -> build\lib.win32-2.7\kivy copying kivy\compat.py -> build\lib.win32-2.7\kivy copying kivy\config.py -> build\lib.win32-2.7\kivy copying kivy\context.py -> build\lib.win32-2.7\kivy copying kivy\event.py -> build\lib.win32-2.7\kivy copying kivy\factory.py -> build\lib.win32-2.7\kivy copying kivy\factory_registers.py -> build\lib.win32-2.7\kivy copying kivy\geometry.py -> build\lib.win32-2.7\kivy copying kivy\gesture.py -> build\lib.win32-2.7\kivy copying kivy\interactive.py -> build\lib.win32-2.7\kivy copying kivy\lang.py -> build\lib.win32-2.7\kivy copying kivy\loader.py -> build\lib.win32-2.7\kivy copying kivy\logger.py -> build\lib.win32-2.7\kivy copying kivy\metrics.py -> build\lib.win32-2.7\kivy copying kivy\multistroke.py -> build\lib.win32-2.7\kivy copying kivy\parser.py -> build\lib.win32-2.7\kivy copying kivy\resources.py -> build\lib.win32-2.7\kivy copying kivy\support.py -> build\lib.win32-2.7\kivy copying kivy\utils.py -> build\lib.win32-2.7\kivy copying kivy\vector.py -> build\lib.win32-2.7\kivy copying kivy\weakmethod.py -> build\lib.win32-2.7\kivy copying kivy\__init__.py -> build\lib.win32-2.7\kivy creating build\lib.win32-2.7\kivy\adapters copying kivy\adapters\adapter.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\args_converters.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\dictadapter.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\listadapter.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\models.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\simplelistadapter.py -> build\lib.win32-2.7\kivy\adapters copying kivy\adapters\__init__.py -> build\lib.win32-2.7\kivy\adapters creating build\lib.win32-2.7\kivy\core copying kivy\core\__init__.py -> build\lib.win32-2.7\kivy\core creating build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\audio_ffpyplayer.py -> build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\audio_gi.py -> build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\audio_gstplayer.py -> build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\audio_pygame.py -> build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\audio_pygst.py -> build\lib.win32-2.7\kivy\core\audio copying kivy\core\audio\__init__.py -> build\lib.win32-2.7\kivy\core\audio creating build\lib.win32-2.7\kivy\core\camera copying kivy\core\camera\camera_gi.py -> build\lib.win32-2.7\kivy\core\camera copying kivy\core\camera\camera_opencv.py -> build\lib.win32-2.7\kivy\core\camera copying kivy\core\camera\camera_pygst.py -> build\lib.win32-2.7\kivy\core\camera copying kivy\core\camera\camera_videocapture.py -> build\lib.win32-2.7\kivy\core\camera copying kivy\core\camera\__init__.py -> build\lib.win32-2.7\kivy\core\camera creating build\lib
Re: [Tutor] Fwd: Kivy Install
This is a general Python mailing list. For Kivy please reference: https://groups.google.com/forum/#!forum/kivy-users or find the developers on freenode IRC in #kivy This is the official Kivy repository here: https://github.com/kivy/kivy The official Kivy site is here: http://kivy.org/ But you are in luck I am a Kivy User too. However I am a Linux OS user so your luck just became a little less. For Windows I do not believe installing via Python's PIP is not supported. However their are pre-built binaries for windows with executable installers here: http://kivy.org/#download So what exactly are you trying to do? Install Kivy on your windows machine for development or Install Kivy on other peoples computers that use your software which is built on Kivy? On Thu, Dec 17, 2015 at 1:06 PM, peter mcfarlane wrote: > Hi, > I don't know if this is the correct forum, I am new to Python and > trying to install Kivy. I keep getting the following error message. > Can you help? > > thanks, > pete > > > > > pip install --user Kivy > > > Collecting Kivy > Using cached Kivy-1.9.0.tar.gz > Requirement already satisfied (use --upgrade to upgrade): > Kivy-Garden==0.1.1 in c:\python27\lib\site-packages (from Kivy) > Requirement already satisfied (use --upgrade to upgrade): requests in > c:\python27\lib\site-packages (from Kivy-Garden==0.1.1->Kivy) > Building wheels for collected packages: Kivy > Running setup.py bdist_wheel for Kivy > Complete output from command C:\Python27\python.exe -c "import > setuptools;__file__='C:\\Users\\edge\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\Kivy\\setup.py';exec(compile(open(__file__).read().replace('\r\n', > '\n'), __file__, 'exec'))" bdist_wheel -d > c:\users\edge\appdata\local\temp\tmps896gmpip-wheel-: > [INFO ] [Logger ] Record log in > C:\Users\edge\.kivy\logs\kivy_15-12-17_35.txt > [INFO ] [Kivy] v1.9.0 > [INFO ] [Python ] v2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 > 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] > > Detected Cython version 0.21.2 > Windows platform detected, force GLEW usage. > Using this graphics system: OpenGL > WARNING: A problem occured while running pkg-config --libs --cflags > gstreamer-1.0 (code 1) > > 'pkg-config' is not recognized as an internal or external command, > operable program or batch file. > > > WARNING: A problem occured while running pkg-config --libs --cflags sdl2 > SDL2_ttf SDL2_image SDL2_mixer (code 1) > > 'pkg-config' is not recognized as an internal or external command, > operable program or batch file. > > > running bdist_wheel > running build > running build_py > creating build > creating build\lib.win32-2.7 > creating build\lib.win32-2.7\kivy > copying kivy\animation.py -> build\lib.win32-2.7\kivy > copying kivy\app.py -> build\lib.win32-2.7\kivy > copying kivy\atlas.py -> build\lib.win32-2.7\kivy > copying kivy\base.py -> build\lib.win32-2.7\kivy > copying kivy\cache.py -> build\lib.win32-2.7\kivy > copying kivy\clock.py -> build\lib.win32-2.7\kivy > copying kivy\compat.py -> build\lib.win32-2.7\kivy > copying kivy\config.py -> build\lib.win32-2.7\kivy > copying kivy\context.py -> build\lib.win32-2.7\kivy > copying kivy\event.py -> build\lib.win32-2.7\kivy > copying kivy\factory.py -> build\lib.win32-2.7\kivy > copying kivy\factory_registers.py -> build\lib.win32-2.7\kivy > copying kivy\geometry.py -> build\lib.win32-2.7\kivy > copying kivy\gesture.py -> build\lib.win32-2.7\kivy > copying kivy\interactive.py -> build\lib.win32-2.7\kivy > copying kivy\lang.py -> build\lib.win32-2.7\kivy > copying kivy\loader.py -> build\lib.win32-2.7\kivy > copying kivy\logger.py -> build\lib.win32-2.7\kivy > copying kivy\metrics.py -> build\lib.win32-2.7\kivy > copying kivy\multistroke.py -> build\lib.win32-2.7\kivy > copying kivy\parser.py -> build\lib.win32-2.7\kivy > copying kivy\resources.py -> build\lib.win32-2.7\kivy > copying kivy\support.py -> build\lib.win32-2.7\kivy > copying kivy\utils.py -> build\lib.win32-2.7\kivy > copying kivy\vector.py -> build\lib.win32-2.7\kivy > copying kivy\weakmethod.py -> build\lib.win32-2.7\kivy > copying kivy\__init__.py -> build\lib.win32-2.7\kivy > creating build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\adapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\args_converters.py -> > build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\dictadapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\listadapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\models.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\simplelistadapter.py -> > build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\__init__.py -> build\lib.win32-2.7\kivy\adapters > creating build\lib.win32-2.7\kivy\core > copying kivy\core\__init__.py -> build\lib.win32-2.7\kivy\core > creating build\
Re: [Tutor] Fwd: Kivy Install
On 17/12/15 18:06, peter mcfarlane wrote: > Hi, > I don't know if this is the correct forum, Not really, this is for folks learning the python language and its standard library. kivy is a bit outside that remit. But pip isn't so... > ...I am new to Python and > trying to install Kivy. I keep getting the following error message. > Can you help? I'm no expert on Kivy and only a basics guy on pip but... > c:\users\edge\appdata\local\temp\pycharm-packaging0.tmp\kivy\kivy\graphics\gl_redirect.h(8) > : fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or > directory >error: command > 'C:\\Users\\edge\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ > for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2 Do you have Visual C++ installed? It looks like its trying to use it to compile something... But thats just a guess. I've just noticed another reply saying there are binary versions of kivy. If so I'd also recommend that route. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor