Re: Vectorized functions

2016-08-10 Thread Christian Gollwitzer
Am 11.08.16 um 06:02 schrieb Steven D'Aprano: Here's a neat little decorator which decorates a function with a special callable attribute "v" which operates somewhat like Julia's dot syntax: def vectorize(func): def v(seq, **kw): return [func(x, **kw) for x in seq] func.v = v

Re: ctypes And The WACAH Principle

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 3:23:58 PM UTC+12, eryk sun wrote: > > ...you can cast() bytes to c_void_p to get the address. > > ... > > For bytearray, use the buffer interface to create a ctypes array. The > array is not a copy. Cool! Those pointers* are much appreciated. *So to speak. :) --

Re: Send Msg To Specific Tcp Client from Tcp Server Python

2016-08-10 Thread Anil reddy reddy M
On Thursday, August 11, 2016 at 11:36:47 AM UTC+5:30, dieter wrote: > Anil reddy reddy M writes: > > > I was written a simple tcp server in python, which is nicely communicating > > with multiple tcp clients. My Tcp Server can accept multiple clients at > > time, each client as a new thread. I

Re: Asynchronous programming

2016-08-10 Thread Christian Gollwitzer
Am 11.08.16 um 06:38 schrieb Terry Reedy: You might be able to glean something from the succession of files I uploaded to https://bugs.python.org/issue27546 Integrate tkinter and asyncio (and async) I started with just mixing tk and asyncio callbacks. After some struggle with similar question a

Re: Asynchronous programming

2016-08-10 Thread Christian Gollwitzer
Am 11.08.16 um 05:53 schrieb Steven D'Aprano: How is this the same as, or different from, event-based programming? I'm familiar with programming in an event-based language where the interpreter itself provides an event loop and dispatches messages to your objects I'll just comment on that one.

Re: Generate reports in Python

2016-08-10 Thread Paul Rubin
"Ernest Bonat, Ph.D." writes: > I'm looking for best modules/practices to generate reports (HTML, PDF, etc) > in Python. Good ideas are very appreciated. See: http://www.reportlab.com/ for a well regarded package -- https://mail.python.org/mailman/listinfo/python-list

Re: Send Msg To Specific Tcp Client from Tcp Server Python

2016-08-10 Thread dieter
Anil reddy reddy M writes: > I was written a simple tcp server in python, which is nicely communicating > with multiple tcp clients. My Tcp Server can accept multiple clients at time, > each client as a new thread. I want send message to specific tcp client after > some time. > I can client Ad

Re: Asynchronous programming

2016-08-10 Thread Paul Rudin
Steven D'Aprano writes: > > Is there a good beginner's tutorial introducing the basics of asynchronous > programming? Starting with, why and where would you use it? You could do worse than watch Dave Beazley's pycon talk: https://www.youtube.com/watch?v=lYe8W04ERnY -- https://mail.python.org/ma

Generate reports in Python

2016-08-10 Thread Ernest Bonat, Ph.D.
Hi, I'm looking for best modules/practices to generate reports (HTML, PDF, etc) in Python. Good ideas are very appreciated. Thanks Ernest Bonat, Ph.D. Senior Software Engineer Senior Data Scientist -- https://mail.python.org/mailman/listinfo/python-list

Re: Asynchronous programming

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 3:06 PM, Paul Rubin wrote: > The basic reason to do it is it lets you serve a lot of concurrent i/o > channels (network connections, say) without using threads. If you want > to read a packet, you launch a non-blocking read that returns > immediately, and then transfer con

Re: Asynchronous programming

2016-08-10 Thread Paul Rubin
Steven D'Aprano writes: > Is there a good beginner's tutorial introducing the basics of asynchronous > programming? Starting with, why and where would you use it? You might look at some node.js tutorials since there are about a gazillion of them and some of them must be good. Also twistedmatrix.

Send Msg To Specific Tcp Client from Tcp Server Python

2016-08-10 Thread Anil reddy reddy M
I was written a simple tcp server in python, which is nicely communicating with multiple tcp clients. My Tcp Server can accept multiple clients at time, each client as a new thread. I want send message to specific tcp client after some time. I can client Address from connction, addr = socket.a

Re: Asynchronous programming

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 1:53 PM, Steven D'Aprano wrote: > How is this the same as, or different from, event-based programming? I'm > familiar with programming in an event-based language where the interpreter > itself provides an event loop and dispatches messages to your objects: > > - I define ob

