Re: deepcopy questions

2012-11-28 Thread lars van gemerden
On Wednesday, November 28, 2012 12:59:38 AM UTC+1, lars van gemerden wrote:
> Hi,
> 
> 
> 
> I get a very strange result when using deepcopy. The following code:
> 
> 
> 
> def __deepcopy__(self, memo):
> 
> independent = self.independent()
> 
> if independent is self:
> 
> out = type(self)()
> 
> out.__dict__ = copy.deepcopy(self.__dict__, memo)
> 
> print self.__dict__
> 
> print out.__dict__ #strange result
> 
> return out
> 
> else:
> 
> return copy.deepcopy(independent, memo).find(self.id).take()
> 
> 
> 
> prints different results for self.__dict__ and out.__dict__:
> 
> 
> 
> {'_active_': False, 'init': {}, '_id_': 0, '_items_': 
> [], '_name_': 'main'} 
> 
> {'_active_': False, 'init': {}, '_id_': 0}
> 
> 
> 
> Two items are missing in the copy. Maybe i am missing something obvious, but 
> i cannot figure out how this could happen.
> 
> 
> 
> Can anyone tell me how this is possible?
> 
> 
> 
> Cheers, Lars

I have just tried to make a simple runnable testcase but no luck. in my code 
it's part of a rather complex data structure. 

As I understood the documentation, the memo parameter is to hold a dictionary 
of data that have already been copied (e.g. to deal with circular references), 
and is normally only explicitly used when implementing __deepcopy__, just 
passing memo to calls to deepcopy within the body of __deepcopy__.

If memo contains items, this should, to my understanding, not remove them from 
the output of deepcopy, they will just not be copied again, but instead be 
taken from memo and put in the output (otherwise 2 references to the same 
object would after deepcopying result in 2 distinct copies of that object).

Anyway, since i cannot reproduce the error in a simple testcase and i have no 
adea what is going on, I'll implement what i need differently.

Any ideas are still more then welcome,

Thanks for the feedback,

Lars
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 108, Issue 248

2012-11-28 Thread support

Message ignored: Did not match any rules

-Original Message-
Subject: Python-list Digest, Vol 108, Issue 248
To: python-list@python.org
From: python-list-requ...@python.org

Send Python-list mailing list submissions to
python-list@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
python-list-requ...@python.org

You can reach the person managing the list at
python-list-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."
Today's Topics:

  1. #python archives? (Steven D'Aprano)
  2. Re: Does os.getcwd() and os.curdir have the same effect ? (iMath)
  3. Re: Does os.getcwd() and os.curdir have the same effect ? (iMath)
  4. Re: python application file format (Dieter Maurer)
  5. ANN: eGenix PyRun - One file Python Runtime 1.1.0
 (eGenix Team: M.-A. Lemburg)
  6. Re: Memory usage per top 10x usage per heapy
 (bryanjugglercryptograp...@yahoo.com)
  7. Re: Memory usage per top 10x usage per heapy
 (bryanjugglercryptograp...@yahoo.com)
  8. Module baldy compiled to pyc? (Laszlo Nagy)
  9. Re: Article on the future of Python (Serhiy Storchaka)
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create an executable from python script in windows

2012-11-28 Thread Ulrich Eckhardt

Am 28.11.2012 07:43, schrieb Prakash:

copying C:\Python24\lib\site-packages\py2exe\run_w.exe

 

Python 2.4 was released 8 years ago and shouldn't be used for new 
development or learning any longer. The first step I would take is to 
upgrade to 2.7, which is the last in the 2.x series.


Further, I would at least consider upgrading to Python 3.x, although 
this might require some tweaking of your sourcecode first. Keep in mind 
that 2.x is a dead end though!




The following modules appear to be missing
['win32com.shell']


If the warning persists with 2.7 and you are actually getting errors at 
runtime, throw the whole message at e.g. google.com and click a few 
links. Hint: This is a known problem, you are not the first one!



Good luck!

Uli


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


ANN: eGenix mx Base Distribution 3.2.5 (mxDateTime, mxTextTools, etc.)

2012-11-28 Thread M.-A. Lemburg


ANNOUNCING

   eGenix.com mx Base Distribution

  Version 3.2.5 for Python 2.4 - 2.7

   Open Source Python extensions providing
 important and useful services
for Python programmers.

This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.5-GA.html



ABOUT

The eGenix.com mx Base Distribution for Python is a collection of
professional quality software tools which enhance Python's usability
in many important areas such as fast text searching, date/time
processing and high speed data types.

The tools have a proven record of being portable across many Unix and
Windows platforms. You can write applications which use the tools on
Windows and then run them on Unix platforms without change due to the
consistent platform independent interfaces.

