doc-generation tool

2015-10-06 Thread c.buhtz
I am confused about to much possible tools and conventions for
doc-strings and the doc-generating tools using it.

My code isn't about a package interface. It is just a simple
application I want I readable documentation for.

I have the following needs
 - in-code doc-string should be readable for humans (e.g.
   reStructuredText, markup)
 - type of a methode-argument or class-attribute can be specified
 - no seperation between class-doc-string and
   class-attribute-doc-strings. the attribute should be described in
   the class-doc-string itself

I read a lot about Doxygen and Sphinx but not sure which one of it I
should concentrate on. And maybe there are other/better/easier
solutions for Python code?
-- 
-BEGIN PGP PUBLIC KEY BLOCK-
Version: GnuPG v1

mQENBFQIluABCACfPwAhRAwFD3NXgv5CtVUGSiqdfJGVViVBqaKd+14E0pASA0MU
G0Ewj7O7cGy/ZIoiZ0+lIEZmzJKHfuGwYhXjR/PhnUDrQIHLBvh9WuD6JQuULXfH
kXtVm/i9wm76QAcvr2pwYgNzhcJntUHl2GcgnInYbZDeVmg+p9yIPJjuq73/lRS3
0/McgNoFOBhKK/S6STQuFyjr9OyJyYd1shoM3hmy+kg0HYm6OgQBJNg92WV9jwGe
GzlipvEp2jpLwVsTxYir2oOPhfd9D1fC9F/l/3gXbfjd5GIIVrZFq2haZmoVeJ33
LJxo3RA5Tf9LoUeels1b4s9kFz6h7+AHERUpABEBAAG0IUNocmlzdGlhbiBCdWh0
eiA8YnVodHpAcG9zdGVvLmRlPokBPgQTAQIAKAUCVAiW4AIbAwUJAeEzgAYLCQgH
AwIGFQgCCQoLBBYCAwECHgECF4AACgkQZLsXsAdRqOxNUAf/V/hDA5zGDpySuCEj
DhjiVRK74J9Wd8gfH0WAf1Co5HZ24wZH8rgOIVIgXw8rWkOw/VA6xfdfT+64xjTY
Fhkpbrk199nDzp72F7Jc4NC+x8xac2e3rK5ifSWhZx7L5A32pGYE+d16m3EEqImK
D4gcZl38x9zdUnD4hHyXkIPz1uCfuMuGgWEnaUk4Wbj41CBZr3O0ABue6regV15U
jaes8r+B8iCcY+0yP2kse+3iaCaMqNv5FgQZ9+b2Cql8pFkZJVtBVUw4GW3DWZJi
du0O/YrC9TgS+xY9ht/MD2qSHwjcK1sdImjqBO7xP8TIOwKeYyDvGKnSO3EJ/sSA
UPGEPrkBDQRUCJbgAQgA0k/Qg67CCUJE2/zuxBEoK4wLJpDRJzh8CQPZpjWx8VP0
KL892jwfxymXn8KNhuy1SgCBFSeV9jg4VZNWDlUGJc2lo82ajr9PzIsrQwu4lf0B
zrUWV5hWepKu/kb8uSjx58YYfx0SFz4+9akX3Wwu9TUHntzL5Gk3Q26nnsr1xEJ+
VEumvCH9AE0Tk0K7dQpJ2/JcLuO+uhrpd/lHFDYVN5NsG3P015uFOkDI6N/xNFCj
v95XNR93QlfKpK3qWlFGescfG+o/7Ub6s67/i/JoNbw0XgPEHmQfXpD7IHO4cu+p
+ETb11cz+1mmi96cy98ID+uTiToJ8G//yD9rmtyxoQARAQABiQElBBgBAgAPBQJU
CJbgAhsMBQkB4TOAAAoJEGS7F7AHUajs6sQH/iKs6sPc0vkRJLfbwrijZeecwCWF
blo/jzIQ8jPykAj9SLjV20Xwqg3XcJyko8ZU6/zuRJq9xjlv9pZr/oVudQAt6v+h
2Cf4rKEjmau483wjMV2xjTXQhZi9+ttDbia4fgdmGtKsOicn5ae2fFXcXNPu3RiW
sZKifWdokA6xqMW6iIG9YjjI5ShxngHWp2xfPscBFMDRtFOMags/Yx+YvwoyEZ4A
dURYMFHFqpwILEc8hIzhRg1gq40AHbOaEdczS1Rr3T7/gS6eBs4u6HuY5g2Bierm
lLjpspFPjMXwJAa/XLOBjMF2vsHPrZNcouNKkumQ36yq/Pm6DFXAseQDxOk=
=PGP9
-END PGP PUBLIC KEY BLOCK-
-- 
https://mail.python.org/mailman/listinfo/python-list


Trouble running

2015-10-06 Thread Cameroni123 ™
Hi I have recently installed python on windows 10 and I’m trying to save in 
order to run the module and I cant I don’t know why, could you please help?
Cameron

Sent from Mail for Windows 10
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: packaging code with compiled libraries

2015-10-06 Thread Tim Golden
On 05/10/2015 20:43, Tim wrote:
> I have a package I want to share but have a question about packaging.
> 
> Mostly the package is pure python code, but it also requires some binary 
> libraries (*.so, *.dll, *.dylib).  I want to bundle these libs so users don't 
> have to compile. The package will run on *nix/windows/mac platforms.
> 
> Currently I handle this in setup.py. In the 'build' phase, I copy the 
> platform-specific libs to a subdirectory called 'libs'.  
> 
> class MyBuilder(build_py):
> def run(self):
> conditional logic for copying 
> appropriate library files to 'libs'
> etc etc.
> build_py.run()
> 
> And that seems to work, but after reading more from the Python Packaging 
> Authority, I wonder if that is the right way.  Should I be using wheels 
> instead? 
> I think my brain fried a little bit while going through the doc.

I suggest you ask on distutils-sig which is where the PPA guys tend to
hang out.

  https://mail.python.org/mailman/listinfo/distutils-sig

TJG

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


Re: doc-generation tool

2015-10-06 Thread Ben Finney
 writes:

> I am confused about to much possible tools and conventions for
> doc-strings and the doc-generating tools using it.

Thank you for taking seriously the job of documenting your software!

> My code isn't about a package interface. It is just a simple
> application I want I readable documentation for.

I am confused; maybe you can help me.

You say that you *don't* want documentation for “a package interface”,
by which I think you mean the interface a programmer needs to use your
code https://en.wikipedia.org/wiki/Application_programming_interface>.

So I think for “a simple application I want readable documentation for”,
I think you are explicitly asking for documentation to be read primarily
by the (non-programmer) *users* of the application.

