Re: Supply condition in function call

2015-03-25 Thread Manuel Graune
Gary Herron writes: > On 03/25/2015 10:29 AM, Manuel Graune wrote: >> >> def test1(a, b, condition="True"): >> for i,j in zip(a,b): >> c=i+j >> if eval(condition): >> print("Foo") >> >> test1([0,1,2,3],[1,2,3,4],"i+j >4") >> print("Bar") >> test1([0,1,2,3],[1,2,

Re: Supply condition in function call

2015-03-25 Thread Chris Angelico
On Thu, Mar 26, 2015 at 3:02 PM, Rustom Mody wrote: > [And BTW > help(filter) in python2 is much better documention than in python3 > ] Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 filter(...) filter(function or None, sequence) -> list, tuple, or string Return tho

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-25 Thread Dave Angel
On 03/26/2015 01:09 AM, Ian Kelly wrote: > > > https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation What the grammar that you quoted from shows is that STRING+ is an expression. The individual STRINGs of a STRING+ are not expressions, except to the extent t

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 10:35 PM, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Sun, Mar 22, 2015 at 2:49 PM, Thomas 'PointedEars' Lahn >> wrote: Implicit concatenation is part of the syntax, not part of the expression evaluator. >>> Reads like nonsense to me. >> >> W

Re: Regex Python Help

2015-03-25 Thread Terry Reedy
On 3/25/2015 7:10 PM, Steven D'Aprano wrote: Does Windows shell have grep? How about Powershell? No. I just use Idle's grep (Find in Files). And I generally would even if Command Prompt did have grep. Idle's has the nice feature that output goes in an Output Window, with each line found p

Re: Basic Python V3 Search Tool using RE module

2015-03-25 Thread Tim Chase
On 2015-03-25 21:20, Dave Angel wrote: >> pattern="DECRYPT_I" >> regexp=re.compile(pattern) > > That could explain why it's so fast. While I might have missed it in the thread, it also seems that regexpen are overkill for this. Why not just test for if pattern in name: ... -tkc -- http

Re: PIL(LOW) - What am I missing?

2015-03-25 Thread kai . peters
On Wednesday, 25 March 2015 20:54:21 UTC-7, kai.p...@gmail.com wrote: > I create an image as per: > > img = Image.new('1', (1024, 1280), 1) > > I then draw on it and do: > > imagedata = list(img.getdata()) > print len(imagedata) > > This gives me 1228800 instead of the expec

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-25 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Sun, Mar 22, 2015 at 2:49 PM, Thomas 'PointedEars' Lahn > wrote: >>> Implicit concatenation is part of the syntax, not part of the expression >>> evaluator. >> Reads like nonsense to me. > > What do you mean? As I showed, string literals and consecutive tokens of stri

Re: PIL(LOW) - What am I missing?

2015-03-25 Thread Gary Herron
On 03/25/2015 08:54 PM, kai.pet...@gmail.com wrote: I create an image as per: img = Image.new('1', (1024, 1280), 1) I then draw on it and do: imagedata = list(img.getdata()) print len(imagedata) This gives me 1228800 instead of the expected 1310720 (1024 * 1280) -

Re: Supply condition in function call

2015-03-25 Thread Rustom Mody
On Thursday, March 26, 2015 at 12:44:03 AM UTC+5:30, Gary Herron wrote: > On 03/25/2015 10:29 AM, Manuel Graune wrote: > > Hi, > > > > I'm looking for a way to supply a condition to an if-statement inside a > > function body when calling the function. I can sort of get what I want > > with using ev

PIL(LOW) - What am I missing?

2015-03-25 Thread kai . peters
I create an image as per: img = Image.new('1', (1024, 1280), 1) I then draw on it and do: imagedata = list(img.getdata()) print len(imagedata) This gives me 1228800 instead of the expected 1310720 (1024 * 1280) - any ideas what I am missing? As always, any help much

Re: Sudoku solver

2015-03-25 Thread Abhiram R
On Thu, Mar 26, 2015 at 8:54 AM, Ian Kelly wrote: > On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R wrote: >> >> On Mar 26, 2015 5:39 AM, "Ian Kelly" wrote: >>> >> >>> "Hard" for a human doesn't necessarily mean "hard" for a programmatic >>> solver in this case. Try your solver on this one: >>> >>> $

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R wrote: > > On Mar 26, 2015 5:39 AM, "Ian Kelly" wrote: >> > >> "Hard" for a human doesn't necessarily mean "hard" for a programmatic >> solver in this case. Try your solver on this one: >> >> $ cat sudoku2.dat >> . . . 7 . . . . . >> 1 . . . . . . . . >>

Re: Sudoku solver

2015-03-25 Thread Abhiram R
On Mar 26, 2015 5:39 AM, "Ian Kelly" wrote: > > "Hard" for a human doesn't necessarily mean "hard" for a programmatic > solver in this case. Try your solver on this one: > > $ cat sudoku2.dat > . . . 7 . . . . . > 1 . . . . . . . . > . . . 4 3 . 2 . . > . . . . . . . . 6 > . . . 5 . 9 . . . > . .

Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > The whole file. The device polls a storage area for incoming files and > display them. If the storage area is on disk and you don't care about speed, then it's enough to convert the bit stream and write it out a character at a time. Some other posters mentioned possi

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 8:18:22 PM UTC-4, MRAB wrote: > On 2015-03-25 22:36, Chris Angelico wrote: > > On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriolwrote: > >> Two possibilities: > >> > >>You are a moderator. If you are a moderator you are welcome to delete > >> my tests posts. This

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 7:59:34 PM UTC-4, Steven D'Aprano wrote: > On Thu, 26 Mar 2015 10:43 am, Tiglath Suriol wrote: > > > I've dealt with people like you in newsgroups for a long time > > So many years, so little learning. It's arseholes like you who make it so > important to invent a

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 7:58:11 PM UTC-4, Mark Lawrence wrote: > > You might be used to dealing with other people in other newsgroups. > This is the Python main mailing list/newsgroup. There is a rather more > civilised way of doing things around here. What arrogance, So you think yo

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Wednesday, 25 March 2015 18:10:00 UTC-7, Paul Rubin wrote: > nobody writes: > > I though that the bytes type is Python 3 only? If so, I cannot use it. > > In Python 2, the regular string type (str) is a byte vector, though it > is immutable. Do you send one scan line at a time to the renderin

Re: Basic Python V3 Search Tool using RE module

2015-03-25 Thread Dave Angel
On 03/25/2015 03:43 PM, Gregg Dotoli wrote: This basic script will help to find evidence of CryptoWall on a slave drive. Although it is just a string, more complex regex patterns can be replaced with the string. It is incredible how fast Python is and how easy it has helped in quickly assessing

Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > I though that the bytes type is Python 3 only? If so, I cannot use it. In Python 2, the regular string type (str) is a byte vector, though it is immutable. Do you send one scan line at a time to the rendering device, or the whole file all at once, or what? Do you w

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: > I have a list containing 9600 integer elements - each integer is either 0 or > 1. > > Starting at the front of the list, I need to combine 8 list elements into 1 > by treating them as if they were bits of one byte with 1 a

Re: test1

2015-03-25 Thread Mark Lawrence
On 26/03/2015 00:17, MRAB wrote: On 2015-03-25 22:36, Chris Angelico wrote: On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol wrote: Two possibilities: You are a moderator. If you are a moderator you are welcome to delete my tests posts. This is of course improbably because this newsgroup is

Re: test1

2015-03-25 Thread MRAB
On 2015-03-25 22:36, Chris Angelico wrote: On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol wrote: Two possibilities: You are a moderator. If you are a moderator you are welcome to delete my tests posts. This is of course improbably because this newsgroup is not moderated. You misunderst

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 2:31 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> The test puzzle that you posted has 23 values already filled in. How >> does it perform on harder puzzles with only 17 clues (the proven >> minimum)? One would expect it to be around a million times slower. > > Just try it.

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Mark Lawrence
On 25/03/2015 23:49, Ian Kelly wrote: On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu wrote: I am learning python programming. One thing that gives me a lot of confusion is the division of labours between the time module and the datetime module. As it turns out to be, time module is not only abo

Re: test1

2015-03-25 Thread Steven D'Aprano
On Thu, 26 Mar 2015 10:43 am, Tiglath Suriol wrote: > I've dealt with people like you in newsgroups for a long time So many years, so little learning. It's arseholes like you who make it so important to invent a way to stab people through the internet. Just go away, you're not wanted here. *plon

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 4:09:39 PM UTC-4, alister wrote: > As Chris is a respected contributor to this newsgroup that would only be > your loss > I'll just have to find some way to go on then, won't I? I bounce some code off a newsgroup, and all these fox-terriers start nipping at my

Re: test1

2015-03-25 Thread Mark Lawrence
On 25/03/2015 23:43, Tiglath Suriol wrote: On Wednesday, March 25, 2015 at 6:38:09 PM UTC-4, Chris Angelico wrote: On Thu, Mar 26, 2015 at 6:49 AM, wrote: Two possibilities: You are a moderator. If you are a moderator you are welcome to delete my tests posts. This is of course improbably

Re: Regex Python Help

2015-03-25 Thread Mark Lawrence
On 25/03/2015 23:10, Steven D'Aprano wrote: On Thu, 26 Mar 2015 08:19 am, Gregg Dotoli wrote: Grep is regular expressions. If I'm using Python, I'll use the Python modules. Silly It very well may be silly. You're using Python regular expressions because you're using Python. Why are you using

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of confusion > is the division of labours between the time module and the datetime module. > > As it turns out to be, time module is not only about time, it's about date > too. A

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Steven D'Aprano
On Thu, 26 Mar 2015 04:43 am, Ivan Evstegneev wrote: > Hello all , > > > Just a little question about function's default arguments. > > Let's say I have this function: > > def my_fun(history=False, built=False, current=False, topo=None, > full=False, file=None): > if currnet and full: > do so

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 6:38:09 PM UTC-4, Chris Angelico wrote: > On Thu, Mar 26, 2015 at 6:49 AM, wrote: > > Two possibilities: > > > >You are a moderator. If you are a moderator you are welcome to delete my > > tests posts. This is of course improbably because this newsgroup is not

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Steven D'Aprano
On Thu, 26 Mar 2015 08:16 am, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of > confusion is the division of labours between the time module and the > datetime module. > > As it turns out to be, time module is not only about time, it's about date > too. And

Re: test1

2015-03-25 Thread Tiglath Suriol
On Wednesday, March 25, 2015 at 4:09:39 PM UTC-4, alister wrote: > On Wed, 25 Mar 2015 12:49:47 -0700, Tiglath Suriol wrote: > > > On Tuesday, March 24, 2015 at 11:04:48 PM UTC-4, Chris Angelico wrote: > >> On Wed, Mar 25, 2015 at 1:47 PM, Tiglath Suriol wrote: > >> > {% block title %}{% endblock

Re: Newbie looking for elegant solution

2015-03-25 Thread Irmen de Jong
On 26-3-2015 0:14, kai.pet...@gmail.com wrote: > On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: >> I have a list containing 9600 integer elements - each integer is either 0 or >> 1. >> >> Starting at the front of the list, I need to combine 8 list elements into 1 >> by tr

Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > im.getdata() => sequence > Returns the contents of an image as a sequence object containing pixel > values. The sequence object is flattened, so that values for line one > follow directly after the values of line zero, and so on. And this is a list of 1's and 0's, I

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: > I have a list containing 9600 integer elements - each integer is either 0 or > 1. > > Starting at the front of the list, I need to combine 8 list elements into 1 > by treating them as if they were bits of one byte with 1 a

Re: Regex Python Help

2015-03-25 Thread Steven D'Aprano
On Thu, 26 Mar 2015 08:19 am, Gregg Dotoli wrote: > Grep is regular expressions. If I'm using Python, I'll use the Python > modules. Silly It very well may be silly. You're using Python regular expressions because you're using Python. Why are you using Python? Early in this thread you said "H

Re: Sudoku solver

2015-03-25 Thread Mark Lawrence
On 25/03/2015 22:50, Steven D'Aprano wrote: On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean they don't exist: http://en.wikipedia.org/wiki

Re: Sudoku solver

2015-03-25 Thread Steven D'Aprano
On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: > I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean they don't exist: http://en.wikipedia.org/wiki/Fibonacci_number#Applications -- Steven

Re: Sudoku solver

2015-03-25 Thread Chris Angelico
On Thu, Mar 26, 2015 at 7:31 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> The test puzzle that you posted has 23 values already filled in. How >> does it perform on harder puzzles with only 17 clues (the proven >> minimum)? One would expect it to be around a million times slower. > > Just try it.

Re: test1

2015-03-25 Thread Chris Angelico
On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol wrote: > Two possibilities: > >You are a moderator. If you are a moderator you are welcome to delete my > tests posts. This is of course improbably because this newsgroup is not > moderated. You misunderstand newsgroups and mailing lists. Post

Re: Regex Python Help

2015-03-25 Thread Mark Lawrence
On 25/03/2015 21:19, Gregg Dotoli wrote: Grep is regular expressions. If I'm using Python, I'll use the Python modules. Silly Gregg Clear as mud, and please don't top post. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrenc

Re: Regex Python Help

2015-03-25 Thread Gregg Dotoli
Grep is regular expressions. If I'm using Python, I'll use the Python modules. Silly Gregg On Wednesday, March 25, 2015 at 4:36:01 PM UTC-4, Denis McMahon wrote: > On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote: > > > I am creating a tool to search a filesystem for one simple string. > > man

time module vs. datetime module: plain language for beginners

2015-03-25 Thread Jinghui Niu
I am learning python programming. One thing that gives me a lot of confusion is the division of labours between the time module and the datetime module. As it turns out to be, time module is not only about time, it's about date too. And datetime doesn't natively support timezone, you have to cre

Re: Supply condition in function call

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 1:53 PM, Grant Edwards wrote: > On 2015-03-25, Ian Kelly wrote: >> On Wed, Mar 25, 2015 at 11:29 AM, Manuel Graune >> wrote: >> >>> I'm looking for a way to supply a condition to an if-statement inside a >>> function body when calling the function. I can sort of get what

RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Ivan Evstegneev
> -Original Message- > From: Python-list [mailto:python-list- > bounces+webmailgroups=gmail@python.org] On Behalf Of Rob Gaddi > Sent: Wednesday, March 25, 2015 22:07 > To: python-list@python.org > Subject: Re: Function Defaults - avoiding unneccerary combinations of > arguments at in

Re: Regex Python Help

2015-03-25 Thread Denis McMahon
On Tue, 24 Mar 2015 11:13:41 -0700, gdotoli wrote: > I am creating a tool to search a filesystem for one simple string. man grep STOP! REINVENTING! THE! WHEEL! Your new wheel will invariably be slower and less efficient than the old one. -- Denis McMahon, denismfmcma...@gmail.com -- https:/

Re: Sudoku solver

2015-03-25 Thread Marko Rauhamaa
Ian Kelly : > The test puzzle that you posted has 23 values already filled in. How > does it perform on harder puzzles with only 17 clues (the proven > minimum)? One would expect it to be around a million times slower. Just try it. The example had a minimum of clues (drop one clue and you'll get

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Terry Reedy
On 3/25/2015 3:50 PM, Ivan Evstegneev wrote: Googled a bit, and found only one, a "ValueError" exception, but still don't understand how it should be implemented in my case. Should my code look like this one: def my_fun(history=False, built=False, current=False, topo=None, full=False, file=No

Re: test2

2015-03-25 Thread alister
On Wed, 25 Mar 2015 14:22:23 +1100, Chris Angelico wrote: > On Wed, Mar 25, 2015 at 2:11 PM, Tiglath Suriol > wrote: >> # Make this unique, and don't share it with anybody. >> SECRET_KEY = '42=kv!a-il*!4j&7v+0(@a@vq_3j-+ysatta@l6-h63odj2)75' > > This right here is a reason to send your test mess

Re: test1

2015-03-25 Thread alister
On Wed, 25 Mar 2015 12:49:47 -0700, Tiglath Suriol wrote: > On Tuesday, March 24, 2015 at 11:04:48 PM UTC-4, Chris Angelico wrote: >> On Wed, Mar 25, 2015 at 1:47 PM, Tiglath Suriol wrote: >> > {% block title %}{% endblock %} >> >> Looks to me like you're playing around with a templating system

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 1:37 PM, Marko Rauhamaa wrote: > John Ladasky : > >> On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: >> >>> I post below a sudoku solver. I eagerly await neater implementations (as >>> well as bug reports). >> >> So, it's a brute-force, recursive sol

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Rob Gaddi
On Wed, 25 Mar 2015 21:50:40 +0200, Ivan Evstegneev wrote: > Hello again ^_^, > > Googled a bit, and found only one, a "ValueError" exception, but still > don't understand how it should be implemented in my case. > > Should my code look like this one: > > def my_fun(history=False, built=False,

Re: Supply condition in function call

2015-03-25 Thread Grant Edwards
On 2015-03-25, Ian Kelly wrote: > On Wed, Mar 25, 2015 at 11:29 AM, Manuel Graune > wrote: > >> I'm looking for a way to supply a condition to an if-statement inside a >> function body when calling the function. I can sort of get what I want >> with using eval [...] > > Pass the condition as a f

RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Ivan Evstegneev
Hello again ^_^, Googled a bit, and found only one, a "ValueError" exception, but still don't understand how it should be implemented in my case. Should my code look like this one: def my_fun(history=False, built=False, current=False, topo=None, full=False, file=None): try:

Re: test1

2015-03-25 Thread Tiglath Suriol
On Tuesday, March 24, 2015 at 11:04:48 PM UTC-4, Chris Angelico wrote: > On Wed, Mar 25, 2015 at 1:47 PM, Tiglath Suriol wrote: > > {% block title %}{% endblock %} > > Looks to me like you're playing around with a templating system like > Jinja, but may I suggest that you send tests to yourself r

Basic Python V3 Search Tool using RE module

2015-03-25 Thread Gregg Dotoli
This basic script will help to find evidence of CryptoWall on a slave drive. Although it is just a string, more complex regex patterns can be replaced with the string. It is incredible how fast Python is and how easy it has helped in quickly assessing a pool of slave drives. I'm improving it as

Re: Sudoku solver

2015-03-25 Thread Marko Rauhamaa
John Ladasky : > On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: > >> I post below a sudoku solver. I eagerly await neater implementations (as >> well as bug reports). > > So, it's a brute-force, recursive solver? The code is nice and short. > But I bet it takes a long time

RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Ivan Evstegneev
Hi Terry, Thanks for answer, I'll google these stdlib instances. Sincerely, Ivan. > -Original Message- > From: Python-list [mailto:python-list- > bounces+webmailgroups=gmail@python.org] On Behalf Of Terry Reedy > Sent: Wednesday, March 25, 2015 20:43 > To: python-list@python.org >

Re: Supply condition in function call

2015-03-25 Thread Gary Herron
On 03/25/2015 10:29 AM, Manuel Graune wrote: Hi, I'm looking for a way to supply a condition to an if-statement inside a function body when calling the function. I can sort of get what I want with using eval (see code below) but I would like to achieve this in a safer way. If there is a solution

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 12:44 PM, John Ladasky wrote: > On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: > >> I post below a sudoku solver. I eagerly await neater implementations (as >> well as bug reports). > > So, it's a brute-force, recursive solver? The code is nice and

Re: Supply condition in function call

2015-03-25 Thread Terry Reedy
On 3/25/2015 1:29 PM, Manuel Graune wrote: Hi, I'm looking for a way to supply a condition to an if-statement inside a function body when calling the function. I can sort of get what I want with using eval (see code below) but I would like to achieve this in a safer way. If there is a solution w

Re: Newbie looking for elegant solution

2015-03-25 Thread Travis Griggs
> On Mar 24, 2015, at 8:28 PM, Chris Angelico wrote: > > On Wed, Mar 25, 2015 at 2:13 PM, wrote: >> I have a list containing 9600 integer elements - each integer is either 0 or >> 1. >> >> Starting at the front of the list, I need to combine 8 list elements into 1 >> by treating them as if

Re: Sudoku solver

2015-03-25 Thread John Ladasky
On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: > I post below a sudoku solver. I eagerly await neater implementations (as > well as bug reports). So, it's a brute-force, recursive solver? The code is nice and short. But I bet it takes a long time to run. I and a stude

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Terry Reedy
On 3/25/2015 1:43 PM, Ivan Evstegneev wrote: Hello all , Just a little question about function's default arguments. Let's say I have this function: def my_fun(history=False, built=False, current=False, topo=None, full=False, file=None): if currnet and full: do somethi

Re: Supply condition in function call

2015-03-25 Thread Joel Goldstick
On Wed, Mar 25, 2015 at 2:22 PM, Ian Kelly wrote: > On Wed, Mar 25, 2015 at 12:17 PM, Joel Goldstick > wrote: >> Oh, now I see. Do you know about this: >> https://docs.python.org/2/library/ast.html#ast.literal_eval > > As the name suggests, that only evals literals. It won't work for > complex e

Re: Supply condition in function call

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 12:17 PM, Joel Goldstick wrote: > Oh, now I see. Do you know about this: > https://docs.python.org/2/library/ast.html#ast.literal_eval As the name suggests, that only evals literals. It won't work for complex expressions like "i + j > 4" -- https://mail.python.org/mailma

Re: Supply condition in function call

2015-03-25 Thread Joel Goldstick
On Wed, Mar 25, 2015 at 1:51 PM, Manuel Graune wrote: > Joel Goldstick writes: > >> On Wed, Mar 25, 2015 at 1:29 PM, Manuel Graune >> wrote: >>> >>> def test1(a, b, condition="True"): >>> for i,j in zip(a,b): >>> c=i+j >>> if eval(condition): >>>print("Foo") >>>

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 11:43 AM, Ivan Evstegneev wrote: > Hello all , > > > Just a little question about function's default arguments. > > Let's say I have this function: > > def my_fun(history=False, built=False, current=False, topo=None, > full=False, file=None): > if currnet and full:

Re: Supply condition in function call

2015-03-25 Thread Manuel Graune
Joel Goldstick writes: > On Wed, Mar 25, 2015 at 1:29 PM, Manuel Graune wrote: >> >> def test1(a, b, condition="True"): >> for i,j in zip(a,b): >> c=i+j >> if eval(condition): >>print("Foo") >> > I'm not sure I understand your question, but condition will evaluate

Re: Supply condition in function call

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 11:29 AM, Manuel Graune wrote: > Hi, > > I'm looking for a way to supply a condition to an if-statement inside a > function body when calling the function. I can sort of get what I want > with using eval (see code below) but I would like to achieve this in a > safer way. If

Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Ivan Evstegneev
Hello all , Just a little question about function's default arguments. Let's say I have this function: def my_fun(history=False, built=False, current=False, topo=None, full=False, file=None): if currnet and full: do something_1 elif current and file:

Re: Supply condition in function call

2015-03-25 Thread Joel Goldstick
On Wed, Mar 25, 2015 at 1:29 PM, Manuel Graune wrote: > Hi, > > I'm looking for a way to supply a condition to an if-statement inside a > function body when calling the function. I can sort of get what I want > with using eval (see code below) but I would like to achieve this in a > safer way. If

Supply condition in function call

2015-03-25 Thread Manuel Graune
Hi, I'm looking for a way to supply a condition to an if-statement inside a function body when calling the function. I can sort of get what I want with using eval (see code below) but I would like to achieve this in a safer way. If there is a solution which is safer while being less flexible, that

Re: PiCxx

2015-03-25 Thread Neal Becker
π wrote: > Hello Python people, > > I've made a C++ wrapper for Python. > I've called it PiCxx and put it up here: https://github.com/p-i-/PiCxx > > > That project runs out of the box on OS X and should be pretty easy to > adapt for other OS. Any help providing d

PiCxx

2015-03-25 Thread π
Hello Python people, I've made a C++ wrapper for Python. I've called it PiCxx and put it up here: https://github.com/p-i-/PiCxx That project runs out of the box on OS X and should be pretty easy to adapt for other OS. Any help providing demo projects for other

Re: Daylight savings time question

2015-03-25 Thread random832
On Tue, Mar 24, 2015, at 18:24, Dan Stromberg wrote: > Is there a way of "adding" 4 hours and getting a jump of 5 hours on > March 8th, 2015 (due to Daylight Savings Time), without hardcoding > when to spring forward and when to fall back? I'd love it if there's > some library that'll do this for

Re: Regex Python Help

2015-03-25 Thread Gregg Dotoli
No worries Steven, Thanks to ALL on this thread. Gregg On Tuesday, March 24, 2015 at 9:43:58 PM UTC-4, Steven D'Aprano wrote: > On Wed, 25 Mar 2015 05:13 am, gdot...@gmail.com wrote: > > > The error is: > > > > SyntaxError: Missing parentheses in call to 'print' > > > I cannot imagine how

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Larry Martell
On Wed, Mar 25, 2015 at 10:44 AM, Ian Kelly wrote: > On Wed, Mar 25, 2015 at 8:36 AM, Larry Martell > wrote: >> On Wed, Mar 25, 2015 at 8:26 AM, Grant Edwards >> wrote: >>> On 2015-03-25, Larry Martell wrote: I have an app that works with 2.6, but in 2.7 it is failing. I traced it d

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 8:36 AM, Larry Martell wrote: > On Wed, Mar 25, 2015 at 8:26 AM, Grant Edwards > wrote: >> On 2015-03-25, Larry Martell wrote: >>> I have an app that works with 2.6, but in 2.7 it is failing. I traced >>> it down to an issue with decimal.Decimal being passed a value of 0

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Tim Golden
On 25/03/2015 14:29, Oscar Benjamin wrote: > On 25 March 2015 at 14:20, Larry Martell wrote: >> I have an app that works with 2.6, but in 2.7 it is failing. I traced >> it down to an issue with decimal.Decimal being passed a value of 0.0. >> It 2.6 this is fine, but in 2.7 it throws an exception:

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Larry Martell
On Wed, Mar 25, 2015 at 8:26 AM, Grant Edwards wrote: > On 2015-03-25, Larry Martell wrote: >> I have an app that works with 2.6, but in 2.7 it is failing. I traced >> it down to an issue with decimal.Decimal being passed a value of 0.0. >> It 2.6 this is fine, but in 2.7 it throws an exception:

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Oscar Benjamin
On 25 March 2015 at 14:20, Larry Martell wrote: > I have an app that works with 2.6, but in 2.7 it is failing. I traced > it down to an issue with decimal.Decimal being passed a value of 0.0. > It 2.6 this is fine, but in 2.7 it throws an exception: > > TypeError: Cannot convert float to Decimal.

Re: Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Grant Edwards
On 2015-03-25, Larry Martell wrote: > I have an app that works with 2.6, but in 2.7 it is failing. I traced > it down to an issue with decimal.Decimal being passed a value of 0.0. > It 2.6 this is fine, but in 2.7 it throws an exception: > > TypeError: Cannot convert float to Decimal. First conve

Python 2.7 issue with decimal value 0.0

2015-03-25 Thread Larry Martell
I have an app that works with 2.6, but in 2.7 it is failing. I traced it down to an issue with decimal.Decimal being passed a value of 0.0. It 2.6 this is fine, but in 2.7 it throws an exception: TypeError: Cannot convert float to Decimal. First convert the float to a string This is easy enough

Re: To Change A Pdf Ebook To Kindle

2015-03-25 Thread David H. Lipman
From: "Steven D'Aprano" On Tue, 24 Mar 2015 11:32 pm, alister wrote: On Tue, 24 Mar 2015 00:05:46 -0700, jeffreyciross wrote: [off-topic spam] Calibre does a very god job as well. Please don't reply to spam. Unless the product is a Python library, or is given in direct reply to an explic

Sudoku solver

2015-03-25 Thread Marko Rauhamaa
A lot of discussion was generated by the good, old fibonacci sequence. I have yet to find practical use for fibonacci numbers. However, the technique behind a sudoku solver come up every now and again in practical situations. I post below a sudoku solver. I eagerly await neater implementations (a

Re: Daylight savings time question

2015-03-25 Thread Chris Angelico
On Wed, Mar 25, 2015 at 10:18 AM, Carl Meyer wrote: > US/Pacific is an alias for America/Los_Angeles, and is also part of the > Olson database (though I guess it's considered an "old" name for the > timezone): https://github.com/eggert/tz/blob/master/backward Ah, okay. No problem then. If it work

Re: Daylight savings time question

2015-03-25 Thread Carl Meyer
Hi Dan, On 03/24/2015 04:24 PM, Dan Stromberg wrote: > Is there a way of "adding" 4 hours and getting a jump of 5 hours on > March 8th, 2015 (due to Daylight Savings Time), without hardcoding > when to spring forward and when to fall back? I'd love it if there's > some library that'll do this for

Re: Daylight savings time question

2015-03-25 Thread Carl Meyer
On 03/24/2015 04:56 PM, Chris Angelico wrote: > On Wed, Mar 25, 2015 at 9:24 AM, Dan Stromberg wrote: >> Is there a way of "adding" 4 hours and getting a jump of 5 hours on >> March 8th, 2015 (due to Daylight Savings Time), without hardcoding >> when to spring forward and when to fall back? I'd l