Contents of the distribution:

 * mxDateTime - Easy to use Date/Time Library for Python
 * mxTextTools - Fast Text Parsing and Processing Tools for Python
 * mxProxy - Object Access Control for Python
 * mxBeeBase - On-disk B+Tree Based Database Kit for Python
 * mxURL - Flexible URL Data-Type for Python
 * mxUID - Fast Universal Identifiers for Python
 * mxStack - Fast and Memory-Efficient Stack Type for Python
 * mxQueue - Fast and Memory-Efficient Queue Type for Python
 * mxTools - Fast Everyday Helpers for Python

The package also include a number of helpful smaller modules in the
mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing
or mx.Misc.CommandLine to quickly write command line applications in
Python.

All available packages have proven their stability and usefulness in
many mission critical applications and various commercial settings all
around the world.

For more information, please see the distribution page:

http://www.egenix.com/products/python/mxBase/



NEWS

The 3.2.5 release of the eGenix mx Base Distribution is the latest
release of our open-source Python extensions.

The new patch-level version includes a few important fixes:

 * Fixed a compatibility problem with Python 2.7.3 on Mac OS X 10.6
   and later: Removed mx_customize_compiler() in favor of the standard
   distutils customize_compiler(). It now installs fine again with pip
   on more recent Mac OS X versions. Thanks to Leonardo Santagada for
   bringing this problem to our attention.

 * mxDateTime: Fixed a possible segfault in mxDateTime that was caused
   by the lazy datetime module import mechanism not catching all cases
   where the C API was used in mxDateTime. Thanks to Joel Rosdahl for
   bringing this to our attention.

 * Fixed a bug in the mx.Misc.CSV.Reader.objects() method, which
   triggered a TypeError.

If you are upgrading from eGenix mx Base 3.1.x, please also see the
eGenix mx Base Distribution 3.2.0 release notes for details on what
has changed and which new features are available:

http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html

As always, we are providing pre-built binaries for all common
platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac
OS X 32/64-bit. Source code archives are available for installation on
all other Python platforms, such as Solaris, AIX, HP-UX, etc.

To simplify installation in Zope/Plone and other egg-based systems, we
have also precompiled egg distributions for all platforms. These are
available on our own PyPI-style index server for easy and automatic
download.

Whether you are using a pre-built package or the source distribution,
installation is a simple "python setup.py install" command in all
cases. The only difference is that the pre-built packages do not
require a compiler or the Python development packages to be installed.

For a full list of changes, please refer to the eGenix mx Base Distribution
change log at

http://www.egenix.com/products/python/mxBase/changelog.html

and the change logs of the various included Python packages.



DOWNLOADS

The download archives and instructions for installing the packages can
be found on the eGenix mx Base Distribution page:

http://www.egenix.com/products/python/mxBase/



LICENSE

The eGenix mx Base package is distributed under the eGenix.com Public
License 1.1.0 which is an Open Source license similar to the Python
license. You can use the packages in both commercial and non-commercial
settings without fee or charge.

The package comes with full source code



SUPPORT

Commercial support for this product is available from 

Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
but, how can I fix it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = 
"127.0.0.1" but there are some bugs 
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Chris Angelico
On Wed, Nov 28, 2012 at 9:52 PM, Minh Dang  wrote:
> but, how can I fix it?

I can't say that for sure, but did you read the bit at the end of my
last post beginning "I think you probably want"? Try doing that, see
what happens.

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


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = 
"127.0.0.1",it's ok, but there are some bugs
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Chris Angelico
On Wed, Nov 28, 2012 at 10:10 PM, Minh Dang  wrote:
> ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = 
> "127.0.0.1" but there are some bugs

I doubt that that will work either. And you may need to be a little
clearer on what you mean by "there are some bugs" - is it doing what
you don't expect? Are you getting an exception?

Tips: http://catb.org/~esr/faqs/smart-questions.html

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


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
yes, still have 2 bugs:
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
please help me, after changing broadcast, there are 2 bugs: 
if __name__ == "__main__":
sys.exit(main())
and 

rQueue, wQueue, xQueue = select.select(inputs, [], []) 
please help me
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Chris Angelico
On Wed, Nov 28, 2012 at 10:57 PM, Minh Dang  wrote:
> please help me, after changing broadcast, there are 2 bugs:
> if __name__ == "__main__":
> sys.exit(main())
> and
>
> rQueue, wQueue, xQueue = select.select(inputs, [], [])
> please help me

By "bug", I'm guessing you mean one of two things:

1) The program fails to run, and an exception is given that points to
one of these lines, or
2) The program runs, but does something different from what you expect it to do.

If it's the first, what's the exception? If the second, what do you
expect and what happens?

You need to provide more information. Check out the link I gave you on
how to ask questions; it's very helpful.

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


Imaging libraries in active development?

