Re: error with Firefox Binary 'The browser appears to have exited'

2015-04-15 Thread me
Have you tried specifying the location of Firefox binary explicitly ?

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = 
FirefoxBinary('C:\Users\aplusk\Documents\FirefoxPortable\App\Firefox\\firefox.exe')
browser = webdriver.Firefox(firefox_binary=binary)
-- 
https://mail.python.org/mailman/listinfo/python-list


PyDev 4.0.0 Released

2015-04-15 Thread Fabio Zadrozny
What is PyDev?
---

PyDev is an open-source Python IDE on top of Eclipse for Python,
Jython and IronPython development.

It comes with goodies such as code completion, syntax highlighting,
syntax analysis, code analysis, refactor, debug, interactive console,
etc.

Details on PyDev: http://pydev.org
Details on its development: http://pydev.blogspot.com


What is LiClipse?
---

LiClipse is a PyDev standalone with goodies such as support for
Multiple cursors, theming and a number of other languages such as
Django Templates, Jinja2, Kivy Language, Mako Templates, Html,
Javascript, etc.

It's also a commercial counterpart which helps supporting the
development of PyDev.

Details on LiClipse: http://www.liclipse.com/


Release Highlights:
---

* **Code Completion**

* PyDev can now code-complete unpacking compound types (such as
list(str), tuple(MyClass), dict(int:str), etc).
* Code-completion now has a maximum amount of time to complete (which
may be changed in the code-completion preferences).

* **Editor**

* Bytes and Unicode literals now have different colors (note: by
default the Unicode kept the same color used for the old 'Strings'
configuration).
* Mark occurrences is now also provided on some statements (such as
return, continue, etc).

* **PyVmMonitor**

* The PyVmMonitor integration was improved on finding the PyVmMonitor
executable on Linux and Mac.

* **Others**

* It's now possible to bind custom keybindings to help in passing
custom commands to the interactive console (see: PyDev > Interactive
Console > User Commands)
* The bundled autopep8.py and pep8.py were upgraded.
* Search for references (Ctrl+Shift+G) is faster (all processors
available are used for the initial search).
* Search page now has a 'whole word' option.
* Fixed PyDev-Mylyn integration in the PyDev Package Explorer to work
with the latest Mylyn.
* Fixed issue doing code-completion for elements of a list (lst[0].)
in the console. (PyDev-531)
* py.test xfailed tests are no longer marked as 'Failed' in PyUnit
view (PyDev-506)


Cheers,

--
Fabio Zadrozny
--
Software Developer

LiClipsehttp://www.liclipse.com

PyDev - Python Development Environment for
Eclipsehttp://pydev.orghttp://pydev.blogspot.com

PyVmMonitor - Python Profilerhttp://www.pyvmmonitor.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: bottle.py app doesn't timeout properly ?

2015-04-15 Thread Yassine Chaouche
Here's a traceback I generated by catching a SIGINT and printing an exception : 

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in 
_handle_request_noblock
self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
  File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
KeyboardInterrupt


Last line shows where the app was when the SIGINT happened, same socket.py's 
readline function.
-- 
https://mail.python.org/mailman/listinfo/python-list


Immediate Hire: ETL Developers - Boise, Idaho

2015-04-15 Thread nagaraju thoudoju
Hi,
 
Hope you are doing well,
This is Raj from International Systems Technologies.

Please find the requirement below and let me know you interest on this position 
on  nagar...@intsystech.com or feel free to call me on D:908-333-3540 

Requirement:
 
Role: ETL Developers
Location: Boise, Idaho

Job Description:

. Should have strong knowledge in SQL Server database including SQL Queries, 
joins, functions, trigger, store procedure. 
. Should have strong knowledge of ETL concept. 
. Should have knowledge of SSIS Including Data  flow component, control flow 
component, SSIS Logging, SSIS Configuration, SSIS Security. SSIS Error 
handling. 
. Should have knowledge of SSIS package deployment. 
. Experience in Product Life Cycle Management development projects. 
. Experience in agile, sprint development projects. 
. Should have knowledge in data warehouse concept. 
. Should have basic knowledge in scripting language like C# or VB.
 
