Re: Python has arrived!

2014-11-07 Thread Steve Hayes
On Thu, 6 Nov 2014 15:22:45 + (UTC), Grant Edwards
 wrote:

>According to 
>http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots:
>
>  "Attacks occur in two phases. Hackers first infect a targeted
>   machine via simple malware that installs Python onto the device,
>   [...]"
>   

404: Page not found


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python has arrived!

2014-11-07 Thread Heinz Schmitz
Steve Hayes wrote:

>>According to 
>>http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots:
>>
>>  "Attacks occur in two phases. Hackers first infect a targeted
>>   machine via simple malware that installs Python onto the device,
>>   [...]"

>[Fri, 07 Nov 2014 06:54:54 +0200]
>404: Page not found

2014-11-07 10:06 MEZ   -> Page found.

Regards,
H.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python has arrived!

2014-11-07 Thread Gregory Ewing

Steve Hayes wrote:

On Thu, 6 Nov 2014 15:22:45 + (UTC), Grant Edwards
 wrote:


According to 
http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots:


404: Page not found


Works if you remove the spurious colon from the end of the url.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread cl
Darren Chen  wrote:
> 在 2014年11月5日星期三UTC+8下午8时17分11秒,larry@gmail.com写道:
> > On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev  
> > wrote:
> > > Firtst of all thanks for reply.
> > >
> > >>>brackets [] means that the argument is optional.
> > >
> > > That's what I'm talking about (asking actually), where do you know it 
> > > from?
> > 
> > I know it because I've been a programmer for 39 years.
> 
> that's awesome!!

Well I started in 1971 or thereabouts.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread Bob Martin
in 730867 20141107 093651 c...@isbd.net wrote:
>Darren Chen  wrote:
>> 在 
>> 2014年11月5日星期三UTC+8下午8时17分11秒,larry@gmail.com写道:
>> > On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev  
>> > wrote:
>> > > Firtst of all thanks for reply.
>> > >
>> > >>>brackets [] means that the argument is optional.
>> > >
>> > > That's what I'm talking about (asking actually), where do you know it 
>> > > from?
>> >
>> > I know it because I've been a programmer for 39 years.
>>
>> that's awesome!!
>
>Well I started in 1971 or thereabouts.

1959 for me ;-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Python @ FOSDEM 2015 - Call For Proposals

2014-11-07 Thread Stéphane Wirtel
* Please forward this CfP to anyone who may be interested in 
participating. *


Hi all,

This is the official call for sessions for the `Python Devroom` at 
`FOSDEM 2015` .


FOSDEM is the Free and Open source Software Developers' European 
Meeting,
a free and non-commercial two-day week-end that offers open source 
contributors

a place to meet, share ideas and collaborate.

It's the biggest event in Europe with +5000 hackers, +400 speakers.

For this edition, Python will be represented by its Community. If you 
want to

discuss with a lot of Python Users, it's the place to be !

Like every year, `FOSDEM 2015` will take place on 31st January and 1st 
February in

Brussels (Belgium).

We will have a room in the K building (80 seats) of the University Libre 
of

Brussels, with a VGA video project and Wireless Internet.

This devroom will be open all day Saturday, 31st January.

Call for Proposals is open until 1st December 2014.

You can watch the talks from the last edition 2014: 
https://www.youtube.com/playlist?list=PLUgTyq9ZstaI3t2XKhPjvnm-QBJTQySjD


Important dates
===

* Submission deadlines: 2014-12-01
* Acceptance notifications: 2014-12-15

Pratical


* The duration for talks will be 30 minutes, including presentations and 
questions & answers.
* Presentations can be recorded and streamed, sending your proposal 
implies giving permission to be recorded.
* A mailing list for the Python devroom is available for discussions 
about devroom organisation. You can register at this address: 
https://lists.fosdem.org/listinfo/python-devroom


How to submit
=