2012-11-28 Thread Alasdair McAndrew
I'm investigating Python for image processing (having used Matlab, then Octave 
for some years).  And I'm spoiled for choice: PIL and its fork pillow, 
scipy.ndimage, scikits-image, mahotas, the Python interface to openCV...

However, PIL doesn't seem to be in active development.  What I want to know is 
- what are the current "standard" libraries for image processing in Python 
which are in active development?  

I have quite a few image processing student notes which I'm thinking of 
converting to Python, but I'd like to use the most up-to-date library.

Thanks,
Alasdair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-28 Thread dachakku
On Monday, 26 November 2012 21:10:02 UTC+5:30, Miki Tebeka  wrote:
> > But i dont know how to pass the "echo t | " in subprocess.check_output 
> > while calling a process.
> 
> You need to create two subprocess and connect the stdout of the first to the 
> stdin of the 2'nd.
> 
> 
> 
> See http://pythonwise.blogspot.com/2008/08/pipe.html for a possible solution.

Hi Miki,
Thanks.. Creating two subprocesses worked for me. I did the code as below,

p = subprocess.Popen("echo t |", shell=True, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p1 = subprocess.Popen(["svn.exe", "list", "Https://127.0.0.1:443/svn/Repos"], 
shell=True, stdin=p.stdout, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE).communicate()
output = p1[0]

Thanks again... :)
-- 
http://mail.python.org/mailman/listinfo/python-list


How to show and parse rsync progress in Python/Django?

2012-11-28 Thread sachit . technerves
I am using the development version of rsync with --info-progress option. I am 
writing a python program which transfer files from server to local computer 
using rsync:
finalresult = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', 
'--info=progress2', 'hostname:/filename', '/home/nfs/django/user'],
stdout=subprocess.PIPE).communicate()[0]

This should store the processing in the finalresult which is not happening. I 
just want to show the file syncing progress in my front-end Django app. How can 
I do that? Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
yes, it's run but appear: 
in server: Server is ready.
Accepted connection from  ('127.0.0.1', 5000)
End connection from ('127.0.0.1', 5000)
after connected, server close.
in client: Connected to server at  127.0.0.1 : 4000
Traceback (most recent call last):
  File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 303, in 

sys.exit(main())
  File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 60, in 
main
rQueue, wQueue, xQueue = select.select(inputs, [], []) 
OSError: [WinError 10038] An operation was attempted on something that is not a 
socket
there are 2 problems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Chris Angelico
On Thu, Nov 29, 2012 at 1:10 AM, Minh Dang  wrote:
>   File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 60, 
> in main
> rQueue, wQueue, xQueue = select.select(inputs, [], [])
> OSError: [WinError 10038] An operation was attempted on something that is not 
> a socket

Have a look at that line of code - specifically, look at what's in
inputs. One of them perhaps isn't a socket. Tip: The print function is
your friend.

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


Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-28 Thread Miki Tebeka
On Wednesday, November 28, 2012 4:38:35 AM UTC-8, dach...@gmail.com wrote:
> Thanks.. Creating two subprocesses worked for me. I did the code as below,
Glad it worked.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "non central" package management

2012-11-28 Thread Miki Tebeka
On Tuesday, November 27, 2012 8:45:56 PM UTC-8, Roy Smith wrote:
> In the future, the plan is to build a complete fresh virtualenv for 
> every deployment.  But we're not there yet.
Maybe a repository of virtualenvs, then when deploying you can see if there's 
one the matches what you need and use it. Otherwise create a new one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
there are still these 2 problems and i don't know how to solve it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Imaging libraries in active development?

2012-11-28 Thread Ritchie Flick
This may be of some interest to you:
http://www.youtube.com/watch?v=Wvvxazwi2IY&feature=plcp


On Wed, Nov 28, 2012 at 1:30 PM, Alasdair McAndrew  wrote:

> I'm investigating Python for image processing (having used Matlab, then
> Octave for some years).  And I'm spoiled for choice: PIL and its fork
> pillow, scipy.ndimage, scikits-image, mahotas, the Python interface to
> openCV...
>
> However, PIL doesn't seem to be in active development.  What I want to
> know is - what are the current "standard" libraries for image processing in
> Python which are in active development?
>
> I have quite a few image processing student notes which I'm thinking of
> converting to Python, but I'd like to use the most up-to-date library.
>
> Thanks,
> Alasdair
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Ritchie Flick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Imaging libraries in active development?

2012-11-28 Thread Michael Torrie
On 11/28/2012 05:30 AM, Alasdair McAndrew wrote:
> I'm investigating Python for image processing (having used Matlab,
> then Octave for some years).  And I'm spoiled for choice: PIL and its
> fork pillow, scipy.ndimage, scikits-image, mahotas, the Python
> interface to openCV...
> 
> However, PIL doesn't seem to be in active development.  What I want
> to know is - what are the current "standard" libraries for image
> processing in Python which are in active development?
> 
> I have quite a few image processing student notes which I'm thinking
> of converting to Python, but I'd like to use the most up-to-date
> library.

