Re: [pyxl] xlrd 0.7.2 released!

2012-02-23 Thread Chris Withers

On 22/02/2012 23:17, Adrian Klaver wrote:

I can see where that would be preferred when managing multiple versions of
Python, but not when using a single version.


Sorry, I don't agree. It is *never* a good idea to install packages 
globally. Using virtualenv or similar (buildout, etc) gives you a 
single, cross platform way of not ending up with a mess of a python 
installation where you have a bunch of libraries of random versions 
installed, often with no way of finding out what version they are or how 
to uninstall them.


Heaven forbid you want to use or develop more than one project per 
machine; then you end up with different projects needing different 
versions of the same libraries and you're screwed. ;-)



The pip system does a good job o
managing package installs in the global context.


Ask the pip maintainers whether they'd suggest using pip on the global 
system python or inside a virtualenv...



see the point. On Windows the installer is the point of entry for 'package'
management, going outside that can get confusing.


"Python" should be though of as the application, not any individual 
library...



I also understand setting up a
Windows installer is non-trivial.


It isn't a lot of work from what I remember, I just don't like 
encouraging bad practices...



offing, the OP might find it easier to use the Python packaging from here on 
out.


What is "the Python packaging" you refer to?


xlrd3 - Library for developers to extract data from
Microsoft Excel (tm) spreadsheet files
xlrd1 - library for extracting data from Microsoft Excel
spreadsheet files


I would avoid both of these like the plague, it's a shame the people who 
dumped them on PyPI don't put up a similar warning :-(


cheers,

Chris

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


Re: storing in list and retrieving.

2012-02-23 Thread Smiley 4321
It requires concepts of 'python persistence' for the code to be designed .

Else it simple.

Looking for some flow??


On Thu, Feb 23, 2012 at 12:01 PM, Chris Angelico  wrote:

> On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321  wrote:
> > I need to write two file using python script as below -
> >
> > 1. Store.py: Write a script to store a list say "store_list = ["Apple",
> > "Orange", "PineApple". “and so on” ]" to disk.
> >
> > 2. Retrieve.py: Read the object stored in the ‘Store.py’ file and print
> the
> > contents of this list.
> >
> > I have to run on Linux with python-2.6.5.
>
> This looks like homework, so I'm just going to give a broad hint.
>
> Figure out a file format (one per line, or pickled, or whatever), then
> write one program that writes that format and another that reads it.
> The open() built-in function will open files for reading or writing,
> so that's a good place to start.
>
> Get as far as you can on your own, and if you get stuck, ask the list
> for more specific help. Good luck!
>
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questionnaire on motivation analysis of open source and open content

2012-02-23 Thread gene heskett
On Wednesday, February 22, 2012 03:14:51 PM George Tsinarakis did opine:

> Dear Sirs,
> 
> We are researchers in Technical University of Crete and our current
> research is in the field of motivation analysis of open source and open
> content software projects participants. We would like to ask you to fill
> a questionnaire and forward it to people involved in such teams and
> projects. The web address is the following:
> 
>  https://docs.google.com/spreadsheet/viewform?formkey=dHdqZUgyay0waXNRbW
> FvV3hleVBZSWc6MQ
> 
> All personal information will be kept confidential and will be used for
> academic purposes only. For further information please do not hesitate
> to contact with us.
> 
> 
> 
> Thank you in advance
> 
> Dr G. Tsinarakis

(*&^%(*%$ phishing folks never give up...  Nuke that subscription 
forthwith, with extreme prejudice.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: 
"We can't schedule an orgy, it might be construed as fighting"
--Stanley Sutton
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: storing in list and retrieving.

2012-02-23 Thread Chris Angelico
On Thu, Feb 23, 2012 at 7:45 PM, Smiley 4321  wrote:
> It requires concepts of 'python persistence' for the code to be designed .
>
> Else it simple.
>
> Looking for some flow??

Go through the tutorial on python.org if you haven't, get some code
written, and then codify your questions :) Chances are you'll figure
it out on your own.

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


Reset static variables or a workaround

2012-02-23 Thread Nav
Hi Guys,

I have a custom user form class, it inherits my own custom Form class:

class UserForm(Form):
first_name = TextField(attributes={id='id_firstname'})

Now, everytime UserForm() is instantiated it saves the attributes of
each form members and passes it on to the new instance. I understand
this is because first_name is static in nature. But I would like to
reset the first_name for every instance? How can I do this?

Regards,
Nav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reset static variables or a workaround

2012-02-23 Thread Chris Rebert
On Thu, Feb 23, 2012 at 1:26 AM, Nav  wrote:
> Hi Guys,
>
> I have a custom user form class, it inherits my own custom Form class:
>
> class UserForm(Form):
>    first_name = TextField(attributes={id='id_firstname'})
>
> Now, everytime UserForm() is instantiated it saves the attributes of
> each form members and passes it on to the new instance. I understand
> this is because first_name is static in nature. But I would like to
> reset the first_name for every instance? How can I do this?

I infer that your question concerns Django. You might want to ask on
their discussion group instead:
http://groups.google.com/group/django-users

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


Re: Reset static variables or a workaround

2012-02-23 Thread Jean-Michel Pichavant

Nav wrote:

Hi Guys,

I have a custom user form class, it inherits my own custom Form class:

class UserForm(Form):
first_name = TextField(attributes={id='id_firstname'})

Now, everytime UserForm() is instantiated it saves the attributes of
each form members and passes it on to the new instance. 
I'm not sure I've understood this sentence but if you're saying that 
class attributes are  copied into the subclass instance, that's wrong.

I understand
this is because first_name is static in nature. But I would like to
reset the first_name for every instance? How can I do this?

Regards,
Nav
  

Class attributes are not default values for instances.
If you want to set the first_name attribute for every instances, you 
have to make it an instance attribute:


class Form:
 def __init__(self):
self.first_name = "foo"

class UserForm(Form):
 def __init__(self, name):
   Form.__init__(self)
   self.first_name = name


uForm = UserForm('banana')
print uForm.first_name

Cheers,

JM

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


Re: storing in list and retrieving.

2012-02-23 Thread Jean-Michel Pichavant

Smiley 4321 wrote:

It requires concepts of 'python persistence' for the code to be designed .

Else it simple.

Looking for some flow??


Hi,

Have a look at http://docs.python.org/library/pickle.html

Cheers,

JM


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


[ANNOUNCE] pypiserver 0.5.1 - minimal pypi server

2012-02-23 Thread Ralf Schmitt
Hi,

I've just uploaded pypiserver 0.5.1 to the python package index.

pypiserver is a minimal PyPI compatible server. It can be used to serve
a set of packages and eggs to easy_install or pip.

pypiserver is easy to install (i.e. just easy_install pypiserver). It
doesn't have any external dependencies.

http://pypi.python.org/pypi/pypiserver/ should contain enough
information to easily get you started running your own PyPI server in a
few minutes.

The code is available on github: https://github.com/schmir/pypiserver


Changes in version 0.5.1
-
- make 'pypi-server -U' compatible with pip 1.1

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


Re: asynchronous downloading

2012-02-23 Thread Mark Hammond

On 23/02/2012 5:58 PM, Plumo wrote:

I want to download content asynchronously. This would be
straightforward to do threaded or across processes, but difficult
asynchronously so people seem to rely on external libraries (twisted
/ gevent / eventlet).


Exactly - the fact it's difficult is why those tools compete.


(I would use gevent under different circumstances, but currently need
to stick to standard libraries.)


As above - use threads or processes - they are fine for relatively 
modest tasks.  If your needs go beyond modest, I'd reevaluate your need 
to stick with just the stdlib - even demanding *sync* http apps often 
wind up using modules outside the stdlib.  Look into virtualenv etc if 
permission to install packages is the issue.


Batteries included free, but turbo-chargers are an extra ;)

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


Re: asynchronous downloading

2012-02-23 Thread Paul Rubin
Plumo  writes:
> What do you recommend? 