Thanks & Best Regards?
Raju
International Systems Technologies Inc.
10 Corporate place south.| Suite 203  |
Piscataway, NJ 08854  |
D:908-333-3540 |Fax:732-348-9533|
E-mail: nagar...@intsystech.com   |
URL: www.intsystech.com
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Searching the archives

2015-04-15 Thread Gil Dawson
This is my first message to this list.  I just signed on.

How do you search the archives?

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


Re: find all multiplicands and multipliers for a number

2015-04-15 Thread Ian Kelly
On Tue, Apr 14, 2015 at 8:37 PM, Paul Rubin  wrote:
> Steven D'Aprano  writes:
>> def turner():
>> nums = itertools.count(2)
>> while True:
>> prime = next(nums)
>> yield prime
>> nums = filter(lambda v, p=prime: (v % p) != 0, nums)
>
> This is nice, though it will still hit the nesting limit about equally
> soon, because of the nested filters.  I like the faster versions in the
> O'Neill paper.

Nope. You do end up with a lot of nested filter objects, but there's
no recursion in the Python code, which means that you're not piling up
frame objects, and you'll never hit the interpreter's recursion limit.
You might eventually get a seg fault when the C stack space runs out,
however.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: find all multiplicands and multipliers for a number

2015-04-15 Thread Paul Rubin
Ian Kelly  writes:
> Nope. You do end up with a lot of nested filter objects, but there's
> no recursion in the Python code, which means that you're not piling up
> frame objects, and you'll never hit the interpreter's recursion limit.

I think you do get frame objects.  A quick experiment:

 def d(fuel):
f = lambda x:x
for i in range(fuel): f = lambda x,g=f: 1+g(x)
return f

>>> d(3)
 at 0x1a3b9b0>
>>> d(100)(0)
100
>>> d(1000)(0)

Traceback (most recent call last):
  File "", line 1, in 
d(1000)(0)
  File "", line 3, in 