I'm curious.  What features do you need that pil doesn't have?  Other
than updating pil to fix bugs, support new image types or new versions
of Python, what kind of active development do you think it needs to
have? Maybe pil has all the features the original author wanted and is
pretty stable.  To judge a package on how fast it's changing seems a bit
odd to me.  Obviously you want to know that bugs can get fixed of
course.  Perhaps none have been reported recently.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to ship eggs with pyo files only

2012-11-28 Thread Andriy Kornatskyy

There is sometimes a need to ship python egg distribution with pyo files only. 
There is confusion using bdist_egg command since it doesn't have any options to 
do that; you can read more about solution here:

http://mindref.blogspot.com/2012/11/python-egg-pyo.html

Thanks.

Andriy Kornatskyy
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Imaging libraries in active development?

2012-11-28 Thread Christian Heimes
Am 28.11.2012 19:14, schrieb Michael Torrie:
> I'm curious.  What features do you need that pil doesn't have?  Other
> than updating pil to fix bugs, support new image types or new versions
> of Python, what kind of active development do you think it needs to
> have? Maybe pil has all the features the original author wanted and is
> pretty stable.  To judge a package on how fast it's changing seems a bit
> odd to me.  Obviously you want to know that bugs can get fixed of
> course.  Perhaps none have been reported recently.

PIL is missing a bunch of features like proper TIFF support (no
multipage, g3/g4 compression and more), JPEG 2000, RAW and HDR image
formats, tone mapping, proper ICC support, PEP 3128 buffer support ...

PIL is also rather slow. My smc.freeimage library can write JPEGs about
six times faster, because it uses libjpeg-turbo. Only some Linux
distributions have replaced libjpeg with the turbo implementation.


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


Re: re.search when used within an if/else fails

2012-11-28 Thread Kevin T
I agree. Being relatively new to python, i was not sure of quirks so i posted 
the original code.  

I did find the real issue, as I found another loop that was not being executed 
properly.

It turns out that if the indent started with spaces and ended with tabs, 
neither eclipse or command line execution would complain.  where as if the 
indent begins with tabs and has spaces in the middle the tools will complain of 
indentation issues.

i have found that the vi plugin for python is the culprit here.  when the 
plugin does block indentation, the result is indents that begin with spaces.  
if i disable the vi plugin and use the regular eclipse editor these issues go 
away.

with other languages i always expand tabs to spaces.  the vi plugin does do 
this properly.  if i change all indents to be spaces only will python behave?  
i inherited a good deal of the code that i am using, which is tab based.

thanks kevin


On Wednesday, November 21, 2012 11:00:50 PM UTC-6, Chris Angelico wrote:
> On Thu, Nov 22, 2012 at 3:41 AM, Kevin T  wrote:
> 
> > I went back and tried version a again, blam it is/does work now ?!?!?
> 

> 
> 
> This is why the Short, Self-Contained, Correct Example is so
> 
> important. See http://sscce.org/ for some info on that. I often find
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re.search when used within an if/else fails

2012-11-28 Thread Ian Kelly
On Wed, Nov 28, 2012 at 12:39 PM, Kevin T  wrote:
> with other languages i always expand tabs to spaces.  the vi plugin does
do this properly.  if i change all indents to be spaces only will python
behave?  i inherited a good deal of the code that i am using, which is tab
based.

Yes, it's best to use either tabs-only or spaces-only.  Quoting from PEP 8
on the subject:

Never mix tabs and spaces.
>
> The most popular way of indenting Python is with spaces only. The
> second-most popular way is with tabs only. Code indented with a mixture of
> tabs and spaces should be converted to using spaces exclusively. When
> invoking the Python command line interpreter with the -t option, it issues
> warnings about code that illegally mixes tabs and spaces. When using -tt
> these warnings become errors. These options are highly recommended!
>
> For new projects, spaces-only are strongly recommended over tabs. Most
> editors have features that make this easy to do.
>

I thought the prohibition against mixing tabs and spaces was made more
strict in Python 3, but I can't find any reference to that now.  Probably I
was mistaken.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: re.search when used within an if/else fails