All submissions are made in the Pentabarf event planning tool at
https://penta.fosdem.org/submission/FOSDEM15

When submitting your talk in Pentabarf, make sure to select the 'Python 
devroom'

as the 'Track'.

Of course, If you already have an account, please reuse it.

Questions & Volunteers
==

Any questions, and volunteers, please mail to i...@python-fosdem.org.

Thank you for submitting your sessions and see you soon in Brussels to 
talk

Python and/or have some nice Belgian Beers.

For this edition, there will be organized a dinner with the Python 
Community.


If you want to keep informed for this edition, you can follow our 
twitter account @PythonFOSDEM .


FOSDEM 2015: http://fosdem.org/2015
Python Devroom: http://python-fosdem.org

Thank you,

Best regards,

The Team Python @ FOSDEM

--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread Dave Angel
Bob Martin  Wrote in message:
> in 730867 20141107 093651 c...@isbd.net wrote:
>>Darren Chen  wrote:
>>> 在 
>>> 2014年11月5日星期三UTC+8下午8时17分11秒,larry@gmail.com写道:
>>> > On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev  
>>> > wrote:
>>> > > Firtst of all thanks for reply.
>>> > >
>>> > >>>brackets [] means that the argument is optional.
>>> > >
>>> > > That's what I'm talking about (asking actually), where do you know it 
>>> > > from?
>>> >
>>> > I know it because I've been a programmer for 39 years.
>>>
>>> that's awesome!!
>>
>>Well I started in 1971 or thereabouts.
> 
> 1959 for me ;-)
> 

Approximately 1968 for me. I wrote programs in 1967, but didn't
 get to run them till 1968.
-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread Steven D'Aprano
Dave Angel wrote:

> Approximately 1968 for me. I wrote programs in 1967, but didn't
>  get to run them till 1968.


I once used a compiler that slow too.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Dinamically set __call__ method

2014-11-07 Thread Ethan Furman

On 11/06/2014 10:59 PM, dieter wrote:

John Ladasky writes:

On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote:


If you really absolutely positively have to have the signature be correct for 
each instance, you may to either look at a
function creating factory, a class creating factory, or a meta-class.


+1.  Overriding __call__() within the class definition, over and over again, 
with different function, looks awkward to me.


A possibility to get the original approach implemented looks like:

   make "__call__" a descriptor on the class which looks up the real
   method on the instance.


This still wouldn't get the signatrue correct, though.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread Larry Martell
On Fri, Nov 7, 2014 at 7:52 AM, Steven D'Aprano
 wrote:
> Dave Angel wrote:
>
>> Approximately 1968 for me. I wrote programs in 1967, but didn't
>>  get to run them till 1968.
>
>
> I once used a compiler that slow too.

Yeah, I think it was made by Intermetrics. Or maybe Borland.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread William Ray Wing
On Nov 7, 2014, at 7:42 AM, Dave Angel  wrote:
> 
> Bob Martin  Wrote in message:
>> in 730867 20141107 093651 c...@isbd.net wrote:
>>> Darren Chen  wrote:
>>>> 在 
>>>> 2014年11月5日星期三UTC+8下午8时17分11秒,larry@gmail.com写道:
>>>>> On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev  
>>>>> wrote:
>>>>>> Firtst of all thanks for reply.
>>>>>> 
>>>>>>>> brackets [] means that the argument is optional.
>>>>>> 
>>>>>> That's what I'm talking about (asking actually), where do you know it 
>>>>>> from?
>>>>> 
>>>>> I know it because I've been a programmer for 39 years.
>>>> 

But, to get back to the OP’s original question.  The earliest manuals that I 
remember looking at (from DEC, remember them) all had sections in the front 
that listed the typological conventions used throughout the manual.  Those 
included the use of square brackets to indicate optional arguments.  Eventually 
some of those conventions, including [ ] and the use of a fixed width font to 
indicate screen output, became so wide spread as to be simply part of the 
cultural context.  