for i in range(fuel): f = lambda x,g=f: 1+g(x)
  File "", line 3, in 
  [ 1000's of lines snipped ]
RuntimeError: maximum recursion depth exceeded
>>> 

This happens in both 2.7 and 3.3.4.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: find all multiplicands and multipliers for a number

2015-04-15 Thread Chris Kaynor
On Wed, Apr 15, 2015 at 9:21 AM, Paul Rubin  wrote:
> Ian Kelly  writes:
>> Nope. You do end up with a lot of nested filter objects, but there's
>> no recursion in the Python code, which means that you're not piling up
>> frame objects, and you'll never hit the interpreter's recursion limit.
>
> I think you do get frame objects.  A quick experiment:
>
>  def d(fuel):
> f = lambda x:x
> for i in range(fuel): f = lambda x,g=f: 1+g(x)
> return f
>
> >>> d(3)
>  at 0x1a3b9b0>
> >>> d(100)(0)
> 100
> >>> d(1000)(0)
>
> Traceback (most recent call last):
>   File "", line 1, in 
> d(1000)(0)
>   File "", line 3, in 
> for i in range(fuel): f = lambda x,g=f: 1+g(x)
>   File "", line 3, in 
>   [ 1000's of lines snipped ]
> RuntimeError: maximum recursion depth exceeded
> >>>

That code is substantially different that the code that Steven
D'Aprano posted: Steven's uses filter to call the lambdas, while your
calls the lambdas from another lambda. Basically, yours has direct
recursion in the Python code, while Steven's does not. The only
recursion in Steven's code is inside of the filter built-in function,
very nicely masked :).

Running Steven's code for a while, on a 32-bit install of Python 3.4.2
on Win64, printing the results, eventually produces:
[A whole pile of primes snipped]
784489
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 4, in turner
  File "", line 6, in 
MemoryError: Stack overflow
-- 
https://mail.python.org/mailman/listinfo/python-list


Python-MVC front/backend 4 firewall OPNsense -> alternative to old m0n0wall/pfSense PHP ?

2015-04-15 Thread chol

Hello dear community, dear Python developers!

Would this be a reasonable and appealing project?  A MVC (backend, frontend) of 
OPNsense (opnsense.org) -> to proof
the security of Python (3. Gen)? The OPNsense backend was recently
rewritten in Python already.

Manuel Kasper wrote a PHP GUI/backend around pf Packetfilter with m0n0wall, 
pfSense forked and did stick to PHP, now the new 02-2015 fork OPNsense did the 
same.

Alan Jude from BSD-Now suggested indirectly  - why not to rewrite it in Python. 
Because of architecture and security reasons, I guess. Maybe it is an 
opportunity right now?

What do you think? - Cheers, Chol.


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


Re: find all multiplicands and multipliers for a number

2015-04-15 Thread Paul Rubin
Chris Kaynor  writes:
> That code is substantially different that the code that Steven
> D'Aprano posted: Steven's uses filter to call the lambdas, while your
> calls the lambdas from another lambda.

I wouldn't have thought it made a difference, but apparently it does.
Thanks.

> Basically, yours has direct recursion in the Python code, while
> Steven's does not. 

I would have said: both have deeply nested function calls but no
recursion per se.

I did another test with Python 2.7.5 under Idle:

from itertools import ifilter
def f(xs): return ifilter(lambda x:True, xs)

def t(n):
xs = range(10)
for i in xrange(n): xs = f(xs)
print list(xs)

and it seemed to survive up to around 130k nested filters, with a
slightly non-deterministic limit: 130900 worked some of the time and
crashed some of the time.  Interesting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Searching the archives

2015-04-15 Thread Gil Dawson
Hi--

I'm new here.  How do you search the archives?

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


Installing Python

2015-04-15 Thread Gil Dawson
Hi--

I'm on MacOS 10.6.8, learning to use Amazon Web Services' Simple Storage 
Service's Command Line Interface (AWS S3 CLI).

They say in their documentation that their CLI needs Python version 2.7 or 3.4. 
 I checked in terminal:

$ python --version
Python 2.6.1

So I ran the python-2.7.9-macosx10.6.pkg downloaded from 
https://www.python.org/downloads/ and now...

$ python --version
Python 2.7.9
$ aws --version
aws-cli/1.7.22 Python/2.6.1 Darwin/10.8.0

...it seems to me that the AWS CLI thinks it is still using the old version.  

Will this cause problems later?  Can it be fixed?  

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


Re: Searching the archives

2015-04-15 Thread Tim Golden

On 15/04/2015 19:47, Gil Dawson wrote:

Hi--

I'm new here.  How do you search the archives?

--Gil



There's nothing builtin to mailman (v 2.x which we're using). You've got 
a few options:


* Use Google (or whatever engine) with site:, eg:

https://www.google.co.uk/search?q=site:mail.python.org/pipermail/python-list/+windows

* Use some other service like markmail:

http://markmail.org/search/?q=list%3Aorg.python.python-list+windows

* (As a last resort): 
https://groups.google.com/forum/#!forum/comp.lang.python


But, seriously, please don't post back through Google Groups: it messes 
up the formatting considerably and will generally annoy people.


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


Please use the Python Job Board (was: Immediate Hire: ETL Developers - Boise, Idaho)

2015-04-15 Thread Ben Finney
nagaraju thoudoju  writes:

> Please find the requirement below and let me know you interest on this
> position

Please do not post recruitment messages here.

Instead, use the Python Job Board https://www.python.org/jobs/>
which is designed for this purpose.