Re: Asynchronous programming

2016-08-10 Thread Terry Reedy
On 8/10/2016 11:53 PM, Steven D'Aprano wrote: The latest versions of Python are introducing new keywords for asynchronous programming, async and await. See PEP 492: https://www.python.org/dev/peps/pep-0492/ Is there a good beginner's tutorial introducing the basics of asynchronous programming?

Asynchronous programming

2016-08-10 Thread Steven D'Aprano
The latest versions of Python are introducing new keywords for asynchronous programming, async and await. See PEP 492: https://www.python.org/dev/peps/pep-0492/ Is there a good beginner's tutorial introducing the basics of asynchronous programming? Starting with, why and where would you use it?

Re: Vectorized functions

2016-08-10 Thread Paul Rubin
Steven D'Aprano writes: > Is there any other functionality which would make this more useful? Cute, but map or listcomps work ok. Here's the Haskell equivalent to your example, fwiw, using the <$> operator from the Control.Applicative module: (+2) <$> [1,2,3] => [3,4,5] If you haven't trie

Vectorized functions

2016-08-10 Thread Steven D'Aprano
Its sometimes very useful to apply a function to each element of a list in turn. One common term for that is "vectorized function". Julia has a convenient syntactic shortcut for this: http://julia.readthedocs.io/en/latest/manual/functions/#dot-syntax-for-vectorizing-functions func(arg) call

Re: ctypes And The WACAH Principle

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 10:26 PM, Lawrence D’Oliveiro wrote: > But it has to copy the bytes into an array.array object, then decode that. Is > there a way it > could access the bytes memory directly? ctypes cast, string_at, wstring_at, memmove, and memset are implemented as FFI calls. Since ctyp

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Steven D'Aprano
On Thu, 11 Aug 2016 06:57 am, Cai Gengyang wrote: > Yea, using IDLE on OSX, Python 3.4.3. > > Yeah it works now ... I had to increase the font size and the indentation > width. When that happened , it could define miles_driven You were always defining "miles_driven", it is just that the display

Re: Python slang

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 7:18:28 AM UTC+12, Marko Rauhamaa wrote: > Oh, there's of course COBOL: > >ADD X TO Y GIVING RESULT I think COBOL has the same usage of “=” as BASIC, as assignment or equality comparison, depending on context. -- https://mail.python.org/mailman/listinfo/pyth

Re: ctypes And The WACAH Principle

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 10:31:36 AM UTC+12, Gregory Ewing wrote: > > Lawrence D’Oliveiro wrote: > >>>It will let you create non-leaky wrappers ... >> >> Why would I want to do that? > > You mentioned that ctypes wrappers are leaky, which I > assumed was meant as a criticism. WACAH! --

Re: Python slang