A fair number of “Introduction to . . .” programming books still have such a 
section.

Bill

>>>> that's awesome!!
>>> 
>>> Well I started in 1971 or thereabouts.
>> 
>> 1959 for me ;-)
>> 
> 
> Approximately 1968 for me. I wrote programs in 1967, but didn't
> get to run them till 1968.
> -- 
> DaveA
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


bdist_rpm with --requires and version

2014-11-07 Thread thomas . lehmann
Hi,

using the RPM build I wonder how I can require a certain version
of another RPM like:

Working:
  python setup.py bdist_rpm --requires=another-package

But how to? ...
  python setup.py bdist_rpm --requires=another-package>=2.1

Of course this will generate a "=2.1" file which is
of course not wanted.

How to do it right?
-- 
https://mail.python.org/mailman/listinfo/python-list


generating 2D bit array variants with specific algorythm

2014-11-07 Thread Robert Voigtländer
Hi,

I need to generate all variants of a 2D array with variable dimension sizes 
which fit a specific rule. (up to 200*1000)

The rules are:
- Values are only 0 or 1
- the sum of each line bust be 1
- only valid results must be generated (generating all and only returning the 
valid results takes to long; that's what I tried already)

So for a 2x2 array these would be the valid results:

10
01

01
10

10
10

01
01


Must be possible with nested loops and a counter per line. But I don't get it.

Can someone help?

Thanks
Robert
-- 
https://mail.python.org/mailman/listinfo/python-list


Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Paul Moore
I'm in the process of developing an automated solution to allow users
to quickly set up a Windows box so that it can be used to compile
Python extensions and build wheels. While it can obviously be used by
Windows developers who want to quickly set up a box, my main target is
Unix developers who want to provide wheels for Windows users.

To that end, I'd like to get an idea of what sort of access to Windows
a typical Unix developer would have. I'm particularly interested in
whether Windows XP/Vista is still in use, and whether you're likely to
already have Python and/or any development tools installed. Ideally, a
clean Windows 7 or later virtual machine is the best environment, but
I don't know if it's reasonable to assume that.

Another alternative is to have an Amazon EC2 AMI prebuilt, and users
can just create an instance based on it. That seems pretty easy to do
from my perspective but I don't know if the connectivity process
(remote desktop) is a problem for Unix developers.

Any feedback would be extremely useful. I'm at a point where I can
pretty easily set up any of these options, but if they don't turn out
to actually be usable by the target audience, it's a bit of a waste of
time! :-)

Thanks,
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Donald Stufft

> On Nov 7, 2014, at 10:46 AM, Paul Moore  wrote:
> 
> I'm in the process of developing an automated solution to allow users
> to quickly set up a Windows box so that it can be used to compile
> Python extensions and build wheels. While it can obviously be used by
> Windows developers who want to quickly set up a box, my main target is
> Unix developers who want to provide wheels for Windows users.
> 
> To that end, I'd like to get an idea of what sort of access to Windows
> a typical Unix developer would have. I'm particularly interested in
> whether Windows XP/Vista is still in use, and whether you're likely to
> already have Python and/or any development tools installed. Ideally, a
> clean Windows 7 or later virtual machine is the best environment, but
> I don't know if it's reasonable to assume that.
> 
> Another alternative is to have an Amazon EC2 AMI prebuilt, and users
> can just create an instance based on it. That seems pretty easy to do
> from my perspective but I don't know if the connectivity process
> (remote desktop) is a problem for Unix developers.
> 
> Any feedback would be extremely useful. I'm at a point where I can
> pretty easily set up any of these options, but if they don't turn out
> to actually be usable by the target audience, it's a bit of a waste of
> time! :-)
> 
> Thanks,
> Paul
> ___
> Distutils-SIG maillist  -  distutils-...@python.org
> https://mail.python.org/mailman/listinfo/distutils-sig