-- 
 \   “The Vatican is not a state.… a state must have people. There |
  `\are no Vaticanians.… No-one gets born in the Vatican except by |
_o__)an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
Ben Finney

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


ctypes: using .value or .value() doesn't work for c_long

2015-04-15 Thread IronManMark20
I am using ctypes to call a few windll funcions. One of them returns a c_long 
object. I want to know what number the function returns. 

Problem is, when I try foo.value , it gives me this:

AttributeError: LP_c_long object has no attribute value.

Any idea of what could cause this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Searching the archives

2015-04-15 Thread Ben Finney
Gil Dawson  writes:

> This is my first message to this list.  I just signed on.

Welcome!

> How do you search the archives?

The forum is archived in numerous places. The complete set of forums is
at http://mail.python.org/>, for example this one is at
https://mail.python.org/mailman/listinfo/python-list>.

One straightforward way to search the official archives is to do a web
search including the term “site:mail.python.org”. You can optionally add
another term for the name of the forum you want the search restricted
to. For example:

https://duckduckgo.com/?q=site%3Amail.python.org+python-list+tutorial>

Good hunting!

-- 
 \  “How many people here have telekenetic powers? Raise my hand.” |
  `\  —Emo Philips |
_o__)  |
Ben Finney

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


Re: Please use the Python Job Board (was: Immediate Hire: ETL Developers - Boise, Idaho)

2015-04-15 Thread Skip Montanaro
On Wed, Apr 15, 2015 at 2:48 PM, Ben Finney  wrote:
> nagaraju thoudoju  writes:
>
>> Please find the requirement below and let me know you interest on this
>> position
>
> Please do not post recruitment messages here.

He would have been rejected there as well. I saw nothing which looked
obviously Python-related (he didn't use the word "Python" in his post,
for example).

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


Re: Please use the Python Job Board

2015-04-15 Thread Paul Rubin
Ben Finney  writes:
> nagaraju thoudoju  writes:>
>> Please find the requirement below 
> use the Python Job Board ... which is designed for this purpose.

It wasn't a Python job from what I could tell.  It was just spam.  I
don't think the Python job board was designed for that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python

2015-04-15 Thread Ned Deily
In article <4048ad0c-a403-4141-ab8b-5884a0084...@gildawson.com>,
 Gil Dawson  wrote:

> Hi--
> 
> I'm on MacOS 10.6.8, learning to use Amazon Web Services' Simple Storage 
> Service's Command Line Interface (AWS S3 CLI).
> 
> They say in their documentation that their CLI needs Python version 2.7 or 
> 3.4.  I checked in terminal:
> 
> $ python --version
> Python 2.6.1
> 
> So I ran the python-2.7.9-macosx10.6.pkg downloaded from 
> https://www.python.org/downloads/ and now...
> 
> $ python --version
> Python 2.7.9
> $ aws --version
> aws-cli/1.7.22 Python/2.6.1 Darwin/10.8.0
> 
> ...it seems to me that the AWS CLI thinks it is still using the old version.  
> 
> Will this cause problems later?  Can it be fixed?  

I don't have any personal experience using that package but, from the 
instructions I see on their website, if you followed their instructions 
to download and install pip, you've installed aws into the system Python 
(2.6) rather than your new Python 2.7.  As of 2.7.9, Pythons installed 
from python.org now include their own version of pip.  What you could 
try is the following:

1. Uninstall the 2.6 version of aws:

   sudo pip uninstall aws

2. Install aws with the 2.7 version of pip:

   python2.7 -m pip install aws

In the future, whenever something suggests using "pip" or "sudo pip", 
just use "python2.7 -m pip" instead to be (more) certain that you are 
installing to the Python instance you want.

-- 
 Ned Deily,
 n...@acm.org

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


Re: ctypes: using .value or .value() doesn't work for c_long

2015-04-15 Thread Ian Kelly
On Wed, Apr 15, 2015 at 1:48 PM, IronManMark20  wrote:
> I am using ctypes to call a few windll funcions. One of them returns a c_long 
> object. I want to know what number the function returns.
>
> Problem is, when I try foo.value , it gives me this:
>
> AttributeError: LP_c_long object has no attribute value.
>
> Any idea of what could cause this?