> I have the following needs
>  - in-code doc-string should be readable for humans (e.g.
>reStructuredText, markup)
>  - type of a methode-argument or class-attribute can be specified
>  - no seperation between class-doc-string and
>class-attribute-doc-strings. the attribute should be described in
>the class-doc-string itself

That is all related to the documentation of very fine-grained parts of
your code; exactly the kind of documentation that is useful for a
programmer needing API documentation.

Your list, above, is *not* what I would expect for an application's
(non-programmer) end-user documentation.

Which is it? Do you want to produce API documentation, or end-user
documentation?

-- 
 \ “I still have my Christmas Tree. I looked at it today. Sure |
  `\   enough, I couldn't see any forests.” —Steven Wright |
_o__)  |
Ben Finney

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


Re: Trouble running

2015-10-06 Thread kennethg
On Tuesday, 6 October 2015 15:09:54 UTC+8, Cameroni123 (tm)  wrote:
> Hi I have recently installed python on windows 10 and I'm trying to save in 
> order to run the module and I cant I don't know why, could you please help?
> Cameron
>  
> Sent from Mail for Windows 10

I presume you wrote your code in a text editor? Or in IDLE? If in IDLE, you 
will need to click on File-new File and then write you code in the window that 
pops up. Hit on File-Save to save the file. The click on the Run-Run Module or 
press F5. This would execute your code within IDLE.

Hope this helps.

Regards,
Kenneth.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading Python

2015-10-06 Thread Tom Hodder
Hi Sharon,

> Sharon MOrine  wrote:
> I am new to programming and the website is confusing and my eyesight
isn't that great.

Welcome to Python!

Announcement mailing lists, like this one, are typically used by python
package maintainers to publicize the availability of new versions of their
software. You could consider it much like a Tannoy system, it is loud,
everyone can hear it, but it is not used very often.

If you are a total beginner, then I would recommend starting with; Python
For Beginners , really there
is no substitute for ploughing through the introductory documentation.

> Can you please tell me how to download python 3.4.2 (or .3)?

There is a guide to downloading python in the wiki, Downloading Python

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


Re: Downloading Python

2015-10-06 Thread Daniel Bradburn
Hi Sharon,

Here are the links for the Python 3.4.2 downloads:

https://www.python.org/downloads/release/python-342/#download

Regards


2015-10-06 6:49 GMT+02:00 Sharon MOrine :

> Hello:
> Can you please tell me how to download python 3.4.2 (or .3)?   I am new to
> programming and the website is confusing and my eyesight isn't that great.
> Thanks!
> --
> https://mail.python.org/mailman/listinfo/python-announce-list
>
> Support the Python Software Foundation:
> http://www.python.org/psf/donations/
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: reg multiple login python

2015-10-06 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, [email protected]  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi,

Anyone suggest...

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


Re: python and ARM memory types

2015-10-06 Thread Jorgen Grahn
On Mon, 2015-10-05, dieter wrote:
> [email protected] writes:
>> ...

>> But how do I specify (streaming,write-combining,write-back) memory
>> types in python ? Is there a library that I can use ? I am thinking of
>> programming some fixed memory space [...]

>
> Python is quite a high level programming language - i.e. lots of things
> are out of direct control of the programmer - among others memory management.
>
> I suppose you will need an approach that gives you more control over
> memory use - maybe, write your algorithms partially in the "C" programming
> language.

C or C++ would work.  He may want to check the assembly code that's
generated too.

> You might find "cython" helpful to easily combine Python parts
> and "C" parts.

In this case I doubt that involving Python will be helpful at all ...
There won't be a lot for it to do: all the interesting stuff will
happen at the level close to the hardware.  There's tweaking the
parameters for the benchmark, but that could be just command-line
options.

He may also want to instrument his programs using valgrind, time(1),
oprofile and perf(1), and I guess the Python interpreter would
introduce some noise there.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and ARM memory types

2015-10-06 Thread Laura Creighton
It is not clear to me if any of the tools that come with volutility are
going to be of any use, but I figure it is worth a look, at any rate.

https://github.com/volatilityfoundation/volatility

I seem to have replied directly, at any rate I mentioned this yesterday
but don't see it in the mailing list archives.

Laura

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


Re: packaging code with compiled libraries

2015-10-06 Thread Oscar Benjamin
On 5 October 2015 at 20:43, Tim  wrote:
>
> I have a package I want to share but have a question about packaging.
>
> Mostly the package is pure python code, but it also requires some binary 
> libraries (*.so, *.dll, *.dylib).  I want to bundle these libs so users don't 
> have to compile. The package will run on *nix/windows/mac platforms.
>
> Currently I handle this in setup.py. In the 'build' phase, I copy the 
> platform-specific libs to a subdirectory called 'libs'.
>
> class MyBuilder(build_py):
> def run(self):
> conditional logic for copying
> appropriate library files to 'libs'
> etc etc.
> build_py.run()
>
> And that seems to work, but after reading more from the Python Packaging 
> Authority, I wonder if that is the right way.  Should I be using wheels 
> instead?
> I think my brain fried a little bit while going through the doc.

The idea of a wheel is that you want to distribute your code fully
precompiled to end users who will be able to install it without
needing any C compilers etc. Of course this requires you to supply
wheels for each platform of interest. If this is what you want to do
then yes absolutely use wheels. Note that if you have installed
setuptools and wheel and you use setuptools in your setup.py then
building a wheel is as simple as running "python setup.py bdist_wheel"
(once your setup.py is complete).

If the binary libraries in question are extension modules then you
should just declare them as such in your setup.py and
distutils/setuptools/wheel will take care of bundling them into the
wheel.

If the binary libraries are not extension modules and you are building
them separately (not using distutils) then you can declare them as
"datafiles" [1] so that they will be bundled into your wheel and
installed alongside your python code.

[1] https://packaging.python.org/en/latest/distributing/#package-data

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


Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Ben Finney
Howdy all,

In Python 2.7, I am seeing this behaviour for ‘print’::

Python 2.7.10 (default, Sep 13 2015, 20:30:50)
[GCC 5.2.1 20150911] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> from __future__ import print_function
>>> import io
>>> print(None)
None
>>> print(None, file=io.StringIO())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unicode argument expected, got 'str'

So, although my string literals are now Unicode objects, apparently
‘print’ still coerces objects using the bytes type ‘str’.

Binding the ‘str’ name to the Unicode type doesn't help::

>>> str = unicode
>>> print(None, file=io.StringIO())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unicode argument expected, got 'str'

The reason I need to do this is that I'm replacing the standard streams
(‘sys.stderr’, etc.) with ‘io.StringIO’ instances in a test suite. That
works great for everything but ‘print’.

Since this is a test suite for existing code, I don't have the option to
change all the existing statements; I need them to work as-is.

How can I convince ‘print’, everywhere throughout a module, that it
should coerce its arguments using ‘unicode’?

-- 
 \  “Not using Microsoft products is like being a non-smoker 40 or |
  `\ 50 years ago: You can choose not to smoke, yourself, but it's |