As an *nix user I have a Windows 7 VM on my OS X machine that I can also
dual boot into which I mostly use for playing games that won’t play on
my OS X box natively. It does not have Python or any development tooling
installed on it.

I also have access to the cloud(tm) which is where I normally spin up
a whatever-the-most-recent-looking-name Windows Server.

---
Donald Stufft
PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread Joel Goldstick
On Fri, Nov 7, 2014 at 10:39 AM, Robert Voigtländer
 wrote:
> Hi,
>
> I need to generate all variants of a 2D array with variable dimension sizes 
> which fit a specific rule. (up to 200*1000)
>
> The rules are:
> - Values are only 0 or 1
> - the sum of each line bust be 1
> - only valid results must be generated (generating all and only returning the 
> valid results takes to long; that's what I tried already)
>
> So for a 2x2 array these would be the valid results:
>
> 10
> 01
>
> 01
> 10
>
> 10
> 10
>
> 01
> 01
>
>
> Must be possible with nested loops and a counter per line. But I don't get it.
>
> Can someone help?

is this valid:
1011
What I mean is do you throw away the carry or does each row have only one zero?

>
> Thanks
> Robert
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread Robert Voigtländer
> 1011
> What I mean is do you throw away the carry or does each row have only one 
> zero?

Not sure what you mean. Each row must have one 1. The rest must be 0.
No combinations not fitting this rule must be generated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Wichert Akkerman

> On 07 Nov 2014, at 16:46, Paul Moore  wrote:
> 
> I'm in the process of developing an automated solution to allow users
> to quickly set up a Windows box so that it can be used to compile
> Python extensions and build wheels. While it can obviously be used by
> Windows developers who want to quickly set up a box, my main target is
> Unix developers who want to provide wheels for Windows users.
> 
> To that end, I'd like to get an idea of what sort of access to Windows
> a typical Unix developer would have.

In my case: none.

The only form of Windows I have are VMs I grab from modern.ie 
 to test things with various IE versions. Those are all 
throw-away instances that are never used for anything other than IE testing.

Wichert.-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread Peter Otten
Robert Voigtländer wrote:

> Hi,
> 
> I need to generate all variants of a 2D array with variable dimension
> sizes which fit a specific rule. (up to 200*1000)
> 
> The rules are:
> - Values are only 0 or 1
> - the sum of each line bust be 1
> - only valid results must be generated (generating all and only returning
> the valid results takes to long; that's what I tried already)
> 
> So for a 2x2 array these would be the valid results:
> 
> 10
> 01
> 
> 01
> 10
> 
> 10
> 10
> 
> 01
> 01
> 
> 
> Must be possible with nested loops and a counter per line. But I don't get
> it.
> 
> Can someone help?

Have a look at itertools.product(). If you need to code it in Python -- the 
documentation has an example implementation.

from itertools import product

def f(n):
rows = [[0] * n for i in range(n)]
for i, row in enumerate(rows):
row[i] = 1
rows = [tuple(row) for row in rows]
return list(product(rows, repeat=n))

if __name__ == "__main__":
from pprint import pprint
pprint(f(2))
print("---")
pprint(f(3))

However, n**n is growing quite fast; you'll soon reach the limits of what is 
feasible in Python. Maybe numpy has something to offer to push these limits 
a bit. An optimisation would be to store the position of the 1, i. e.

01

10

00

11

for n=2. If you reorder these you get 0, 1, 2, 3. I think I'm seeing a 
pattern...

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast


"Robert Voigtländer"  a écrit dans le message de 
news:e5c93b46-a32b-4eca-a00d-f7dd2b4bb...@googlegroups.com...

1011
What I mean is do you throw away the carry or does each row have only one zero?


Not sure what you mean. Each row must have one 1. The rest must be 0.
No combinations not fitting this rule must be generated.


OK exactly one 1 per line, others are 0
I understood sum modulo 2 = 1, so an odd number of 1 as joel ;) 


--
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast


"Robert Voigtländer"  a écrit dans le message de 
news:0e6787f9-88d6-423a-8410-7578fa83d...@googlegroups.com...


Let be L the number of lines and C the numbers of column

You solve your problem just with counting on base C

On base C, a number may be represented with

N(L-1)N(L-2) ... N(0)N(0) where N(i) goes from 0 to C-1

N(i) is associated with line i of your array. Lines are numbered from 0
if N(i) == j, then bit in column j of line i is 1 and all others 0, columns are 
numbered from 0

For example, with an array of 2 lines and 3 colums

00 -->

100 <  line 1
100  < line 0

01 ->

100
010

02 ->

100
001

10 ->

010
100

11 ->

010
010

12 ->

010
001

20 ->

001
100

21 ->

001
010

22 ->

001
001






--
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread ast


"ast"  a écrit dans le message de 
news:545cf9f0$0$2913$426a3...@news.free.fr...


On base C, a number may be represented with

N(L-1)N(L-2) ... N(1)N(0) where N(i) goes from 0 to C-1


--
https://mail.python.org/mailman/listinfo/python-list


RE: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Steve Dower
Ben Finney wrote:
> Paul Moore  writes:
> 
>> To that end, I'd like to get an idea of what sort of access to Windows
>> a typical Unix developer would have. […] Ideally, a clean Windows 7 or
>> later virtual machine is the best environment, but I don't know if
>> it's reasonable to assume that.
> 
> It's difficult to say what “a typical Unix developer” is. But a significant 
> use
> case is going to be “no legal access to any MS Windows instance”.
> 
> The restrictions of the license terms make MS Windows an unacceptable risk on
> any machine I'm responsible for.

Just out of interest, which restrictions would those be? I may be able to raise 
them with one of our lawyers and get some clarification.

> It has been many years since I've even had a colleague who has a MS Windows
> instance, and I am not sure where I'd go for one if the need arose.
>
> If I was required to provide packages for MS Windows, the only viable 
> solutions
> would be those that don't involve me obtaining an MS Windows instance myself.

Does this prevent you from creating a VM on a cloud provider on your own 
account? As far as Microsoft Azure is concerned, this is well within the 
license restrictions (at least for Windows Server right now), and all providers 
giving you access to Windows should be bundling in a license fee, which makes 
it about as legit as possible. Simply giving you "share time" on someone else's 
copy of Windows is much more of a grey area as far as licensing is concerned.

If the licensing is a real issue, I'm in a position where I can have a positive 
impact on fixing it, so any info you can provide me (on- or off-list) about 
your concerns is valuable.

Cheers,
Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Paul Moore
On 7 November 2014 16:52, Ben Finney  wrote:
> If I was required to provide packages for MS Windows, the only viable
> solutions would be those that don't involve me obtaining an MS Windows
> instance myself.

For that usage, an Amazon EC2 AMI sounds ideal, as the license costs
are covered by the AWS costs (which are zero, if you're on the free
usage tier).

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Paul Moore
On 7 November 2014 17:17, Ben Finney  wrote:
> Paul Moore  writes:
>
>> On 7 November 2014 16:52, Ben Finney  wrote:
>> > If I was required to provide packages for MS Windows, the only viable
>> > solutions would be those that don't involve me obtaining an MS Windows
>> > instance myself.
>>
>> For that usage […] the license costs […]
>
> I didn't mention monetary costs at all. My understanding is that
> changing the cost doesn't in any way affect the terms of the license one
> is bound by.

Sorry, I misunderstood you. As Steve said, it would be necessary to
understand the restrictions you're working under to be able to
comment.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Distutils] Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Paul Moore
On 7 November 2014 17:42, Ben Finney  wrote:
>> Does this prevent you from creating a VM on a cloud provider on your
>> own account?
>
> If I need to accept restrictions such as the above, I don't see that the
> location of the instance (nor the fees charged) has any affect on these
> concerns. The risks discussed above are not mitigated.