The error message indicates that this is not actually a c_long object,
but an LP_c_long object; i.e., a pointer to a c_long. You can
dereference the pointer using the contents attribute:

>>> x = ctypes.c_long(42)
>>> px = ctypes.pointer(x)
>>> px
<__main__.LP_c_long object at 0x7fd0812d7950>
>>> px.contents
c_long(42)
>>> px.contents.value
42

See https://docs.python.org/3.4/library/ctypes.html#pointers for more
details on working with pointers in ctypes.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ctypes: using .value or .value() doesn't work for c_long

2015-04-15 Thread Dave Angel

On 04/15/2015 03:48 PM, IronManMark20 wrote:

I am using ctypes to call a few windll funcions. One of them returns a c_long 
object. I want to know what number the function returns.

Problem is, when I try foo.value , it gives me this:

AttributeError: LP_c_long object has no attribute value.

Any idea of what could cause this?



I don't use Windows, so I can't try it, especially since you didn't 
include any code .  And apparently whatever function you're using 
returns a pointer to a c_long, not a c_long.


I see Ian has given you an answer.  But let me show you how you might 
have come up with it on your own, for next time.


The fragment of the error you include says that the instance of the 
class LP_c_long doesn't have an attribute called "value".  But it 
undoubtedly has other attributes, so you could look with dir


print(dir(foo))

Presumably from there you'll see that you need the 'contents' attribute. 
 Then you print that out, and/or dir a dir() on it, and you see that 
you now have a value attribute.



https://docs.python.org/3/library/ctypes.html

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


xlwt 1.0.0 released!

2015-04-15 Thread Chris Withers

Hi All,

I'm pleased to announce the release of xlwt 1.0.0.

This release contains the following:

- Python 3 support.

- An initial set of unit tests.

- An initial set of Sphinx documentation.

- Move to setuptools for packaging.

- Wire up Travis, Coveralls and ReadTheDocs.

- Allow longs as row indexes.

Big thanks to Thomas Kluyver for his work on Python 3 support, Manfred 
Moitzi

for donating his unit tests.

Belated thanks to Landon Jurgens for his help on converting the 
documentation

to Sphinx.

If you find any problems, please ask about them on the 
python-ex...@googlegroups.com list, or submit an issue on GitHub:


https://github.com/python-excel/xlwt/issues

There's also details of all things Python and Excel related here:

http://www.python-excel.org/

NB: This is likely the last "new feature" release of xlwt. If there are 
bugs, we will try and fix them, but it may be a slow process. If you're 
starting a new project, you should probably consider openpyxl or 
xlsxwriter instead.


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Re: ctypes: using .value or .value() doesn't work for c_long

2015-04-15 Thread ethansmithoakland
Thanks so much! Btw (face-palm) Dave, I know dir(), I probably should have used 
it here, I just read that the return type was a c_long, and I didn't know that 
LP_c_long was a pointer. Thanks to you both!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xlwt 1.0.0 released!

2015-04-15 Thread Gary Herron

On 04/15/2015 02:51 PM, Chris Withers wrote:

Hi All,

I'm pleased to announce the release of xlwt 1.0.0.


What a curiously incomplete announcement.  Could you tell us what xlwt 
is?  I see no hint here.


Gary Herron




This release contains the following:

- Python 3 support.

- An initial set of unit tests.

- An initial set of Sphinx documentation.

- Move to setuptools for packaging.

- Wire up Travis, Coveralls and ReadTheDocs.

- Allow longs as row indexes.

Big thanks to Thomas Kluyver for his work on Python 3 support, Manfred 
Moitzi

for donating his unit tests.

Belated thanks to Landon Jurgens for his help on converting the 
documentation

to Sphinx.

If you find any problems, please ask about them on the 
python-ex...@googlegroups.com list, or submit an issue on GitHub:


https://github.com/python-excel/xlwt/issues

There's also details of all things Python and Excel related here:

http://www.python-excel.org/