_o__)   hard to avoid second-hand smoke.” —Michael Tiemann |
Ben Finney

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Ben Finney
Ben Finney  writes:

> In Python 2.7, I am seeing this behaviour for ‘print’::
>
> Python 2.7.10 (default, Sep 13 2015, 20:30:50)
> [GCC 5.2.1 20150911] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from __future__ import unicode_literals
> >>> from __future__ import print_function
> >>> import io
> >>> print(None)
> None
> >>> print(None, file=io.StringIO())
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unicode argument expected, got 'str'
>
> So, although my string literals are now Unicode objects, apparently
> ‘print’ still coerces objects using the bytes type ‘str’.

To eliminate ‘from __future__ import print_function’ as a possible
factor, here is another demonstration without that::

Python 2.7.10 (default, Sep 13 2015, 20:30:50) 
[GCC 5.2.1 20150911] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> import sys
>>> import io
>>> print "foo"
foo
>>> print None
None
>>> sys.stdout = io.StringIO()
>>> print "foo"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unicode argument expected, got 'str'
>>> print None
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unicode argument expected, got 'str'

So it appears that even a string literal, which is explicitly Unicode by
the above ‘from __future__ import unicode_literals’, is still being
coerced to a bytes ‘str’ object by ‘print’.

How can I convince ‘print’, everywhere throughout a module, that it
should coerce its arguments using ‘unicode’?