2016-08-10 Thread Michael Torrie
On 08/10/2016 05:57 PM, Michael Torrie wrote: > On 08/10/2016 10:19 AM, Random832 wrote: >> On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: >>> The use of = also has a long history... FORTRAN (where the comparison >>> was .EQ.), BASIC (granted, K&K required assignment to start with the

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Torrie
On 08/10/2016 11:29 AM, Michael Selik wrote: > On Tue, Aug 9, 2016 at 9:31 PM Steven D'Aprano > wrote: > >> >> http://steve-yegge.blogspot.com.au/2008/05/dynamic-languages-strike-back.html > > > Great link. I enjoyed the video, too. > https://www.youtube.com/watch?v=tz-Bb-D6teE > > Buried deep

Re: Python slang

2016-08-10 Thread Michael Torrie
On 08/10/2016 10:19 AM, Random832 wrote: > On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: >> The use of = also has a long history... FORTRAN (where the comparison >> was .EQ.), BASIC (granted, K&K required assignment to start with the >> keyword LET, so the use of = was mainly a deli

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016, 6:44 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > As to why I asked that, there are several reasons: I have a very concrete > need right now to find pragmatic ways to increase code quality, reduce > number of defects, etc. in a Python code base. But also I

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Gregory Ewing
Dennis Lee Bieber wrote: Stray gamma rays flipping bits in memory (though a bit harder to do, considering the firmware was in some hard-wired mess of core, I think the RAM was core too, so pretty much immune to gamma rays as well (at least at any intensity that wouldn't instantly kill the crew)

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 8:48 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> I suppose you could put down Kelvin as a last name and either Baron or >> Lord as a first name, but that'd just be cheating... > > > Or put NULL as the first name and have fun watching > the database break. > > htt

Re: Python slang

2016-08-10 Thread Ian Kelly
On Aug 10, 2016 4:36 PM, "Lawrence D’Oliveiro" wrote: On Thursday, August 11, 2016 at 5:35:03 AM UTC+12, Rustom Mody wrote: > On Wednesday, August 10, 2016 at 9:31:40 PM UTC+5:30, Anders J. Munch wrote: > Python’s inspiration and origin is ABC > Whose assignment looked like > PUT expr INTO var

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread Gregory Ewing
Chris Angelico wrote: I suppose you could put down Kelvin as a last name and either Baron or Lord as a first name, but that'd just be cheating... Or put NULL as the first name and have fun watching the database break. http://www.wired.com/2015/11/null/ Or perhaps even profit: http://www.dail

Re: ctypes And The WACAH Principle

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 8:31 AM, Gregory Ewing wrote: > Lawrence D’Oliveiro wrote: > >>> It will let you create non-leaky wrappers ... >> >> >> Why would I want to do that? > > > You mentioned that ctypes wrappers are leaky, which I > assumed was meant as a criticism. But if you *like* > your wrap

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Juan Pablo Romero Méndez
I've made my motives to start this conversation very clear: """ Determine if there is a style of writing code in a dynamic language that minimizes the occurrence of runtime errors AND avoids two things: 1) using runtime checks all over the place (either ad hoc or using tools like Valideer) 2) att

Re: How do I make a video animation with transparent background?

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 9:34:33 AM UTC+12, Martin Schöön wrote: > Next on my TODO list is to look into the color composition idea. I > have already looked this tutorial: > https://youtu.be/sZzmksnzrX0 If the images you generate have an alpha channel, Blender can composite them directly, w

Re: ctypes And The WACAH Principle

2016-08-10 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: It will let you create non-leaky wrappers ... Why would I want to do that? You mentioned that ctypes wrappers are leaky, which I assumed was meant as a criticism. But if you *like* your wrappers to be leaky, by all means go for it. :-) -- Greg -- https://mail.pyth

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread Lawrence D’Oliveiro
On Wednesday, August 10, 2016 at 4:47:33 PM UTC+12, sh.a...@gmail.com wrote: > i have installed python 3.5 , but the python command is not recognized Windows does not make it easy to install things, does it... -- https://mail.python.org/mailman/listinfo/python-list

Re: Python slang

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 4:01:40 AM UTC+12, Anders J. Munch wrote: > Lawrence D’Oliveiro: >> >>> [...] as much like C++ as possible. >> >> Nevertheless, Python copied the C misfeature [...] > > You segued a little too easily from C++ to C. Because C++ copied that same C misfeature. -- ht

Re: Python slang

2016-08-10 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 5:35:03 AM UTC+12, Rustom Mody wrote: > On Wednesday, August 10, 2016 at 9:31:40 PM UTC+5:30, Anders J. Munch wrote: > Python’s inspiration and origin is ABC > Whose assignment looked like > PUT expr INTO var HyperTalk did that in 1987. Is that where GvR got the id

Re: ctypes And The WACAH Principle

2016-08-10 Thread Lawrence D’Oliveiro
On Wednesday, August 10, 2016 at 10:13:53 PM UTC+12, eryk sun wrote: > ctypes classes have from_buffer and from_buffer_copy methods that use > the buffer protocol. For example, for a read-only buffer you can use > from_buffer_copy: > > >>> b = bytes(b'1234') > >>> a = (ctypes.c_char * 3).

Re: How do I make a video animation with transparent background?

2016-08-10 Thread Martin Schöön
Den 2016-08-10 skrev Christian Gollwitzer : > Am 09.08.16 um 14:44 schrieb Martin Schöön: >> Using this example: >> http://matplotlib.org/examples/animation/moviewriter.html >> and this tutorial: >> https://www.youtube.com/watch?v=h0F5X4b7jug >> I have covered a lot of ground. >> >> What I have fai

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Ethan Furman
On 08/10/2016 01:57 PM, Cai Gengyang wrote: Yea, using IDLE on OSX, Python 3.4.3. Yeah it works now ... I had to increase the font size and the indentation width. When that happened , it could define miles_driven I suspect you were defining it before, you just couldn't see the underscore. --

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Cai Gengyang
Yea, using IDLE on OSX, Python 3.4.3. Yeah it works now ... I had to increase the font size and the indentation width. When that happened , it could define miles_driven On Thursday, August 11, 2016 at 2:09:11 AM UTC+8, Zachary Ware wrote: > On Wed, Aug 10, 2016 at 12:39 PM, Cai Gengyang wr

Re: cross-platform logging.config: how to set cross platform log (handlers) file location?

2016-08-10 Thread Berteh BE
Thanks Peter for the insights that args are passed to eval(). Thanks Steven for the suggestion that ´~/' may actually work in windows. Combining both I'm now successfully using the following in my logging.conf configuration file, that works in both *nix and Windows: [handler_file] class=handlers

Re: Python slang

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 5:18 AM, Marko Rauhamaa wrote: > Rustom Mody : > >> On Wednesday, August 10, 2016 at 9:31:40 PM UTC+5:30, Anders J. Munch wrote: >> Python’s inspiration and origin is ABC >> Whose assignment looked like >> PUT expr INTO var >> >> This has the salutary effect >> - Of being l

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016, 4:34 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > > I've been trying to find (without success so far) an example of a situation > where the dynamic features of a language like Python provides a clear > advantage over languages with more than one type. > On

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Juan Pablo Romero Méndez
2016-08-09 18:28 GMT-07:00 Steven D'Aprano : > On Wed, 10 Aug 2016 04:29 am, Juan Pablo Romero Méndez wrote: > > > Hello, > > > > In online forums sometimes people complain that they end up having to > test > > constantly for None, > > Then don't return None to indicate an error. If you write this

Re: Python slang

2016-08-10 Thread Marko Rauhamaa
Rustom Mody : > On Wednesday, August 10, 2016 at 9:31:40 PM UTC+5:30, Anders J. Munch wrote: > Python’s inspiration and origin is ABC > Whose assignment looked like > PUT expr INTO var > > This has the salutary effect > - Of being l-to-r (the only other such case I know is gas mov) Oh, there's of

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 2:03 PM, Random832 wrote: > On Wed, Aug 10, 2016, at 06:34, eryk sun wrote: >> On Wed, Aug 10, 2016 at 4:46 AM, wrote: >> > >> > i have installed python 3.5 , but the python command is not recognized >> > >> > C:\Users\sharmaaj>python >> > 'python' is not recognized as an

Re: cross-platform logging.config: how to set cross platform log (handlers) file location?

2016-08-10 Thread bertrand . courts . circuits
Thanks Peter for the insights that args are passed to eval(). Thanks Steven for the suggestion that ´~/' may actually work in windows. Combining both I'm now successfully using the following in my logging.conf configuration file, that works in both *nix and Windows: [handler_file] class=handlers

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 1:46 PM, BartC wrote: > On 10/08/2016 11:34, eryk sun wrote: >> >> On Wed, Aug 10, 2016 at 4:46 AM, wrote: >>> >>> i have installed python 3.5 , but the python command is not recognized >>> >>> C:\Users\sharmaaj>python >>> 'python' is not recognized as an internal or exte

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Zachary Ware
On Wed, Aug 10, 2016 at 12:39 PM, Cai Gengyang wrote: > I managed to get this piece of code to work : > print("This program calculates mpg.") > This program calculates mpg. milesdriven = input("Enter miles driven:") > Enter miles driven: 50 milesdriven = float(milesdriven) gall

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016 at 1:41 PM Cai Gengyang wrote: > I managed to get this piece of code to work : > > >>> print("This program calculates mpg.") > This program calculates mpg. > >>> milesdriven = input("Enter miles driven:") > Enter miles driven: 50 > >>> milesdriven = float(milesdriven) > >>> g

Re: Specify the database for a Django ModelForm instance

2016-08-10 Thread Phil Boutros
Ben Finney wrote: > > The person who wrote that question must think very like myself. > > That doesn't address the question about ‘ModelForm.clean’ or > ‘ModelForm.is_valid’, though; how to tell the instance which database to > use for those? I must admit to not using multi-DB myself, but I t

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Juan Pablo Romero Méndez
2016-08-09 23:16 GMT-07:00 Gregory Ewing : > Juan Pablo Romero Méndez wrote: > > This is interesting. You are Ok having runtime errors? >> > > You're going to have runtime errors in any case, whether > they come from code you've put there yourself to check > types, or from somewhere deeper down. >

Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Cai Gengyang
I managed to get this piece of code to work : >>> print("This program calculates mpg.") This program calculates mpg. >>> milesdriven = input("Enter miles driven:") Enter miles driven: 50 >>> milesdriven = float(milesdriven) >>> gallonsused = input("Enter gallons used:") Enter gallons used: 100 >>>

Re: Python slang

2016-08-10 Thread Rustom Mody
On Wednesday, August 10, 2016 at 9:31:40 PM UTC+5:30, Anders J. Munch wrote: > Lawrence D’Oliveiro: > >> [...] as much like C++ as > >> possible. > > > > Nevertheless, Python copied the C misfeature [...] > > You segued a little too easily from C++ to C. When talking language > evolution and

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Tue, Aug 9, 2016 at 9:31 PM Steven D'Aprano wrote: > > http://steve-yegge.blogspot.com.au/2008/05/dynamic-languages-strike-back.html Great link. I enjoyed the video, too. https://www.youtube.com/watch?v=tz-Bb-D6teE Buried deep in the QA section, there's a comment from the audience (I'll par

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Juan Pablo Romero Méndez
2016-08-09 23:47 GMT-07:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > On Wednesday 10 August 2016 15:20, Juan Pablo Romero Méndez wrote: > > > Ok, so you suggested 1) catching exceptions at the point where you care, > 2) > > preemptively check for certain runtime conditions to avoi

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread BartC
On 10/08/2016 15:03, Random832 wrote: On Wed, Aug 10, 2016, at 06:34, eryk sun wrote: On Wed, Aug 10, 2016 at 4:46 AM, wrote: i have installed python 3.5 , but the python command is not recognized C:\Users\sharmaaj>python 'python' is not recognized as an internal or external command, operab

Re: Python slang

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: > The use of = also has a long history... FORTRAN (where the comparison > was .EQ.), BASIC (granted, K&K required assignment to start with the > keyword LET, so the use of = was mainly a delimiter between target and > expression being a

Re: Python slang

2016-08-10 Thread Anders J. Munch
Lawrence D’Oliveiro: >> [...] as much like C++ as >> possible. > > Nevertheless, Python copied the C misfeature [...] You segued a little too easily from C++ to C. When talking language evolution and inspirations, they are entirely different things. - Anders -- https://mail.python.org/mailman/

Re: Individuals and groups (was Specify the database for a Django)

2016-08-10 Thread Ben Finney
Rustom Mody writes: > On Wednesday, August 10, 2016 at 6:39:31 AM UTC+5:30, Ben Finney wrote: > > -- > > \ “I love and treasure individuals as I meet them, I loathe and | > > `\ despise the groups they identify with and belong to.” —George | > > _o__)

Re: Error running the exe file in Windows "Failed to execute script pyi_rth_pkgres"

2016-08-10 Thread Ernest Bonat, Ph.D.
Hi, I have fixed this problem by following the steps: 1. Uninstall the PyInstaller downloaded from http://www.pyinstaller.org/ pip install pyinstaller 2. Install the PyInstaller from the GitHub developer repository pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip Still

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 06:34, eryk sun wrote: > On Wed, Aug 10, 2016 at 4:46 AM, wrote: > > > > i have installed python 3.5 , but the python command is not recognized > > > > C:\Users\sharmaaj>python > > 'python' is not recognized as an internal or external command, > > operable program or batc

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread BartC
On 10/08/2016 11:34, eryk sun wrote: On Wed, Aug 10, 2016 at 4:46 AM, wrote: i have installed python 3.5 , but the python command is not recognized C:\Users\sharmaaj>python 'python' is not recognized as an internal or external command, operable program or batch file. what should i do to run

Re: cropping a random part of an image

2016-08-10 Thread drewes . mil
Ok, now it works for me! Thanks again! import random, os, time from PIL import Image INPATH = ('/home/.../Start/') OUTPATH = ('/home/.../Ziel/') dx = dy = 228 tilesPerImage = 25 files = os.listdir(INPATH) numOfImages = len(files) print(files) t = time.time() for file in files: im = Imag

Re: cropping a random part of an image

2016-08-10 Thread drewes . mil
Ok, did it :) import random, os, time from PIL import Image INPATH = ('/home/sdrewes/Desktop/Portaits/Bilder/Test/') OUTPATH = ('/home/sdrewes/Desktop/Portaits/Bilder/Gut_Crop/') dx = dy = 228 tilesPerImage = 100 files = os.listdir(INPATH) numOfImages = len(files) print(files) t = time.time() f

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread Chris Angelico
On Wed, Aug 10, 2016 at 8:21 PM, alister wrote: - but secondly, don't force people's names to be subdivided. >>> >>> I like the French convention >>> . >> >> I may not have a family name at all > > Damn this would have been an id

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Steven D'Aprano
On Wed, 10 Aug 2016 07:48 pm, BartC wrote: > On 10/08/2016 02:47, Steven D'Aprano wrote: >> How about the difference between getting a compile-time error immediately >> you try to compile your program, and a run-time error three quarters of >> the way through processing a billion records, leaving

Re: cropping a random part of an image

2016-08-10 Thread drewes . mil
Hi Robin, I tried to understand and run your code, and I get the Error: "File "Rand_Crop.py", line 15, in with Image.open(os.path.join(INPATH, file)) as im: File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 528, in __getattr__ raise AttributeError(name) AttributeError: __exit_

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 4:46 AM, wrote: > > i have installed python 3.5 , but the python command is not recognized > > C:\Users\sharmaaj>python > 'python' is not recognized as an internal or external command, > operable program or batch file. > > what should i do to run python commands. Modify y

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread alister
On Wed, 10 Aug 2016 09:23:40 +, alister wrote: > On Tue, 09 Aug 2016 19:53:56 -0700, Lawrence D’Oliveiro wrote: > >> On Tuesday, August 9, 2016 at 4:20:37 AM UTC+12, Chris Angelico wrote: >>> Firstly, the bare "except:" clause should basically never be used; >>> instead, catch a very specific

Re: ctypes And The WACAH Principle

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 1:45 AM, Lawrence D’Oliveiro wrote: > > Ah, I wish... I had a look at the documentation for the buffer interface and > memory views, > and found no way to make use of them from pure Python. Basically, the > paragraph I quoted > above is wrong in just about every important

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread BartC
On 10/08/2016 02:47, Steven D'Aprano wrote: On Wed, 10 Aug 2016 11:02 am, Chris Angelico wrote: On Wed, Aug 10, 2016 at 10:58 AM, Juan Pablo Romero Méndez wrote: This is interesting. You are Ok having runtime errors? Absolutely. In real terms, there's no difference between "compile-time e

Re: cropping a random part of an image

2016-08-10 Thread drewes . mil
Hi Peter, Hi Robin, thanks for your help, and especially for the code ;) @Peter: thanks for the links, I know, it is always better to write the code than to copy and paste! @Robin: the question, iḿ trying to answer is, if good pictures, in this case portraits, also have good "Parts", so if th

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread alister
On Tue, 09 Aug 2016 19:53:56 -0700, Lawrence D’Oliveiro wrote: > On Tuesday, August 9, 2016 at 4:20:37 AM UTC+12, Chris Angelico wrote: >> Firstly, the bare "except:" clause should basically never be used; >> instead, catch a very specific exception and figure out what you want >> to do here > >

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread Wolfgang Maier
Try py instead of python. That invokes a thing called the python launcher (see https://docs.python.org/3/using/windows.html#python-launcher-for-windows for more details). Best, Wolfgang On 10.08.2016 06:46, sh.aja...@gmail.com wrote: Hi Everyone i have installed python 3.5 , but the python

Re: ctypes And The WACAH Principle

2016-08-10 Thread Lawrence D’Oliveiro
On Wednesday, August 10, 2016 at 6:35:57 PM UTC+12, Gregory Ewing wrote: > It's talking about accessing the internals of an object from C or C++ code, > *not* from Python. It’s saying that’s “the only way to effectively make use of this information”, which it is not. > If you're using ctypes an

Re: How do I make a video animation with transparent background?

2016-08-10 Thread Christian Gollwitzer
Am 09.08.16 um 14:44 schrieb Martin Schöön: Using this example: http://matplotlib.org/examples/animation/moviewriter.html and this tutorial: https://www.youtube.com/watch?v=h0F5X4b7jug I have covered a lot of ground. What I have failed to achieve is a graph with a transparent background. None of

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Steven D'Aprano
On Wednesday 10 August 2016 15:20, Juan Pablo Romero Méndez wrote: > Ok, so you suggested 1) catching exceptions at the point where you care, 2) > preemptively check for certain runtime conditions to avoid exceptions 3) > write as many tests as possible 4) learn to live with runtime errors. > >