NB: This is likely the last "new feature" release of xlwt. If there 
are bugs, we will try and fix them, but it may be a slow process. If 
you're starting a new project, you should probably consider openpyxl 
or xlsxwriter instead.


cheers,

Chris



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


Re: xlwt 1.0.0 released!

2015-04-15 Thread Steven D'Aprano
On Thu, 16 Apr 2015 08:21 am, Gary Herron wrote:

> On 04/15/2015 02:51 PM, Chris Withers wrote:
>> Hi All,
>>
>> I'm pleased to announce the release of xlwt 1.0.0.
> 
> What a curiously incomplete announcement.  Could you tell us what xlwt
> is?  I see no hint here.

Perhaps you stopped reading too soon. There are a few definite hints -- but
only hints -- further down:

[...]
>> If you find any problems, please ask about them on the
>> python-ex...@googlegroups.com list, or submit an issue on GitHub:
>>
>> https://github.com/python-excel/xlwt/issues
>>
>> There's also details of all things Python and Excel related here:
>>
>> http://www.python-excel.org/

Presumably xlwt has something to do with Python and eXceL ? And a second
hint:

>> NB: This is likely the last "new feature" release of xlwt. If there
>> are bugs, we will try and fix them, but it may be a slow process. If
>> you're starting a new project, you should probably consider openpyxl
>> or xlsxwriter instead.

Possibly something to do with *writing* Excel documents?

I agree that as announcements go, it lacks a little something, but it sounds
like the xlwt project is being retired so it may not matter.



-- 
Steven

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


Re: xlwt 1.0.0 released!

2015-04-15 Thread Tim Chase
On 2015-04-15 15:21, Gary Herron wrote:
> On 04/15/2015 02:51 PM, Chris Withers wrote:
> > I'm pleased to announce the release of xlwt 1.0.0.
> 
> What a curiously incomplete announcement.  Could you tell us what
> xlwt is?  I see no hint here.

Heh, this and its sibling package, xlrd, are Python packages for
writing and reading MS Excel files.  Unlike other Python
Excel-manipulation libraries I've encountered, they don't rely on
having an installed copy of Excel and can thus run on platforms where
Excel doesn't.

They've been pretty robust based on my poking at them, have been
around a good length of time (meaning more bugs have been worked out),
and Chris posts release notes here pretty regularly.  Regularly
enough that I'm pretty sure this isn't the first time he's omitted
the "this is what xlrd/xlwt is" line in his announcement. :-)

Thanks to Chris for all the dirty work done mucking around with .xls
internals to make these modules.

-tkc



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


Re: xlwt 1.0.0 released!

2015-04-15 Thread Mirage Web Studio


On 2015-04-16 4:55 AM, Tim Chase wrote:

On 2015-04-15 15:21, Gary Herron wrote:

On 04/15/2015 02:51 PM, Chris Withers wrote:

I'm pleased to announce the release of xlwt 1.0.0.

What a curiously incomplete announcement.  Could you tell us what
xlwt is?  I see no hint here.

Heh, this and its sibling package, xlrd, are Python packages for
writing and reading MS Excel files.  Unlike other Python
Excel-manipulation libraries I've encountered, they don't rely on
having an installed copy of Excel and can thus run on platforms where
Excel doesn't.

They've been pretty robust based on my poking at them, have been
around a good length of time (meaning more bugs have been worked out),
and Chris posts release notes here pretty regularly.  Regularly
enough that I'm pretty sure this isn't the first time he's omitted
the "this is what xlrd/xlwt is" line in his announcement. :-)

Thanks to Chris for all the dirty work done mucking around with .xls
internals to make these modules.

-tkc


xlrd and xlwt have been of great help to me since the time i started 
using python.


thank u for such a nice library.

George

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

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


New to Python - block grouping (spaces)

2015-04-15 Thread Blake McBride
Greetings,

I am new to Python.  I am sorry for beating what is probably a dead horse but I 
checked the net and couldn't find the answer to my question.