-- 
 \  “Pity the meek, for they shall inherit the earth.” —Donald |
  `\  Robert Perry Marquis |
_o__)  |
Ben Finney

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


Re: Finding Blank Columns in CSV

2015-10-06 Thread Jaydip Chakrabarty
On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote:

> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase
>  wrote:
>> That way, if you determine by line 3 that your million-row CSV file has
>> no blank columns, you can get away with not processing all million
>> rows.
> 
> Sure, although that effectively means the entire job is moot. I kinda
> assume that the OP knows that there are some blank columns (maybe lots
> of them). The extra check is unnecessary unless it's actually plausible
> that there'll be no blanks whatsoever.
> 
> Incidentally, you have an ordered_headers list which is the blank
> columns in order; I think the OP was looking for a list of the
> _non_blank columns. But that's a trivial difference, easy to tweak.
> 
> ChrisA

Thanks to you all. I got it this far. But while writing back to another 
csv file, I got this error - "ValueError: dict contains fields not in 
fieldnames: None". Here is my code.

rdr = csv.DictReader(fin, delimiter=',')
header_set = set(rdr.fieldnames)
for r in rdr:
header_set = set(h for h in header_set if not r[h])
if not header_set:
break

for r in rdr:
data = list(r[i] for i in header_set)

dw = csv.DictWriter(fout, header_set)
dw.writeheader()
dw.writerows(data)

Also, there is difference between len(header_set) and len(data[0].keys). 
Why is so?
Thanks again for all your help.

Thanks.

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


PyDev 4.4.0 Released

2015-10-06 Thread Fabio Zadrozny
Release Highlights:
---

* Improved PyDev Package Explorer to give more information when all
elements are filtered.

* Code completion improvements: when a parameter is typed in the docstring,
assigning it to an instance gives proper code-completion results when
accessing the instance.

* Fixed issues dealing with ansi colors in the interactive console.

* When autopep8 is applied as the code formatting engine, the region
selected is used to specify the lines for formatting.

* Minor improvements in the debugger.


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, TextMate bundles 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/



Cheers,

--
Fabio Zadrozny
--
Software Developer

LiClipse
http://www.liclipse.com

PyDev - Python Development Environment for Eclipse
http://pydev.org
http://pydev.blogspot.com

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


Re: Finding Blank Columns in CSV

2015-10-06 Thread Peter Otten
Jaydip Chakrabarty wrote:

> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote:
> 
>> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase
>>  wrote:
>>> That way, if you determine by line 3 that your million-row CSV file has
>>> no blank columns, you can get away with not processing all million
>>> rows.
>> 
>> Sure, although that effectively means the entire job is moot. I kinda
>> assume that the OP knows that there are some blank columns (maybe lots
>> of them). The extra check is unnecessary unless it's actually plausible
>> that there'll be no blanks whatsoever.
>> 
>> Incidentally, you have an ordered_headers list which is the blank
>> columns in order; I think the OP was looking for a list of the
>> _non_blank columns. But that's a trivial difference, easy to tweak.
>> 
>> ChrisA
> 
> Thanks to you all. I got it this far. But while writing back to another
> csv file, I got this error - "ValueError: dict contains fields not in
> fieldnames: None". Here is my code.
> 
> rdr = csv.DictReader(fin, delimiter=',')
> header_set = set(rdr.fieldnames)
> for r in rdr:
> header_set = set(h for h in header_set if not r[h])
> if not header_set:
> break
> 
> for r in rdr:
> data = list(r[i] for i in header_set)
> 
> dw = csv.DictWriter(fout, header_set)
> dw.writeheader()
> dw.writerows(data)

Sorry, this is not the code you ran. I could guess what the missing parts 
might be, but it is easier for both sides if you provide a small script that 
actually can be executed and a small dataset that shows the behaviour you 
describe. Then post the session and especially the traceback. Example:

$ cat my_data.csv
0
$ cat my_code.py 
print 1/int(open("my_data.csv").read())
$ python my_code.py 
Traceback (most recent call last):
  File "my_code.py", line 1, in 
print 1/int(open("my_data.csv").read())
ZeroDivisionError: integer division or modulo by zero

Don't retype, use cut and paste. Thank you.



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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Laura Creighton
I think the thing you want to converse is your stringIO not your print.
I think you do this using six.stringIO
https://pythonhosted.org/six/

But I have only read the doc, not done this in practice.

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Laura Creighton
Hmm, now that I read the six document again
 @six.python_2_unicode_compatible

seems exactly what you are asking for ...

https://pythonhosted.org/six/
Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and ARM memory types

2015-10-06 Thread voxner
The main intent to use python was because it was easier to code the
algorithms. Also I was hoping to reuse the parallel algorithms
specifically iterative ones where we have some sort of control thread
that distributes data between the threads.

Now I am planning to have 2 different set of kernel with malloc that
returns WB and WT memory respectively. Then run the parallel python
program on top of that.

On 6 October 2015 at 15:08, Laura Creighton  wrote:
> It is not clear to me if any of the tools that come with volutility are
> going to be of any use, but I figure it is worth a look, at any rate.
>
> https://github.com/volatilityfoundation/volatility
>
> I seem to have replied directly, at any rate I mentioned this yesterday
> but don't see it in the mailing list archives.
>
> Laura
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Peter Otten
Ben Finney wrote:

> Ben Finney  writes:
> 
>> In Python 2.7, I am seeing this behaviour for ‘print’::
>>
>> Python 2.7.10 (default, Sep 13 2015, 20:30:50)
>> [GCC 5.2.1 20150911] on linux2
>> Type "help", "copyright", "credits" or "license" for more
>> information.
>> >>> from __future__ import unicode_literals
>> >>> from __future__ import print_function
>> >>> import io
>> >>> print(None)
>> None
>> >>> print(None, file=io.StringIO())
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> TypeError: unicode argument expected, got 'str'
>>
>> So, although my string literals are now Unicode objects, apparently
>> ‘print’ still coerces objects using the bytes type ‘str’.
> 
> To eliminate ‘from __future__ import print_function’ as a possible
> factor, here is another demonstration without that::
> 
> Python 2.7.10 (default, Sep 13 2015, 20:30:50)
> [GCC 5.2.1 20150911] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from __future__ import unicode_literals
> >>> import sys
> >>> import io
> >>> print "foo"
> foo
> >>> print None
> None
> >>> sys.stdout = io.StringIO()
> >>> print "foo"
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unicode argument expected, got 'str'
> >>> print None
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unicode argument expected, got 'str'
> 
> So it appears that even a string literal, which is explicitly Unicode by
> the above ‘from __future__ import unicode_literals’, is still being
> coerced to a bytes ‘str’ object by ‘print’.
> 
> How can I convince ‘print’, everywhere throughout a module, that it
> should coerce its arguments using ‘unicode’?

I don't think this is possible with the print statement, but the print() 
function can be replaced with anything you like:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> from __future__ import print_function
>>> import io
>>> _print = print
>>> def print(*args, **kw):
... return _print(*map(unicode, args), **kw)
... 
>>> print(None, file=io.StringIO())
>>> outstream = io.StringIO()
>>> print(None, file=outstream)
>>> outstream.getvalue()
u'None\n'
>>> print(None)
None


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


Re: Pyarmor, guard your python scripts

2015-10-06 Thread Josef Pktd
On Monday, October 5, 2015 at 11:27:58 PM UTC-4, Ian wrote:
> On Oct 5, 2015 4:27 PM, "Ben Finney"  wrote:
> 
> >
> 
> > Josef Pktd  writes:
> 
> >
> 
> > > related
> 
> >
> 
> > Care to give us a summary of what that is, and describe what you think
> 
> > is the relevant point?
> 
> Following the link reveals it to be the video of a talk on Python exe 
> compilation from PyCon 2014.
> 
> If you're worried about the safety of the link, know that youtu.be is the 
> official URL shortener for YouTube and only leads to YouTube videos.

The talk is by Brandon Rhodes that I found quite refreshing the first time I 
attended Pycon https://us.pycon.org/2014/schedule/presentation/201/
The approach is building an exe file, but the motivation is the same as here.

About the keys:

Consider it as price discrimination between "cheap" hackers and plain users.

When I was a student I wasn't very reluctant to install cracked versions, but 
as far as I remember, I haven't installed a cracked version of a program in 15 
years or so. 
All the application and music on the ipads in my family are legitimate 
versions, either free minimal functionality versions or purchased on apps store 
or through itunes.

The python community in general seems to be a lot in favor of SaaS but not much 
in favor of selling (small) software products. When we got our first ipad, (I'm 
traditionally a Windows user) I was surprised how large the market for small 
and larger programs is and the opportunities that it provides for single 
developers or small groups of developers. In contrast, SaaS requires a much 
larger setup cost and larger scale.

I pretty much share Jondy Zhao's view.


That doesn't mean it's always a good idea. I have been working for many years 
on BSD licensed open source software.

Josef

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


Re: Trouble running

2015-10-06 Thread Emile van Sebille

On 10/5/2015 11:06 AM, Cameroni123 ™ wrote:

Hi I have recently installed python on windows 10 and I’m trying to save
in order to run the module and I cant I don’t know why, could you please
help?


you might find the following helpful:
http://www.cs.utexas.edu/~mitra/bytes/start.html

emile


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


pls help me install 3.5 and 2.7.10

2015-10-06 Thread rajesh thanu
[14C0:1718][2015-10-06T20:09:57]i001: Burn v3.10.0.1823, Windows v6.1
(Build 7601: Service Pack 1), path:
C:\Users\raj\Downloads\python-3.5.0-webinstall.exe
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'ActionLikeInstalling' to value 'Installing'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'ActionLikeInstallation' to value 'Setup'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'ShortVersion' to value '3.5'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'ShortVersionNoDot' to value '35'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'InstallAllUsers' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'InstallLauncherAllUsers' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'TargetDir' to value ''
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'DefaultAllUsersTargetDir' to value '[ProgramFilesFolder]Python
[ShortVersion]'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'TargetPlatform' to value 'x86'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'DefaultJustForMeTargetDir' to value
'[LocalAppDataFolder]Programs\Python\Python[ShortVersionNoDot]-32'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'OptionalFeaturesRegistryKey' to value
'Software\Python\PythonCore\[ShortVersion]-32\InstalledFeatures'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'TargetDirRegistryKey' to value
'Software\Python\PythonCore\[ShortVersion]-32\InstallPath'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'DefaultCustomTargetDir' to value ''
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'InstallAllUsersState' to value 'enabled'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'InstallLauncherAllUsersState' to value 'enabled'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'CustomInstallLauncherAllUsersState' to value
'[InstallLauncherAllUsersState]'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'TargetDirState' to value 'enabled'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'CustomBrowseButtonState' to value 'enabled'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_core' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_exe' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_dev' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_lib' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_test' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_doc' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_tools' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_tcltk' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_pip' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_launcher' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_symbols' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Include_debug' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'LauncherOnly' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'AssociateFiles' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'Shortcuts' to value '1'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'PrependPath' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'CompileAll' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable
'SimpleInstall' to value '0'
[14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable
'SimpleInstallDescription' to value ''
[14C0:1718][2015-10-06T20:09:57]i009: Command Line: '-burn.unelevated
BurnPipe.{B3FE2E0A-C963-4F43-9B16-7706F1471DA1}
{AD66A7E6-551E-4F74-871C-78CDC3FABCA9} 4796'
[14C0:1718][2015-10-06T20:09:57]i000: Setting string variable
'WixBundleLog' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0
(32-bit)_20151006200957.log'
[14C0:1718][2015-10-06T20:09:57]i000: Setting string variable
'WixBundleOriginalSource' to value
'C:\Users\raj\Downloads\python-3.5.0-webinstall.exe'
[14C0:1718][2015-10-06T20:09:57]i000: Setting string variable
'WixBundleOriginalSourceFolder' to value 'C:\Users\raj\Downloads\'
[14C0:1718][2015-10-06T20:09:57]i000: Setting string variable
'WixBundleName' to value 'Python 3.5.0 (32-bit)'
[14C0:1718][2015-10-06T20:09:57]i000: Setting string variable
'WixBundleManufacturer' to value 'Python Software Foundation'
[14C0:1718][20

Re: Trouble running

2015-10-06 Thread John Gordon
In  
=?utf-8?Q?Cameroni123_=E2=84=A2?=  writes:

> Hi I have recently installed python on windows 10 and I'm trying to
> save in order to run the module and I cant I don't know why, could
> you please help?
> Cameron

We need more details to help you.

What program are you using to try to save?  Is it a text editor?

What happens when you try to save?  How do you know it didn't work?
Do you get an error message?

-- 
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Finding Blank Columns in CSV

2015-10-06 Thread MRAB

On 2015-10-06 12:24, Jaydip Chakrabarty wrote:

On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote:


On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase
 wrote:

That way, if you determine by line 3 that your million-row CSV file has
no blank columns, you can get away with not processing all million
rows.


Sure, although that effectively means the entire job is moot. I kinda
assume that the OP knows that there are some blank columns (maybe lots
of them). The extra check is unnecessary unless it's actually plausible
that there'll be no blanks whatsoever.

Incidentally, you have an ordered_headers list which is the blank
columns in order; I think the OP was looking for a list of the
_non_blank columns. But that's a trivial difference, easy to tweak.

ChrisA


Thanks to you all. I got it this far. But while writing back to another
csv file, I got this error - "ValueError: dict contains fields not in
fieldnames: None". Here is my code.

rdr = csv.DictReader(fin, delimiter=',')
header_set = set(rdr.fieldnames)


Initially, header_set contains all of the field names.


for r in rdr:
 header_set = set(h for h in header_set if not r[h])


Keeping the field name if the field is empty.


 if not header_set:
 break


At this point, header_set will contain the field names where none of
its values are empty.

Wasn't the original question about excluding columns where all of the
values are empty? You're excluding columns where _any_ of the values
are empty.


for r in rdr:
 data = list(r[i] for i in header_set)


data will contain each processed row in turn. Because of the
indentation, only the final data (row) will be would be written out.



dw = csv.DictWriter(fout, header_set)
dw.writeheader()
dw.writerows(data)

Also, there is difference between len(header_set) and len(data[0].keys).
Why is so?
Thanks again for all your help.

Thanks.



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


python3.5 + reportlab + windows again

2015-10-06 Thread Robin Becker
I can run all of the reportlab tests OK under ubuntu 14.04 amd65 with the latest 
python 3.5 (built using configure make dance).


However, when I try to do the same with windows 7 x64 & VS2015 as the compiler I 
am getting strange issues.


Basically at some point in the run python pops up a dialogue that says python 
has stopped working and MS is searching for a solution :(


MS doesn't find a solution and then my only options are debug & stop. Debugging 
reveals that the error appeared to happen somewhere in 'external code' called 
from python, but I don't have any idea which of the possible extensions is at 
fault. So far as I know I'm only using two extensions from inside reportlab and 
pillow.


When tested separately, the two RL extensions appear to work OK, but I don't 
know where pillow came from. I just used c:\python35\scripts\pip install pillow 
and it automagically got downloaded as a wheel. I can at least import _imaging 
etc etc so I assume the pillow 3.0.0 is working.


I guess I have to think about creating a debug build of python 3.5 and or one or 
more extensions.


Does anyone know which flags I should be setting in the PCBUILD? I vaguely 
remember /Od /Zi, but this is a new version of VS so perhaps I'm out of date.

--
Robin Becker

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


Re: python3.5 + reportlab + windows again

2015-10-06 Thread Robin Becker

On 06/10/2015 16:14, Robin Becker wrote:

I can run all of the reportlab tests OK under ubuntu 14.04 amd65 with the latest
python 3.5 (built using configure make dance).




I guess I have to think about creating a debug build of python 3.5 and or one or
more extensions.

Does anyone know which flags I should be setting in the PCBUILD? I vaguely
remember /Od /Zi, but this is a new version of VS so perhaps I'm out of date.


well it seems someone can build these extensions properly. I used Christoph 
Gohlke's reportlab build and although there are 3 failures in the latest tests I 
don't see any crashes etc etc and all the failures are explainable. Last thing I 
saw from him in respect of pyRXPU was to use extra_compile_args=['/Od']. I will 
try that in the reportlab extension builds and see if the problems go away.

--
Robin Becker

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


Re: packaging code with compiled libraries

2015-10-06 Thread Tim
On Tuesday, October 6, 2015 at 5:51:48 AM UTC-4, Oscar Benjamin wrote:
> On 5 October 2015 at 20:43, Tim  wrote:
> >
> > I have a package I want to share but have a question about packaging.
> >
> > Mostly the package is pure python code, but it also requires some binary 
> > libraries (*.so, *.dll, *.dylib).  I want to bundle these libs so users 
> > don't have to compile. The package will run on *nix/windows/mac platforms.

> The idea of a wheel is that you want to distribute your code fully
> precompiled to end users who will be able to install it without
> needing any C compilers etc. Of course this requires you to supply
> wheels for each platform of interest. If this is what you want to do
> then yes absolutely use wheels. Note that if you have installed
> setuptools and wheel and you use setuptools in your setup.py then
> building a wheel is as simple as running "python setup.py bdist_wheel"
> (once your setup.py is complete).
> 
> If the binary libraries in question are extension modules then you
> should just declare them as such in your setup.py and
> distutils/setuptools/wheel will take care of bundling them into the
> wheel.
> 
> If the binary libraries are not extension modules and you are building
> them separately (not using distutils) then you can declare them as
> "datafiles" [1] so that they will be bundled into your wheel and
> installed alongside your python code.
> 
> [1] https://packaging.python.org/en/latest/distributing/#package-data
> 
> --
> Oscar

Thanks for that description. I read through the recent archives on 
distutils-sig and it's pretty much over my head. These libs are built 
separately (not extension modules) so I will use wheels with the 'datafiles' 
approach.
--Tim
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding Blank Columns in CSV

2015-10-06 Thread Jaydip Chakrabarty
On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote:

> Jaydip Chakrabarty wrote:
> 
>> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote:
>> 
>>> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase
>>>  wrote:
 That way, if you determine by line 3 that your million-row CSV file
 has no blank columns, you can get away with not processing all
 million rows.
>>> 
>>> Sure, although that effectively means the entire job is moot. I kinda
>>> assume that the OP knows that there are some blank columns (maybe lots
>>> of them). The extra check is unnecessary unless it's actually
>>> plausible that there'll be no blanks whatsoever.
>>> 
>>> Incidentally, you have an ordered_headers list which is the blank
>>> columns in order; I think the OP was looking for a list of the
>>> _non_blank columns. But that's a trivial difference, easy to tweak.
>>> 
>>> ChrisA
>> 
>> Thanks to you all. I got it this far. But while writing back to another
>> csv file, I got this error - "ValueError: dict contains fields not in
>> fieldnames: None". Here is my code.
>> 
>> rdr = csv.DictReader(fin, delimiter=',')
>> header_set = set(rdr.fieldnames)
>> for r in rdr:
>> header_set = set(h for h in header_set if not r[h])
>> if not header_set:
>> break
>> 
>> for r in rdr:
>> data = list(r[i] for i in header_set)
>> 
>> dw = csv.DictWriter(fout, header_set)
>> dw.writeheader()
>> dw.writerows(data)
> 
> Sorry, this is not the code you ran. I could guess what the missing
> parts might be, but it is easier for both sides if you provide a small
> script that actually can be executed and a small dataset that shows the
> behaviour you describe. Then post the session and especially the
> traceback. Example:
> 
> $ cat my_data.csv 0
> $ cat my_code.py print 1/int(open("my_data.csv").read())
> $ python my_code.py Traceback (most recent call last):
>   File "my_code.py", line 1, in 
> print 1/int(open("my_data.csv").read())
> ZeroDivisionError: integer division or modulo by zero
> 
> Don't retype, use cut and paste. Thank you.

I downloaded gmail contacts in google csv format. There are so many 
columns. So I was trying to create another csv with the required columns. 
Now when I tried to open the gmail csv file with csv DictReader, it said 
the file contained NULL characters.
So first I did - 

data = open(fn, 'rb').read()
fout = open(ofn, 'wb')
fout.write(data.replace('\x00', ''))
fout.close()
shutil.move(ofn, fn)

Then I found, there were some special characters in the file. So, once 
again I opened the file and did -

data = open(fn, 'rb').read()
fout = open(ofn, 'wb')
fout.write(data.replace('\xff\xfe', ''))
fout.close()
shutil.move(ofn, fn)

Now it seemed right. So I started to remove empty columns. 

fin = open(fn, 'rb')
fout = open(ofn, 'wb')

rdr = csv.DictReader(fin, delimiter=',')
flds = rdr.fieldnames
header_set = set(rdr.fieldnames)
for r in rdr:
header_set = set(h for h in header_set if not r[h])
if not header_set:
break
for r in rdr:
data = list(r[i] for i in header_set)

dw = csv.DictWriter(fout, data[0].keys())
dw.writeheader()
dw.writerows(data)

fin.close()
fout.close()

But, I am getting error at dw.writerows(data). I put the whole code here. 
Please help.

Thanks.

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


Re: Finding Blank Columns in CSV

2015-10-06 Thread Peter Otten
Jaydip Chakrabarty wrote:

> On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote:
> 
>> Jaydip Chakrabarty wrote:
>> 
>>> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote:
>>> 
 On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase
  wrote:
> That way, if you determine by line 3 that your million-row CSV file
> has no blank columns, you can get away with not processing all
> million rows.
 
 Sure, although that effectively means the entire job is moot. I kinda
 assume that the OP knows that there are some blank columns (maybe lots
 of them). The extra check is unnecessary unless it's actually
 plausible that there'll be no blanks whatsoever.
 
 Incidentally, you have an ordered_headers list which is the blank
 columns in order; I think the OP was looking for a list of the
 _non_blank columns. But that's a trivial difference, easy to tweak.
 
 ChrisA
>>> 
>>> Thanks to you all. I got it this far. But while writing back to another
>>> csv file, I got this error - "ValueError: dict contains fields not in
>>> fieldnames: None". Here is my code.
>>> 
>>> rdr = csv.DictReader(fin, delimiter=',')
>>> header_set = set(rdr.fieldnames)
>>> for r in rdr:
>>> header_set = set(h for h in header_set if not r[h])
>>> if not header_set:
>>> break
>>> 
>>> for r in rdr:
>>> data = list(r[i] for i in header_set)
>>> 
>>> dw = csv.DictWriter(fout, header_set)
>>> dw.writeheader()
>>> dw.writerows(data)
>> 
>> Sorry, this is not the code you ran. I could guess what the missing
>> parts might be, but it is easier for both sides if you provide a small
>> script that actually can be executed and a small dataset that shows the
>> behaviour you describe. Then post the session and especially the
>> traceback. Example:
>> 
>> $ cat my_data.csv 0
>> $ cat my_code.py print 1/int(open("my_data.csv").read())
>> $ python my_code.py Traceback (most recent call last):
>>   File "my_code.py", line 1, in 
>> print 1/int(open("my_data.csv").read())
>> ZeroDivisionError: integer division or modulo by zero
>> 
>> Don't retype, use cut and paste. Thank you.
> 
> I downloaded gmail contacts in google csv format. There are so many
> columns. So I was trying to create another csv with the required columns.
> Now when I tried to open the gmail csv file with csv DictReader, it said
> the file contained NULL characters.
> So first I did -
> 
> data = open(fn, 'rb').read()
> fout = open(ofn, 'wb')
> fout.write(data.replace('\x00', ''))
> fout.close()
> shutil.move(ofn, fn)
> 
> Then I found, there were some special characters in the file. So, once
> again I opened the file and did -
> 
> data = open(fn, 'rb').read()
> fout = open(ofn, 'wb')
> fout.write(data.replace('\xff\xfe', ''))
> fout.close()
> shutil.move(ofn, fn)

Uh this looks like the file is in UTF-16. Use

import codecs
fn = ...
ofn = ...
with codecs.open(fn, encoding="utf-16") as f:
with codecs.open(ofn, "w", encoding="utf-8") as g:
g.writelines(f)
...

to convert it to UTF-8 which is compatible with the csv module of Python 2.

> Now it seemed right. 

Only if all characters are encodable as iso-8859-1.

> So I started to remove empty columns.
> 
> fin = open(fn, 'rb')
> fout = open(ofn, 'wb')
> 
> rdr = csv.DictReader(fin, delimiter=',')
> flds = rdr.fieldnames
> header_set = set(rdr.fieldnames)
> for r in rdr:
> header_set = set(h for h in header_set if not r[h])
> if not header_set:
> break
> for r in rdr:
> data = list(r[i] for i in header_set)
> 
> dw = csv.DictWriter(fout, data[0].keys())
> dw.writeheader()
> dw.writerows(data)
> 
> fin.close()
> fout.close()
> 
> But, I am getting error at dw.writerows(data). I put the whole code here.
> Please help.

I really meant it when I asked you to post the code you actually ran, and 
the traceback it produces. 

When I fill in the blanks by guessing

$ cat in.csv
one,two,three
foo,,
bar,,baz
$ cat remove_empty_colums.py 
import csv
fn = "in.csv"
ofn = "out.csv"

fin = open(fn, 'rb')
fout = open(ofn, 'wb')

rdr = csv.DictReader(fin, delimiter=',')
flds = rdr.fieldnames
header_set = set(rdr.fieldnames)
for r in rdr:
header_set = set(h for h in header_set if not r[h])
if not header_set:
break
for r in rdr:
data = list(r[i] for i in header_set)

dw = csv.DictWriter(fout, data[0].keys())
dw.writeheader()
dw.writerows(data)

fin.close()
fout.close()

and then run the resulting script I get

$ python remove_empty_colums.py 
Traceback (most recent call last):
  File "remove_empty_colums.py", line 18, in 
dw = csv.DictWriter(fout, data[0].keys())
NameError: name 'data' is not defined

So this is my traceback, and while the NameError is trivial to fix (reopen 
the file or do a seek) but not sufficient to make the script do what you 
want it doesn't seem to be the problem you ran into. 
So you have a different script. I'd really like to see it, and the traceback 
it produces. 


-- 
https://mail.python.org/mailma

Re: Finding Blank Columns in CSV

2015-10-06 Thread MRAB

On 2015-10-06 18:23, Jaydip Chakrabarty wrote:

On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote:


[snip]


I downloaded gmail contacts in google csv format. There are so many
columns. So I was trying to create another csv with the required columns.
Now when I tried to open the gmail csv file with csv DictReader, it said
the file contained NULL characters.


Why would there be nulls in a CSV file?


So first I did -

data = open(fn, 'rb').read()
fout = open(ofn, 'wb')
fout.write(data.replace('\x00', ''))
fout.close()
shutil.move(ofn, fn)

Then I found, there were some special characters in the file. So, once
again I opened the file and did -

data = open(fn, 'rb').read()
fout = open(ofn, 'wb')
fout.write(data.replace('\xff\xfe', ''))
fout.close()
shutil.move(ofn, fn)


b'\xff\xfe' looks like a BOM.

If it's at the start of the file, it indicates that the file is encoded
in 'UTF16-LE'.

So, apparently, the original file was CSV encoded in 'UTF16-LE'.

You _do_ still have the original file, don't you?

[snip]

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Ben Finney
Laura Creighton  writes:

> Hmm, now that I read the six document again
>  @six.python_2_unicode_compatible


Peter Otten <[email protected]> writes:

> I don't think this is possible with the print statement, but the
> print() function can be replaced with anything you like:


Hmm. I am more looking for something that doesn't involve replacing
‘print’, but rather to hook into whatever it uses to coerce the type of
its arguments.

-- 
 \“The problem with television is that the people must sit and |
  `\keep their eyes glued on a screen: the average American family |