Threads.

> And why is there poor support for asynchronous execution?

The freenode #python crowd seems to hate threads and prefer twisted,
which seems to have the features you want and probably handles very
large #'s of connections better than POSIX threads do.  But I find the
whole event-driven model to be an annoying abstraction inversion and
threads to be simpler, so I've stayed with threads.  I keep hearing
boogieman stories about the evil hazards of race conditions etc. but
none of that stuff has ever happened to me (yet) as far as I can tell.
The main thing is to avoid sharing mutable data between threads to the
extent that you can.  Keep the threads isolated from each other except
for communication through Queues and not too much can go wrong.  The
last program I wrote had around 20 threads and one or two condition
variables and I don't think any significant bugs resulted from that.

FWIW, the Erlang language is built around the above concept, it uses
super-lightweight userland threads so it can handle millions of them
concurrently, and it's used successfully for ultra-high-reliability
phone switches and similar applications that are not allowed to fail, so
it must be doing something right.

There are a few schemes like Camaelia (sp?) implementing concurrency
with Python generators or coroutines, but I think they're not widely
used, and Python coroutines are kind of crippled because they don't
carry any stack below their entry point.
-- 
http://mail.python.org/mailman/listinfo/python-list


unexpected behaviour playing with dynamic methods

2012-02-23 Thread Marc Aymerich
Hi,

I'm playing a bit with python dynamic methods and I came up with a
scenario that I don't understant. Considering the follow code:

# Declare a dummy class
class A(object):
pass

# generate a dynamic method and insert it to A class
for name in ['a', 'b', 'c']:
if name == 'b':
@property
def get_name(self):
return name
A.name = get_name


a_instance = A()
a_instance.name

# So far I exptect that a_instance.name  returns 'b', since it has
been created when name == 'b', but this is what actually returns:

>>> a_instance.name
'c'

just the last 'name' value.
What can I do in order to generate a method like this but that returns
'b' ? What is wrong in my understanding of this pice of code?

Thanks !!!
marc

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


Re: unexpected behaviour playing with dynamic methods

2012-02-23 Thread Peter Otten
Marc Aymerich wrote:

> Hi,
> 
> I'm playing a bit with python dynamic methods and I came up with a
> scenario that I don't understant. Considering the follow code:
> 
> # Declare a dummy class
> class A(object):
> pass
> 
> # generate a dynamic method and insert it to A class
> for name in ['a', 'b', 'c']:
> if name == 'b':
> @property
> def get_name(self):
> return name
> A.name = get_name
> 
> 
> a_instance = A()
> a_instance.name
> 
> # So far I exptect that a_instance.name  returns 'b', since it has
> been created when name == 'b', but this is what actually returns:
> 
 a_instance.name
> 'c'
> 
> just the last 'name' value.
> What can I do in order to generate a method like this but that returns
> 'b' ? What is wrong in my understanding of this pice of code?

Look at the method again:

> def get_name(self):
> return name

It returns the global variable name. Why would you expect to see a 
historical value of that variable?
If you want to capture the value of name at the time when get_name() is 
defined you have several options:

- The default argument trick:

def get_name(self, name=name):
return name

- A closure:

def make_get_name(name):
def get_name(self):
return name
return get_name
A.name = property(make_get_name(name))

- functools.partial()

def get_name(self, name):
return name
A.name = property(partial(get_name, name=name))



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


Re: unexpected behaviour playing with dynamic methods

2012-02-23 Thread Marc Aymerich
On Feb 23, 2:05 pm, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > Hi,
>
> > I'm playing a bit with python dynamic methods and I came up with a
> > scenario that I don't understant. Considering the follow code:
>
> > # Declare a dummy class
> > class A(object):
> >     pass
>
> > # generate a dynamic method and insert it to A class
> > for name in ['a', 'b', 'c']:
> >     if name == 'b':
> >         @property
> >         def get_name(self):
> >             return name
> >         A.name = get_name
>
> > a_instance = A()
> > a_instance.name
>
> > # So far I exptect that a_instance.name  returns 'b', since it has
> > been created when name == 'b', but this is what actually returns:
>
>  a_instance.name
> > 'c'
>
> > just the last 'name' value.
> > What can I do in order to generate a method like this but that returns
> > 'b' ? What is wrong in my understanding of this pice of code?
>
> Look at the method again:
>
> >         def get_name(self):
> >             return name
>
> It returns the global variable name. Why would you expect to see a
> historical value of that variable?

hehe, yeah, after sending my email I realized that it was obvious, but
the true is I came up with this problem in a more complex situation
involving lot's of imports and so on.. so the question: wtf is going
on?? came up to me at this time :P

> If you want to capture the value of name at the time when get_name() is
> defined you have several options:
>
> - The default argument trick:
>
> def get_name(self, name=name):
>     return name
>
> - A closure:
>
> def make_get_name(name):
>     def get_name(self):
>         return name
>     return get_name
> A.name = property(make_get_name(name))
>
> - functools.partial()
>
> def get_name(self, name):
>     return name
> A.name = property(partial(get_name, name=name))

Wow Peter, I was expecting one solution and you give me 3 amazing
solutions!! :) Thanks a lot!

btw I always wondered for what functools.partial can be useful, now I
know an example :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asynchronous downloading

2012-02-23 Thread Richard Baron Penman
>> I want to download content asynchronously. This would be
>> straightforward to do threaded or across processes, but difficult
>> asynchronously so people seem to rely on external libraries (twisted
>> / gevent / eventlet).
>
>
> Exactly - the fact it's difficult is why those tools compete.

It is difficult in Python because the async libraries do not offer
much. Straightforward in some other languages.

Do you know why there is little support for asynchronous execution in
the standard libraries?
For large scale downloading I found thread pools do not scale well.

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


distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
Following instructions here:

http://docs.python.org/py3k/distutils/builtdist.html#creating-windows-installers

I am trying to create a Windows installer for a pure-module distribution 
using Python 3.2. I get a "LookupError: unknown encoding: mbcs"

Here is the full output of distutils and the traceback:


[steve@ando pyprimes]$ python3.2 setup.py bdist_wininst
running bdist_wininst
running build
running build_py
creating build/lib
copying src/pyprimes.py -> build/lib
installing to build/bdist.linux-i686/wininst
running install_lib
creating build/bdist.linux-i686/wininst
creating build/bdist.linux-i686/wininst/PURELIB
copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB
running install_egg_info
Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info
creating '/tmp/tmp3utw4_.zip' and adding '.' to it
adding 'PURELIB/pyprimes.py'
adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info'
creating dist
Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.
Traceback (most recent call last):
  File "setup.py", line 60, in 
"License :: OSI Approved :: MIT License",
  File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
  File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
  File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
  File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, 
in run
self.create_exe(arcname, fullname, self.bitmap)
  File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, 
in create_exe
cfgdata = cfgdata.encode("mbcs")
LookupError: unknown encoding: mbcs


How do I fix this, and is it a bug in distutils?



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


What does exc_info do in a logging call?

2012-02-23 Thread Roy Smith
In http://docs.python.org/release/2.6.7/library/logging.html, it says:

logging.debug(msg[, *args[, **kwargs]])
[...]
There are two keyword arguments in kwargs which are inspected: exc_info 
which, if it does not evaluate as false, causes exception information to 
be added to the logging message. If an exception tuple (in the format 
returned by sys.exc_info()) is provided, it is used; otherwise, 
sys.exc_info() is called to get the exception information.

I don't get what this is trying to do.  I have this code:

try:
f = urllib2.urlopen(url)
except urllib2.HTTPError as ex:
logger.error("Unable to retrieve profile from facebook 
(access_token='%r')" % access_token,
 exc_info=ex)

which ends up logging:

[...] ERROR _get_profile Unable to retrieve profile from facebook 
(access_token='u'[token elided]'')

so what is the exc_info doing?  What "exception information" is being 
added to the message?  Am I just calling this wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [pyxl] xlrd 0.7.2 released!