2012-11-28 Thread Evan Driscoll
On 11/28/2012 01:57 PM, Ian Kelly wrote:
> Yes, it's best to use either tabs-only or spaces-only.  Quoting from PEP
> 8 on the subject:
> 
> Never mix tabs and spaces.
> 
> The most popular way of indenting Python is with spaces only. The
> second-most popular way is with tabs only. Code indented with a
> mixture of tabs and spaces should be converted to using spaces
> exclusively. When invoking the Python command line interpreter with
> the -t option, it issues warnings about code that illegally mixes
> tabs and spaces. When using -tt these warnings become errors. These
> options are highly recommended!
> 
> For new projects, spaces-only are strongly recommended over tabs.
> Most editors have features that make this easy to do.
> 
> 
> I thought the prohibition against mixing tabs and spaces was made more
> strict in Python 3, but I can't find any reference to that now. 
> Probably I was mistaken.

I'm only entering this thread now so I'm not really in context, but
you're correct; in Python 3, -tt is set by default, which makes illegal
mixing an error.

However, not all mixing is illegal: what it means by "code that
illegally mixes tabs and spaces" is "code whose interpretation differs
depending upon the interpretation of the tab width". While I'm not going
to go test it, I think that if you, say, indent from the first to the
second level with tabs (consistently), indent from the second to third
level with spaces (consistently), and indent from the third to fourth
level with tabs (consistently), it should not complain. Or perhaps I
should say "it should complain that you're a bad person and should feel
bad, but it won't." :-) (In fact, you could indent one block at the
second level with tabs and another with spaces.)

Evan



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re.search when used within an if/else fails

2012-11-28 Thread Steven D'Aprano
On Wed, 28 Nov 2012 11:39:48 -0800, Kevin T wrote:

> with other languages i always expand tabs to spaces.  the vi plugin does
> do this properly.  if i change all indents to be spaces only will python
> behave?  i inherited a good deal of the code that i am using, which is
> tab based.

Python will behave correctly if you use all spaces, or all tabs, for 
indents. If you mix spaces and tabs, anything can happen.

For this reason, Python 3 is more strict and will raise an explicit error 
when it detects mixed spaces/tabs in an indent.

See also the tabnanny tool provided with Python:

[steve@ando ~]$ python -m tabnanny
Usage: /usr/local/lib/python2.7/tabnanny.py [-v] file_or_directory ...



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules or Package for my application

2012-11-28 Thread goon12
On Tuesday, November 27, 2012 3:04:03 AM UTC-5, Stone wrote:
> Dear developers,
> 
> 
> 
> I am creating application (originally written in perl) 
> 
> which will take care about replication from one system to the another system 
> over command rsync. It will simulate High-availability solution.
> 
> 
> 
> The application will contains main module called like ha.py
> 
> and another modules will have names Replication.py, Trace.py, Misc.py, 
> Procs.py, Constants.py, Lan.py, Display.py
> 
> 
> 
> My questions are:
> 
> 1) When I would like to make a global logging to the one file is it enough to 
> do that like
> 
> TRACE='/var/ha/log/sso_trace.log'
> 
> logger = logging.getLogger('sso')
> 
> hdrl = logging.FileHandler(TRACE)
> 
> formatter = logging.Formatter('%{asctime}s %{levelname}s %{message}s')
> 
> hdrl.setFormatter(formatter)
> 
> logger.addHandler(hdrl)
> 
> logger.setLevel(logging.WARNING)
> 
> and make for them one module or how to solve that?
> 
> How to call that logger from all modules / packages?
> 
> Is it necessary to create alone module?
> 
> 
> 
> 2) Is it package necessary or simply modules are enough
> 
> - Replication.py will take care about alone replication
> 
> - Procs.py will take care about some processes
> 
> - Constants.py will take care about definition of global constants
> 
> - Lan.py will take care about LAN definition
> 
> - Dipslay.py will take care about showing screen (GUI or text_based)
> 
> 3) How / where to define global variables?
> 
> 
> 
> best regards
> 
> Petr

If you create the logger in your main module and this main module imports the 
other modules, the logger should be available, to the imported modules, by the 
name "sso". Now in the other modules, you get the logger using logger = 
logging.getLogger("sso").

In the end, I would probably put all these modules in a package and use a 
logging config file. Define a logger with the same name as your root package 
and in each module, within the package, just use "logger = 
logging.getLogger(__name__)"

http://docs.python.org/2/howto/logging.html#logging-advanced-tutorial
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Imaging libraries in active development?

2012-11-28 Thread Jorgen Grahn
On Wed, 2012-11-28, Christian Heimes wrote:
> Am 28.11.2012 19:14, schrieb Michael Torrie:
>> I'm curious.  What features do you need that pil doesn't have?  Other
>> than updating pil to fix bugs, support new image types or new versions
>> of Python, what kind of active development do you think it needs to
>> have? Maybe pil has all the features the original author wanted and is
>> pretty stable.  To judge a package on how fast it's changing seems a bit
>> odd to me.

Not to me -- the slower the change, the better!