_o__) hasn't time for it.” —_The New York Times_, 1939 |
Ben Finney

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


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Grant Edwards
On 2015-10-03, Laura Creighton  wrote:

>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
>  seems to be about a whole lot of serial ports to me, not just FTDI

We just ran into the OP's problem where I work: Ununtu kernel updated
and all serial ports stopped working (it isn't just an FTDI problem). 

Booting with the previous kernel makes the serial ports work again.

What I'm trying to figure out: is this something _Ubuntu_ did so that
only affects Ubuntu kernels?  [I haven't seen it mentioned on the
linux-serial mailing list, and nobody other than Ubuntu users seem to
have the problem, so I think the answer to my question is "yes".]

-- 
Grant Edwards   grant.b.edwardsYow! Am I SHOPLIFTING?
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Rob Gaddi
On Tue, 06 Oct 2015 21:31:02 +, Grant Edwards wrote:

> On 2015-10-03, Laura Creighton  wrote:
> 
>>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/
+bug/1501345
>>  seems to be about a whole lot of serial ports to me, not just FTDI
> 
> We just ran into the OP's problem where I work: Ununtu kernel updated
> and all serial ports stopped working (it isn't just an FTDI problem).
> 
> Booting with the previous kernel makes the serial ports work again.
> 
> What I'm trying to figure out: is this something _Ubuntu_ did so that
> only affects Ubuntu kernels?  [I haven't seen it mentioned on the
> linux-serial mailing list, and nobody other than Ubuntu users seem to
> have the problem, so I think the answer to my question is "yes".]

Glad I was able to get you some heads-up on it; I wound up burning 4 
hours before I figured out what the problem was.

I'm not sure if these are Ubuntu specific problems, but I slung some C to 
test and confirmed that they're not Python specific problems.  Pyserial 
uses select(), and on Linux all of select(), poll(), and epoll() are 
handled at the driver level by the same entry point.  Anything in the 
genre is hosed until they get it back under control.

Personally, I'm so upset that I'm going to call Linux and demand my money 
back.  But until then I'm regressed to -63.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-06 Thread Laura Creighton
In a message of Tue, 06 Oct 2015 21:31:02 -, Grant Edwards writes:
>On 2015-10-03, Laura Creighton  wrote:
>
>>  https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345
>>  seems to be about a whole lot of serial ports to me, not just FTDI
>
>We just ran into the OP's problem where I work: Ununtu kernel updated
>and all serial ports stopped working (it isn't just an FTDI problem). 
>
>Booting with the previous kernel makes the serial ports work again.
>
>What I'm trying to figure out: is this something _Ubuntu_ did so that
>only affects Ubuntu kernels?  [I haven't seen it mentioned on the
>linux-serial mailing list, and nobody other than Ubuntu users seem to
>have the problem, so I think the answer to my question is "yes".]
>
>-- 
>Grant Edwards   grant.b.edwardsYow! Am I SHOPLIFTING?
>  at   
>  gmail.com

Upstream from ubuntu is debian.
I am running debian unstable.
I did a kernel update, all my serial ports work fine,
but since I don't have a simple script to test if
I have the problem, I cannot swear for certain ubuntu did it ...

Laura

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Peter Otten
Ben Finney wrote:

>> I don't think this is possible with the print statement, but the
>> print() function can be replaced with anything you like:
> 
> 
> Hmm. I am more looking for something that doesn't involve replacing
> ‘print’, but rather to hook into whatever it uses to coerce the type of
> its arguments.
 
Have a look at PyFile_WriteObject in Objects/fileobject.c.
As I understand the code it basically does

if isinstance(obj) and stream.encoding is not None:
s = obj.encode(stream.encoding))
else:
s = str(obj)
stream.write(s)

There's no way to get the original object.




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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Terry Reedy

On 10/6/2015 6:45 AM, Ben Finney wrote:

Ben Finney  writes:



How can I convince ‘print’, everywhere throughout a module, that it
should coerce its arguments using ‘unicode’?


Use Python 3.  I am only half joking.  Switching to unicode  instead of 
bytes as the default text type fixed numerous bugs all at once.


--
Terry Jan Reedy


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


Re: Trouble running

2015-10-06 Thread Terry Reedy

On 10/6/2015 10:56 AM, John Gordon wrote:

In  
=?utf-8?Q?Cameroni123_=E2=84=A2?=  writes:


Hi I have recently installed python on windows 10 and I'm trying to
save in order to run the module and I cant I don't know why, could
you please help?
Cameron


Which version of Python.  How installed.


We need more details to help you.

What program are you using to try to save?  Is it a text editor?

What happens when you try to save?  How do you know it didn't work?
Do you get an error message?


If you are using IDLE, to see errors messages, run it from Command 
Prompt window with 'python -m idlelib' or perhaps 'py -3.y -m idlelib' 
(replacing 'y' with the appropriate number) or 'py -2.7 -m idlelib.idle'.


--
Terry Jan Reedy

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Ben Finney
Peter Otten <[email protected]> writes:

> Have a look at PyFile_WriteObject in Objects/fileobject.c.
> As I understand the code it basically does
>
> if isinstance(obj) and stream.encoding is not None:
> s = obj.encode(stream.encoding))
> else:
> s = str(obj)
> stream.write(s)

So as I understand it I'm looking for the hypothetical

from __future__ import print_coerce_args_to_unicode

and without that, I'm stuck with the hard-coded ‘str’ coercion.

Thanks, at least now I can stop flailing to try to get it working.

-- 
 \   “Fear him, which after he hath killed hath power to cast into |
  `\   hell; yea, I say unto you, Fear him.” –Jesus, as quoted in Luke |
_o__) 12:5 |
Ben Finney

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


Re: Python 2 ‘print’, coercing arguments to Unicode

2015-10-06 Thread Ben Finney
Terry Reedy  writes:

> On 10/6/2015 6:45 AM, Ben Finney wrote:
> > Ben Finney  writes:
>
> > How can I convince ‘print’, everywhere throughout a module, that it
> > should coerce its arguments using ‘unicode’?
>
> Use Python 3.  I am only half joking.  Switching to unicode  instead
> of bytes as the default text type fixed numerous bugs all at once.

This is all part of a transition to Python 3, so I am fully on board
with that. It doesn't help address the problem to tell me I want to do
what I'm already in pursuit of doing :-)

-- 
 \“Intellectual property is to the 21st century what the slave |
  `\  trade was to the 16th.” —David Mertz |
_o__)  |
Ben Finney

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