I like a lot of what I've seen in Python, however, after 35 years and probably 
a dozen languages under my belt, I very strongly disagree with the notion of 
using white space to delimit blocks.  Not wanting to beat what I believe is 
probably a dead horse, I have one question.  

Is there a utility that will allow me to write Python-like code that includes 
some block delimiter that I can see, that converts the code into runnable 
Python code?  If so, where can I find it?

Thanks!

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


Re: find all multiplicands and multipliers for a number

2015-04-15 Thread Rustom Mody
On Wednesday, April 15, 2015 at 8:07:31 AM UTC+5:30, Paul Rubin wrote:
> Steven D'Aprano writes:
> > primes = sieve [2..]
> > sieve (p : xs) = p : sieve [x | x <- xs, x `mod` p > 0]
> > In her paper http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf, Melissa
> > O'Neill calls this the "Sleight on Eratosthenes".
> 
> Oh cool, I wrote very similar Haskell code and converted it to Python.
> I probably saw it before though, so it looks like a case of
> not-exactly-independent re-invention.
> 
> > def turner():
> > nums = itertools.count(2)
> > while True:
> > prime = next(nums)
> > yield prime
> > nums = filter(lambda v, p=prime: (v % p) != 0, nums)

Here's a massive parallel (and more massively inefficient)
Turner sieve as bash script

$ cat nos2

n=2
while true ; do
echo $n
n=$(($n + 1))
done

$ cat filt 
read x
while true ; do
if [ $(($x % $1))  -ne 0 ] ; then
echo $x
fi
read x
done


$ cat sieve
read x
echo $x
filt $x | sieve


Call as
nos2|sieve|less
For 1st ten primes

$ nos2|sieve |head
2
3
5
7
11
13
17
19
23
29
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-15 Thread Paul Rubin
Blake McBride  writes:
> probably a dozen languages under my belt, I very strongly disagree
> with the notion of using white space to delimit blocks. 

I suggest giving it a try before deciding something like that.  I don't
guarantee you'll come around, but a lot of people decide after a while
that they like it after all.

> Is there a utility that will allow me to write Python-like code that
> includes some block delimiter that I can see, that converts the code
> into runnable Python code?  If so, where can I find it?

I'm not aware of one.  People who don't like Python's indentation syntax
tend to choose other languages.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-15 Thread Chris Angelico
On Thu, Apr 16, 2015 at 2:07 PM, Blake McBride  wrote:
> I like a lot of what I've seen in Python, however, after 35 years and 
> probably a dozen languages under my belt, I very strongly disagree with the 
> notion of using white space to delimit blocks.  Not wanting to beat what I 
> believe is probably a dead horse, I have one question.
>
> Is there a utility that will allow me to write Python-like code that includes 
> some block delimiter that I can see, that converts the code into runnable 
> Python code?  If so, where can I find it?
>

Python has a mechanic for handling syntax changes in a
backward-compatible way: the __future__ module. Some handy reading:

https://docs.python.org/3/library/__future__.html
https://www.python.org/dev/peps/pep-0236/
https://docs.python.org/3/reference/simple_stmts.html#future

To make use of this, put this line at the top of your program:

from __future__ import braces

Give it a try, I'll wait for you. Or paste that in at the interactive
interpreter prompt.

Done it?

Okay. Now you understand how Python's developers feel about this kind
of thing :)

What you may want to consider is a Python-like language that uses a
different syntax: Pike. It's semantically very similar to Python, but
syntactically similar to C. Learn both, and then you'll understand a
bit more of the debate. I used to be firmly on the side of braces, but
not so much now; Python's use of indentation eliminates some
redundancy (since, after all, you're probably going to be indenting
correctly anyway). Yes, it's using something syntactically that you
might think of as pure formatting (leading whitespace on a line), but
it's not fundamentally illogical or anything.