>> Obviously you want to know that bugs can get fixed of
>> course.  Perhaps none have been reported recently.
>
> PIL is missing a bunch of features like proper TIFF support (no
> multipage, g3/g4 compression and more), JPEG 2000,

I thought those formats were dead since about a decade?  (Ok, I know
TIFF has niches, but JPEG 2000?)

> RAW and HDR image
> formats, tone mapping, proper ICC support, PEP 3128 buffer support ...

I won't comment on those, but they seem likely to be valid complaints.

> PIL is also rather slow. My smc.freeimage library can write JPEGs about
> six times faster, because it uses libjpeg-turbo. Only some Linux
> distributions have replaced libjpeg with the turbo implementation.

That seems like an argument for *not* having support for many file
formats in the imaging library itself -- just pipeline into the best
standalone utilities available.

/Jorgen

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


Re: please help me to debud my local chat network program

2012-11-28 Thread Jorgen Grahn
On Wed, 2012-11-28, Chris Angelico wrote:
> On Wed, Nov 28, 2012 at 1:50 PM, Minh Dang  wrote:
>> Hello everybody, i am doing my project: local network chat using python
>> here is my file
>> http://www.mediafire.com/?cc2g9tmsju0ba2m
>
> Hmm. Might I recommend some other means of sharing your code? The
> unrar-free utility from the Debian repo won't extract more than the
> first file (accounts.txt), and I don't know if that's a problem with
> unrar-free or your file. A better-known format like zip or tar.gz
> would make things easier.

Or a Git repository at github.com or similar.

/Jorgen

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


Exponential arrival distribution in Python

2012-11-28 Thread Ricky

Hi all,

I am doing a project on traffic simulation. I want to introduce exponential 
arrival distribution to precede this task. Therefore I want write a code in 
python for exponential arrival distribution. I am very new for programming and 
if anybody can help me on this that would be great.

Cheers,
Ricky
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re.search when used within an if/else fails

2012-11-28 Thread Steven D'Aprano
On Wed, 28 Nov 2012 14:08:15 -0600, Evan Driscoll wrote:

> I'm only entering this thread now so I'm not really in context, but
> you're correct; in Python 3, -tt is set by default, which makes illegal
> mixing an error.
> 
> However, not all mixing is illegal: what it means by "code that
> illegally mixes tabs and spaces" is "code whose interpretation differs
> depending upon the interpretation of the tab width". While I'm not going
> to go test it, I think that if you, say, indent from the first to the
> second level with tabs (consistently), indent from the second to third
> level with spaces (consistently), and indent from the third to fourth
> level with tabs (consistently), it should not complain. 

Correct, which disappoints me. Testing with Python 3:

py> if True:
... if True: # tab
... pass  # tab, then four spaces
...
py>

I would prefer that the "pass" line would fail with an illegal indent, 
but it does not. But at least the following fails cleanly:


py> if True:
... if True: # tab
... pass  # tab, then four spaces
... pass  # two spaces, tab, four spaces
  File "", line 4
pass  # two spaces, tab, four spaces
   ^
TabError: inconsistent use of tabs and spaces in indentation


> Or perhaps I
> should say "it should complain that you're a bad person and should feel
> bad, but it won't." :-) (In fact, you could indent one block at the
> second level with tabs and another with spaces.)

I don't mind different blocks using different indentation. You have 
always been able to do this:


py> if True:
... pass  # eight spaces
...
py> if True:
...   pass  # two spaces
...
py>

If you don't like that, don't do it! Consistent indentation globally per 
file is a matter for coding conventions. However, I think that within a 
single block, Python should enforce "all tabs" or "all spaces".

Perhaps it would be nice if Python honoured a directive setting indent 
style to spaces or indents, as it honours source code encoding lines:

# -*- indent:  -*-

Where  could be one of:

space[s]Only accept spaces in indentation
tab[s]  Only accept tabs in indentation
mixed   Accept "mixed" tabs and spaces, but only if consistent

with mixed the default for backward compatibility.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exponential arrival distribution in Python

2012-11-28 Thread Ian Kelly
On Wed, Nov 28, 2012 at 2:34 PM, Ricky  wrote:

>
> Hi all,
>
> I am doing a project on traffic simulation. I want to introduce
> exponential arrival distribution to precede this task. Therefore I want
> write a code in python for exponential arrival distribution. I am very new
> for programming and if anybody can help me on this that would be great.
>

Are you looking for a PRNG using the the exponential distribution?  The
random module built into the standard library already implements this; see:

http://docs.python.org/3/library/random.html#random.expovariate
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exponential arrival distribution in Python

2012-11-28 Thread David Hutto
>> I am doing a project on traffic simulation. I want to introduce
>> exponential arrival distribution to precede this task. Therefore I want
>> write a code in python for exponential arrival distribution. I am very new
>> for programming and if anybody can help me on this that would be great.