building Demo/embed on Mac OS 10.10 from source: configure args?

2015-10-06 Thread vaporbleep
I'm trying to build the embedding demo (Demo/embed in the source directory)

After configuring with

$ ./configure --enable-framework MACOSX_DEPLOYMENT_TARGET=10.10

And calling "make" in the root source directory to build python.exe

I then change directory to Demo/embed and edit LIBS and LDFLAGS in Demo/embed 
(per instructions in Makefile)

Now I can make the "demo"

$ make demo
gcc -g -I../../Include -I../..  -c -o demo.o demo.c
demo.c:7:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(int argc, char **argv)
^
1 warning generated.
gcc  demo.o ../../libpython2.7.a  -ldl  -framework CoreFoundation -lm -o demo

But when I try to run it,

$ ./demo 
Could not find platform independent libraries 
Could not find platform dependent libraries 
Consider setting $PYTHONHOME to [:]
ImportError: No module named site

Mac OS X
Version 10.10.5
MacBook Pro

Not sure what is going on here / what the problem is

My goal is to change the Python commands in demo.c to a simple script to put up 
the pyglet Hello, World: 
http://pyglet-current.readthedocs.org/en/latest/programming_guide/quickstart.html

When I run the file 

Python source distribution 2.7.10

Is anyone else finding it impossible to get Demo/embed to run on a Mac?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding Blank Columns in CSV