2012-02-23 Thread xlstime
Hi,

i want to learn pyxl  please help me...

kindly send useful information about pyxl


*Thank you in Advance*
XLS S :)

On Thu, Feb 23, 2012 at 4:45 AM,  wrote:

> Chris Withers wrote:
>
> > On 22/02/2012 00:37, python-ex...@raf.org wrote:
> > >was good for previous versions. two reasons that spring to mind
> > >immediately are:
> > >
> > >  - it makes it much easier to tell what version is installed
> > >  - it makes it much easier to uninstall the package
> > >
> > >i know that both of these are things that the python community
> > >does not yet seem to find useful but everyone else seems to.
> >
> > That's because it's no longer best practice to polute the global
> > python installation by installing packages directly into it.
> >
> > The recommended wisdom nowadays is to use a virtualenv and then pip
> > install the package.
> >
> > I believe that will give you everything you need, please explain if
> > it doesn't.
> >
> > cheers,
> >
> > Chris
>
> thanks. i'm sure that'll do nicely.
>
> cheers,
> raf
>
> --
> You received this message because you are subscribed to the Google Groups
> "python-excel" group.
> To post to this group, send an email to python-ex...@googlegroups.com.
> To unsubscribe from this group, send email to
> python-excel+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/python-excel?hl=en-GB.
>
>


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


Re: What does exc_info do in a logging call?

2012-02-23 Thread Peter Otten
Roy Smith wrote:

> In http://docs.python.org/release/2.6.7/library/logging.html, it says:
> 
> logging.debug(msg[, *args[, **kwargs]])
> [...]
> There are two keyword arguments in kwargs which are inspected: exc_info
> which, if it does not evaluate as false, causes exception information to
> be added to the logging message. If an exception tuple (in the format
> returned by sys.exc_info()) is provided, it is used; otherwise,
> sys.exc_info() is called to get the exception information.
> 
> I don't get what this is trying to do.  I have this code:
> 
> try:
> f = urllib2.urlopen(url)
> except urllib2.HTTPError as ex:
> logger.error("Unable to retrieve profile from facebook
> (access_token='%r')" % access_token,
>  exc_info=ex)
> 
> which ends up logging:
> 
> [...] ERROR _get_profile Unable to retrieve profile from facebook
> (access_token='u'[token elided]'')
> 
> so what is the exc_info doing?  What "exception information" is being
> added to the message?  Am I just calling this wrong?

I think whatever the formatter's formatException() makes out of the 
(exception_type, exception_value, traceback) tuple lands in the logfile:

>> import logging
>>> logging.basicConfig()
>>> try: 1/0
... except: logging.error("yadda")
...
ERROR:root:yadda
>>> try: 1/0
... except: logging.error("yadda", exc_info=True)
...
ERROR:root:yadda
Traceback (most recent call last):
  File "", line 1, in 
ZeroDivisionError: integer division or modulo by zero
>>> class Formatter(logging.Formatter):
... def formatException(self, *args): return "OOPS"
...
>>> logging._handlers.keys()[0].setFormatter(Formatter()) # ;)
>>> try: 1/0
... except: logging.error("yadda", exc_info=True)
...
yadda
OOPS


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


Re: distutils bdist_wininst failure on Linux

2012-02-23 Thread jmfauth
On 23 fév, 15:06, Steven D'Aprano  wrote:
> Following instructions here:
>
> http://docs.python.org/py3k/distutils/builtdist.html#creating-windows...
>
> I am trying to create a Windows installer for a pure-module distribution
> using Python 3.2. I get a "LookupError: unknown encoding: mbcs"
>
> Here is the full output of distutils and the traceback:
>
> [steve@ando pyprimes]$ python3.2 setup.py bdist_wininst
> running bdist_wininst
> running build
> running build_py
> creating build/lib
> copying src/pyprimes.py -> build/lib
> installing to build/bdist.linux-i686/wininst
> running install_lib
> creating build/bdist.linux-i686/wininst
> creating build/bdist.linux-i686/wininst/PURELIB
> copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB
> running install_egg_info
> Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info
> creating '/tmp/tmp3utw4_.zip' and adding '.' to it
> adding 'PURELIB/pyprimes.py'
> adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info'
> creating dist
> Warning: Can't read registry to find the necessary compiler setting
> Make sure that Python modules winreg, win32api or win32con are installed.
> Traceback (most recent call last):
>   File "setup.py", line 60, in 
>     "License :: OSI Approved :: MIT License",
>   File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup
>     dist.run_commands()
>   File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands
>     self.run_command(cmd)
>   File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command
>     cmd_obj.run()
>   File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 
> 179, in run
>     self.create_exe(arcname, fullname, self.bitmap)
>   File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 
> 262, in create_exe
>     cfgdata = cfgdata.encode("mbcs")
> LookupError: unknown encoding: mbcs
>
> How do I fix this, and is it a bug in distutils?
>
> --
> Steven

Because the 'mbcs' codec is missing in your Linux, :-)

>>> 'abc需'.encode('cp1252')
b'abc\xe9\x9c\x80'
>>> 'abc需'.encode('missing')
Traceback (most recent call last):
  File "", line 1, in 
LookupError: unknown encoding: missing

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


Re: What does exc_info do in a logging call?

2012-02-23 Thread Roy Smith
Duh, I figured out what's going on.  I'm using a custom Formatter class, which 
overrides format().  It's the job of format() to handle this, and ours doesn't!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-23 Thread Vinay Sajip
On Feb 22, 4:44 am, Fayaz Yusuf Khan 
wrote:

> Anyway, I read the source and found many interesting things that ought to be
> mentioned in the docs.
> Such as flush() should be called from close() whenever it's implemented.
> (FileHandler.close() is doing it)

This is entirely handler-dependent - there's no absolute rule that you
*have* to call flush() before close(). Some underlying will do
flushing when you close.

> And how come close()/flush() isn't being called from inside a lock?

Why does it need to be? Are you aware of any race conditions or other
concurrency problems which will occur with the code as it is now?

> (Handler.close() calls the module level _acquireLock() and _releaseLock()s but
> nothing about the instance level acquire() or release())
> Or is it being locked from somewhere else?

The module level acquisitions are because module-level handler lists
are changed in Handler.close().

If locking is required in a particular handler class for close or
flush, that can be implemented by the developer of that handler class.
AFAIK there is no such need for the handler classes in the stdlib - if
you have reason to believe otherwise, please give some examples of
potential problems and with example code if possible.

Regards,

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


Re: [pyxl] xlrd 0.7.2 released!

2012-02-23 Thread Chris Withers

On 23/02/2012 14:40, xlstime wrote:

Hi,

i want to learn pyxl  please help me...

kindly send useful information about pyxl


I would suggest:

- using your real name when posting
- reading the tutorial at http://www.python-excel.org/

cheers,

Chris

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


Re: asynchronous downloading

2012-02-23 Thread Giampaolo Rodolà
Il 23 febbraio 2012 07:58, Plumo  ha scritto:
> I want to download content asynchronously. This would be straightforward to 
> do threaded or across processes, but difficult asynchronously so people seem 
> to rely on external libraries (twisted / gevent / eventlet).
>
> (I would use gevent under different circumstances, but currently need to 
> stick to standard libraries.)
>
> I looked around and found there is little interest in developing a proper 
> HTTP client on asyncore. The best I found stopped development a decade ago: 
> http://sourceforge.net/projects/asynchttp/
>
> What do you recommend?
> And why is there poor support for asynchronous execution?
>
> Richard
> --
> http://mail.python.org/mailman/listinfo/python-list

If you want to stick with asyncore try to take a look at this:
https://gist.github.com/151

> And why is there poor support for asynchronous execution?

I'd say that's true for stdlib only (asyncore/asynchat).
There are plenty of choices amongst third party modules though.
To say one, I particularly like tornado which is simple and powerful:
http://www.tornadoweb.org/documentation/httpclient.html

