Re: Packaging and deployment of standalone Python applications?

2015-09-15 Thread paul.hermeneutic
This might be helpful.

https://docs.python.org/3/distributing/index.html

See also

https://docs.python.org/3/library/venv.html?highlight=venv#module-venv
Folks;

coming from a server-sided Java background, I'm recently exploring
frameworks such as cherrypy or webpy for building RESTful services, which
is quite a breeze and a pretty pleasant experience; however one thing so
far bugs me: Using Java tooling and libraries such as DropWizard, it is
pretty straightforward to build an "all-inclusive" application containing
(a) all code of my own, (b) all required dependencies, (c) all other
resources and, if required, even (d) a Java virtual machine in one large
.zip file which can easily be copied to a clean Linux VM, unzipped and
started there.

Are there ways of doing so using Python, too? I'd like to set up a project
structure / working environment that includes all Python 3rd party
libraries, my own code and maybe even a "standard" Python runtime for 64bit
Linux systems (to not depend too much on what version a certain Linux
distribution actually ships) and focus on doing deployment to various
machines at best by simply copying these packages around.

Any pointers, ideas, inspirations on that greatly appreciated - even in
total different ways if what I am about to do is completely off anyone
would do it in a Python environment. ;)

TIA and all the best,
Kristian
--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: kivy editable multicolumn list

2015-09-15 Thread David Aldrich
> Not sure if this is the place to ask about kivy ...

Try the kivy users list here:

https://groups.google.com/forum/#!forum/kivy-users

Best regards

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


Pyarmor, guard your python scripts

2015-09-15 Thread Jondy Zhao
Pyarmor is a simple to use tool which is capable of importing or running 
encrypted Python script files. Moreover, it can apply encoding algorithms to 
your Python scripts, in order to help you protect them before you can 
distribute them. You may also generate license files with custom validity 
conditions.

Python protector application

Pyarmor is dedicated to users who create their applications, components, 
scripts or any file with the help of the Python programming language. You may 
use this application to encrypt the files, in order to protect their content 
and your intellectual property, by encoding the scripts.

Pyarmor uses two alternative methods of applying protection: converting the 
Python script file to an encrypted type of item, with the .PYX extension. 
Otherwise, you may add specific files to the script and distribute it as a 
package: the program can create and attach license files, with various validity 
terms.

Change the shape, not the content

While Pyarmor can modify the package in which the Python script is distributed, 
it hardly applies any modifications to the script itself. In fact, the program 
is not a script editor and does not allow you to make changes within the files.

The program allows you to encrypt files, but to also open and run them as if no 
protection was applied. Moreover, it can run or import encrypted Python scripts 
in any target machine, only in specified machines or before a specified date. 
This aspect can be controlled by the creation of the license files: bound to a 
hard disk serial number or by an expiration date.

Simple to use application

Pyarmor comes as a wizard, which can guide you through all the steps of the 
process, for your convenience. The steps are not restricted by certain 
requirements, so you may easily skip either of them and customize the process. 
Moreover, the program allows you to save the files at any location on your 
computer.

For more information, search pyarmor in pypi.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Ben Finney
Jondy Zhao  writes:

> Pyarmor is a simple to use tool which is capable of importing or
> running encrypted Python script files. Moreover, it can apply encoding
> algorithms to your Python scripts, in order to help you protect them
> before you can distribute them. You may also generate license files
> with custom validity conditions.

Protect them from whom? What is the threat model against which Pyarmor
is claimed to protect? Who is the attacker, who is being protected?

> The program allows you to encrypt files, but to also open and run them
> as if no protection was applied. Moreover, it can run or import
> encrypted Python scripts in any target machine, only in specified
> machines or before a specified date. This aspect can be controlled by
> the creation of the license files: bound to a hard disk serial number
> or by an expiration date.

So a Python file encrypted this way will be arbitrarily restricted in
how it can be inspected for debugging, performance monitoring, and
testing?

This seems to explicitly treat the user of the Python software as a
hostile attacker. That is not a friendly or respectful position, and I
hope I misunderstand Pyarmor's operation.