2015-10-06 Thread Jaydip Chakrabarty
On Tue, 06 Oct 2015 19:25:12 +0100, MRAB wrote:

> On 2015-10-06 18:23, Jaydip Chakrabarty wrote:
>> On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote:
>>
> [snip]
>>
>> I downloaded gmail contacts in google csv format. There are so many
>> columns. So I was trying to create another csv with the required
>> columns.
>> Now when I tried to open the gmail csv file with csv DictReader, it
>> said the file contained NULL characters.
> 
> Why would there be nulls in a CSV file?
> 
>> So first I did -
>>
>> data = open(fn, 'rb').read()
>> fout = open(ofn, 'wb')
>> fout.write(data.replace('\x00', ''))
>> fout.close()
>> shutil.move(ofn, fn)
>>
>> Then I found, there were some special characters in the file. So, once
>> again I opened the file and did -
>>
>> data = open(fn, 'rb').read()
>> fout = open(ofn, 'wb')
>> fout.write(data.replace('\xff\xfe', ''))
>> fout.close()
>> shutil.move(ofn, fn)
>>
> b'\xff\xfe' looks like a BOM.
> 
> If it's at the start of the file, it indicates that the file is encoded
> in 'UTF16-LE'.
> 
> So, apparently, the original file was CSV encoded in 'UTF16-LE'.
> 
> You _do_ still have the original file, don't you?
> 
> [snip]

Yes, I am having it.

Thanks.

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


Re: reg multiple login python

2015-10-06 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, [email protected]  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

please respond...actually i am in need of this multiprocessing..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: threading bug in strptime

2015-10-06 Thread Akira Li
Larry Martell  writes:

> We have been trying to figure out an intermittent problem where a
> thread would fail with this:
>
> AttributeError: 'module' object has no attribute '_strptime'
>
> Even though we were importing datetime. After much banging our heads
> against the wall, we found this:
>
> http://code-trick.com/python-bug-attribute-error-_strptime/
>
> The workaround suggested there, to call strptime before starting your
> threads, seems to have fixed the issue.
>
> I thought I'd mention it here in case anyone else is facing this.

I can reproduce it in Python 2 (but not in Python 3) even with
*threading* module:

  #!/usr/bin/env python
  import threading
  import time

  for _ in range(10):
  threading.Thread(target=time.strptime,
   args=("2013-06-02", "%Y-%m-%d")).start()

Don't use *thread* directly (it is even renamed to *_thread* in Python
3, to discourage an unintended usage), use *threading* module instead.

In Python 3.3+, PyImport_ImportModuleNoBlock()  is deprecated
  https://bugs.python.org/issue9260

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