--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
http://code.google.com/p/pysendfile/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-23 Thread Fayaz Yusuf Khan
On Thursday 23 Feb 2012 8:23:42 AM Vinay Sajip wrote:
> If locking is required in a particular handler class for close or
> flush, that can be implemented by the developer of that handler class.
> AFAIK there is no such need for the handler classes in the stdlib - if
> you have reason to believe otherwise, please give some examples of
> potential problems and with example code if possible.
Well, I'm not currently facing any race-around conditions. As I said, I was 
mostly familiarizing myself with the API.
Well, as emit() is always being called from within a lock, I assumed that 
flush() should/would also be handled similarly. Afterall, they are handling the 
same underlying output stream or in case of the BufferingHandler share the same 
buffer. Shouldn't the access be synchronized?
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


multiprocessing, what am I doing wrong?

2012-02-23 Thread Eric Frederich
Below is some pretty simple code and the resulting output.
Sometimes the code runs through but sometimes it just freezes for no
apparent reason.
The output pasted is where it just got frozen on me.
It called start() on the 2nd worker but the 2nd worker never seemed to
enter the run method.

### the code

#!/usr/bin/env python

import sys
import Queue
import multiprocessing
import time
todo = multiprocessing.Queue()

for i in xrange(100):
todo.put((i, i+1, i+2))

def FOO(a, b, c):
print 'foo', a, b, c
return (a + b) * c

class MyWorker(multiprocessing.Process):
def __init__(self, inbox, outbox):
super(MyWorker, self).__init__()
self.inbox = inbox
self.outbox = outbox
print >> sys.stderr, '1' * 80; sys.stderr.flush()
def run(self):
print >> sys.stderr, '2' * 80; sys.stderr.flush()
while True:
try:
args = self.inbox.get_nowait()
except Queue.Empty:
break
self.outbox.put(FOO(*args))

print >> sys.stderr, 'a' * 80; sys.stderr.flush()
result_queue = multiprocessing.Queue()

print >> sys.stderr, 'b' * 80; sys.stderr.flush()
w1 = MyWorker(todo, result_queue)
print >> sys.stderr, 'c' * 80; sys.stderr.flush()
w2 = MyWorker(todo, result_queue)

print >> sys.stderr, 'd' * 80; sys.stderr.flush()
w1.start()
print >> sys.stderr, 'e' * 80; sys.stderr.flush()
w2.start()
print >> sys.stderr, 'f' * 80; sys.stderr.flush()

for i in xrange(100):
print result_queue.get()



### the output









foo 0 1 2
foo 1 2 3
foo 2 3 4
foo 3 4 5
foo 4 5 6


2
9
20
35
54
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-23 Thread Vinay Sajip
On Feb 23, 5:55 pm, Fayaz Yusuf Khan 
wrote:

> Well, as emit() is always being called from within a lock, I assumed that
> flush() should/would also be handled similarly. Afterall, they are handling 
> the
> same underlying output stream or in case of the BufferingHandler share the 
> same
> buffer. Shouldn't the access be synchronized?

Yes, you might well be right - though no problems have been reported,
it's probably best to be safe.

Regards,

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


Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread HoneyMonster
$ cd /usr/bin
$ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
lrwxrwxrwx 1 root root6 Oct 29 19:34 python2 -> python
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
$ diff -s  python python2.7
Files python and python2.7 are identical
$ 

I'm just curious: Why two identical files rather than a symlink?

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


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Colin Higwell
On Thu, 23 Feb 2012 19:11:16 +, HoneyMonster wrote:

(reformatted (I hope)

> $ cd /usr/bin
> $ ls -l python*
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
> lrwxrwxrwx 1 root root  6 Oct 29 19:34 python2 -> python
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
> $ diff -s  python python2.7
> Files python and python2.7 are identical
> $
> 
> I'm just curious: Why two identical files rather than a symlink?

Sorry, my first post didn't format properly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Jerry Hill
On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster  wrote:
> $ cd /usr/bin
> $ ls -l python*
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
> lrwxrwxrwx 1 root root    6 Oct 29 19:34 python2 -> python
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
> $ diff -s  python python2.7
> Files python and python2.7 are identical
> $
>
> I'm just curious: Why two identical files rather than a symlink?

It's not two files, it's a hardlink.  You can confirm by running ls
-li python* and comparing the inode numbers.

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


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Chris Rebert
On Thu, Feb 23, 2012 at 11:11 AM, Colin Higwell
 wrote:
> $ cd /usr/bin
> $ ls -l python*
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
> lrwxrwxrwx 1 root root    6 Oct 29 19:34 python2 -> python
> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
> $ diff -s  python python2.7
> Files python and python2.7 are identical
> $
>
> I'm just curious: Why two identical files rather than a symlink?

Depends on your distro / installation method:
$ ls -l python*
lrwxrwxrwx 1 root root   9 Apr 12  2011 python -> python2.6
-rwxr-xr-x 1 root root 2288272 Dec 27  2010 python2.6
$ # this is on my Debian server

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


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread HoneyMonster
On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote:

> On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster
>  wrote:
>> $ cd /usr/bin $ ls -l python*
>> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root
>>    6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27
>> 02:42 python2.7 $ diff -s  python python2.7 Files python and python2.7
>> are identical $
>>
>> I'm just curious: Why two identical files rather than a symlink?
> 
> It's not two files, it's a hardlink.  You can confirm by running ls -li
> python* and comparing the inode numbers.

You are spot on. Thank you, and sorry for my stupidity.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-23 Thread Vinay Sajip
On Feb 23, 5:55 pm, Fayaz Yusuf Khan 
wrote:

> buffer. Shouldn't the access be synchronized?

I've now updated the repos for 2.7, 3.2 and default to add locking for
flush/close operations. Thanks for the suggestion.

Regards,


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


Re: multiprocessing, what am I doing wrong?

2012-02-23 Thread MRAB

On 23/02/2012 17:59, Eric Frederich wrote:

Below is some pretty simple code and the resulting output.
Sometimes the code runs through but sometimes it just freezes for no
apparent reason.
The output pasted is where it just got frozen on me.
It called start() on the 2nd worker but the 2nd worker never seemed to
enter the run method.


[snip]

The 2nd worker did enter the run method; there are 2 lines of "2".

Maybe there's an uncaught exception in the run method for some reason.
Try doing something like this:

try:
args = self.inbox.get_nowait()
except Queue.Empty:
break
except:
import traceback
print "*** Exception in worker"
print >> sys.stderr, traceback.print_exc()
sys.stderr.flush()
print "***"
raise
--
http://mail.python.org/mailman/listinfo/python-list


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Terry Reedy

On 2/23/2012 2:34 PM, HoneyMonster wrote:

On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote:


On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster
  wrote:

$ cd /usr/bin $ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root
6 Oct 29 19:34 python2 ->  python -rwxr-xr-x 2 root root 9496 Oct 27
02:42 python2.7 $ diff -s  python python2.7 Files python and python2.7
are identical $

I'm just curious: Why two identical files rather than a symlink?


It's not two files, it's a hardlink.  You can confirm by running ls -li
python* and comparing the inode numbers.


You are spot on. Thank you, and sorry for my stupidity.


The question 'why a hardlink rather than symlink' is not stupid. It was 
part of the discussion of http://python.org/dev/peps/pep-0394/
The answer was 'history' and how things were 20 years ago and either the 
pep or the discussion around it says symlinks are fine now and the 
decision is up to distributors.


--
Terry Jan Reedy

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


sum() requires number, not simply __add__

2012-02-23 Thread Buck Golemon
I feel like the design of sum() is inconsistent with other language
features of python. Often python doesn't require a specific type, only
that the type implement certain methods.

Given a class that implements __add__ why should sum() not be able to
operate on that class?

We can fix this in a backward-compatible way, I believe.

Demonstration:
I'd expect these two error messages to be identical, but they are
not.

 >>> class C(object): pass
 >>> c = C()
 >>> sum((c,c))
TypeError: unsupported operand type(s) for +: 'int' and 'C'
>>> c + c
TypeError: unsupported operand type(s) for +: 'C' and 'C'


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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Buck Golemon
On Feb 23, 1:19 pm, Buck Golemon  wrote:
> I feel like the design of sum() is inconsistent with other language
> features of python. Often python doesn't require a specific type, only
> that the type implement certain methods.
>
> Given a class that implements __add__ why should sum() not be able to
> operate on that class?
>
> We can fix this in a backward-compatible way, I believe.
>
> Demonstration:
>     I'd expect these two error messages to be identical, but they are
> not.
>
>      >>> class C(object): pass
>      >>> c = C()
>      >>> sum((c,c))
>     TypeError: unsupported operand type(s) for +: 'int' and 'C'
>     >>> c + c
>     TypeError: unsupported operand type(s) for +: 'C' and 'C'

Proposal:

def sum(values,
base=0):
  values =
iter(values)

  try:
  result = values.next()
  except StopIteration:
  return base

  for value in values:
  result += value
  return result
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum() requires number, not simply __add__

2012-02-23 Thread Arnaud Delobelle
On 23 February 2012 21:19, Buck Golemon  wrote:
> I feel like the design of sum() is inconsistent with other language
> features of python. Often python doesn't require a specific type, only
> that the type implement certain methods.
>
> Given a class that implements __add__ why should sum() not be able to
> operate on that class?

It can.  You need to pass a second argument which will be the start
value.  Try help(sum) for details.

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Rebert
On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon  wrote:
> I feel like the design of sum() is inconsistent with other language
> features of python. Often python doesn't require a specific type, only
> that the type implement certain methods.
>
> Given a class that implements __add__ why should sum() not be able to
> operate on that class?

The time machine strikes again! sum() already can. You just need to
specify an appropriate initial value (the empty list in this example)
for the accumulator :

Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> sum([[1,2],[3,4]], [])
[1, 2, 3, 4]

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum() requires number, not simply __add__

2012-02-23 Thread Buck Golemon
On Feb 23, 1:32 pm, Chris Rebert  wrote:
> On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon  wrote:
> > I feel like the design of sum() is inconsistent with other language
> > features of python. Often python doesn't require a specific type, only
> > that the type implement certain methods.
>
> > Given a class that implements __add__ why should sum() not be able to
> > operate on that class?
>
> The time machine strikes again! sum() already can. You just need to
> specify an appropriate initial value (the empty list in this example)
> for the accumulator :
>
> Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
> [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> sum([[1,2],[3,4]], [])
>
> [1, 2, 3, 4]
>
> Cheers,
> Chris
> --http://rebertia.com

Thanks. I did not know that!

My proposal is still *slightly* superior in two ways:

1) It reduces the number of __add__ operations by one
2) The second argument isn't strictly necessary, if you don't mind
that the 'null sum' will produce zero.