Thanks for the clarification. Given what you say, I don't see any way
that I can offer a solution you'd be willing to accept - I suspect the
only viable option for you would be support for cross-compilation
using mingw/ggg, which I'm not able to offer. For now, I guess, that
simply means I'll have to consider you (and anyone else for whom even
running a Windows system is unacceptable) outside of my target
audience.

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:generating 2D bit array variants with specific algorythm

2014-11-07 Thread Dave Angel
Robert Voigtländer  Wrote in message:
> Hi,
> 
> I need to generate all variants of a 2D array with variable dimension sizes 
> which fit a specific rule. (up to 200*1000)
> 
> The rules are:
> - Values are only 0 or 1
> - the sum of each line bust be 1
> - only valid results must be generated (generating all and only returning the 
> valid results takes to long; that's what I tried already)
> 
> So for a 2x2 array these would be the valid results:
> 
> 10
> 01
> 
> 01
> 10
> 
> 10
> 10
> 
> 01
> 01
> 
> 
> Must be possible with nested loops and a counter per line. But I don't get it.

If the matrix is m by n, then there are 2**n possibilities for
 each row. But only n of them are legal by your rules. So your
 problem is just a matter of counting in base n, all the possible
 m digit numbers.


-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
def jump_to_blockD(self):
end = len(self.b)
row, col = self.w.cursor
while row <= end:
try:
new_col = self.b[row].index('def')
self.w.cursor = row, new_col
break
except ValueError:
pass
row += 1

def jump_to_blockU(self):
end = 0
row, col = self.w.cursor
while row >= end:
try:
new_col = self.b[row].rindex('def')
self.w.cursor = row, new_col
break
except ValueError:
pass
row -= 1



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread Gregory Ewing

Robert Voigtländer wrote:


I need to generate all variants of a 2D array with variable dimension sizes
which fit a specific rule. (up to 200*1000)


Um... you realise there are 200**1000 solutions for the
200x1000 case? Are you sure that's really what you want?

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Joel Goldstick
On Fri, Nov 7, 2014 at 5:16 AM, Veek M  wrote:
> def jump_to_blockD(self):
> end = len(self.b)
> row, col = self.w.cursor
> while row <= end:
> try:
> new_col = self.b[row].index('def')
> self.w.cursor = row, new_col
> break
> except ValueError:
> pass
> row += 1
>
> def jump_to_blockU(self):
> end = 0
> row, col = self.w.cursor
> while row >= end:
> try:
> new_col = self.b[row].rindex('def')
> self.w.cursor = row, new_col
> break
> except ValueError:
> pass
> row -= 1
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

add a direction parameter to the call, and test direction to change
the while test, and row increment/decrement

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Denis McMahon
On Fri, 07 Nov 2014 21:22:22 +0630, Veek M wrote:

> Veek M wrote:
> 
> 
>> new_col = self.b[row].index('def') self.w.cursor = row,
>> new_col
> 
>> new_col = self.b[row].rindex('def')
>> self.w.cursor = row, new_col
> 
> There's also the different methods index vs rindex.

yes, those fall under point 2 of my earlier post. "something" and 
"something else" would be the complete means of calculating the value to 
assign to variable.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Chris Angelico
On Fri, Nov 7, 2014 at 9:16 PM, Veek M  wrote:
> def jump_to_blockD(self):
> end = len(self.b)
> row, col = self.w.cursor
> while row <= end:
> try:
> new_col = self.b[row].index('def')
> self.w.cursor = row, new_col
> break
> except ValueError:
> pass
> row += 1
>
> def jump_to_blockU(self):
> end = 0
> row, col = self.w.cursor
> while row >= end:
> try:
> new_col = self.b[row].rindex('def')
> self.w.cursor = row, new_col
> break
> except ValueError:
> pass
> row -= 1

Start by translating this into for loops, rather than while, and then
it'll be much easier to put all the differences in the signature. Tell
me if this translation is faithful:

def jump_to_blockD(self):
for row in range(self.w.cursor[0], len(self.b)+1, 1):
try:
new_col = self.b[row].index('def')
self.w.cursor = row, new_col
break
except ValueError:
pass

def jump_to_blockU(self):
for row in range(self.w.cursor[0], -1, -1):
try:
new_col = self.b[row].rindex('def')
self.w.cursor = row, new_col
break
except ValueError:
pass

Try those two, see if they function the same as your original code. If
they do, you should be able to figure out how to merge them, in their
new form.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Steven D'Aprano
Paul Moore wrote:

> To that end, I'd like to get an idea of what sort of access to Windows
> a typical Unix developer would have. I'm particularly interested in
> whether Windows XP/Vista is still in use, and whether you're likely to
> already have Python and/or any development tools installed. Ideally, a
> clean Windows 7 or later virtual machine is the best environment, but
> I don't know if it's reasonable to assume that.

I don't think that there is such a beast as a "typical Unix developer",
since Unix covers such a wide range. In very rough order of decreasing
market share, there is Linux (not actually a form of Unix, but in practice
people gloss over that technicality), Apple OS X, FreeBSD, OpenBSD, various
commercial Unixes which still exist, and so on. They tend to attract very
different sorts of people, although if they had anything in common it would
probably be a dislike or rejection of Windows, so you can probably safely
assume that the average Unix/Linux/Mac user has little access to Windows.

Speaking for myself, I have effectively no access to Windows. Once a year I
manage to borrow a laptop with Windows 7 so I can do my taxes, but it has
no development tools on it. I also have access to a Windows 2000 VM for
work purposes, but I don't have admin rights to it and it too has no
development tools on it.


> Another alternative is to have an Amazon EC2 AMI prebuilt, and users
> can just create an instance based on it. That seems pretty easy to do
> from my perspective but I don't know if the connectivity process
> (remote desktop) is a problem for Unix developers.

If it uses a standard protocol like RDP or VNC, there shouldn't be a
problem, most Unixes have clients for these. I use rdesktop to talk to the
Win2000 VM at work all the time, and I can even do so over an ssh tunnel if
I need to access it from home.

https://en.wikipedia.org/wiki/Rdesktop

If it uses some secret or unusual proprietary protocol, forget it.

If remote access requires a specific Flash or Java app in the browser, it
may or may not work, but probably won't. Flash support on Linux is better
than it was but still mediocre. Since Flash these days is mostly used for
two things (crappy games and obnoxious adverts) most Linux folks I know
simply don't bother with it unless they use Chrome, in which case they get
it whether they want it or not.

Java is probably a bit better supported, but it can be annoying to set up.
It took me about a day to get my bank's Java app working in Firefox, and it
wouldn't work at all in other browsers or with the standard version of Java
provided by my Linux distro. I had to replace my system Java with Oracle's
Java, symlink it to an alternate location, and have my browser lie about
what it is in the user-agent.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread sohcahtoa82
On Friday, November 7, 2014 1:13:27 PM UTC-8, Gregory Ewing wrote:
> Robert Voigtländer wrote:
> 
> > I need to generate all variants of a 2D array with variable dimension sizes
> > which fit a specific rule. (up to 200*1000)
> 
> Um... you realise there are 200**1000 solutions for the
> 200x1000 case? Are you sure that's really what you want?
> 
> -- 
> Greg


It sounds like it is indeed what he wants, however, this is likely a homework 
assignment and the idea is that your program COULD produce the answer for that 
if he wanted, not that he will actually be using the result.

I'd handle it with recursion, myself.  It sounds like a cool idea for a game of 
Code Golf on Stack Exchange.
-- 
https://mail.python.org/mailman/listinfo/python-list


Different behaviour in list comps and generator expressions

2014-11-07 Thread Steven D'Aprano
The following list comprehension and generator expression are almost, but
not quite, the same:

[expr for x in iterable]

list(expr for x in iterable)


The difference is in the handling of StopIteration raised inside the expr.
Generator expressions consume them and halt, while comprehensions allow
them to leak out. A simple example:

iterable = [iter([])]
list(next(x) for x in iterable)
=> returns []

But:

[next(x) for x in iterable]
=> raises StopIteration


Has anyone come across this difference in the wild? Was it a problem? Do you
rely on that difference, or is it a nuisance? Has it caused difficulty in
debugging code?

If you had to keep one behaviour, which would you keep?



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Different behaviour in list comps and generator expressions

2014-11-07 Thread Roy Smith
In article <545d76fe$0$12980$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> The following list comprehension and generator expression are almost, but
> not quite, the same:
> 
> [expr for x in iterable]
> 
> list(expr for x in iterable)
> 
> 
> The difference is in the handling of StopIteration raised inside the expr.
> Generator expressions consume them and halt, while comprehensions allow
> them to leak out. A simple example:
> 
> iterable = [iter([])]
> list(next(x) for x in iterable)
> => returns []
> 
> But:
> 
> [next(x) for x in iterable]
> => raises StopIteration
> 
> 
> Has anyone come across this difference in the wild? Was it a problem? Do you
> rely on that difference, or is it a nuisance? Has it caused difficulty in
> debugging code?
> 
> If you had to keep one behaviour, which would you keep?

Wow, that's really esoteric.  I can't imagine this happening in 
real-life code (but I'm sure somebody will come up with an example :-))

My inclination is that a list comprehension should stop if StopIteration 
is raised by the comprehension body.  I can't come up with a good 
argument to support that, other than it seems like the right thing to do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
Veek M wrote:


> new_col = self.b[row].index('def')
> self.w.cursor = row, new_col

> new_col = self.b[row].rindex('def')
> self.w.cursor = row, new_col

There's also the different methods index vs rindex. Does this sort of thing 
justify two functions and associated infrastructure (it's for vim so 2 x 3 
mode lines in my .vimrc)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Denis McMahon
On Fri, 07 Nov 2014 16:46:19 +0630, Veek M wrote:

(1) Pass a true or false parameter to the function as the direction of 
search toggle.

(2) replace the relevant assignments with something like:

variable = something if condition else something else

(3) Figuring out the while loop control is a bit trickier, the best I 
came up with was:

while direction and condition_a or (not direction) and condition_b

But I'm sure someone has something better

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: bdist_rpm with --requires and version

2014-11-07 Thread Chris Angelico
On Sat, Nov 8, 2014 at 2:18 AM,   wrote:
> But how to? ...
>   python setup.py bdist_rpm --requires=another-package>=2.1
>
> Of course this will generate a "=2.1" file which is
> of course not wanted.

What shell are you on? On POSIX shells, just quote or escape the
relevant part. On Windows... I'm not sure. Depends whether you have
cmd.exe, powershell, or something else, and I don't know any of them
well enough to advise. But try putting the whole argument in quotes.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Dinamically set __call__ method

2014-11-07 Thread dieter
Ethan Furman  writes:

> On 11/06/2014 10:59 PM, dieter wrote:
>> John Ladasky writes:
>>> On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote:
>>>
 If you really absolutely positively have to have the signature be correct 
 for each instance, you may to either look at a
 function creating factory, a class creating factory, or a meta-class.
>>>
>>> +1.  Overriding __call__() within the class definition, over and over 
>>> again, with different function, looks awkward to me.
>>
>> A possibility to get the original approach implemented looks like:
>>
>>make "__call__" a descriptor on the class which looks up the real
>>method on the instance.
>
> This still wouldn't get the signatrue correct, though.

Why not? Once the descriptor is resolved, you get the final
instance method - with the correct signature.

-- 
https://mail.python.org/mailman/listinfo/python-list