First, I would suggest that you give yourself a GUI like tkinter,
wxpython to visualize the data. An average of the sequential(averaged
per 60 second intervals) traveled by drivers on the road, and at what
times.

Then, and I don't know why, but it seems you want a logarithmic, scale where:


for i in range(0,4)
print "%i = %i" % (i * 10 **i)

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exponential arrival distribution in Python

2012-11-28 Thread David Hutto
I mean this one:

for i in range(0,4):
print "%i = %i" % (i * 10 **i)



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Tabs/spaces for indentation (was Re: re.search when used within an if/else fails)

2012-11-28 Thread Chris Angelico
On Thu, Nov 29, 2012 at 8:39 AM, Steven D'Aprano
 wrote:
> Perhaps it would be nice if Python honoured a directive setting indent
> style to spaces or indents, as it honours source code encoding lines:
>
> # -*- indent:  -*-
>
> Where  could be one of:
>
> space[s]Only accept spaces in indentation
> tab[s]  Only accept tabs in indentation
> mixed   Accept "mixed" tabs and spaces, but only if consistent
>
> with mixed the default for backward compatibility.

I don't know that it needs to be a declaration like that; character
encodings are critical to parsing the file, but
newline-followed-by-tab and newline-followed-by-space are unambiguous.
But it would be of value to have something like that, as editors could
then be configured to respect it - set the editor to turn tab-key into
N spaces but only if "indent tab" is not set, for instance. The
question is, is it worth it? The main value would be when you're
editing someone else's code.

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


Re: Exponential arrival distribution in Python

2012-11-28 Thread Albert Chun-Chieh Huang
Hi, Ricky,

Traffic simulation sounds like a good topic to use SimPy, which is a
discrete-event simulation library in Python,
c.f. http://simpy.sourceforge.net

Professor Norm Matloff wrote a very good tutorial on SimPy, and you can
download it here: http://heather.cs.ucdavis.edu/~matloff/simcourse.html
Also, I've presented this SimPy package before, my slides might be
helpful,
http://alberthuang314.blogspot.tw/2012/01/simpy-slides-in-our-company-and-pyhug_26.html

In short, SimPy is a process-oriented discrete-event simulation package,
which will be easier to maintain than event-oriented discrete-event
simulation. It also contains some tools to help us to visualize
simulation data. It takes some time to study it, but if you would like to do
some simulation projects, it will definitely be a good investment! Have
fun with simulation!

with Regards,

Albert Huang

Ricky  writes:

> Hi all,
>
> I am doing a project on traffic simulation. I want to introduce exponential 
> arrival distribution to precede this task. Therefore I want write a code in 
> python for exponential arrival distribution. I am very new for programming 
> and if anybody can help me on this that would be great.
>
> Cheers,
> Ricky
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exponential arrival distribution in Python

2012-11-28 Thread Paul Rubin
Ricky  writes:
> I am doing a project on traffic simulation. I want to introduce
> exponential arrival distribution to precede this task. Therefore I
> want write a code in python for exponential arrival distribution.

I've never heard of an "exponential arrival distribution" and googling
fails.  Do you mean an exponential distribution, that describes the
expected arrival times in a Poisson process?  Python's "random" module
has the random.expovariate function for that:

  http://docs.python.org/3/library/random.html

If you want an actual (discrete) Poisson distribution, see:

http://en.wikipedia.org/wiki/Poisson_distribution#Generating_Poisson-distributed_random_variables

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


Re: re.search when used within an if/else fails

2012-11-28 Thread Ian Kelly
On Wed, Nov 28, 2012 at 5:20 PM, Dennis Lee Bieber wrote:

> On 28 Nov 2012 21:39:03 GMT, Steven D'Aprano
>  declaimed the following in
> gmane.comp.python.general:> py> if True:
> > ... if True: # tab
> > ... pass  # tab, then four spaces
> > ... pass  # two spaces, tab, four spaces
> >   File "", line 4
> > pass  # two spaces, tab, four spaces
> >^
> > TabError: inconsistent use of tabs and spaces in indentation
> >
>
> Unless there has been a major change in the parser... (I still
> don't
> have Python 3.x installed)
>
> I believe  is expanded to 8-spaces -- NOT TO NEXT MULTIPLE OF
> 8...
>

Next multiple of 8 is correct, according to the docs:

Tabs are replaced (from left to right) by one to eight spaces such that the
> total number of characters up to and including the replacement is a
> multiple of eight (this is intended to be the same rule as used by Unix).
> The total number of spaces preceding the first non-blank character then
> determines the line’s indentation. Indentation cannot be split over
> multiple physical lines using backslashes; the whitespace up to the first
> backslash determines the indentation.
>