def sum(values, base=0):
  values = iter(values)

  try:
  result = values.next()
  except StopIteration:
  return base

  for value in values:
  result += value

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Arnaud Delobelle
On 23 February 2012 21:23, Buck Golemon  wrote:
> def sum(values,
> base=0):
>      values =
> iter(values)
>
>      try:
>          result = values.next()
>      except StopIteration:
>          return base
>
>      for value in values:
>          result += value
>      return result

This is definitely not backward compatible.  To get something that has
a better chance of working with existing code, try this (untested):

_sentinel = object()

def sum(iterable, start=_sentinel):
if start is _sentinel:
iterable = iter(iterable)
try:
start = iterable.next()
except StopIteration:
return 0
for x in iterable:
start += x
return start

del _sentinel

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Stefan Behnel
Chris Rebert, 23.02.2012 22:32:
> On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon  wrote:
>> I feel like the design of sum() is inconsistent with other language
>> features of python. Often python doesn't require a specific type, only
>> that the type implement certain methods.
>>
>> Given a class that implements __add__ why should sum() not be able to
>> operate on that class?
> 
> The time machine strikes again! sum() already can. You just need to
> specify an appropriate initial value (the empty list in this example)
> for the accumulator :
> 
> Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
> [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
 sum([[1,2],[3,4]], [])
> [1, 2, 3, 4]

I know that you just meant this as an example, but it's worth mentioning in
this context that it's not exactly efficient to "sum up" lists this way
because there is a lot of copying involved. Each adding of two lists
creates a third one and copies all elements into it. So it eats a lot of
time and space.

Stefan

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle  wrote:
> _sentinel = object()
>
> def sum(iterable, start=_sentinel):
>    if start is _sentinel:
>
> del _sentinel

Somewhat off-topic: Doesn't the if statement there do a lookup for a
global, which would mean that 'del _sentinel' will cause it to fail?
Or have I missed something here?

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Ian Kelly
On Thu, Feb 23, 2012 at 2:38 PM, Buck Golemon  wrote:
> My proposal is still *slightly* superior in two ways:
>
> 1) It reduces the number of __add__ operations by one
> 2) The second argument isn't strictly necessary, if you don't mind
> that the 'null sum' will produce zero.

It produces the wrong result, though:

>>> sum([3,4], base=12)
7

If I'm starting with 12 and summing 3 and 4, I expect to get 19.

Ideally the second argument should be ignored only if it isn't passed
in at all, and I don't know off-hand why the built-in sum doesn't do
this.  We really don't need to replace it, though.  If you want a
different sum behavior, just write your own.

def sum(iterable, *args):
return reduce(operator.add, iterable, *args)

>>> sum([3,4])
7
>>> sum([3,4], 12)
19
>>> sum(['hello', 'world'])
'helloworld'

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Arnaud Delobelle
On 23 February 2012 21:53, Chris Angelico  wrote:
> On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle  wrote:
>> _sentinel = object()
>>
>> def sum(iterable, start=_sentinel):
>>    if start is _sentinel:
>>
>> del _sentinel
>
> Somewhat off-topic: Doesn't the if statement there do a lookup for a
> global, which would mean that 'del _sentinel' will cause it to fail?
> Or have I missed something here?

Yes, you're right :)  Change the signature to

def sum(iterable, start=_sentinel, _sentinel=_sentinel):

This is not pretty...

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Ian Kelly
On Thu, Feb 23, 2012 at 2:53 PM, Chris Angelico  wrote:
> On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle  wrote:
>> _sentinel = object()
>>
>> def sum(iterable, start=_sentinel):
>>    if start is _sentinel:
>>
>> del _sentinel
>
> Somewhat off-topic: Doesn't the if statement there do a lookup for a
> global, which would mean that 'del _sentinel' will cause it to fail?
> Or have I missed something here?

I believe you're correct.  If you really want to delete the _sentinel
reference though, you could do:

def sum(iterable, start=object()):
if start is sum.func_defaults[0]:
...

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle  wrote:
> def sum(iterable, start=_sentinel, _sentinel=_sentinel):

Is this a reason for Python to introduce a new syntax, such as:

def foo(blah, optional=del):
if optional is del: print("No argument was provided")

Basically, 'del' is treated like a unique non-providable object, only
possible in an argument list and only if the argument was omitted. No
more proliferation of individual sentinels... what do you think?

(I picked "del" because it's an existing keyword. Fairly arbitrary
choice though.)

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Arnaud Delobelle
On 23 February 2012 22:04, Chris Angelico  wrote:
> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle  wrote:
>> def sum(iterable, start=_sentinel, _sentinel=_sentinel):
>
> Is this a reason for Python to introduce a new syntax, such as:
>
> def foo(blah, optional=del):
>    if optional is del: print("No argument was provided")
>
> Basically, 'del' is treated like a unique non-providable object, only
> possible in an argument list and only if the argument was omitted. No
> more proliferation of individual sentinels... what do you think?

The problem with these proposals is to avoid the leakage of 'del'.
Here you could do:

def get_del(x=del):
return x