You can, of course, come up with a syntax for a "brace-blocked
Python", and precompile it into actual runnable Python code. That'd be
fairly straight-forward. But the question is, why do it? You wouldn't
be able to take much advantage of it without making a whole lot of
other changes, which would basically mean turning it into a completely
different language, and then there's not a lot of point using Python
behind the scenes. For instance, Python has declared mutable globals,
whereas bracey languages usually have declared locals, or in the case
of PHP, declared globals (mutable or read-only). Which way would you
do it? And what about semicolons? If you're going to allow blocks of
code to be defined by visible characters instead of whitespace,
wouldn't it make sense to do the same with statements? In Python, for
instance, you can't do this:

if x==1: for i in range(3): print(i)

but you can do this:

if x==1: print(1); print(2);

and they'll both be governed by the 'if'.

I strongly recommend NOT doing a half-way change like this, just
adding braces and nothing more. All you'll end up doing is wishing
that Python were like C in some other way, and then another, and then
another, and you'll find yourself hating Python. Learn Python the way
Python is meant to be, and learn a different language if you like its
semantics but not its syntax.

And I'm happy to talk to you off-list about Pike. In my opinion, it
and Python are the two best programming languages in the world.

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


Re: New to Python - block grouping (spaces)

2015-04-15 Thread Steven D'Aprano
On Thursday 16 April 2015 14:07, Blake McBride wrote:

> Greetings,
> 
> I am new to Python.  I am sorry for beating what is probably a dead horse
> but I checked the net and couldn't find the answer to my question.
> 
> I like a lot of what I've seen in Python, however, after 35 years and
> probably a dozen languages under my belt, I very strongly disagree with
> the notion of using white space to delimit blocks.  Not wanting to beat
> what I believe is probably a dead horse, I have one question.
> 
> Is there a utility that will allow me to write Python-like code that
> includes some block delimiter that I can see, that converts the code into
> runnable Python code?  If so, where can I find it?

Python already supports this with the optional "block delimiter" sigil. For 
example, if you like braces, you can write:


def function(x):
#{
if x > 1:
#{
print "x bigger than 1"
#}
else:
#{
print "x smaller than or equal to 1"
while x <= 1:  #{
x += 1  #}
#}
return x
#}

Notice that Python is clever enough to allow many brace styles, or even 
allow you to invent your own style.

If you prefer Pascal style, Python supports that too:

def function(x):
# BEGIN
return x
# END

You can even localise it:

def function(x):  # ANFANGEN
return x
# BEENDEN


Best of all, Python's parser includes an advanced "Do What I Mean" expert 
system which can infer the intended block grouping from the indentation 
alone, even when braces are missing or in the wrong position. Unlike C, 
Python will do the right thing here:


if condition:
do_this()
do_that()


No more bugs from accidentally forgetting to use optional braces!



Sorry for the flippant response, but it's 2015, not 1995, and the question 
about the Offside Rule is not just a dead horse but it is positively 
fossilized.

https://en.wikipedia.org/wiki/Off-side_rule

I'm not aware of any pre-processor tools for Python that will syntactically 
check that added braces match the indentation. Such a tool would be 
unPythonic: if they match, the braces are redundant and are not needed, and 
if they do not match, then the compiler (or preprocessor) should not guess 
whether the indentation is right or the braces are right. But if you enforce 
the rule that braces must match indentation, then the braces are redundant!

If you find such a preprocessor, or write your own, feel free to use it. But 
you won't get any respect from experienced Python programmers: we use Python 
in part to get away from braces, we're not chomping at the bit to put them 
back in.

I'm aware that Coffeescript provides a brace-free wrapper around Javascript; 
I'm not aware of any wrapper that *adds* braces to a language without them. 
I suspect such a thing would be of limited use and even less popularity. But 
feel free to try developing one, I could be wrong!



-- 
Steve

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


Re: New to Python - block grouping (spaces)

2015-04-15 Thread Paul Rubin
Steven D'Aprano  writes:
> I'm aware that Coffeescript provides a brace-free wrapper around Javascript; 
> I'm not aware of any wrapper that *adds* braces to a language without them. 

You're not old enough to remember Ratfor ;-)
-- 
https://mail.python.org/mailman/listinfo/python-list