http://docs.python.org/3/reference/lexical_analysis.html#indentation

Testing Steven's formulation with Python 2, I find that it runs without
comment without the -tt option, but it raises the TabError with the -tt
option.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me to debud my local chat network program

2012-11-28 Thread Minh Dang
ok, here is my code, zip
http://www.mediafire.com/?ob4kokda81fj6xc
-- 
http://mail.python.org/mailman/listinfo/python-list


Weird import failure with "nosetests --processes=1"

2012-11-28 Thread Roy Smith
I've got a minimal test script:

-
$ cat test_foo.py
import pyza.models
print pyza.models

def test_foo():
pass
-

pyza.models is a package.  Under normal conditions, I can import it fine:

$ python
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyza.models
>>> print pyza.models

>>> 

But when I run nosetests in parallel mode, the import fails in a way 
which has me baffled.  What's going on here?

$ nosetests --processes=1 -s test_foo:test_foo

E
==
ERROR: Failure: AttributeError ('module' object has no attribute 
'models')
--
Traceback (most recent call last):
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/loade
r.py", line 390, in loadTestsFromName
addr.filename, addr.module)
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/impor
ter.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/impor
ter.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
  File "/home/roy/songza/pyza/djapi/test_foo.py", line 2, in 
print pyza.models
AttributeError: 'module' object has no attribute 'models'

--
Ran 1 test in 0.107s

FAILED (errors=1)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.popen and the subprocess module

2012-11-28 Thread Tim Roberts
Andrew  wrote:
>
>I'm working on a script that will run an executable obtaine the output  
> from the executable
>and do some analysis on the output. Essentially the script runs the  
>executable analyses
>the data.
>I'm looking into os.popen and the subprocess module, implementing os.popen  
>is easy but i hear
>it is depreciating  however I'm finding the implemantation of subprocess  
>daunting can anyone help

One of my favorite things about the subprocess module is that the
introductory comments have examples of how to use subprocess to replace
almost every use case for os.system and os.popen.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Imaging libraries in active development?

2012-11-28 Thread Alasdair McAndrew
I take your point that not being actively developed doesn't necessarily mean 
that the software is bad - but in general healthy software is continuously 
updated and expanded to meet the needs of its users, or to take advantage of 
new algorithms or hardware.

And in its current form PIL has a number of limitations: it doesn't allow 
linear filters of arbitrary size or shape, or non-linear filters (such as 
median filter) of arbitrary size. There doesn't seem to be built in support for 
standard imaging filters: Gaussian, Laplacian, LoG, edge detection, unsharp 
masking and so on.  It doesn't seem to have support for color space conversions 
(RGB, YIQ, HSV etc).  There don't seem to be standard edge detection routines 
(Laplacian of Gaussian, Canny, etc).  And so on.  Now maybe some of these can 
be found in other Python libraries, but I can't imagine I'm the only person who 
would ever want them in an imaging library.  Other libraries (scipy.ndimage, 
scikits-image) do go a long way to addressing my concerns.

Anyway, I was curious to know why PIL is lacking so much of what I would 
consider fairly fundamental imaging facilities, and why development seems to 
have stalled since 2009.

On Thursday, 29 November 2012 05:14:30 UTC+11, Michael Torrie  wrote:
> On 11/28/2012 05:30 AM, Alasdair McAndrew wrote:
> 
> > I'm investigating Python for image processing (having used Matlab,
> 
> > then Octave for some years).  And I'm spoiled for choice: PIL and its
> 
> > fork pillow, scipy.ndimage, scikits-image, mahotas, the Python
> 
> > interface to openCV...
> 
> > 
> 
> > However, PIL doesn't seem to be in active development.  What I want
> 
> > to know is - what are the current "standard" libraries for image
> 
> > processing in Python which are in active development?
> 
> > 
> 
> > I have quite a few image processing student notes which I'm thinking
> 
> > of converting to Python, but I'd like to use the most up-to-date
> 
> > library.
> 
> 
> 
> I'm curious.  What features do you need that pil doesn't have?  Other
> 
> than updating pil to fix bugs, support new image types or new versions
> 
> of Python, what kind of active development do you think it needs to
> 
> have? Maybe pil has all the features the original author wanted and is
> 
> pretty stable.  To judge a package on how fast it's changing seems a bit
> 
> odd to me.  Obviously you want to know that bugs can get fixed of
> 
> course.  Perhaps none have been reported recently.

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


Re: deepcopy questions

2012-11-28 Thread Dieter Maurer
lars van gemerden  writes:
> ... "deepcopy" dropping some items ...
> Any ideas are still more then welcome,

"deepcopy" is implemented in Python (rather than "C").
Thus, if necessary, you can debug what it is doing
and thereby determine where the items have been dropped.

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