And then you're in trouble again.

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


Optional arguments syntax (was Re: sum() requires number, not simply __add__)

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 9:09 AM, Arnaud Delobelle  wrote:
> On 23 February 2012 22:04, Chris Angelico  wrote:
>> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle  wrote:
>>> def sum(iterable, start=_sentinel, _sentinel=_sentinel):
>>
>> Is this a reason for Python to introduce a new syntax, such as:
>>
>> def foo(blah, optional=del):
>>    if optional is del: print("No argument was provided")
>>
>> Basically, 'del' is treated like a unique non-providable object, only
>> possible in an argument list and only if the argument was omitted. No
>> more proliferation of individual sentinels... what do you think?
>
> The problem with these proposals is to avoid the leakage of 'del'.
> Here you could do:
>
> def get_del(x=del):
>    return x
>
> And then you're in trouble again.

Yep; what I was thinking was that this would be a magic token that, if
used in any expression other than "is del", would decay to some other
object such as 0 or None. Otherwise, yeah, there's no difference
between that and any other global sentinel.

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


Please verify!!

2012-02-23 Thread Manish Sharma
Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

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


Re: Please verify!!

2012-02-23 Thread Amirouche Boubekki
2012/2/23 Manish Sharma 

> Hi I am new to python language. On my first day, somebody told me that
> if any python script file is opened with any editor except python
> editor, the file is corrupted. Some spacing or indentation is changed
> and script stops working. I was opening the script file in Windows
> using Notepad++ but I didn't save anything and closed it. Still it was
> suggested to never open the python file in any other editor.
>
> Can anybody please verify this? Can opening a python script in any
> editor other than python editor corrupt the script? Did anybody ever
> face such type of issue or its just misunderstanding of the concept.



There is compatibility issue with line ending in Windows vs other OS that's
all I'm aware of.

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


Re: Please verify!!

2012-02-23 Thread Ben
They are telling you not to switch between editors that use tabs as tabs and 
ones that use spaces as tabs. Python gets all wonky. No big, use one editor or 
have your preferred editor highlight your non-preferred whitespace. 

FWIW, I use spaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Chris Kaynor
On Thu, Feb 23, 2012 at 2:22 PM, Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

>
>
> 2012/2/23 Manish Sharma 
>
>> Hi I am new to python language. On my first day, somebody told me that
>> if any python script file is opened with any editor except python
>> editor, the file is corrupted. Some spacing or indentation is changed
>> and script stops working. I was opening the script file in Windows
>> using Notepad++ but I didn't save anything and closed it. Still it was
>> suggested to never open the python file in any other editor.
>>
>> Can anybody please verify this? Can opening a python script in any
>> editor other than python editor corrupt the script? Did anybody ever
>> face such type of issue or its just misunderstanding of the concept.
>
>
>
> There is compatibility issue with line ending in Windows vs other OS
> that's all I'm aware of.
>

The only issues I can think of off the top of my head would be line endings
and indentation (tabs vs spaces, number of spaces for one level). The
second would just require care to avoid issues to make sure you match the
style guides for the files you are working on (the Python standard is 4
spaces, I believe). The first could be a silent issue with some editors and
some versions of Python if crossing between Windows, Linux, and Mac,
however most software (including Python) will now convert between the
different forms automatically, and Notepad++ is good about its handling -
it will create new newlines in the format of the file, if such can be
determined.


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


Re: Please verify!!

2012-02-23 Thread Dave Angel

On 02/23/2012 05:13 PM, Manish Sharma wrote:

Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

:)
Manish


That is nonsense.  I've used at least a dozen text editors, from Windows 
Notepad to emacs on Linux.  And since I know of no program called 
"python editor," I'm sure none of them was that one.


Of course, there are editors that are broken, or can be configured to be 
broken.  I certainly wouldn't try wordpad, even in text mode.  But a 
good editor with a good configuration can be much nicer to use than Notepad.


First thing I'd do is to disable tab logic in the editor.  When you 
press the tab key, there's no excuse for an editor to actually put a tab 
in the file.  It should adjust the column by adding the appropriate 
number of spaces.  The main place you get in trouble is when a file has 
tabs in some lines, and uses spaces for indenting on other lines.  Since 
tabs are not interpreted the same way in various utilities, it's just 
better not to use them at all.


As Amirouche has pointed out, line endings can be inconsistent between 
different operating systems, and not all editors can handle the 
differences.   But the python compiler/interpreter doesn't care about 
which line ending is used.


One other issue could be files that have non-ASCII characters.  Since a 
text file has no standard way to indicate what format it uses (utf8, 
ucs2, or dozens of "extended ASCII" encodings), another editor might not 
deal with it correctly.  There is a standard way to indicate to Python 
how to interpret non-ascii characters, so if you either  1) always use 
ASCII1 2) always use the same character encoding, or 3) have your editor 
look for the declaration and honor it,  you'd have no trouble.


If these problems do occur, they'll be pretty easy to spot.  And you can 
always revert to an earlier version, by using your revision control 
system.   Enabling one of those is about as important as choosing your 
editor.


--

DaveA

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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Steven D'Aprano
On Fri, 24 Feb 2012 08:53:49 +1100, Chris Angelico wrote:

> On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle 
> wrote:
>> _sentinel = object()
>>
>> def sum(iterable, start=_sentinel):
>>    if start is _sentinel:
>>
>> del _sentinel
> 
> Somewhat off-topic: Doesn't the if statement there do a lookup for a
> global, which would mean that 'del _sentinel' will cause it to fail? Or
> have I missed something here?

Yes, deleting _sentinel will cause the custom sum to fail, and yes, you 
have missed something.

If the caller wants to mess with your library and break it, they have 
many, many ways to do so apart from deleting your private variables.


del _sentinel
_sentinel = "something else"
sum.__defaults__ = (42,)  # mess with the function defaults
sum.__code__ = (lambda a, b=None: 100).__code__  # and with func internals
sum = None  # change your custom sum to something else
del sum  # or just delete it completely
len = 42  # shadow a built-in
import builtins; del builtins.range  # really screw with you


If your application stops working after you carelessly mess with 
components your application relies on, the right answer is usually:

"Don't do that then."

Python doesn't try to prevent people from shooting themselves in the foot.


Monkey-patching-by-actual-monkeys-for-fun-and-profit-ly y'rs,


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


Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 10:33 AM, Steven D'Aprano
 wrote:
> Yes, deleting _sentinel will cause the custom sum to fail, and yes, you
> have missed something.
>
> If the caller wants to mess with your library and break it, they have
> many, many ways to do so apart from deleting your private variables.

I was looking at the module breaking itself, though, not even waiting
for the caller to do it.

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


Re: distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote:

> On 23 fév, 15:06, Steven D'Aprano  +comp.lang.pyt...@pearwood.info> wrote:
>> Following instructions here:
>>
>> http://docs.python.org/py3k/distutils/builtdist.html#creating-
windows...
>>
>> I am trying to create a Windows installer for a pure-module
>> distribution using Python 3.2. I get a "LookupError: unknown encoding:
>> mbcs"
[...]
>> How do I fix this, and is it a bug in distutils?
> 
> Because the 'mbcs' codec is missing in your Linux, :-)

Well duh :-)

This is a bug in distutils. Prompted by your comment I expanded my search 
terms and found this bug report:

http://bugs.python.org/issue10945

The problem is that mbcs is not a real codec, it means "whatever codec is 
currently configured in Windows". So it doesn't exist on non-Windows 
platforms. But distutils bdist_wininst is explicitly documented as 
working on non-Windows platforms. Hence, it's a bug.


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


Re: asynchronous downloading

2012-02-23 Thread Plumo
My current implementation works fine below a few hundred threads. But each 
thread takes up a lot of memory so does not scale well. 

I have been looking at Erlang for that reason, but found it is missing useful 
libraries in other areas.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
On Fri, 24 Feb 2012 00:11:11 +, Steven D'Aprano wrote:

> On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote:
> 
>> On 23 fév, 15:06, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
>>> Following instructions here:
>>>
>>> http://docs.python.org/py3k/distutils/builtdist.html#creating-
> windows...
>>>
>>> I am trying to create a Windows installer for a pure-module
>>> distribution using Python 3.2. I get a "LookupError: unknown encoding:
>>> mbcs"
> [...]
>>> How do I fix this, and is it a bug in distutils?
>> 
>> Because the 'mbcs' codec is missing in your Linux, :-)
> 
> Well duh :-)
> 
> This is a bug in distutils. Prompted by your comment I expanded my
> search terms and found this bug report:
> 
> http://bugs.python.org/issue10945
> 
> The problem is that mbcs is not a real codec, it means "whatever codec
> is currently configured in Windows". So it doesn't exist on non-Windows
> platforms. But distutils bdist_wininst is explicitly documented as
> working on non-Windows platforms. Hence, it's a bug.


And I have a work-around that seems to work for me. Put this at the top 
of your setup.py install script:



# Work around mbcs bug in distutils.
# http://bugs.python.org/issue10945
import codecs
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
codecs.register(func)




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


A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Alex Willmer
This week I was slightly surprised by a behaviour that I've not
considered before. I've long used

for i, x in enumerate(seq):
   # do stuff

as a standard looping-with-index construct. In Python for loops don't
create a scope, so the loop variables are available afterward. I've
sometimes used this to print or return a record count e.g.

for i, x in enumerate(seq):
   # do stuff
print 'Processed %i records' % i+1

However as I found out, if seq is empty then i and x are never
created. The above code will raise NameError. So if a record count is
needed, and the loop is not guaranteed to execute the following seems
more correct:

i = 0
for x in seq:
# do stuff
i += 1
print 'Processed %i records' % i

Just thought it worth mentioning, curious to hear other options/
improvements/corrections.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Steven D'Aprano
On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote:

> This week I was slightly surprised by a behaviour that I've not
> considered before. I've long used
> 
> for i, x in enumerate(seq):
># do stuff
> 
> as a standard looping-with-index construct. In Python for loops don't
> create a scope, so the loop variables are available afterward. I've
> sometimes used this to print or return a record count e.g.
> 
> for i, x in enumerate(seq):
># do stuff
> print 'Processed %i records' % i+1
> 
> However as I found out, if seq is empty then i and x are never created.

This has nothing to do with enumerate. It applies to for loops in 
general: the loop variable is not initialised if the loop never runs. 
What value should it take? Zero? Minus one? The empty string? None? 
Whatever answer Python choose would be almost always wrong, so it refuses 
to guess.


> The above code will raise NameError. So if a record count is needed, and
> the loop is not guaranteed to execute the following seems more correct:
> 
> i = 0
> for x in seq:
> # do stuff
> i += 1
> print 'Processed %i records' % i

What fixes the problem is not avoiding enumerate, or performing the 
increments in slow Python instead of fast C, but that you initialise the 
loop variable you care about before the loop in case it doesn't run.

i = 0
for i,x in enumerate(seq):
# do stuff

is all you need: the addition of one extra line, to initialise the loop 
variable i (and, if you need it, x) before hand.
 



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


Re: asynchronous downloading

2012-02-23 Thread Plumo
that example is excellent - best use of asynchat I have seen so far.

I read through the python-dev archives and found the fundamental problem is no 
one maintains asnycore / asynchat. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Paul Rubin
Alex Willmer  writes:
> i = 0
> for x in seq:
> # do stuff
> i += 1
> print 'Processed %i records' % i
>
> Just thought it worth mentioning, curious to hear other options/
> improvements/corrections.

Stephen gave an alternate patch, but you are right, it is a pitfall that
can be easy to miss in simple testing.

A more "functional programming" approach might be:

  def do_stuff(x): ...

  n_records = sum(1 for _ in imap(do_stuff, seq))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Joshua Miller
Wasn't supposed to be private, just something went funky with gmail
when i sent it out, oddly enough

On Thu, Feb 23, 2012 at 8:32 PM, Dave Angel  wrote:
> On 02/23/2012 07:15 PM, Joshua Miller wrote:
>>
>> When he/she said "python editor" i'm sure they meant IDLE which in
>> some cases is the worst ide to use. Some ide's do mess with python
>> files you just have to make sure to change their settings to
>> accomadate python. Otherwise no it's a better idea to use  something
>> other than IDLE. For windows generally people use eclipse with the
>> pydev extension, pyscripter, or the several other IDE's that are known
>> with a little help not to do what you are describing ;)
>>
>
> I can't argue with anything you say here.  But you shouldn't have sent it
> privately, as this is a public list.  And please don't top-post
>
> So I'm forwarding it to the list.
>
> --
>
> DaveA



-- 
~ Josh Miller

A young guy learning to program and develop websites all while still in school
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asynchronous downloading

2012-02-23 Thread Fayaz Yusuf Khan
On Thursday 23 Feb 2012 5:10:25 PM Plumo wrote:
> I read through the python-dev archives and found the fundamental problem is
> no one maintains asnycore / asynchat. 
By all means, scratch your own itch. :)
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Andrew Berg
On 2/23/2012 4:43 PM, Dave Angel wrote:
> First thing I'd do is to disable tab logic in the editor.  When you 
> press the tab key, there's no excuse for an editor to actually put a tab 
> in the file.  It should adjust the column by adding the appropriate 
> number of spaces.
Unless, of course, you know, you actually /want/ to use tabs (the
horror!). The decision whether to use tabs or spaces shouldn't be made
for the novice programmer. Make an argument, explain the
advantages/disadvantages, whatever, but don't state your opinion like
it's fact. Even worse, you brought it up in the context of editor
issues, making it sound like using tabs is a common source of problems.
Much of it is personal preference (I could give objective reasons in
support of tabs in Python, but I don't intend to start the whole spaces
vs. tabs discussion again).

> The main place you get in trouble is when a file has 
> tabs in some lines, and uses spaces for indenting on other lines.
I wouldn't call it the main problem, but yes, that happens. It's not
terribly difficult to convert all indentation to tabs or spaces (unless
the number of spaces used to indent is inconsistent).

> As Amirouche has pointed out, line endings can be inconsistent between 
> different operating systems, and not all editors can handle the 
> differences.   But the python compiler/interpreter doesn't care about 
> which line ending is used.
Yes. However, there are many editors for various platforms that handle
the different line endings just fine. In fact, Notepad is the only
editor I can think of off the top of my head that has an issue.

> One other issue could be files that have non-ASCII characters.  Since a 
> text file has no standard way to indicate what format it uses (utf8, 
> ucs2, or dozens of "extended ASCII" encodings), another editor might not 
> deal with it correctly.  There is a standard way to indicate to Python 
> how to interpret non-ascii characters, so if you either  1) always use 
> ASCII1 2) always use the same character encoding, or 3) have your editor 
> look for the declaration and honor it,  you'd have no trouble.
I recommend using UTF-8 always unless there's some reason not to.

> If these problems do occur, they'll be pretty easy to spot.  And you can 
> always revert to an earlier version, by using your revision control 
> system.   Enabling one of those is about as important as choosing your 
> editor.
I don't think you can really go wrong outside of Git, Bazaar, or
Mercurial. Which of those 3 is best is mainly personal preference.
CVS/SVN should be considered legacy and not suitable for new projects.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Ethan Furman

Steven D'Aprano wrote:

On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote:


This week I was slightly surprised by a behaviour that I've not
considered before. I've long used

for i, x in enumerate(seq):
   # do stuff

as a standard looping-with-index construct. In Python for loops don't
create a scope, so the loop variables are available afterward. I've
sometimes used this to print or return a record count e.g.

for i, x in enumerate(seq):
   # do stuff
print 'Processed %i records' % i+1

However as I found out, if seq is empty then i and x are never created.