-- 
 \   “Any fool can write code that a computer can understand. Good |
  `\   programmers write code that humans can understand.” —Martin |
_o__)  Fowler, _Refactoring_, 2000 |
Ben Finney

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


Re: From logging to files to a better solution: syslog, Sentry, Logstash, ....

2015-09-15 Thread Thomas Güttler
Am Freitag, 11. September 2015 11:03:52 UTC+2 schrieb jmp:
> On 09/11/2015 09:22 AM, Thomas Güttler wrote:
> >
> > I want INFO to be logged and stored on the remote host.
> > Therefore I must not filter INFO messages.
> >
> > I don't want to pull INFO messages over the VPN.
> >
> > Ergo, the filtering at Python level does not help in my use case.
> > Or I am missing something.
> 
> Probably,
> 
> Your logger should have
> 
>* a remote host handler
>* and a VPN handler.
> 
> You can set filters and log levels separately for each handler.
> More info here
> https://docs.python.org/2/library/logging.html#handler-objects
> https://docs.python.org/2/howto/logging-cookbook.html#logging-to-multiple-destinations
> 
> Something like (python 2.7)
> 
> import logging
> 
> logCfg = {
>  'remote':(
>  logging.StreamHandler(),
>  logging.Formatter('Remote - %(levelname)s - %(message)s'),
>  logging.INFO,
>  ),
>  'vpn':(
>  logging.StreamHandler(),
>  logging.Formatter('VPN - %(levelname)s - %(message)s'),
>  logging.ERROR,
>  ),
> }


 Yes, I could do it this way.

But somehow I am not happy with this solution.

I think the filtering should be outside of python.

I like DevOp, but sometimes clear responsibilities help to
cut big problems into smaller ones.

I would like to handle the log message filtering outside of python.

Can you understand my concerns?

  Thomas Güttler

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


Re: From logging to files to a better solution: syslog, Sentry, Logstash, ....

2015-09-15 Thread Thomas Güttler
Am Freitag, 11. September 2015 10:18:11 UTC+2 schrieb [email protected]:
> On Friday, September 11, 2015 at 9:22:42 AM UTC+2, Thomas Güttler wrote:
> > Am Donnerstag, 10. September 2015 08:42:47 UTC+2 schrieb dieter:
> > > Thomas Güttler writes:
> > > > ...
> > > > Why we are unhappy with logging to files:
> > > >
> > > >  - filtering: We don't want to get INFO messages over the VPN.
> > > 
> > > You can quite easily control at what level messages are logged with
> > > the standard Python logging framework. Each handler has a level
> > > and will ignore messages at a lower level.
> > 
> > 
> > I want INFO to be logged and stored on the remote host.
> > Therefore I must not filter INFO messages.
> > 
> > I don't want to pull INFO messages over the VPN.
> > 
> > Ergo, the filtering at Python level does not help in my use case.
> > Or I am missing something.
> > 
> > And now I have an ugly soup. 
> > 
> > The ugly soup is a text file with not well defined syntax. It looks line
> > based. But sometimes there are log messages which span multiple lines 
> > 
> > Remember: "Life is too short to (re)write parsers"
> > 
> > Yes, there are tools to parse that soup. But why create this soup in 
> > the first place?
> > 
> > That's why I want to move from file based logging to a different solution.
> > 
> > Unfortunately there too many choices (graylog, logstash, sentry, ...) :-(
> > 
> > 
> > 
> > > >  - Rotating: Rotating files is possible, but somehow cumbersome.
> > > 
> > > There are standard tools to rotate logfiles.
> > > 
> > > >  - Support structured logging of values (json) in the future.
> > > 
> > > Again, the Python logging framework is quite flexible with
> > > respect to the format of logged messages.
> > > 
> > > > ...
> > > > Which solution could fit for our environment?
> > > 
> > > I work for a customer with a similar environment (he uses "Zope" instead
> > > of "Django") - and he uses logfiles. The logfiles are automatically
> > > rotated and there are in the order of half a dozen to a dozen logfiles
> > > per day.
> > > 
> > > When I have to analyse a problem with the help of the logfiles,
> > > I do not copy them via VPN but do the filtering remotely and only
> > > copy the filtered portion, if necessary.
> > 
> > Good to know that I am not the only one running servers in remote intranets.
> > 
> > Regards,
> >   Thomas Güttler
> 
> So, if logging to json is on the horizon anyway, why don't you create
> something like a MongoDb handler in the standard Python logging framework 
> and run a MongoDb server in the client intranet? You could then connect
> over VPN to MongoDb, filter the warning/error messages there on the server
> side and fetch them to your local systems for analysis.


Yes I could set up a MongoDB server. But I would like to reuse and not to 
reinvent. 

I would like to go a proven solid road.


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


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Chris Angelico
On Tue, Sep 15, 2015 at 7:21 PM, Jondy Zhao  wrote:
> Pyarmor is dedicated to users who create their applications, components, 
> scripts or any file with the help of the Python programming language. You may 
> use this application to encrypt the files, in order to protect their content 
> and your intellectual property, by encoding the scripts.
>
>
> The program allows you to encrypt files, but to also open and run them as if 
> no protection was applied.

If they can be run as if no protection had been applied, that
presumably means the loader is capable of decrypting them, right? So
what's to stop anyone from reading the loader, using it to decrypt the
actual code, and running it?

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


Re: kivy editable multicolumn list

2015-09-15 Thread Laura Creighton
In a message of Tue, 15 Sep 2015 03:31:49 +0100, Paulo da Silva writes:
>Hi all.
>Not sure if this is the place to ask about kivy ...
>I apologize if not.
>
>I am playing with the example here
>https://gist.github.com/geojeff/4442405
>
>Now I would like to change the background color the editable field.
>
>So I added
>   def __init__(self,**kwargs):
>   super(EditableLabel,self).__init__(**kwargs)
>   with self.canvas.before:
>   Color(0,1,0)
>   Rectangle(pos=self.pos,size=self.size)
>   print(self.pos,self.size)
>
>to class EditableLabel.
>
>But when entering __init__ self.pos and self.size do not have the
>correct pos/size for the EditableLabel.
>
>How can I fix this? Please no kv solutions. I need dynamic change it in
>a real example.

I am not sure what you want for your integers_dict.  It isn't the
something that Rob Collins fixtures package provides. :)
https://pypi.python.org/pypi/fixtures

I just hardcoded it like this:

integers_dict = {str(i): {'text': str(i), 'is_selected': False}
 for i in range(100)}

which I pasted out of http://kivy.org/docs/api-kivy.uix.listview.html
'Using an Item View Template'.  This may have no relation to what you
really want.

you also need a line
from kivy.graphics import Color, Rectangle

Then you change your class definition to be:

class EditableLabel(ListItemLabel):
def __init__(self,**kwargs):
super(EditableLabel, self).__init__(**kwargs)
self.bind(pos=self.redraw)
self.bind(size=self.redraw)

def redraw(self, *args):
self.canvas.clear()
with self.canvas:
Color(.5,.5,.5)
Rectangle(pos=self.pos,size=self.size)

I don't know why changing self.canvas.before: to self.canvas: in the redraw
method was needed here.  I expected self.canvas.before to be what was
needed, but doesn't seem that way.

If you don't clear the canvas first, in the redraw the results look very
silly to me. However, since you are just playing around to learn things,
then that behaviour may be what you are looking for, so comment it out
and see if you like that better.

HTH,
Laura



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


Re: Packaging and deployment of standalone Python applications?

2015-09-15 Thread marco . nawijn
On Monday, September 14, 2015 at 8:58:51 AM UTC+2, Kristian Rink wrote:
> Folks;
> 
> coming from a server-sided Java background, I'm recently exploring frameworks 
> such as cherrypy or webpy for building RESTful services, which is quite a 
> breeze and a pretty pleasant experience; however one thing so far bugs me: 
> Using Java tooling and libraries such as DropWizard, it is pretty 
> straightforward to build an "all-inclusive" application containing (a) all 
> code of my own, (b) all required dependencies, (c) all other resources and, 
> if required, even (d) a Java virtual machine in one large .zip file which can 
> easily be copied to a clean Linux VM, unzipped and started there.
> 
> Are there ways of doing so using Python, too? I'd like to set up a project 
> structure / working environment that includes all Python 3rd party libraries, 
> my own code and maybe even a "standard" Python runtime for 64bit Linux 
> systems (to not depend too much on what version a certain Linux distribution 
> actually ships) and focus on doing deployment to various machines at best by 
> simply copying these packages around. 
> 
> Any pointers, ideas, inspirations on that greatly appreciated - even in total 
> different ways if what I am about to do is completely off anyone would do it 
> in a Python environment. ;)
> 
> TIA and all the best,
> Kristian

If your business-cases allows it, I would seriously consider using
Docker. I makes it pretty straightforward to move your deployments
around from your development machine, to a test setup, to a cloud
provider (e.g. AWS) etc.

Lack or incomplete support on Windows systems is a little bit a 
deal breaker, but this situation is improving quickly.

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


Re: how to build windows extensions for python 3.5

2015-09-15 Thread Robin Becker

On 14/09/2015 17:26, Mark Lawrence wrote:

On 14/09/2015 16:52, Robin Becker wrote:

...


http://stevedower.id.au/blog/building-for-python-3-5-part-two/

The most important thing is to have something to do while the Visual
Studio installation takes up 8G of your disk space and several hours of elapsed
time.  At least the installation went smoothly.



thanks
--
Robin Becker

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


Horizontal Scalability in python

2015-09-15 Thread AliReza Firuzabadi
I am new in tornado and I want to make web application with tornado and want to 
scale one instance of tornado application to many in separated servers. I 
should have load balancer and it send client requests to servers. please tell 
me how can I do it in the best way.
thank you for helping me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horizontal Scalability in python

2015-09-15 Thread Iuri
You can do it with nginx.

Tornado has some docs about it:
http://tornado.readthedocs.org/en/latest/guide/running.html#running-behind-a-load-balancer

Also, nginx has extensive documentation about the topic;
https://www.nginx.com/resources/admin-guide/load-balancer/

Cheers!

On Tue, Sep 15, 2015 at 8:54 AM, AliReza Firuzabadi  wrote:

> I am new in tornado and I want to make web application with tornado and
> want to scale one instance of tornado application to many in separated
> servers. I should have load balancer and it send client requests to
> servers. please tell me how can I do it in the best way.
> thank you for helping me.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Packaging and deployment of standalone Python applications?

2015-09-15 Thread Laura Creighton
>On Monday, September 14, 2015 at 8:58:51 AM UTC+2, Kristian Rink wrote:

>> Folks; coming from a server-sided Java background, I'm recently
>> exploring frameworks such as cherrypy or webpy for building RESTful
>> services, which is quite a breeze and a pretty pleasant experience;
>> however one thing so far bugs me: Using Java tooling and libraries
>> such as DropWizard, it is pretty straightforward to build an
>> "all-inclusive" application containing (a) all code of my own, (b)
>> all required dependencies, (c) all other resources and, if
>> required, even (d) a Java virtual machine in one large .zip file
>> which can easily be copied to a clean Linux VM, unzipped and
>> started there.  Are there ways of doing so using Python, too? I'd
>> like to set up a project structure / working environment that
>> includes all Python 3rd party libraries, my own code and maybe even
>> a "standard" Python runtime for 64bit Linux systems (to not depend
>> too much on what version a certain Linux distribution actually
>> ships) and focus on doing deployment to various machines at best by
>> simply copying these packages around.

Your main problem may not be technical, but political.  PyInstaller
will do what you want, and docker is really really interesting, but
many linux users really detest the idea of getting a huge package
which duplicates stuff they already have installed on their system.
And it isn't something they are used to -- it is rarely done.
Instead, they will want you to send them a .deb or a .rpm (whatever
their OS package manager wants) or they will want a PyPI package.

If you are distributing them python source, then rather than have you
build them an app, they are more likely to want instructions for what
are the dependencies so they can build your app itself, and also
control whether or not to install the dependencies you require
system-wide or in a virtualenv.

You know your own situation best, but if you are aiming for widespread
adoption by linux users everywhere, well, I am just warning you that
they aren't going to like it.  (Unless docker, which is very new,
turns into The Next Big Thing, which I suppose always could happen.)

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


{Spam?} Re: need help with selenium

2015-09-15 Thread Nagy László Zsolt



After clicking on submit button, a message is displayed on the same page 
whether login was successful or not.
However after clicking on submit button, I lose control over the web page. I 
can't use any selenium functions now like 'driver.find_element_by_name()'.
You need to wait until the submit completes. Firefox works in paralel in 
the background, so don't expect the new page to be loaded right after 
you called .submit().


One way to do it is this: after calling submit, call this:

self.browser.find_element_by_tag_name("body")

This call will return ONLY if the page has completed loading. Then you 
can get page_source or do whatever you want.




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Grant Edwards
On 2015-09-15, Chris Angelico  wrote:
> On Tue, Sep 15, 2015 at 7:21 PM, Jondy Zhao  wrote:
>> Pyarmor is dedicated to users who create their applications, components, 
>> scripts or any file with the help of the Python programming language. You 
>> may use this application to encrypt the files, in order to protect their 
>> content and your intellectual property, by encoding the scripts.
>>
>> The program allows you to encrypt files, but to also open and run
>> them as if no protection was applied.
>
> If they can be run as if no protection had been applied, that
> presumably means the loader is capable of decrypting them, right? So
> what's to stop anyone from reading the loader, using it to decrypt
> the actual code, and running it?

I rather expect the answer to that questions is "laziness".

It's like the lock on my front door.  It's not going to stop anybody
who really wants to get in, but it will prevent the idle curious from
wandering in and messing about with my stuff.

-- 
Grant Edwards   grant.b.edwardsYow! Are we on STRIKE yet?
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Chris Angelico
On Tue, Sep 15, 2015 at 11:16 PM, Grant Edwards  wrote:
> On 2015-09-15, Chris Angelico  wrote:
>> On Tue, Sep 15, 2015 at 7:21 PM, Jondy Zhao  wrote:
>>> Pyarmor is dedicated to users who create their applications, components, 
>>> scripts or any file with the help of the Python programming language. You 
>>> may use this application to encrypt the files, in order to protect their 
>>> content and your intellectual property, by encoding the scripts.
>>>
>>> The program allows you to encrypt files, but to also open and run
>>> them as if no protection was applied.
>>
>> If they can be run as if no protection had been applied, that
>> presumably means the loader is capable of decrypting them, right? So
>> what's to stop anyone from reading the loader, using it to decrypt
>> the actual code, and running it?
>
> I rather expect the answer to that questions is "laziness".
>
> It's like the lock on my front door.  It's not going to stop anybody
> who really wants to get in, but it will prevent the idle curious from
> wandering in and messing about with my stuff.

Maybe. It seems more like having a lock on your front door, with the
key permanently inside it. But maybe that's just me.

In any case, this needs to be clear about how much security it's
actually offering.

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


Re: how to build windows extensions for python 3.5

2015-09-15 Thread Robin Becker

On 15/09/2015 12:38, Robin Becker wrote:

On 14/09/2015 17:26, Mark Lawrence wrote:

On 14/09/2015 16:52, Robin Becker wrote:

...


http://stevedower.id.au/blog/building-for-python-3-5-part-two/

The most important thing is to have something to do while the Visual
Studio installation takes up 8G of your disk space and several hours of elapsed
time.  At least the installation went smoothly.



thanks
Mark's reference seems more directed at designers of the compilation steps for 
the extension. From Zachary's comment it seems I should be able to build with 
distutils without too much trouble.


However, I try to link bits of various libraries statically into the reportlab 
extensions eg freetype.lib. Does anyone know if I will need separate versions of 
those for VS2015? Currently I build with distutils for Python 27, 33 & 34. 
Currently the .libs seem OK with both 2.7 & >=3.3 builds, but I notice from the 
reference that all the code for VS2015 needs to be built with specific options 
set, so will I need separate versions of the relocatable libs?

--
Robin Becker

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


testfixtures 4.3.0 Released!

2015-09-15 Thread Chris Withers

Hi All,

I'm pleased to announce the release of testfixtures 4.3.0. This is a 
feature release that adds the following:


- Add TempDirectory.compare with a cleaner, more explicit API that
  allows comparison of only the files in a temporary directory.

- Deprecate TempDirectory.check, TempDirectory.check_dir
  and TempDirectory.check_all

- Relax absolute-path rules so that if it's inside the TempDirectory,
  it's allowed.

- Allow OutputCapture to separately check output to stdout and
  stderr.

The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


https://github.com/Simplistix/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris

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


Re: Terminology: "reference" versus "pointer"

2015-09-15 Thread Steven D'Aprano
On Tue, 15 Sep 2015 04:02 am, Random832 wrote:

> The point is that with immutable objects no-one cares if they are three
> objects with the same value, or three references to the same object.

Well, you might care...

a = (1,)*(10**12)
b = (1,)*(10**12)
c = (1,)*(10**12)


Each of those tuples would require a rather lot of memory. The difference
between "a lot" and "three times a lot" could be significant.

But other than memory efficiency, yes, you are correct, there's no real
reason to care about the difference between the two cases.


-- 
Steven

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


Re: Terminology: "reference" versus "pointer"

2015-09-15 Thread Steven D'Aprano
On Tue, 15 Sep 2015 03:34 am, Random832 wrote:

> On Mon, Sep 14, 2015, at 13:03, Steven D'Aprano wrote:
>> On Tue, 15 Sep 2015 01:10 am, Random832 wrote:
>> > That's not true in CPython. In fact, the range object in python
>> > contains *four* reference boxes - one more for length.
>> 
>> I really don't see why any of this is relevant to the business being
>> discussed.
> 
> When you're drawing this sort of diagram then what references are held
> by an object are more important than what interfaces it implements.

Hmmm. Well, that's going to be tricky then, at least for some objects. Take
a function object, for example:

   +-+
func > | function object |
   +-+

Nice and simple if you draw it like that. Or:

   +---+
func > | function object   |
   |  -|---> ...
   +-|--|--|---+ 
 |  |  |
 |  |  +---> ...
 V  |
   +-+  |
   | __doc__ |  +--> ...
   +-+


Due to laziness, the diagram is incomplete. But here is a partial list of
references held by each function object. For brevity, I have not included
the leading and trailing underscores:

doc (string, or None);
annotations (dict mapping strings to arbitrary objects);
class (type object);
closure (None, or closure object);
code (code object)
dict (dict mapping strings to arbitrary objects);
module (string)
name (string)

and various more. Some of them, such as __code__, themselves include
references to many other objects. Even relatively small diagrams with only
a few objects could easily expand in complexity.

> 
> Personally I think it's a bit silly to insist on a diagram model where a
> box with an arrow in it pointing at an int object can't be represented
> by a box with an integer in it (where 'int' is any immutable type -
> string, tuple, even range), but people don't like boxes with integers in
> them for some reason.


What's wrong with this?

   +--+
myint ---> |  23  |
   +--+




-- 
Steven

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


Re: From logging to files to a better solution: syslog, Sentry, Logstash, ....

2015-09-15 Thread jmp

On 09/15/2015 11:35 AM, Thomas Güttler wrote:


 Yes, I could do it this way.

But somehow I am not happy with this solution.

I think the filtering should be outside of python.

[snip]

Can you understand my concerns?

   Thomas Güttler



No, not really.

I showed you how it can be done in python using standard logging 
technics. Others have also provided suggestions and you've also 
dismissed those with a "I don't feel like it".


Remember this is a python mailing list hence if you're looking for help 
about a non python log infrastructure, you probably find better answers 
in those said log infrastructures mailing lists.


JM

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


Re: how to build windows extensions for python 3.5

2015-09-15 Thread Zachary Ware
On Tue, Sep 15, 2015 at 8:32 AM, Robin Becker  wrote:
> However, I try to link bits of various libraries statically into the
> reportlab extensions eg freetype.lib. Does anyone know if I will need
> separate versions of those for VS2015? Currently I build with distutils for
> Python 27, 33 & 34. Currently the .libs seem OK with both 2.7 & >=3.3
> builds, but I notice from the reference that all the code for VS2015 needs
> to be built with specific options set, so will I need separate versions of
> the relocatable libs?

I'm a bit surprised that you can successfully use the same .libs for
2.7 and 3.3/3.4.  But since that seems to work, I'd say go ahead and
try it with 3.5, and if the build succeeds test the crap out of it :)

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


Re: how to build windows extensions for python 3.5

2015-09-15 Thread Robin Becker

On 15/09/2015 16:54, Zachary Ware wrote:

On Tue, Sep 15, 2015 at 8:32 AM, Robin Becker  wrote:




I'm a bit surprised that you can successfully use the same .libs for
2.7 and 3.3/3.4.  But since that seems to work, I'd say go ahead and
try it with 3.5, and if the build succeeds test the crap out of it :)

I've downloaded the vs2015 iso from msdn and I'll give the install a try 
tomorrow. It can't be that hard to build our extensions since Christoph Golhke 
has done a reportlab wheel for 3.5 at http://www.lfd.uci.edu/~gohlke/pythonlibs/

--
Robin Becker

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


testfixtures 4.3.3 Released!

2015-09-15 Thread Chris Withers
Sorry, the move to using Travis CI was not without bumps, and we're now 
on 4.3.3, which should be correctly built, including docs up on 
http://testfixtures.readthedocs.org/.


Apologies for the noise...

Chris

On 15/09/2015 14:54, Chris Withers wrote:

Hi All,

I'm pleased to announce the release of testfixtures 4.3.0. This is a 
feature release that adds the following:


- Add TempDirectory.compare with a cleaner, more explicit API that
  allows comparison of only the files in a temporary directory.

- Deprecate TempDirectory.check, TempDirectory.check_dir
  and TempDirectory.check_all

- Relax absolute-path rules so that if it's inside the TempDirectory,
  it's allowed.

- Allow OutputCapture to separately check output to stdout and
  stderr.

The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


https://github.com/Simplistix/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris



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


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Chris Angelico
On Wed, Sep 16, 2015 at 2:20 AM, Grant Edwards  wrote:
> On 2015-09-15, Chris Angelico  wrote:
>> On Tue, Sep 15, 2015 at 11:16 PM, Grant Edwards  
>> wrote:
>>> On 2015-09-15, Chris Angelico  wrote:
 If they can be run as if no protection had been applied, that
 presumably means the loader is capable of decrypting them, right? So
 what's to stop anyone from reading the loader, using it to decrypt
 the actual code, and running it?
>>>
>>> I rather expect the answer to that questions is "laziness".
>>>
>>> It's like the lock on my front door.  It's not going to stop anybody
>>> who really wants to get in, but it will prevent the idle curious from
>>> wandering in and messing about with my stuff.
>>
>> Maybe. It seems more like having a lock on your front door, with the
>> key permanently inside it. But maybe that's just me.
>
> I you may be underestimating the laziness and overestimating the
> cleverness of most people. ;)

Heh :) But in that case, you can probably get away with just
zipimport. Deflation sure isn't encryption, but the code is pretty
thoroughly concealed anyway.

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


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Grant Edwards
On 2015-09-15, Chris Angelico  wrote:
> On Tue, Sep 15, 2015 at 11:16 PM, Grant Edwards  
> wrote:
>> On 2015-09-15, Chris Angelico  wrote:
>>> On Tue, Sep 15, 2015 at 7:21 PM, Jondy Zhao  wrote:
 Pyarmor is dedicated to users who create their applications, components, 
 scripts or any file with the help of the Python programming language. You 
 may use this application to encrypt the files, in order to protect their 
 content and your intellectual property, by encoding the scripts.

 The program allows you to encrypt files, but to also open and run
 them as if no protection was applied.
>>>
>>> If they can be run as if no protection had been applied, that
>>> presumably means the loader is capable of decrypting them, right? So
>>> what's to stop anyone from reading the loader, using it to decrypt
>>> the actual code, and running it?
>>
>> I rather expect the answer to that questions is "laziness".
>>
>> It's like the lock on my front door.  It's not going to stop anybody
>> who really wants to get in, but it will prevent the idle curious from
>> wandering in and messing about with my stuff.
>
> Maybe. It seems more like having a lock on your front door, with the
> key permanently inside it. But maybe that's just me.

I you may be underestimating the laziness and overestimating the
cleverness of most people. ;)

-- 
Grant Edwards   grant.b.edwardsYow! Is this sexual
  at   intercourse yet??  Is it,
  gmail.comhuh, is it??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Grant Edwards
On 2015-09-15, Chris Angelico  wrote:
>
>> I you may be underestimating the laziness and overestimating the
>> cleverness of most people. ;)
>
> Heh :) But in that case, you can probably get away with just
> zipimport. Deflation sure isn't encryption, but the code is pretty
> thoroughly concealed anyway.

I agree completely.  There are three categories of protection:

  1) The program never leaves your computer.

  2) Obfuscation to deter the idle curious from mucking about.

  3) Put the source code on the interwebs.

In category 2 you find the single-file/directory-app bundlers[1]
(which IIRC mostly use something like zipimport) and various other
"encryption" wrappers.  They all provide pretty much the same minimal
"protection".

[1] Most of which are intended to provide ease of distribution and
installation -- the obfuscation is mostly a side-effect.

-- 
Grant Edwards   grant.b.edwardsYow! I love ROCK 'N ROLL!
  at   I memorized the all WORDS
  gmail.comto "WIPE-OUT" in 1965!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-09-15 Thread Chris Angelico
On Wed, Sep 16, 2015 at 2:40 AM, Grant Edwards  wrote:
> On 2015-09-15, Chris Angelico  wrote:
>>
>>> I you may be underestimating the laziness and overestimating the
>>> cleverness of most people. ;)
>>
>> Heh :) But in that case, you can probably get away with just
>> zipimport. Deflation sure isn't encryption, but the code is pretty
>> thoroughly concealed anyway.
>
> I agree completely.  There are three categories of protection:
>
>   1) The program never leaves your computer.
>
>   2) Obfuscation to deter the idle curious from mucking about.
>
>   3) Put the source code on the interwebs.

Agreed. #3 is the protection that I use for most of my code, and it's
protected me several times from a threat that's far more serious (in
my mind) than someone ripping off my code: it's kept my code safe from
hard drive failures. Yeah, nothing like seeing errors spewing off a
drive that's suddenly died to make you appreciate distributed source
control! (Oh look, my private key is no longer accessible. How
terrible... I have to go to GitHub and register a new public key
before I can continue development. That's gonna set me back... five
whole minutes!)

#1 wasn't really viable until the always-on internet connection became
a normal thing, but today, it's actually pretty easy. Shove your
application up onto cheap hosting somewhere, and make it accessible
via the web... anyone can do it, and your code needs no obfuscation to
be truly secure.

> In category 2 you find the single-file/directory-app bundlers[1]
> (which IIRC mostly use something like zipimport) and various other
> "encryption" wrappers.  They all provide pretty much the same minimal
> "protection".
>
> [1] Most of which are intended to provide ease of distribution and
> installation -- the obfuscation is mostly a side-effect.

Right. Anyone who thinks zipapp is good for security is wrong, but it
sure can be handy for packaging up a one-click "here, download and run
this" Windows .exe file. Any obfuscation should be seen as a freebie,
on par with the toy you get in a fast-food meal.

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


Python Developer- Houston, TX

2015-09-15 Thread appthought1
Hi,

Hope you are doing good!!

Please revert back to me if the below job description matches your profile

Position: Python  Developer
Location: Houston, TX
Duration: Long Term

Job Description
*   6+ years of experience with Linux/UNIX Systems Administration
*   2+ years of Openstack Experience
*   Hypervisor KVM, BIOS, Firmware update
*   Storage Technologies (NAS, SAN & Cloud Storage)
*   Experience with configuration management tools (Chef expert!!)
*   Analytical problem-solving and conceptual skills
*   Strong scripting and/or development chops (Ruby, Python, Bash, Perl)
*   Experience with database technologies (MySQL, Percona, MongoDB)
*   Experience with automation (Chef etc.) and monitoring (Nagios, etc.) 
technologies in production setting
*   Experience with networking technologies including TCP/IP VPN DNS 
routing firewalls VLAN.
*   Excellent communication skills
*   Excellent team player

Thanks & Regards
Vignesh
Talent Acquisition Specialist 
Email: [email protected]
IM: vicky_298
Phone: 407-574-2696 
Fax: 407-641-8184
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem with lists

2015-09-15 Thread Rafael David
Hi guys,

I'm newbie in Python (but not a newbie developer). I'm facing a problem with a 
bidimensional list (list of lists) containing dictionaries. I don't know if I 
didn't understand how lists and dictionaries work in Python or if there is a 
mistake in my code that I can't see. In the code I'm printing the list values 
just after the assignment and they are ok, but when I try to print the list at 
the end of the function the values are different (repeated). Below is the code 
and the result in Python 3.4.0. Could you guys please help me with that?

Thanks a lot!

Rafael

>>> def preencherTabuleiroInicial():
tabuleiro = [[None for x in range(8)] for y in range(8)]
peca = {}
for lin in range(8):
for col in range(8):
if lin == 0 or lin == 1 or lin == 6 or lin == 7:
if lin == 0 or lin == 1:
peca['cor'] = 'b'
elif lin == 6 or lin == 7:
peca['cor'] = 'p'
if lin == 1 or lin == 6:
peca['nome'] = 'p'   
elif col == 0 or col == 7:
peca['nome'] = 't'
elif col == 1 or col == 6:
peca['nome'] = 'c'
elif col == 2 or col == 5:
peca['nome'] = 'b'
elif col == 3:
peca['nome'] = 'd'
else:
peca['nome'] = 'r'
tabuleiro[lin][col] = peca
print(str(lin) + ' ' + str(col) + ' ' + str(tabuleiro[lin][col]))
print()
print(tabuleiro)

>>> 
>>> preencherTabuleiroInicial()
0 0 {'nome': 't', 'cor': 'b'}
0 1 {'nome': 'c', 'cor': 'b'}
0 2 {'nome': 'b', 'cor': 'b'}
0 3 {'nome': 'd', 'cor': 'b'}
0 4 {'nome': 'r', 'cor': 'b'}
0 5 {'nome': 'b', 'cor': 'b'}
0 6 {'nome': 'c', 'cor': 'b'}
0 7 {'nome': 't', 'cor': 'b'}
1 0 {'nome': 'p', 'cor': 'b'}
1 1 {'nome': 'p', 'cor': 'b'}
1 2 {'nome': 'p', 'cor': 'b'}
1 3 {'nome': 'p', 'cor': 'b'}
1 4 {'nome': 'p', 'cor': 'b'}
1 5 {'nome': 'p', 'cor': 'b'}
1 6 {'nome': 'p', 'cor': 'b'}
1 7 {'nome': 'p', 'cor': 'b'}
2 0 None
2 1 None
2 2 None
2 3 None
2 4 None
2 5 None
2 6 None
2 7 None
3 0 None
3 1 None
3 2 None
3 3 None
3 4 None
3 5 None
3 6 None
3 7 None
4 0 None
4 1 None
4 2 None
4 3 None
4 4 None
4 5 None
4 6 None
4 7 None
5 0 None
5 1 None
5 2 None
5 3 None
5 4 None
5 5 None
5 6 None
5 7 None
6 0 {'nome': 'p', 'cor': 'p'}
6 1 {'nome': 'p', 'cor': 'p'}
6 2 {'nome': 'p', 'cor': 'p'}
6 3 {'nome': 'p', 'cor': 'p'}
6 4 {'nome': 'p', 'cor': 'p'}
6 5 {'nome': 'p', 'cor': 'p'}
6 6 {'nome': 'p', 'cor': 'p'}
6 7 {'nome': 'p', 'cor': 'p'}
7 0 {'nome': 't', 'cor': 'p'}
7 1 {'nome': 'c', 'cor': 'p'}
7 2 {'nome': 'b', 'cor': 'p'}
7 3 {'nome': 'd', 'cor': 'p'}
7 4 {'nome': 'r', 'cor': 'p'}
7 5 {'nome': 'b', 'cor': 'p'}
7 6 {'nome': 'c', 'cor': 'p'}
7 7 {'nome': 't', 'cor': 'p'}

[[{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [{'nome': 
't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [None, None, None, 
None, None, None, None, None], [None, None, None, None, None, None, None, 
None], [None, None, None, None, None, None, None, None], [None, None, None, 
None, None, None, None, None], [{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 
't', 'cor': 'p'}], [{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome'
 : 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}]]
>>> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with lists

2015-09-15 Thread C Smith
>>tabuleiro[lin][col] = peca

use peca.copy() here or else a deep copy is made.

On Tue, Sep 15, 2015 at 4:45 PM, Rafael David  wrote:
> Hi guys,
>
> I'm newbie in Python (but not a newbie developer). I'm facing a problem with 
> a bidimensional list (list of lists) containing dictionaries. I don't know if 
> I didn't understand how lists and dictionaries work in Python or if there is 
> a mistake in my code that I can't see. In the code I'm printing the list 
> values just after the assignment and they are ok, but when I try to print the 
> list at the end of the function the values are different (repeated). Below is 
> the code and the result in Python 3.4.0. Could you guys please help me with 
> that?
>
> Thanks a lot!
>
> Rafael
>
 def preencherTabuleiroInicial():
> tabuleiro = [[None for x in range(8)] for y in range(8)]
> peca = {}
> for lin in range(8):
> for col in range(8):
> if lin == 0 or lin == 1 or lin == 6 or lin == 7:
> if lin == 0 or lin == 1:
> peca['cor'] = 'b'
> elif lin == 6 or lin == 7:
> peca['cor'] = 'p'
> if lin == 1 or lin == 6:
> peca['nome'] = 'p'
> elif col == 0 or col == 7:
> peca['nome'] = 't'
> elif col == 1 or col == 6:
> peca['nome'] = 'c'
> elif col == 2 or col == 5:
> peca['nome'] = 'b'
> elif col == 3:
> peca['nome'] = 'd'
> else:
> peca['nome'] = 'r'
> tabuleiro[lin][col] = peca
> print(str(lin) + ' ' + str(col) + ' ' + str(tabuleiro[lin][col]))
> print()
> print(tabuleiro)
>

 preencherTabuleiroInicial()
> 0 0 {'nome': 't', 'cor': 'b'}
> 0 1 {'nome': 'c', 'cor': 'b'}
> 0 2 {'nome': 'b', 'cor': 'b'}
> 0 3 {'nome': 'd', 'cor': 'b'}
> 0 4 {'nome': 'r', 'cor': 'b'}
> 0 5 {'nome': 'b', 'cor': 'b'}
> 0 6 {'nome': 'c', 'cor': 'b'}
> 0 7 {'nome': 't', 'cor': 'b'}
> 1 0 {'nome': 'p', 'cor': 'b'}
> 1 1 {'nome': 'p', 'cor': 'b'}
> 1 2 {'nome': 'p', 'cor': 'b'}
> 1 3 {'nome': 'p', 'cor': 'b'}
> 1 4 {'nome': 'p', 'cor': 'b'}
> 1 5 {'nome': 'p', 'cor': 'b'}
> 1 6 {'nome': 'p', 'cor': 'b'}
> 1 7 {'nome': 'p', 'cor': 'b'}
> 2 0 None
> 2 1 None
> 2 2 None
> 2 3 None
> 2 4 None
> 2 5 None
> 2 6 None
> 2 7 None
> 3 0 None
> 3 1 None
> 3 2 None
> 3 3 None
> 3 4 None
> 3 5 None
> 3 6 None
> 3 7 None
> 4 0 None
> 4 1 None
> 4 2 None
> 4 3 None
> 4 4 None
> 4 5 None
> 4 6 None
> 4 7 None
> 5 0 None
> 5 1 None
> 5 2 None
> 5 3 None
> 5 4 None
> 5 5 None
> 5 6 None
> 5 7 None
> 6 0 {'nome': 'p', 'cor': 'p'}
> 6 1 {'nome': 'p', 'cor': 'p'}
> 6 2 {'nome': 'p', 'cor': 'p'}
> 6 3 {'nome': 'p', 'cor': 'p'}
> 6 4 {'nome': 'p', 'cor': 'p'}
> 6 5 {'nome': 'p', 'cor': 'p'}
> 6 6 {'nome': 'p', 'cor': 'p'}
> 6 7 {'nome': 'p', 'cor': 'p'}
> 7 0 {'nome': 't', 'cor': 'p'}
> 7 1 {'nome': 'c', 'cor': 'p'}
> 7 2 {'nome': 'b', 'cor': 'p'}
> 7 3 {'nome': 'd', 'cor': 'p'}
> 7 4 {'nome': 'r', 'cor': 'p'}
> 7 5 {'nome': 'b', 'cor': 'p'}
> 7 6 {'nome': 'c', 'cor': 'p'}
> 7 7 {'nome': 't', 'cor': 'p'}
>
> [[{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
> 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [{'nome': 
> 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
> {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [None, None, 
> None, None, None, None, None, None], [None, None, None, None, None, None, 
> None, None], [None, None, None, None, None, None, None, None], [None, None, 
> None, None, None, None, None, None], [{'nome': 't', 'cor': 'p'}, {'nome': 
> 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
> {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> 'p'}, {'nome': 't', 'cor': 'p'}], [{'nome': 't', 'cor': 'p'}, {'nome': 't', 
> 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 
> 't', 'cor': 'p'}, {'nom
 e'
>  : 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}]]

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


Re: Problem with lists

2015-09-15 Thread MRAB

On 2015-09-16 00:45, Rafael David wrote:

Hi guys,

I'm newbie in Python (but not a newbie developer). I'm facing a
problem with a bidimensional list (list of lists) containing
dictionaries. I don't know if I didn't understand how lists and
dictionaries work in Python or if there is a mistake in my code that
I can't see. In the code I'm printing the list values just after the
assignment and they are ok, but when I try to print the list at the
end of the function the values are different (repeated). Below is
the code and the result in Python 3.4.0. Could you guys please help
me with that?

Thanks a lot!

Rafael


def preencherTabuleiroInicial():

 tabuleiro = [[None for x in range(8)] for y in range(8)]
 peca = {}
 for lin in range(8):
 for col in range(8):
 if lin == 0 or lin == 1 or lin == 6 or lin == 7:
 if lin == 0 or lin == 1:
 peca['cor'] = 'b'
 elif lin == 6 or lin == 7:
 peca['cor'] = 'p'
 if lin == 1 or lin == 6:
 peca['nome'] = 'p'
 elif col == 0 or col == 7:
 peca['nome'] = 't'
 elif col == 1 or col == 6:
 peca['nome'] = 'c'
 elif col == 2 or col == 5:
 peca['nome'] = 'b'
 elif col == 3:
 peca['nome'] = 'd'
 else:
 peca['nome'] = 'r'
 tabuleiro[lin][col] = peca
 print(str(lin) + ' ' + str(col) + ' ' + str(tabuleiro[lin][col]))
 print()
 print(tabuleiro)



preencherTabuleiroInicial()

0 0 {'nome': 't', 'cor': 'b'}
0 1 {'nome': 'c', 'cor': 'b'}
0 2 {'nome': 'b', 'cor': 'b'}
0 3 {'nome': 'd', 'cor': 'b'}
0 4 {'nome': 'r', 'cor': 'b'}
0 5 {'nome': 'b', 'cor': 'b'}
0 6 {'nome': 'c', 'cor': 'b'}
0 7 {'nome': 't', 'cor': 'b'}
1 0 {'nome': 'p', 'cor': 'b'}
1 1 {'nome': 'p', 'cor': 'b'}
1 2 {'nome': 'p', 'cor': 'b'}
1 3 {'nome': 'p', 'cor': 'b'}
1 4 {'nome': 'p', 'cor': 'b'}
1 5 {'nome': 'p', 'cor': 'b'}
1 6 {'nome': 'p', 'cor': 'b'}
1 7 {'nome': 'p', 'cor': 'b'}
2 0 None
2 1 None
2 2 None
2 3 None
2 4 None
2 5 None
2 6 None
2 7 None
3 0 None
3 1 None
3 2 None
3 3 None
3 4 None
3 5 None
3 6 None
3 7 None
4 0 None
4 1 None
4 2 None
4 3 None
4 4 None
4 5 None
4 6 None
4 7 None
5 0 None
5 1 None
5 2 None
5 3 None
5 4 None
5 5 None
5 6 None
5 7 None
6 0 {'nome': 'p', 'cor': 'p'}
6 1 {'nome': 'p', 'cor': 'p'}
6 2 {'nome': 'p', 'cor': 'p'}
6 3 {'nome': 'p', 'cor': 'p'}
6 4 {'nome': 'p', 'cor': 'p'}
6 5 {'nome': 'p', 'cor': 'p'}
6 6 {'nome': 'p', 'cor': 'p'}
6 7 {'nome': 'p', 'cor': 'p'}
7 0 {'nome': 't', 'cor': 'p'}
7 1 {'nome': 'c', 'cor': 'p'}
7 2 {'nome': 'b', 'cor': 'p'}
7 3 {'nome': 'd', 'cor': 'p'}
7 4 {'nome': 'r', 'cor': 'p'}
7 5 {'nome': 'b', 'cor': 'p'}
7 6 {'nome': 'c', 'cor': 'p'}
7 7 {'nome': 't', 'cor': 'p'}

[[{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [{'nome': 
't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [None, None, None, 
None, None, None, None, None], [None, None, None, None, None, None, None, 
None], [None, None, None, None, None, None, None, None], [None, None, None, 
None, None, None, None, None], [{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 
't', 'cor': 'p'}], [{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, 
{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
'p'}, {'no

me'

  : 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}]]





You're creating a dict:

peca = {}

putting entries into it:

peca['cor'] = ...

or:
peca['nome'] = ...

and then putting it into one of the lists of lists:

tabuleiro[lin][col] = peca

but it's the same dict; you're re-using it.

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


Re: Problem with lists

2015-09-15 Thread Rafael David
Em terça-feira, 15 de setembro de 2015 21:11:38 UTC-3, MRAB  escreveu:
> On 2015-09-16 00:45, Rafael David wrote:
> > Hi guys,
> >
> > I'm newbie in Python (but not a newbie developer). I'm facing a
> > problem with a bidimensional list (list of lists) containing
> > dictionaries. I don't know if I didn't understand how lists and
> > dictionaries work in Python or if there is a mistake in my code that
> > I can't see. In the code I'm printing the list values just after the
> > assignment and they are ok, but when I try to print the list at the
> > end of the function the values are different (repeated). Below is
> > the code and the result in Python 3.4.0. Could you guys please help
> > me with that?
> >
> > Thanks a lot!
> >
> > Rafael
> >
>  def preencherTabuleiroInicial():
> >  tabuleiro = [[None for x in range(8)] for y in range(8)]
> >  peca = {}
> >  for lin in range(8):
> >  for col in range(8):
> >  if lin == 0 or lin == 1 or lin == 6 or lin == 7:
> >  if lin == 0 or lin == 1:
> >  peca['cor'] = 'b'
> >  elif lin == 6 or lin == 7:
> >  peca['cor'] = 'p'
> >  if lin == 1 or lin == 6:
> >  peca['nome'] = 'p'
> >  elif col == 0 or col == 7:
> >  peca['nome'] = 't'
> >  elif col == 1 or col == 6:
> >  peca['nome'] = 'c'
> >  elif col == 2 or col == 5:
> >  peca['nome'] = 'b'
> >  elif col == 3:
> >  peca['nome'] = 'd'
> >  else:
> >  peca['nome'] = 'r'
> >  tabuleiro[lin][col] = peca
> >  print(str(lin) + ' ' + str(col) + ' ' + 
> > str(tabuleiro[lin][col]))
> >  print()
> >  print(tabuleiro)
> >
> 
>  preencherTabuleiroInicial()
> > 0 0 {'nome': 't', 'cor': 'b'}
> > 0 1 {'nome': 'c', 'cor': 'b'}
> > 0 2 {'nome': 'b', 'cor': 'b'}
> > 0 3 {'nome': 'd', 'cor': 'b'}
> > 0 4 {'nome': 'r', 'cor': 'b'}
> > 0 5 {'nome': 'b', 'cor': 'b'}
> > 0 6 {'nome': 'c', 'cor': 'b'}
> > 0 7 {'nome': 't', 'cor': 'b'}
> > 1 0 {'nome': 'p', 'cor': 'b'}
> > 1 1 {'nome': 'p', 'cor': 'b'}
> > 1 2 {'nome': 'p', 'cor': 'b'}
> > 1 3 {'nome': 'p', 'cor': 'b'}
> > 1 4 {'nome': 'p', 'cor': 'b'}
> > 1 5 {'nome': 'p', 'cor': 'b'}
> > 1 6 {'nome': 'p', 'cor': 'b'}
> > 1 7 {'nome': 'p', 'cor': 'b'}
> > 2 0 None
> > 2 1 None
> > 2 2 None
> > 2 3 None
> > 2 4 None
> > 2 5 None
> > 2 6 None
> > 2 7 None
> > 3 0 None
> > 3 1 None
> > 3 2 None
> > 3 3 None
> > 3 4 None
> > 3 5 None
> > 3 6 None
> > 3 7 None
> > 4 0 None
> > 4 1 None
> > 4 2 None
> > 4 3 None
> > 4 4 None
> > 4 5 None
> > 4 6 None
> > 4 7 None
> > 5 0 None
> > 5 1 None
> > 5 2 None
> > 5 3 None
> > 5 4 None
> > 5 5 None
> > 5 6 None
> > 5 7 None
> > 6 0 {'nome': 'p', 'cor': 'p'}
> > 6 1 {'nome': 'p', 'cor': 'p'}
> > 6 2 {'nome': 'p', 'cor': 'p'}
> > 6 3 {'nome': 'p', 'cor': 'p'}
> > 6 4 {'nome': 'p', 'cor': 'p'}
> > 6 5 {'nome': 'p', 'cor': 'p'}
> > 6 6 {'nome': 'p', 'cor': 'p'}
> > 6 7 {'nome': 'p', 'cor': 'p'}
> > 7 0 {'nome': 't', 'cor': 'p'}
> > 7 1 {'nome': 'c', 'cor': 'p'}
> > 7 2 {'nome': 'b', 'cor': 'p'}
> > 7 3 {'nome': 'd', 'cor': 'p'}
> > 7 4 {'nome': 'r', 'cor': 'p'}
> > 7 5 {'nome': 'b', 'cor': 'p'}
> > 7 6 {'nome': 'c', 'cor': 'p'}
> > 7 7 {'nome': 't', 'cor': 'p'}
> >
> > [[{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
> > 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 
> > 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], 
> > [{'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> > 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
> > 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [None, 
> > None, None, None, None, None, None, None], [None, None, None, None, None, 
> > None, None, None], [None, None, None, None, None, None, None, None], [None, 
> > None, None, None, None, None, None, None], [{'nome': 't', 'cor': 'p'}, 
> > {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> > 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 
> > 'cor': 'p'}, {'nome': 't', 'cor': 'p'}], [{'nome': 't', 'cor': 'p'}, 
> > {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 
> > 'p'}, {'nome': 't', 'cor': 'p'}, {'no
> me'
> >   : 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}, {'nome': 't', 'cor': 'p'}]]
> 
> >
> You're creating a dict:
> 
>  peca = {}
> 
> putting entries into it:
> 
>  peca['cor'] = ...
> 
> or:
>  peca['nome'] = ...
> 
> and then putting it into one of the lists of lists:
> 
>  tabuleiro[lin][col] = peca
> 
> but it's the same dict; you're re-using it.

Oooohhh ... I think I got it! I'm assigning a reference to peca and not the 
value itself! Thank you very much MRAB a

Re: Problem with lists

2015-09-15 Thread Chris Angelico
On Wed, Sep 16, 2015 at 10:29 AM, Rafael David  wrote:
> Oooohhh ... I think I got it! I'm assigning a reference to peca and not the 
> value itself! Thank you very much MRAB and C Smith for the enlightenment :)

Right! That's how Python's assignment always works. You may find, in
your case, that you can simply reassign peca={} every time through the
loop. No copying necessary - just make yourself a new dict for each
iteration.

And you might be able to do the whole thing with a gigantic
list/list/dict comprehension, but that may or may not be an
improvement on your code :)

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


Re: Python handles globals badly.

2015-09-15 Thread Steven D'Aprano
On Mon, 14 Sep 2015 06:30 pm, Antoon Pardon wrote:

> Op 12-09-15 om 05:48 schreef Steven D'Aprano:
>> I believe I already acknowledged that assignment-as-expression was fine
>> if it avoided the = versus == error, from the perspective of avoiding
>> errors. But from the perspective of a clean and logical programming
>> model, perhaps not so much. Assignment is imperative, not functional, and
>> requiring it to return a result is somewhat unclean.
> 
> I thought practicallity beats purity? AFAICS python doesn't use such a
> clean and logical programming model and it isn't given much critique over
> it. So I don't think it is fair to critique assignment as an expression
> because of this aspect.

Python is a remarkably clean and consistent language. There's only one kind
of value (the object -- everything is an object, even classes are objects).
The syntax isn't full of special cases. For example, there's nothing like
this horror from Ruby:

#!/usr/bin/ruby
def a(x=4)
x+2
end

b = 1
print "a + b => ", (a + b), "\n"
print "a+b   => ", (a+b), "\n"
print "a+ b  => ", (a+ b), "\n"
print "a +b  => ", (a +b), "\n"


which prints:

7
7
7
3

This is not a bug in the language (well, yes it is, it's a design bug), but
it is a consequence of the syntax.

Python has nothing like this. Python's syntax is quite clean and consistent.


[...]
> But we are not talking about all commands, we are just talking about
> assignments. Sure an assignment has a side effect. But so has ls.pop(). So
> something having a side-effect and a value is not unheard of even within a
> python context.

Sure, I already said that some commands might return a value.

But assignment? Assignment is a pure command. There's nothing to return.
Having `x = 23` return 23 is, well, weird. If we start from the premise
that a return result is generated from a *calculation* or a *query*, we
have to ask what is being calculated or asked? 

I'm not quite willing to say that assignment-as-expression is an error,
because I acknowledge that it could be useful in some places. But it seems
bolted on and arbitrary, like having del return the name you just unbound:

assert (del x) == 'x'

And one other reason why I dislike it: it makes for a verbose and messy
interactive experience. Take Ruby:

irb(main):001:0> a = 23
=> 23


I don't need to see 23 printed, because I already know what the value is, so
that takes two lines where one would do. (On the rare case I did want to
see the value of something I had just assigned to, I could just print the
expression.)


-- 
Steven

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


Re: Python handles globals badly.

2015-09-15 Thread Steven D'Aprano
On Wed, 16 Sep 2015 11:13 am, Steven D'Aprano wrote:

> Python is a remarkably clean and consistent language. There's only one
> kind of value (the object -- everything is an object, even classes are
> objects). The syntax isn't full of special cases. For example, there's
> nothing like this horror from Ruby:
> 
> #!/usr/bin/ruby
> def a(x=4)
> x+2
> end
> 
> b = 1
> print "a + b => ", (a + b), "\n"
> print "a+b   => ", (a+b), "\n"
> print "a+ b  => ", (a+ b), "\n"
> print "a +b  => ", (a +b), "\n"
> 
> 
> which prints:
> 
> 7
> 7
> 7
> 3


Of course it doesn't. It prints:

a + b => 7
a+b   => 7
a+ b  => 7
a +b  => 3


Sorry about that.



-- 
Steven

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


Re: Python handles globals badly.

2015-09-15 Thread Random832
Steven D'Aprano  writes:
> I don't need to see 23 printed, because I already know what the value is, so
> that takes two lines where one would do. (On the rare case I did want to
> see the value of something I had just assigned to, I could just print the
> expression.)

Of course, you could just as well say that you _never_ need to see
anything printed unless you ask for it. The first time I used the REPL I
was irritated by the fact that None wasn't printed. The reason that None
isn't printed is, of course, because Python has no distinction between a
function that returns None as a value and a function that doesn't return
a value.

The alternative is to make assignments special within the REPL, or even
turn it into something that looks less like a REPL and more like the
variable/expression list that some IDE debuggers have.

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


Re: Python handles globals badly.

2015-09-15 Thread Chris Angelico
On Wed, Sep 16, 2015 at 11:20 AM, Steven D'Aprano  wrote:
> On Wed, 16 Sep 2015 11:13 am, Steven D'Aprano wrote:
>
>> Python is a remarkably clean and consistent language. There's only one
>> kind of value (the object -- everything is an object, even classes are
>> objects). The syntax isn't full of special cases. For example, there's
>> nothing like this horror from Ruby:
>>
>> #!/usr/bin/ruby
>> def a(x=4)
>> x+2
>> end
>>
>> b = 1
>> print "a + b => ", (a + b), "\n"
>> print "a+b   => ", (a+b), "\n"
>> print "a+ b  => ", (a+ b), "\n"
>> print "a +b  => ", (a +b), "\n"
>>
>>
>> which prints:
>>
>> 7
>> 7
>> 7
>> 3
>
>
> Of course it doesn't. It prints:
>
> a + b => 7
> a+b   => 7
> a+ b  => 7
> a +b  => 3
>
>
> Sorry about that.

I'm not a Rubyist, but my reading of this is that the last one is
calling a with +b as its argument, where all the others are calling a
with no argument, and then using the result in an expression. ISTM the
problem here is omitting the parentheses on a function call.

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


Re: how to build windows extensions for python 3.5

2015-09-15 Thread Mark Lawrence

On 15/09/2015 17:03, Robin Becker wrote:

On 15/09/2015 16:54, Zachary Ware wrote:

On Tue, Sep 15, 2015 at 8:32 AM, Robin Becker 
wrote:




I'm a bit surprised that you can successfully use the same .libs for
2.7 and 3.3/3.4.  But since that seems to work, I'd say go ahead and
try it with 3.5, and if the build succeeds test the crap out of it :)


I've downloaded the vs2015 iso from msdn and I'll give the install a try
tomorrow. It can't be that hard to build our extensions since Christoph
Golhke has done a reportlab wheel for 3.5 at
http://www.lfd.uci.edu/~gohlke/pythonlibs/


I'd be inclined to check out anything on the bug tracker involving 
Christoph Golhke, there was certainly one show stopper within the last 
few days.  It make take a few minutes, on the other hand it might save 
you days :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: From logging to files to a better solution: syslog, Sentry, Logstash, ....

2015-09-15 Thread dieter
Thomas Güttler  writes:
> Am Freitag, 11. September 2015 11:03:52 UTC+2 schrieb jmp:
> ...
>> Something like (python 2.7)
>> 
>> import logging
>> 
>> logCfg = {
>>  'remote':(
>>  logging.StreamHandler(),
>>  logging.Formatter('Remote - %(levelname)s - %(message)s'),
>>  logging.INFO,
>>  ),
>>  'vpn':(
>>  logging.StreamHandler(),
>>  logging.Formatter('VPN - %(levelname)s - %(message)s'),
>>  logging.ERROR,
>>  ),
>> }
>
>
>  Yes, I could do it this way.
>
> But somehow I am not happy with this solution.
>
> I think the filtering should be outside of python.

Do you think, it will be easier there?

You could also use the "syslog" handler and use "syslog"
configuration features to separate the various message levels.
>From my point of view, this will not be easier - but outside of Python :-)

And you can develop your own Python logging handler delegating logging to
your favorite external logging subsystem and then configure that.
Likely the hardest approach...

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