This has nothing to do with enumerate. It applies to for loops in 
general: the loop variable is not initialised if the loop never runs. 
What value should it take? Zero? Minus one? The empty string? None? 
Whatever answer Python choose would be almost always wrong, so it refuses 
to guess.




The above code will raise NameError. So if a record count is needed, and
the loop is not guaranteed to execute the following seems more correct:

i = 0
for x in seq:
# do stuff
i += 1
print 'Processed %i records' % i


What fixes the problem is not avoiding enumerate, or performing the 
increments in slow Python instead of fast C, but that you initialise the 
loop variable you care about before the loop in case it doesn't run.


i = 0
for i,x in enumerate(seq):
# do stuff

is all you need: the addition of one extra line, to initialise the loop 
variable i (and, if you need it, x) before hand.


Actually,

i = -1

or his reporting will be wrong.

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


namespace question

2012-02-23 Thread xixiliguo
c = [1, 2, 3, 4, 5]
class TEST():
c = [5, 2, 3, 4, 5]
def add( self ):
c[0] = 15

a = TEST()


a.add()

print( c, a.c, TEST.c )

result :
[15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5]


why a.add() do not update c in Class TEST? but update c in main file
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generate Windows exe on Linux

2012-02-23 Thread Waldek M.
On Wed, 22 Feb 2012 18:42:11 +0100, Jérôme wrote:
>>> Has anyone had success generating exe's from within Linux?
>> 
>> That doesn't seem to have anything to do with Python,
>> but you might want to google for cross-compiling.
> 
> I think his question is totally python related. 
> 
> As I understand it, Richard creates executables from python scripts using a
> tool, such as py2exe [1], that requires windows. He would like to have an
> equivalent tool that runs on linux, to avoid going through the trouble of
> having to run a windows installation.

Ah, that's the part I was missing :-)
Thanks.

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


Re: namespace question

2012-02-23 Thread Chris Rebert
On Thu, Feb 23, 2012 at 9:55 PM, xixiliguo  wrote:
> c = [1, 2, 3, 4, 5]
> class TEST():
>    c = [5, 2, 3, 4, 5]

That line creates a class (i.e. "static") variable, which is unlikely
to be what you want. Instance variables are normally created in the
body of an __init__() method.

>    def add( self ):
>        c[0] = 15
>
> a = TEST()
>
>
> a.add()
>
> print( c, a.c, TEST.c )
>
> result :
> [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5]
>
>
> why a.add() do not update c in Class TEST? but update c in main file

Python is not Java (or similar). To refer to instance variables, you
must explicitly use `self`; i.e. use "self.c[0] = 15" in add().

I would recommend reviewing the relevant section of the Python tutorial:
http://docs.python.org/tutorial/classes.html

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


Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Mark Lawrence

On 24/02/2012 03:49, Ethan Furman wrote:

Steven D'Aprano wrote:

On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote:


This week I was slightly surprised by a behaviour that I've not
considered before. I've long used

for i, x in enumerate(seq):
# do stuff

as a standard looping-with-index construct. In Python for loops don't
create a scope, so the loop variables are available afterward. I've
sometimes used this to print or return a record count e.g.

for i, x in enumerate(seq):
# do stuff
print 'Processed %i records' % i+1

However as I found out, if seq is empty then i and x are never created.


This has nothing to do with enumerate. It applies to for loops in
general: the loop variable is not initialised if the loop never runs.
What value should it take? Zero? Minus one? The empty string? None?
Whatever answer Python choose would be almost always wrong, so it
refuses to guess.



The above code will raise NameError. So if a record count is needed, and
the loop is not guaranteed to execute the following seems more correct:

i = 0
for x in seq:
# do stuff
i += 1
print 'Processed %i records' % i


What fixes the problem is not avoiding enumerate, or performing the
increments in slow Python instead of fast C, but that you initialise
the loop variable you care about before the loop in case it doesn't run.

i = 0
for i,x in enumerate(seq):
# do stuff

is all you need: the addition of one extra line, to initialise the
loop variable i (and, if you need it, x) before hand.


Actually,

i = -1

or his reporting will be wrong.

~Ethan~


Methinks an off by one error :)

--
Cheers.

Mark Lawrence.

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


Re: Please verify!!

2012-02-23 Thread Manish Sharma
Hi All,

Thanks a ton for your replies!

Still my question is what if I open the file and dont make any changes to
it and close it again? Can it be possible just by doing these steps add
indentation to lines? I am not changing the file prefrences to open it
always with notepad++. Opening it once only.

On Fri, Feb 24, 2012 at 6:08 AM, Jason Friedman  wrote:

> > Hi I am new to python language. On my first day, somebody told me that
> > if any python script file is opened with any editor except python
> > editor, the file is corrupted. Some spacing or indentation is changed
> > and script stops working. I was opening the script file in Windows
> > using Notepad++ but I didn't save anything and closed it. Still it was
> > suggested to never open the python file in any other editor.
>
> It is possible that the OP is not aware of that Python is space
> sensitive, unlike most(?) programming languages.
>
> for i in range(5):
>print("Hello.")
>print("Goodbye.")
>
> will not run because the indentation (leading spaces) on the third
> line is incorrect.  It must instead line up with the second line.
>
> A single tab is equivalent to a single space as far as Python is
> concerned, but your eyes will report a difference and editors that
> substitute one for the other can cause, after saving, code that was
> formerly working to not work (and, I suppose, the reverse).
>
> Make sure to read the tutorial at http://python.org (which is
> unfortunately down at this moment
> (http://www.downforeveryoneorjustme.com/python.org)).
>



-- 
-
Thanks & Regards
Manish Kumar
| Mob: +91-9911635906 |
manish2...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Andrew Berg
On 2/24/2012 1:11 AM, Manish Sharma wrote:
> Still my question is what if I open the file and dont make any changes
> to it and close it again? Can it be possible just by doing these steps
> add indentation to lines? I am not changing the file prefrences to open
> it always with notepad++. Opening it once only.
Notepad++ won't change line endings or indentation unless you tell it
to. In any case, it will indicate when a file has been changed (the
little blue disk icon in the file's tab will turn red).

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Jerry Hill
On Thu, Feb 23, 2012 at 2:34 PM, HoneyMonster  wrote:
> On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote:
>> It's not two files, it's a hardlink.  You can confirm by running ls -li
>> python* and comparing the inode numbers.
>
> You are spot on. Thank you, and sorry for my stupidity.

I don't think you're stupid.  It's hard to tell the difference between
two separate files with the same file size and a hardlink.  The
biggest clue is the number "2" in the second column.  If I recall
correctly, for directories, that's the number of entries in the
directory.  For files, that number is the number of hardlinks
referring to that file.

Even with that, it's hard to tell what files are hardlinked together,
and figuring it out by inode is a pain in the neck.  Personally, I
prefer symlinks, even if they introduce a small performance hit.
Readability counts, even in the filesystem.

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


Is Federal Reserve a Private Property or Public Property ? Exhilerating video by Honorable Alex Jones

2012-02-23 Thread small Pox
Is Federal Reserve a Private Property or Public Property ?
Exhilerating video by Honorable Alex Jones 

http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27...


gnu.emacs.help,soc.culture.jewish,sci.electronics.design,comp.lang.scheme,comp.lang.python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Thomas Rachel

Am 23.02.2012 20:54 schrieb Jerry Hill:


If I recall
correctly, for directories, that's the number of entries in the
directory.


No. It is the number of subdirectories (it counts their ".." entries) 
plus 2 (the parent directory and the own "." entry).




Even with that, it's hard to tell what files are hardlinked together,
and figuring it out by inode is a pain in the neck.  Personally, I
prefer symlinks, even if they introduce a small performance hit.


Not only that, they have slightly different semantics. With hardlinks 
you can say "I want this file, no matter if someone else holds it as 
well". Symlinks say "I want the file which is referred to by there".


In the given case, however, this difference doesn't count, and I agree 
on you that a symlink would be better here.



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