Re: JSON translated into SQL by python

2013-11-23 Thread Jussi Piitulainen
Aaron G. writes:

> I am new to programming python for JSON to SQL and I was wondering
> why this does not work. All the values for entering the DB are
> correct. The EnterpriseValue data is not entering the database.
>  
> #collect data from JSON source at Yahoo
> url = ["db", "http://y.ahoo.it/wlB89";]
> #check all sites
> checkstatus(url[]);
> #retrieve EnterpriseValue data from yahoo to DB
> url = "http://y.ahoo.it/wlB89";
> data = helper.openJSON_URL(url)
> #store data
> curObservation = data["EnterpriseValue"]
> 
> #connect to amazon and post data from Yahoo
> conn = inti_psql_amazon("db name", "db user", "password", "db source")
> query = "CREATE TABLE temp2 (ID int NOT NULL AUTO_INCREMENT, Enterprise_Value 
> float, PRIMARY KEY(ID));"
> query = "INSERT INTO TABLE temp2 (enterprise) VALUES("+ str(curObservation) 
> +");"   
> do_query_amazon(conn, query)
> close_psql_amazon(conn)

Possibly you should let the database know about the first query. Now
it's just a very short-lived string in the Python program.

Is there no exception?

My inclination would be to go to the Python interpreter and try very
simple interactions with the database. Create a table with only one
column. Insert one value. See if the value is there. Hello, world.
-- 
https://mail.python.org/mailman/listinfo/python-list


Behavior of staticmethod in Python 3

2013-11-23 Thread Marco Buttu

In Python 3 the following two classes should be equivalent:

$ cat foo.py
class Foo:
def foo():
pass
print(callable(foo))

class Foo:
@staticmethod
def foo():
pass
print(callable(foo))

But they do not:

$ python3 foo.py
True
False

How come the metaclass does not skip the staticmethod decorator?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list


Re: JSON translated into SQL by python

2013-11-23 Thread Peter Otten
Aaron G. wrote:

> I am new to programming python for JSON to SQL and I was wondering why
> this does not work. All the values for entering the DB are correct. The
> EnterpriseValue data is not entering the database.

> #collect data from JSON source at Yahoo
> url = ["db", "http://y.ahoo.it/wlB89";]
> #check all sites
> checkstatus(url[]);
> #retrieve EnterpriseValue data from yahoo to DB
> url = "http://y.ahoo.it/wlB89";
> data = helper.openJSON_URL(url)
> #store data
> curObservation = data["EnterpriseValue"]
> 
> #connect to amazon and post data from Yahoo
> conn = inti_psql_amazon("db name", "db user", "password", "db source")

inti_psql_amazon? Please post your actual code. Cut and paste, don't retype. 
If there's an exception, post that, too. The source code of

do_query_amazon()

might be interesting, too. A commit() on the db cursor might do wonders.

> query = "CREATE TABLE temp2 (ID int NOT NULL AUTO_INCREMENT, 
Enterprise_Value float, PRIMARY KEY(ID));"
> query = "INSERT INTO TABLE temp2 (enterprise) VALUES("+ 
str(curObservation) +");"

As a general remark, don't build your queries like that, rely on the API to 
insert the values. E. g.:

cursor = conn.cursor()
cursor.execute("insert into table temp2 (enterprise) values (?);", 
(curObservation,))

(Some databases use '%s' instead of '?')

> do_query_amazon(conn, query)
> close_psql_amazon(conn)


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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Peter Otten
Marco Buttu wrote:

> In Python 3 the following two classes should be equivalent:

Says who?

> $ cat foo.py
> class Foo:
>  def foo():
>  pass
>  print(callable(foo))
> 
> class Foo:
>  @staticmethod
>  def foo():
>  pass
>  print(callable(foo))
> 
> But they do not:
> 
> $ python3 foo.py
> True
> False
> 
> How come the metaclass does not skip the staticmethod decorator?

What? Your print()s are executed inside the class body, so the classes don't 
come into play at all.

Your script is saying that a staticmethod instance is not a callable object. 
It need not be because

Foo.foo()

doesn't call the Foo.foo attribute directly, it calls

Foo.foo.__get__(None, Foo)()

>>> class D:
... def __get__(self, *args): print(args)
... 
>>> class Foo:
... foo = D()
... 
>>> Foo.foo()
(None, )
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not callable

Look for "descriptor protocol" to learn the details.

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


Simple TCP message framework

2013-11-23 Thread Padawan Learner
Seems like the following pattern must be very common, solved a million 
times, but I can't seem to find anything this simple and ready to use. 
Basically I just want a simple python messaging layer that hides some of 
the messiness of the underlying sockets and user authentication. It 
would be asyncore under the hood of course.


Perhaps what I am looking for is hiding in plain sight, but there are so 
many asynchronous communication tools out there, it's hard to thumb 
through them all. So I'm not looking for such a list of toolkits to 
browse through. Just something simple that does the equivalent of the 
following:


Server:
on_open(user) - called when a user logs in
on_close(user) - called when a user disconnects
on_recv(user, s) - called when a user sends a message
send(user, s) - send a message to a user

Client:
open(host, user, password) - open an authenticated session with the 
host

close() - disconnect
send(s) - send a message to the server
on_recv(s): called when a message is received from the server

Methods starting with "on_" are callbacks intended to be implemented by 
derived classes.


Messages are atomic and delimited by '\n'. So concatenation of buffered 
messages is hidden. A message is received when complete (i.e. terminated 
with '\n'). Also, each message should be implicitly flushed, so that it 
will be received in a timely manner in the absence of additional messages.


Extra bonus for a compatible javascript implementation of the Client as 
well, so it can run in a browser.


Thanks in advance for any thoughts.
- Padawan


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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Marco Buttu

On 11/23/2013 10:01 AM, Peter Otten wrote:


In Python 3 the following two classes should be equivalent:

Says who?


>$ cat foo.py
>class Foo:
>  def foo():
>  pass
>  print(callable(foo))
>
>class Foo:
>  @staticmethod
>  def foo():
>  pass
>  print(callable(foo))
>
>But they do not:
>
>$ python3 foo.py
>True
>False



Your script is saying that a staticmethod instance is not a callable object.
It need not be because

Foo.foo()


Yes, you are right about Python 3. But in Python 2, if I am not going 
wrong, there is not solution, and I need to define a function outside 
the class. For instance:


$ cat config.py
class Configuration(object):

def positiveCheck(value):
if not value > 0:
raise AttributeError('Must be a positive number')

attributes = {
# Attribute name: (type, checkrule)
'myattr': (int, positiveCheck),
}

def __setattr__(self, name, value):
if not name in Configuration.attributes:
raise AttributeError("Attribute `%s` non allowed." %name)

expected_type, checkrule = Configuration.attributes[name]
if not isinstance(value, expected_type):
raise TypeError('The value %s is not of type %s' \
%(value, expected_type.__name__))
if callable(checkrule):
print('calling %s(%s)' %(checkrule.__name__, value))
checkrule(value)

super(Configuration, self).__setattr__(name, value)

The positive check works fine:

>>> from config import Configuration
>>> c = Configuration()
>>> c.myattr = -10
calling positiveCheck(-10)
Traceback (most recent call last):
...
AttributeError: Must be a positive number

But I cannot use the method as a function:

>>> Configuration.positiveCheck(-10)
Traceback (most recent call last):
...
Configuration instance as first argument (got int instance instead).

Furthemore, I cannot use the method as a staticmethod, becase otherwise 
it will not be callable inside the class body.


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


Showing Progress Bar

2013-11-23 Thread Himanshu Garg
I want to show simple dots while my program copies the files.  I have found the 
code like:

for i in range(10):
print '.',
time.sleep(1)

But this will execute ten times as it is predefined and the task to copy will 
execute after or before this loop based on the location I have placed my line 
to copy the files using shutil.copy().

I want that the files should be copied and in parallel the progress should be 
shown and when the files are copied, the progress should exit.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Showing Progress Bar

2013-11-23 Thread Ned Batchelder
On Saturday, November 23, 2013 6:36:28 AM UTC-5, Himanshu Garg wrote:
> I want to show simple dots while my program copies the files.  I have found 
> the code like:
> 
> for i in range(10):
> print '.',
> time.sleep(1)
> 
> But this will execute ten times as it is predefined and the task to copy will 
> execute after or before this loop based on the location I have placed my line 
> to copy the files using shutil.copy().
> 
> I want that the files should be copied and in parallel the progress should be 
> shown and when the files are copied, the progress should exit.

Stdout is buffered, meaning it will wait for a newline, or for some large 
amount of output, before actually outputting the characters to the screen.  Use 
the flush method to force it to be output now.  Writing to sys.stdout directly 
also lets you avoid the space that a print-comma gives you:

for i in range(10):
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\n")

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


Re: Showing Progress Bar

2013-11-23 Thread Himanshu Garg
for i in range(10):
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\n") 

shutil.copytree("pack", "/lxc/pack")

But Here, the loop will first print the progress dots and then it will copy the 
directory.  But I want that these two tasks should run simultaneously.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Showing Progress Bar

2013-11-23 Thread Frank Millman

"Himanshu Garg"  wrote in message 
news:b4b7cf70-07fa-455a-b01f-cb69b9402...@googlegroups.com...
>I want to show simple dots while my program copies the files.  I have found 
>the code like:
>
> for i in range(10):
>print '.',
>time.sleep(1)
>
> But this will execute ten times as it is predefined and the task to copy 
> will execute after or before this loop based on the location I have placed 
> my line to copy the files using shutil.copy().
>
> I want that the files should be copied and in parallel the progress should 
> be shown and when the files are copied, the progress should exit.

Ned has shown how to view the dots as they are printed, but has not 
addressed the 'parallel' aspect.

Here is one approach, which uses the threading module to print the dots in a 
separate thread while the main thread does the copying.

import sys
import threading

class ProgressBar(threading.Thread):
"""
In a separate thread, print dots to the screen until terminated.
"""

def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()

def run(self):
event = self.event  # make local
while not event.is_set():
sys.stdout.write(".")
sys.stdout.flush()
event.wait(1)  # pause for 1 second
sys.stdout.write("\n")

def stop(self):
self.event.set()

Before starting the copy -

progress_bar = ProgressBar()
progress_bar.start()

When the copy is finished -

progress_bar.stop()
progress_bar.join()

HTH

Frank Millman



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


Re: Showing Progress Bar

2013-11-23 Thread Himanshu Garg
Thanks a lot Frank!  Its superb.  I got what I wanted.  Thanks Again!

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


Re: Showing Progress Bar

2013-11-23 Thread Chris Angelico
On Sat, Nov 23, 2013 at 11:11 PM, Frank Millman  wrote:
> class ProgressBar(threading.Thread):
> """
> In a separate thread, print dots to the screen until terminated.
> """

It's worth noting that this, as coded, is not a progress bar but
merely an activity bar. The number of dots printed depends on the time
taken and not on the amount of "stuff" done. For a true progress bar,
you'd have to manage something through the copy process itself -
figure out how much there is to copy, figure out how many dots to
display in total (probably a fixed number, eg 50), then output a dot
every X bytes or files copied, based on that proportion. This is a lot
simpler, of course!

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


Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
How can I write to the same file from two different scripts opened at same time?
-- 
https://mail.python.org/mailman/listinfo/python-list


sys.stdout and Python3

2013-11-23 Thread Frank Millman
Hi all

I have a question arising from another thread, but on a different topic, 
hence the new thread.

Under Python2, if you want to print a series of dots to the screen without a 
newline, you can do the following:

for i in range(10):
  sys.stdout.write('.')
  sys.stdout.flush()
  time.sleep(1)
sys.stdout.write('\n')

I tried it under Python3, and found that it differs in two ways -

1. Each 'write' is terminated by a newline
2. Each 'write' appends the length of the string written.

So instead of  -
..
I get -
.1
.1
etc

I found that the new 'print' function has a 'flush' argument, so it can now 
be written as -

for i in range(10):
  print('.', end='', flush=False)
  time.sleep(1)
print()

I tried to read the docs on sys.stdout, and I see a lot of changes in this 
area, but I could not see the reason for the above behaviour.

Is there a way to reproduce the Python2 behaviour in Python3 using 
sys.stdout?

Thanks

Frank Millman



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


Question about import hooks

2013-11-23 Thread Ed Schofield
Hi all, 

I am the author of the ``future`` package for Python 2/3 compatibility 
(http://python-future.org). A bug report has recently been posted about its use 
of import hooks that I don't yet have an answer for, and I am looking for some 
guidance on how to customize the import mechanism in a safer way.

The current interface is as follows:

>>> from future import standard_library

Any subsequent import statements using Python 3-style module names are mapped 
onto the relevant Python 2-style names (or, where needed, backported modules 
provided by ``future``). For example, these then work in the same way on both 
Python 2 and Python 3:

>>> from http.client import HttpConnection
>>> import html.parser
>>> import queue

>>> import configparser

Although this is a nice interface, reminiscent of ``from __future__ import 
...``, the problem is that the current implementation, which appends finder 
objects to the ``sys.meta_path`` list 
(http://docs.python.org/2/library/sys.html#sys.meta_path) renders the import 
hooks globally, even for modules imported by other modules. What I want instead 
is for the import hooks to apply only to a particular module, so that a script 
containing:

from future import standard_library
import requests

would not apply the import hooks to modules imported within the ``requests`` 
module, merely to import statements in the script itself.

There is a note in the Python 3.3 documentation (and the current Python 3.4 
draft) that I had hoped would provide the answer for how to implement this:

"When calling __import__() 
(http://docs.python.org/3/library/functions.html#__import__)
as part of an import statement, the import system first checks the module 
global namespace for a function by that name. If it is not found, then the 
standard builtin __import__() 
(http://docs.python.org/3/library/functions.html#__import__)
is called."


If this were true, it would be possible to change the interface to something 
like this:

>>> from future.standard_library import __import__

which would then override the ``__import__`` function in ``builtins`` or 
``__builtin__`` affecting subsequent ``import`` statements only in that module. 
The interface wouldn't be quite as nice, but it wouldn't cause the import hooks 
to bleed into other modules that don't need them. However, the docs seem to be 
wrong; defining __import__ as a global seems to have no effect on imports in 
Py3.3, and ``future`` needs to implement this for Python 2 anyway.

Can you think of a way to implement import hooks safely, for one particular 
module, while providing a nice clean interface? Preferably this would remain 
accessible through a one-line import like ``from future import 
standard_library``.

Thanks in advance for any ideas!

Best wishes,
Ed


-- 
Dr. Edward Schofield
(M) +61 (0)405 676 229
Python Charmers
http://pythoncharmers.com


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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Steven D'Aprano
On Sat, 23 Nov 2013 09:28:43 +0100, Marco Buttu wrote:

> In Python 3 the following two classes should be equivalent:

They certainly are not equivalent in *any* version of Python, because 
staticmethods are not equivalent to instance methods.


> $ cat foo.py
> class Foo:
>  def foo():
>  pass
>  print(callable(foo))
> 
> class Foo:
>  @staticmethod
>  def foo():
>  pass
>  print(callable(foo))
> 
> But they do not:
> 
> $ python3 foo.py
> True
> False

And Python 2 gives the same result for staticmethods:

[steve@ando ~]$ python2.7
Python 2.7.2 (default, May 18 2012, 18:25:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
py> 
py> class Test(object):
... @staticmethod
... def method():
... pass
... print callable(method)
...
False


> How come the metaclass does not skip the staticmethod decorator?

What makes you think the metaclass gets the opportunity to skip the 
decorator? By the time the metaclass gets called, the decorator has 
already run.

You seem to be conflating behaviour in Python 2 that doesn't actually 
occur. Staticmethods are not directly callable in any version of Python.

The problem you seem to have is that you want to call a method both 
during and after construction:

class MyClass(object):
def helper(arg):
return arg + 1
x = helper(10)
y = helper(20)
def method(self, arg):
return self.helper(arg)


Here, the attributes x and y rely on calling helper as a function, where 
it does not receive a self argument, but when calling helper from inside 
the instance method, or when calling it like MyClass.helper(), it will 
receive a self argument.

Unfortunately there is no good solution to this using just built-ins. 
staticmethod doesn't work, as it's not callable. However, we can create 
our own callable version of staticmethod:


class callable_staticmethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, cls=None):
return self.func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)


class MyClass(object):
@callable_staticmethod
def helper(arg):
return arg + 1
x = helper(10)
y = helper(20)
def method(self, arg):
return self.helper(arg)


This should now work exactly as you hope.



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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread William Ray Wing
On Nov 23, 2013, at 1:42 AM, Ian Kelly  wrote:

> On Fri, Nov 22, 2013 at 7:18 PM, Steven D'Aprano
>  wrote:
>> I'm not an expert on Indian English, but I understand that in that
>> dialect it is grammatically correct to say "the codes", just as in UK and
>> US English it is grammatically correct to say "the programs".
> 
> I wouldn't necessarily even consider it an Indian thing, as I've known
> Americans to use the same phrase.
> 

Yes - when I arrived at a Department of Energy national laboratory in the late 
1960s, code, to code, and coding were pretty much the accepted verb forms.  To 
the best of my knowledge, the word program didn't start to creep in until 
later.  I'm guessing, but I'd assume it started to arrive with the first 
computer science graduates.

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


Re: sys.stdout and Python3

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 12:26 AM, Frank Millman  wrote:
> for i in range(10):
>   sys.stdout.write('.')
>   sys.stdout.flush()
>   time.sleep(1)
> sys.stdout.write('\n')
>
> I tried it under Python3, and found that it differs in two ways -
>
> 1. Each 'write' is terminated by a newline
> 2. Each 'write' appends the length of the string written.

Only in the interactive interpreter, where return values get printed.
In a script, that won't happen. To prevent that from happening
interactively, just assign the result to something:

for i in range(10):
_=sys.stdout.write(".")
sys.stdout.flush()

There definitely is a difference between Py2 and Py3 there, but it's
nothing to do with sys.stdout - it's a change in the REPL (interactive
interpreter, Read/Eval/Print Loop) and how it handles return values
inside loops. I think it's an improvement, overall, though it is a
little confusing when you work with partial output.

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Mark Lawrence

On 23/11/2013 02:18, Steven D'Aprano wrote:


In other words, in UK/US English,


UK English?  Clearly you've never been to Newcastle upon Tyne or Glasgow :)

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Question about import hooks

2013-11-23 Thread Mark Lawrence

On 23/11/2013 12:23, Ed Schofield wrote:

Hi all,

I am the author of the ``future`` package for Python 2/3 compatibility 
(http://python-future.org). A bug report has recently been posted about its use 
of import hooks that I don't yet have an answer for, and I am looking for some 
guidance on how to customize the import mechanism in a safer way.

The current interface is as follows:


from future import standard_library


Any subsequent import statements using Python 3-style module names are mapped 
onto the relevant Python 2-style names (or, where needed, backported modules 
provided by ``future``). For example, these then work in the same way on both 
Python 2 and Python 3:


from http.client import HttpConnection
import html.parser
import queue



import configparser


Although this is a nice interface, reminiscent of ``from __future__ import 
...``, the problem is that the current implementation, which appends finder 
objects to the ``sys.meta_path`` list 
(http://docs.python.org/2/library/sys.html#sys.meta_path) renders the import 
hooks globally, even for modules imported by other modules. What I want instead 
is for the import hooks to apply only to a particular module, so that a script 
containing:

 from future import standard_library
 import requests

would not apply the import hooks to modules imported within the ``requests`` 
module, merely to import statements in the script itself.

There is a note in the Python 3.3 documentation (and the current Python 3.4 
draft) that I had hoped would provide the answer for how to implement this:

"When calling __import__() 
(http://docs.python.org/3/library/functions.html#__import__)
as part of an import statement, the import system first checks the module 
global namespace for a function by that name. If it is not found, then the 
standard builtin __import__() 
(http://docs.python.org/3/library/functions.html#__import__)
is called."


If this were true, it would be possible to change the interface to something 
like this:


from future.standard_library import __import__


which would then override the ``__import__`` function in ``builtins`` or 
``__builtin__`` affecting subsequent ``import`` statements only in that module. 
The interface wouldn't be quite as nice, but it wouldn't cause the import hooks 
to bleed into other modules that don't need them. However, the docs seem to be 
wrong; defining __import__ as a global seems to have no effect on imports in 
Py3.3, and ``future`` needs to implement this for Python 2 anyway.

Can you think of a way to implement import hooks safely, for one particular 
module, while providing a nice clean interface? Preferably this would remain 
accessible through a one-line import like ``from future import 
standard_library``.

Thanks in advance for any ideas!

Best wishes,
 Ed




I've no idea if this http://www.python.org/dev/peps/pep-0451/ is 
relevent to your needs but thought I'd point it out anyway.  It has been 
implemented in Python 3.4 beta.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


finding masking boundary indices

2013-11-23 Thread Sudheer Joseph
Hi,
   I have a masked array like in the attached link, I wanted to find 
indices of the bounds where the mask is false ie in this case of depth file 
where there is depth less than shore. Is there a pythonic way of finding the 
boundary indices? please advice?
https://drive.google.com/file/d/0B3heUQNme7G5d2dYZzgxTG1NdG8/edit?usp=sharing
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: finding masking boundary indices

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 1:29 AM, Sudheer Joseph  wrote:
> Hi,
>I have a masked array like in the attached link, I wanted to find 
> indices of the bounds where the mask is false ie in this case of depth file 
> where there is depth less than shore. Is there a pythonic way of finding the 
> boundary indices? please advice?
> https://drive.google.com/file/d/0B3heUQNme7G5d2dYZzgxTG1NdG8/edit?usp=sharing

First piece of advice: Don't post a link that requires that you share
the file with us :) We can't see what you've posted there. Actually,
just don't post a link at all, for preference; include your code right
here in the mail, that's the most effective.

Also: Please don't use Google Groups. It makes your posts ugly in the
archive, as the lines are not wrapped, and it has some abysmal
practices with regard to replies/follow-ups. There are better news
clients around; alternatively, you can read and post on the mailing
list python-list@python.org, which carries the same content. Here's
the mailing list:

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

Beyond that, I can't really advise, as I have no idea what your code is doing :)

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


Using sh library with grep command

2013-11-23 Thread Luca
I'm trying to use sh (https://pypi.python.org/pypi/sh) for calling
system grep command but it's now working as expected.

An example:

import sh
sh.grep('abc', os.getcwd(), '-r')

But I get the ErrorReturnCode_1: exception, that I learned is the
normal exit code for grep command when it not found any match.

The error instance object reported that the command run is:

*** ErrorReturnCode_1:
  RAN: '/usr/bin/grep abc /Users/keul/test_sh'

Obviously manually running the command I get some output and exit code 0.

Where I'm wrong?

-- 
-- luca

twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Peter Otten
Marco Buttu wrote:

> On 11/23/2013 10:01 AM, Peter Otten wrote:
> 
>>> In Python 3 the following two classes should be equivalent:
>> Says who?
>>
>>> >$ cat foo.py
>>> >class Foo:
>>> >  def foo():
>>> >  pass
>>> >  print(callable(foo))
>>> >
>>> >class Foo:
>>> >  @staticmethod
>>> >  def foo():
>>> >  pass
>>> >  print(callable(foo))
>>> >
>>> >But they do not:
>>> >
>>> >$ python3 foo.py
>>> >True
>>> >False
>>>
>>
>> Your script is saying that a staticmethod instance is not a callable
>> object. It need not be because
>>
>> Foo.foo()
> 
> Yes, you are right about Python 3. But in Python 2, if I am not going
> wrong, there is not solution, and I need to define a function outside
> the class. For instance:
> 
> $ cat config.py
> class Configuration(object):
> 
>  def positiveCheck(value):
>  if not value > 0:
>  raise AttributeError('Must be a positive number')
> 
>  attributes = {
>  # Attribute name: (type, checkrule)
>  'myattr': (int, positiveCheck),
>  }

Just add

   positiveCheck = staticmethod(positiveCheck)

at this point and everything should work in both Python 2 and 3.
Alternatively use Steven's callable_staticmethod as a decorator.

> 
>  def __setattr__(self, name, value):
>  if not name in Configuration.attributes:
>  raise AttributeError("Attribute `%s` non allowed." %name)
> 
>  expected_type, checkrule = Configuration.attributes[name]
>  if not isinstance(value, expected_type):
>  raise TypeError('The value %s is not of type %s' \
>  %(value, expected_type.__name__))
>  if callable(checkrule):
>  print('calling %s(%s)' %(checkrule.__name__, value))
>  checkrule(value)
> 
>  super(Configuration, self).__setattr__(name, value)
> 
> The positive check works fine:
> 
>  >>> from config import Configuration
>  >>> c = Configuration()
>  >>> c.myattr = -10
> calling positiveCheck(-10)
> Traceback (most recent call last):
>  ...
> AttributeError: Must be a positive number
> 
> But I cannot use the method as a function:
> 
>  >>> Configuration.positiveCheck(-10)
> Traceback (most recent call last):
>  ...
> Configuration instance as first argument (got int instance instead).
> 
> Furthemore, I cannot use the method as a staticmethod, becase otherwise
> it will not be callable inside the class body.


PS: AttributeErrors should be raised when an attribute does not exist or 
cannot be set; I recommend that you raise a ValueError in positiveCheck().

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


Re: Using sh library with grep command

2013-11-23 Thread Roy Smith
In article ,
 Luca  wrote:

> I'm trying to use sh (https://pypi.python.org/pypi/sh) for calling
> system grep command but it's now working as expected.
> 
> An example:
> 
> import sh
> sh.grep('abc', os.getcwd(), '-r')
> 
> But I get the ErrorReturnCode_1: exception, that I learned is the
> normal exit code for grep command when it not found any match.
> 
> The error instance object reported that the command run is:
> 
> *** ErrorReturnCode_1:
>   RAN: '/usr/bin/grep abc /Users/keul/test_sh'
> 
> Obviously manually running the command I get some output and exit code 0.
> 
> Where I'm wrong?

I'm not an expert on the sh module.  I took a quick look at the docs for 
it and didn't find anything about debugging or logging, but if there was 
something I missed which allows you to log what it's doing in greater 
detail, the first thing I would do is turn that on.

Here's some things I would try.

First, do:

dir = os.getcwd()
print dir

then pass dir as the second argument to grep().  It's one less variable 
in the equation.  Maybe os.getcwd() isn't returning what you think it 
is.  Not terribly likely, but easy to check, so eliminate that.

Next, try a simpler command.  Don't grep a whole directory, grep a 
single file.  Try:

sh.grep('abc', '/tmp/my-test-file')

and see what happens.  Get a simple case to work, then try the more 
complicated stuff.

Lastly, you might try pulling out the big guns.  Trace your entire 
process, with something like truss or strace (the details will be very 
system-dependent).  At some point, you're going to see your Python 
process do a fork/exec sequence on /bin/grep (or, perhaps, some other 
version of grep elsewhere in your path).  At that point, you'll know 
exactly what it ran, with what arguments.

Also, it helps when asking questions like this to tell us about your 
environment.  What version of Python are you running.  What version of 
the sh module did you download.  What operating system (I'm guessing 
OSX, just because of how /User/keul is capitalized).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method chaining

2013-11-23 Thread Laszlo Nagy




OK, that one is disgusting...

Anyway, I'd like to see a sequence of method names taken from actual code
that profits from this chaining pattern.


Actually, wx.lib.agw uses this a lot. Especially for AuiPaneInfo:

http://www.wxpython.org/docs/api/wx.aui.AuiPaneInfo-class.html

All right, this is a C++ proxy. But still, it is actively used by many.

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

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


Re: run command line on Windows without showing DOS console window

2013-11-23 Thread iMath
在 2013年11月20日星期三UTC+8下午10时49分50秒,Tim Golden写道:
> On 20/11/2013 14:44, iMath wrote:
> 
> > 
> 
> > 
> 
> > is there anyway to run command line on Windows without showing DOS console 
> > window ?
> 
> > 
> 
> > can you use the following command line to give a little example ?
> 
> > 
> 
> > wget -r -np -nd http://example.com/packages/
> 
> > 
> 
> > the path to wget is C:\Program Files\GnuWin32\bin\wget.exe
> 
> > 
> 
> 
> 
> subprocess.call(["wget", "-r", "-np", "-nd", "http://example.com";])
> 
> 
> 
> TJG
Have you tried it ? the DOS console window still pops up?
but I found when shell=True ,the DOS console window doesn't pop up,anyone can 
explain why ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using sh library with grep command

2013-11-23 Thread Peter Otten
Luca wrote:

> I'm trying to use sh (https://pypi.python.org/pypi/sh) for calling
> system grep command but it's now working as expected.
> 
> An example:
> 
> import sh
> sh.grep('abc', os.getcwd(), '-r')
> 
> But I get the ErrorReturnCode_1: exception, that I learned is the
> normal exit code for grep command when it not found any match.
> 
> The error instance object reported that the command run is:
> 
> *** ErrorReturnCode_1:
>   RAN: '/usr/bin/grep abc /Users/keul/test_sh'
> 
> Obviously manually running the command I get some output and exit code 0.
> 
> Where I'm wrong?

Did you run grep with or without the -r option? 

The code sample and the error message don't match. Maybe you accidentally 
left out the -r in your actual code.


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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Tim Chase
On 2013-11-23 10:44, Dennis Lee Bieber wrote:
> On Fri, 22 Nov 2013 23:42:44 -0700, Ian Kelly
>  declaimed the following:
> >
> >On Fri, Nov 22, 2013 at 8:47 PM, Dennis Lee Bieber
> > wrote:  
> >>
> >> Rice is the plural of rouse  
> >
> >Not according to the dictionary.  But it does seem a more likely
> >candidate for a hypothetical back formation than "ri", which
> >perhaps was your point.  
> 
>   Mice/Mouse <> Rice/*Rouse

Wordplay is one of my worst vouse. ;-)

-tkc


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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Steve Simmons

  
  
By the same logic
the plural of spouse is spice and most men that have had more
than one wife will tell you that, whilst it may be the
expectation, it ain't necessarily so  ;-)
 
On 23/11/2013 16:44, Dennis Lee Bieber
  wrote:


  On Fri, 22 Nov 2013 23:42:44 -0700, Ian Kelly 
declaimed the following:

  

On Fri, Nov 22, 2013 at 8:47 PM, Dennis Lee Bieber
 wrote:


  
Rice is the plural of rouse



Not according to the dictionary.  But it does seem a more likely
candidate for a hypothetical back formation than "ri", which perhaps
was your point.

  
  
	Mice/Mouse <> Rice/*Rouse





  

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 3:35 AM, Tim Chase
 wrote:
>>   Mice/Mouse <> Rice/*Rouse
>
> Wordplay is one of my worst vouse. ;-)

Yeah, some people can come up with bad puns in a trouse.

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Steve Simmons


On 23/11/2013 17:35, Chris Angelico wrote:

On Sun, Nov 24, 2013 at 3:35 AM, Tim Chase
 wrote:

   Mice/Mouse <> Rice/*Rouse

Wordplay is one of my worst vouse. ;-)

Yeah, some people can come up with bad puns in a trouse.

ChrisA

Well!  That wasn't very nouse!

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


Re: Using sh library with grep command

2013-11-23 Thread Luca Fabbri
On Sat, Nov 23, 2013 at 5:29 PM, Peter Otten <__pete...@web.de> wrote:
> Luca wrote:
>
>> I'm trying to use sh (https://pypi.python.org/pypi/sh) for calling
>> system grep command but it's now working as expected.
>>
>> An example:
>>
>> import sh
>> sh.grep('abc', os.getcwd(), '-r')
>>
>> But I get the ErrorReturnCode_1: exception, that I learned is the
>> normal exit code for grep command when it not found any match.
>>
>> The error instance object reported that the command run is:
>>
>> *** ErrorReturnCode_1:
>>   RAN: '/usr/bin/grep abc /Users/keul/test_sh'
>>
>> Obviously manually running the command I get some output and exit code 0.
>>
>> Where I'm wrong?
>
> Did you run grep with or without the -r option?
>
> The code sample and the error message don't match. Maybe you accidentally
> left out the -r in your actual code.
>

Sorry all, it was a stupid error and I provided a bad example.

I was running...
   sh.grep('"abc"', os.getcwd(), '-r')

...and the output of the command inside the exception was exactly...
RAN: '/usr/bin/grep "abc" /Users/keul/test_sh -r'

So, at first glance it was ok (copying/pasting it in in the terminal
return exactly was I expected).

The error? The doublequote inclusion.

Using this...
   sh.grep('abc', os.getcwd(), '-r')

...I  get this output...
RAN: '/usr/bin/grep abc /Users/keul/test_sh -r'

But this time I get the expected result (both in terminal and python
env). So seems that when quoting you get a false positive right
command output but a wrong execution.


-- 
-- luca

twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Denis McMahon
On Sat, 23 Nov 2013 02:18:03 +, Steven D'Aprano wrote:
> On Sat, 23 Nov 2013 01:55:44 +, Denis McMahon wrote:
>> On Fri, 22 Nov 2013 18:22:29 +0530, Bharath Kummar wrote:

>>> Could you PLEASE provide me with the codes (codes only for the asked
>>> queries) ?

>> The codes are:

>> 1) 7373a28109a7c4473a475b2137aa92d5 2) f2fae9a4ad5ded75e4d8ac34b90d5c9c
>> 3) 935544894ca6ad7239e0df048b9ec3e5 4) b1bc9942d029a4a67e4b368a1ff8d883

>> Please contact your local government eavesdropping agency for
>> assistance on decoding the codes.

> I'm not an expert on Indian English, but I understand that in that
> dialect it is grammatically correct to say "the codes", just as in UK
> and US English it is grammatically correct to say "the programs".

Sorry, I should obviously have replied to the OP as follows:

We don't write your python code for you, we help you to fix your python 
code. Please post the code you have developed to solve your problem, and 
explain what you expect it to do, and then we will try and explain to you 
why it's doing what it does instead of what you want it to.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method chaining

2013-11-23 Thread Rotwang

On 22/11/2013 11:26, Steven D'Aprano wrote:

A frequently missed feature is the ability to chain method calls:

x = []
x.append(1).append(2).append(3).reverse().append(4)
=> x now equals [3, 2, 1, 4]


This doesn't work with lists, as the methods return None rather than
self. The class needs to be designed with method chaining in mind before
it will work, and most Python classes follow the lead of built-ins like
list and have mutator methods return None rather than self.

Here's a proof-of-concept recipe to adapt any object so that it can be
used for chaining method calls:


class chained:
 def __init__(self, obj):
 self.obj = obj
 def __repr__(self):
 return repr(self.obj)
 def __getattr__(self, name):
 obj = getattr(self.obj, name)
 if callable(obj):
 def selfie(*args, **kw):
 # Call the method just for side-effects, return self.
 _ = obj(*args, **kw)
 return self
 return selfie
 else:
 return obj


chained([]).append(1).append(2).append(3).reverse().append(4)
=> returns [3, 2, 1, 4]


That's pretty cool. However, I can imagine it would be nice for the 
chained object to still be an instance of its original type. How about 
something like this:


def getr(self, name):
obj = super(type(self), self).__getattribute__(name)
if callable(obj):
def selfie(*args, **kwargs):
result = obj(*args, **kwargs)
return self if result is None else result
return selfie
return obj

class chained(type):
typedict = {}
def __new__(cls, obj):
if type(obj) not in cls.typedict:
cls.typedict[type(obj)]  = type.__new__(
cls, 'chained%s' % type(obj).__name__,
(type(obj),), {'__getattribute__': getr})
return cls.typedict[type(obj)](obj)


# In the interactive interpreter:
>>> d = chained({}).update({1: 2}).update({3: 4})
>>> d
{1: 2, 3: 4}
>>> type(d)

>>> isinstance(d, dict)
True


The above code isn't very good - it will only work on types whose 
constructor will copy an instance, and it discards the original. And its 
dir() is useless. Can anyone suggest something better?

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


Re: Periodic execution with asyncio

2013-11-23 Thread Tobias M.

Thanks a lot for your helpful posts, Terry!

On 11/23/2013 01:00 AM, Terry Reedy wrote:

* Make the task function a parameter 'func'.

I actually like subclassing, but yes I know there are some downsides :)


* Rename start to _set to better describe what is does and call it in 
the _run function to not repeat the handler setting line. (If 'start' 
has any magic meaning, I am not aware of it. I am aware that there 
could be situations in which one would want a public method, to be 
called from other handlers. But that would be a different class ;-)


* Comment out the stop method because it is useless in the current 
usage. I believe handler.cancel is only relevant after the handler is 
set and before it is fired. This can only be done from another handler.

You are right, the handler setting line should not be repeated.

I choose start() and stop() for controlling the task because this is an 
interface I would instantly understand as a user of this class.
By the way: My whole motivation is, that I want to implement such a task 
class in a network library I am currently writing.



On 11/23/2013 02:33 AM, Terry Reedy wrote:
I was initially baffled also until I managed to assemble all the 
needed pieces.


import asyncio

def f():
print('Hello World')

@asyncio.coroutine
def g(func, interval):
while True:
yield from asyncio.sleep(interval)
func()

loop = asyncio.get_event_loop()

try:
loop.run_until_complete(asyncio.Task(g(f, 2)))
except KeyboardInterrupt:
print('Loop stopped')

Thanks, now I got it. I just couldn't figure out that I have to yield 
from the sleep function.


Now putting this into a PeriodicTask class that provides a similar 
interface like our callback version, I get:



import asyncio

class PeriodicTask2(object):

 def __init__(self, func, interval):
 self.func = func
 self.interval = interval
 self._loop = asyncio.get_event_loop()

 def start(self):
 self.loop.run_until_complete(asyncio.Task(self._run()))

@asyncio.coroutine
 def _run(self):
 while True:
yield from asyncio.sleep(self.interval)
self.func()


I don't know if I misunderstood anything, but as a user of this class I 
am not able to run two task simultaneously because start() will block. 
In the callback version I could instanciate two PeriodicTasks and run 
them both at the same time (after a call to loop.run_forever()), which 
is actually what I wanted to achieve with this class.

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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Antoon Pardon
Op 23-11-13 10:01, Peter Otten schreef:

> 
> Your script is saying that a staticmethod instance is not a callable object. 
> It need not be because
> 
> Foo.foo()
> 
> doesn't call the Foo.foo attribute directly, it calls
> 
> Foo.foo.__get__(None, Foo)()

I think you are burdening the programmer with implemantation details
that don't matter to him.

IMO if Foo.foo() is legal then Foo.foo is callable. That the actual call
is delegated to Foo.foo.__get__(None, Foo) shouldn't matter.

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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 2:00 AM, Antoon Pardon
 wrote:
> IMO if Foo.foo() is legal then Foo.foo is callable. That the actual call
> is delegated to Foo.foo.__get__(None, Foo) shouldn't matter.

I absolutely agree. But isn't that already the case? I seem to be
missing something here.

>>> class Foo:
@staticmethod
def foo():
pass

>>> callable(Foo.foo)
True
>>> callable(Foo().foo)
True

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


Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Peter Otten
Antoon Pardon wrote:

> Op 23-11-13 10:01, Peter Otten schreef:
> 
>> 
>> Your script is saying that a staticmethod instance is not a callable
>> object. It need not be because
>> 
>> Foo.foo()
>> 
>> doesn't call the Foo.foo attribute directly, it calls
>> 
>> Foo.foo.__get__(None, Foo)()
> 
> I think you are burdening the programmer with implemantation details
> that don't matter to him.
> 
> IMO if Foo.foo() is legal then Foo.foo is callable. That the actual call
> is delegated to Foo.foo.__get__(None, Foo) shouldn't matter.

If you read the original post -- I think in this case the details do matter. 

What is your highlevel explanation for

>> class Foo:
... @staticmethod
... def foo(): pass
... try: foo()
... except Exception as err:
... print(err)
... 
'staticmethod' object is not callable
>>> Foo.foo()

or maybe clearer:

>>> @staticmethod
... def foo(): pass
... 
>>> def bar(): pass
... 
>>> class Foo:
... foo = foo
... bar = bar
... 
>>> Foo.bar is bar
True
>>> Foo.foo is foo
False

How would you explain that without mentioning the descriptor protocol?

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Rick Johnson
On Friday, November 22, 2013 8:18:03 PM UTC-6, Steven D'Aprano wrote:
> [snip] I look forward to the day that "rice" is the plural of "ri" 

Yes and i look forward to the day when "thread hijacking" perpetrated under the 
guise of "exploring linguistic minutia" perpetrated under the guise of "vanity" 
is frowned upon. 

PS: The only method chaining going on here is via the .brown_nosing() method.

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


stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
data = sock.recv(RECV_BUFFER)
username = str(sock.getpeername())
username = usernames[username]  
if command == "/quit":
print data
sock.send("bye")
sock.close()
CONNECTION_LIST.remove(sock)

even if the received data is '/quit' the if condition not excuting...please 
help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
 wrote:
> data = sock.recv(RECV_BUFFER)
> username = str(sock.getpeername())
> username = usernames[username]
> if command == "/quit":
> print data
> sock.send("bye")
> sock.close()
> CONNECTION_LIST.remove(sock)
>
> even if the received data is '/quit' the if condition not excuting...please 
> help.

At what point is command set? You're setting data here; is command
supposed to be derived from data?

This looks like a MUD or IRC style of server, which would suggest that
commands are terminated by end-of-line. You may need to take content
from the socket (currently in data) and split it off on either "\r\n"
or "\n". But it's hard to tell from this small snippet.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico  wrote:
> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
> 
>  wrote:
> 
> > data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]
> 
> > if command == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> >
> 
> > even if the received data is '/quit' the if condition not excuting...please 
> > help.
> 
> 
> 
> At what point is command set? You're setting data here; is command
> 
> supposed to be derived from data?
> 
> 
> 
> This looks like a MUD or IRC style of server, which would suggest that
> 
> commands are terminated by end-of-line. You may need to take content
> 
> from the socket (currently in data) and split it off on either "\r\n"
> 
> or "\n". But it's hard to tell from this small snippet.
> 
> 
> 
> ChrisA

sorry its not command its data

I miss wrote it here...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:29 AM, Bhanu Karthik
 wrote:
> sorry its not command its data
>
> I miss wrote it here...

Okay. Start by copying and pasting your actual code, and saying what
you're doing to trigger it. If this is a stream socket (eg TCP), you
have no way of knowing where one read will end and the next start, so
you'll need to do some kind of buffering and splitting.

Also, please use something better than Google Groups; your posts are
looking rather ugly, and it's the fault of your client rather than
yourself.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico  wrote:
> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
> 
>  wrote:
> 
> > data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]
> 
> > if command == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> >
> 
> > even if the received data is '/quit' the if condition not excuting...please 
> > help.
> 
> 
> 
> At what point is command set? You're setting data here; is command
> 
> supposed to be derived from data?
> 
> 
> 
> This looks like a MUD or IRC style of server, which would suggest that
> 
> commands are terminated by end-of-line. You may need to take content
> 
> from the socket (currently in data) and split it off on either "\r\n"
> 
> or "\n". But it's hard to tell from this small snippet.
> 
> 
> 
> ChrisA

 data = sock.recv(RECV_BUFFER)
username = str(sock.getpeername())
username = usernames[username]  
if data == "/quit":
print data
sock.send("bye")
sock.close()
CONNECTION_LIST.remove(sock)


this is exact code..
it is not even entering the if ...
I tried ( c= (data is '/quit')if c)

when i print c ,its printing falseI dont understand what is 
happening...please help..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Roy Smith
In article <8445e47e-7efe-4f37-9b40-db2896d58...@googlegroups.com>,
 Bhanu Karthik  wrote:

>  data = sock.recv(RECV_BUFFER)
>   username = str(sock.getpeername())
>   username = usernames[username]  
>   if data == "/quit":
>   print data
>   sock.send("bye")
>   sock.close()
>   CONNECTION_LIST.remove(sock)
> 
> 
> this is exact code..
> it is not even entering the if ...
> I tried ( c= (data is '/quit')if c)

That can't be the exact code.  What you posted is a syntax error because 
the line after the "if" statement isn't indented properly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:33 AM, Bhanu Karthik
 wrote:
> this is exact code..
> it is not even entering the if ...
> I tried ( c= (data is '/quit')if c)
>
> when i print c ,its printing falseI dont understand what is 
> happening...please help..

Again, please get off Google Groups. Have a look at how your posts come out:

https://mail.python.org/pipermail/python-list/2013-November/661005.html

Note how your quoted text is double-spaced. This is one of the most
obvious and obnoxious problems, though not the only one.

You have two problems here. Firstly, comparing strings with 'is' is
wrong in most cases[1], so stick with ==. And secondly, my crystal
ball says that you're typing "/quit" and pressing enter, so your
socket read will be "/quit\r\n" or "/quit\n". To properly handle this,
you'll need to buffer and split as I was describing.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:37:09 UTC-8, Roy Smith  wrote:
> In article <8445e47e-7efe-4f37-9b40-db2896d58...@googlegroups.com>,
> 
>  Bhanu Karthik  wrote:
> 
> 
> 
> >  data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]  
> 
> > if data == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> > 
> 
> > 
> 
> > this is exact code..
> 
> > it is not even entering the if ...
> 
> > I tried ( c= (data is '/quit')if c)
> 
> 
> 
> That can't be the exact code.  What you posted is a syntax error because 
> 
> the line after the "if" statement isn't indented properly.

indentation is correct when I trying to paste it here,it is showing like it is 
unindented.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:39 AM, Bhanu Karthik
 wrote:
> indentation is correct when I trying to paste it here,it is showing like it 
> is unindented.

That's because Google Groups mucks things up. Get a better client.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread MRAB
On 23/11/2013 22:29, Bhanu Karthik wrote:> On Saturday, 23 November 2013 
14:23:08 UTC-8, Chris Angelico  wrote:

>> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
>>  wrote:
>> > data = sock.recv(RECV_BUFFER)
>> > username = str(sock.getpeername())
>> > username = usernames[username]
>> > if command == "/quit":
>> > print data
>> > sock.send("bye")
>> > sock.close()
>> > CONNECTION_LIST.remove(sock)
>> >
>> > even if the received data is '/quit' the if condition not 
excuting...please help.

>>
>> At what point is command set? You're setting data here; is command
>> supposed to be derived from data?
>>
>> This looks like a MUD or IRC style of server, which would suggest that
>> commands are terminated by end-of-line. You may need to take content
>> from the socket (currently in data) and split it off on either "\r\n"
>> or "\n". But it's hard to tell from this small snippet.
>>
>> ChrisA
>
> sorry its not command its data
>
> I miss wrote it here...
>
If the 'if' condition not executing then it must be because the
received data isn't "/quit", so what is it? Print it out, or, even
better, print out repr(data), which will show you any spaces or "\n" in
it.

sock.recv(RECV_BUFFER) will receive up to RECV_BUFFER bytes, so if the
sender is sending other stuff after the "/quit" and RECV_BUFFER > 5,
then you might be receiving some of that later stuff too.

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


Re: Help me to print to screen as well as log

2013-11-23 Thread Dave Angel
On Sat, 23 Nov 2013 05:11:11 -0800 (PST), Himanshu Garg 
 wrote:
How can I write to the same file from two different scripts opened 

at same time?

Using what version of python and on what OS?

Sone OS's will open the file exclusively by default. Others will let 
you stomp all over some other process' output.


Why not show us what you're trying and what happens and ask a much 
more specific question?


--
DaveA

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Rick Johnson
On Friday, November 22, 2013 8:18:03 PM UTC-6, Steven D'Aprano wrote:
> As this is an international forum, it behoves us all to make allowances 
> for slight difference in dialect.

I don't thank so. What purpose does that serve?

If we allow people to speak INCORRECT English under the
guise of "political correctness" then no one will benefit.
The speaker will continue using the language improperly and
his audience will continue to be confused.

 "But Rick, we don't want to offend people!"

Piss off you spineless invertebrate!I would be more offended
if people did NOT correct me. People "correct" you when they
WANT you to learn, likewise, people "tolerate" you when they
want you to remain inferior.

 "Tolerance and apathy are the last virtues of a dying society"

Only those societies with a vision for the future will
survive, that is, until they inevitably grow tired from the
intense competition and lose their vision THEN apathy sets
in and a NEW society steps in to fill the vacuum.

 "Competition is the engine that drives the cogs of evolution"

You are all but pawns in a greater game. It is better to die
fighting for SOMETHING, then to wither away intolerant of
NOTHING. There exists no utopia. And any pursuit of such
ends is foolish.

Have you ever even considered what sort of disgusting filth
humans would degenerate into if we achieved a utopia free
from competition? What would we do all day? What purpose
would our lives fulfill?

 "Would you eat if you were never hungry?"

Evolution will NEVER allow such a dismal state to prosper,
no, it will stamp out every attempt by convincing the strong
to conquer the weak -- and to do so with extreme prejudice!

The system abhors the weak; the system ridicules the weak;
because the weak serve no end but their own selfish and feeble
attempts to convince themselves they are not but lowly pawns.

 "Time to pull your head out of the sand!"

People like you don't want to accept the truth, you want to
believe that "living in harmony" is the answer. No, harmony
is a death wish. If you wish to reach a state of harmony,
then not only are you suicidal but you're homicidal also
because you obviously don't care about your fellow human
beings future progression.

If however, you cared about what really matters, you would
advise our Indian friend to speak better English. By
learning proper English he can become a productive member of
this society -- maybe one day even contributing something
remarkable.

But until his communication can rise above the level of a
3rd grade public school student in rural Kentucky, he is
draining resources instead of creating them!I WANT our Indian
friend to become proficient so that he *might* one day be a
*worthy* advisory for me to challenge.

Anyone can defeat the weak, only the strong have a snowballs
chance in hell to defeat the strong.

 "Who said chivalry was dead?"

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Tim Chase
On 2013-11-23 15:06, Rick Johnson wrote:
> I don't thank so. What purpose does that serve?
> 
> If we allow people to speak INCORRECT English under the
> guise of "political correctness" then no one will benefit.

"I don't thank so"?

talk about the plank in your own eye...

-tkc



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


Automation P-I-D

2013-11-23 Thread Renato Barbosa Pim Pereira
I mentioned some time ago about a program to calculate PID constants for
tuning controllers, follow the link to its online version algorithm for
anyone interested http://pastebin.com/wAqZmVnR
I thank you for the help I received from many here on the list. ;D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 10:06 AM, Rick Johnson
 wrote:
> On Friday, November 22, 2013 8:18:03 PM UTC-6, Steven D'Aprano wrote:
>> As this is an international forum, it behoves us all to make allowances
>> for slight difference in dialect.
>
> I don't thank so. What purpose does that serve?
> ...
> Anyone can defeat the weak, only the strong have a snowballs
> chance in hell to defeat the strong.

Think. Snowball's. Welcome to Muphry's Law.

https://en.wikipedia.org/wiki/Muphry's_law

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Gregory Ewing

On Fri, Nov 22, 2013 at 8:47 PM, Dennis Lee Bieber
 wrote:

>

   Rice is the plural of rouse


And spice is the plural of spouse. :-)

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Gregory Ewing

Ian Kelly wrote:

I wouldn't necessarily even consider it an Indian thing, as I've known
Americans to use the same phrase.


In my experience it seems to be a scientific community
vs. computer science community thing. I often hear Fortran
people talk about "a code" where we would say "a library"
or "a piece of code".

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


Re: Help me to print to screen as well as log

2013-11-23 Thread Miki Tebeka
> I want that print "hello" should appear on screen as well as get saved in a 
> log file.
> How can I accomplish this?
There are many ways to do this, here's one:

class MultiWriter(object):
def __init__(self, *writers):
self.writers = writers
self.isatty = False

def write(self, data):
for writer in self.writers:
writer.write(data)

def flush(self):
for writer in self.writers:
writer.flush()


out = open('/tmp/log.txt', 'a')
import sys
sys.stdout = MultiWriter(sys.stdout, out)
print('hello')

IMO you're better with the logging package, see 
http://docs.python.org/2/howto/logging.html#configuring-logging for more 
details.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method chaining

2013-11-23 Thread Rotwang

On 23/11/2013 19:53, Rotwang wrote:

[...]

That's pretty cool. However, I can imagine it would be nice for the
chained object to still be an instance of its original type. How about
something like this:

[crap code]

The above code isn't very good - it will only work on types whose
constructor will copy an instance, and it discards the original. And its
dir() is useless. Can anyone suggest something better?


Here's another attempt:

class dummy:
pass

def initr(self, obj):
super(type(self), self).__setattr__('__obj', obj)
def getr(self, name):
try:
return super(type(self), self).__getattribute__(name)
except AttributeError:
return getattr(self.__obj, name)
def methr(method):
def selfie(self, *args, **kwargs):
result = method(self.__obj, *args, **kwargs)
return self if result is None else result
return selfie

class chained(type):
typedict = {}
def __new__(cls, obj):
if type(obj) not in cls.typedict:
dict = {}
for t in reversed(type(obj).__mro__):
dict.update({k: methr(v) for k, v in t.__dict__.items()
if callable(v) and k != '__new__'})
dict.update({'__init__': initr, '__getattribute__': getr})
cls.typedict[type(obj)] = type.__new__(cls, 'chained%s'
% type(obj).__name__, (dummy, type(obj)), dict)
return cls.typedict[type(obj)](obj)


This solves some of the problems in my earlier effort. It keeps a copy 
of the original object, while leaving its interface pretty much 
unchanged; e.g. repr does what it's supposed to, and getting or setting 
an attribute of the chained object gets or sets the corresponding 
attribute of the original. It won't work on classes with properties, 
though, nor on classes with callable attributes that aren't methods (for 
example, a class with an attribute which is another class).

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


Re: Method chaining

2013-11-23 Thread Rotwang

On 24/11/2013 00:28, Rotwang wrote:

[...]

This solves some of the problems in my earlier effort. It keeps a copy
of the original object,


Sorry, I meant that it keeps a reference to the original object.
--
https://mail.python.org/mailman/listinfo/python-list


Re: python for everyday tasks

2013-11-23 Thread koch . mate
Thank you very much, that's much more detailed than I dared to hope for, it's 
going to be a great help.  :) Since the course will begin in January, I'm just 
starting to prepare, I'm happy to hear any other ideas, comments. 

Thank you all,
Mate
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Steven D'Aprano
On Sat, 23 Nov 2013 15:06:42 -0800, Rick Johnson wrote:

> On Friday, November 22, 2013 8:18:03 PM UTC-6, Steven D'Aprano wrote:
>> As this is an international forum, it behoves us all to make allowances
>> for slight difference in dialect.
> 
> I don't thank so. What purpose does that serve?
> 
> If we allow people to speak INCORRECT English under the guise of
> "political correctness" then no one will benefit.
[...]

Thank you for the lesson in the virtues of bluntness, and why politeness 
and political correctness is a vice. Never let it be said that I'm not 
willing to learn from you Rick, so keeping everything you said in mind, 
let me say this:

It's not INCORRECT English, you small-minded little git. That was the 
point of my post, which clearly was too difficult for your feeble little 
thought processes to comprehend. Where do you, an American, get off 
telling others that their regional variety of English is incorrect?

After criticising me for hijacking threads, the hypocrisy and cheek of 
you doing the same thing with your odious and naive social Darwinism is 
breathtaking. Sod off and take your despicable little Randian pseudo-
philosophy with you.


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


Re: Recursive generator for combinations of a multiset?

2013-11-23 Thread John O'Hagan
On Sat, 23 Nov 2013 04:23:42 +
MRAB  wrote:

> On 23/11/2013 00:58, John O'Hagan wrote:
> > On Thu, 21 Nov 2013 12:59:26 -0800
> > Dan Stromberg  wrote:
> >
> >> On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan
> >> wrote:
> >>
> >> >
> >> > Short story: the subject says it all, so if you have an answer
> >> > already, fire away. Below is the long story of what I'm using it
> >> > for, and why I think it needs to be recursive. It may even be of
> >> > more general interest in terms of filtering the results of
> >> > generators.
> >> >
> >>
> >> I think you probably need permutations rather than combinations.
> >>
> >> Also, I think you'll need to form a word (partitioned off by
> >> spaces), and then check it against a set
> >> containing /usr/share/dict/words before recursing for the
> >> remainder of the sentence - this should speed things up a LOT.
> >
> > Thanks for the reply. If I understand you correctly, you are
> > suggesting permuting the input _characters_ to form words and then
> > seeing if they exist, as opposed to my approach of combining known
> > words and seeing if they are anagrams. (Permutations of words would
> > not help find anagrams as they merely change the word order). Here
> > is an attempt at that:
> >
> > def anagrams(partition, input_string):
> >  """Find anagrams which fit given partition of input string
> > length""" if not partition:
> >  yield (), input_string
> >  return
> >  for words, checkstring in anagrams(partition[:-1],
> > input_string): for word in itertools.permutations(checkstring,
> > partition[-1]): word = ''.join(word)
> >  if word in WORDS: #WORDS is collection of dictionary
> > words newstring = checkstring
> >  for l in word:
> >  newstring = newstring.replace(l, '' , 1)
> >  yield words + (word,), newstring
> >
> > There are two problems with this. If there are repeated characters
> > in the input, redundant results are produced; a multiset-permutation
> > algorithm would fix this. But the main problem is it is incredibly
> > slow: on my run-of-the-mill laptop, it chokes on anything longer
> > than about 10 characters, spending most of its time rejecting
> > non-words.
> >
> > Or have I misunderstood your suggestion?
> >
> If you want to know how to get unique permutations, have a look here:
> 
> http://mail.python.org/pipermail/python-ideas/2013-October/023610.html
> 

For this particular problem I don't need multiset permutations but
multiset combinations (see original post). But that thread was a good
read.

This is a little OT, but I did need multiset permutations a couple of
years back for a project involving the generation of musical
structures. There was zero interest here at the time (fair enough!) and
I ended up implementing the C++ function "next_permutation" in Python.

So it was good to read in that thread that there seems to be some
interest in incorporating multiset combinatorics into itertools
(including your excellent contribution). IMHO the scepticism there about
non-exotic use-cases was unjustified. Leaving aside my probably atypical
uses, it crops in many ordinary situations dealing with arrangements of
multiple items of several types where each instance of a type is
equivalent. Take stock control: when stacking a warehouse shelf it
doesn't matter which particular box goes where, only how many of each
size. Or timetabling: if Mrs Smith teaches the same students maths on
Tuesdays and Thursdays, swapping the classes does nothing. 

The same goes for cyclic and cyclic-multiset ("necklaces")
combinatorics, where the beginning and end of an arrangement is not
significant, eg. 24-hour rostering, laying tiles, etc. And musical
scales.

Disclaimer: I am far from expert on combinatorics but seem to end up
using it a lot.

--

John

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


Re: Recursive generator for combinations of a multiset?

2013-11-23 Thread John O'Hagan
On Fri, 22 Nov 2013 22:33:29 -0800
Dan Stromberg  wrote:

> On Fri, Nov 22, 2013 at 4:58 PM, John O'Hagan
> wrote:
> 
> > On Thu, 21 Nov 2013 12:59:26 -0800
> > Dan Stromberg  wrote:
> >
> > > On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan
> > > wrote:
> > >
> > > >
> > > > Short story: the subject says it all, so if you have an answer
> > > > already, fire away. Below is the long story of what I'm using it
> > > > for, and why I think it needs to be recursive. It may even be of
> > > > more general interest in terms of filtering the results of
> > > > generators.
> > > >
> > >
> > > I think you probably need permutations rather than combinations.
> > >
> > > Also, I think you'll need to form a word (partitioned off by
> > > spaces), and then check it against a set
> > > containing /usr/share/dict/words before recursing for the
> > > remainder of the sentence - this should speed things up a LOT.
> >
> > Thanks for the reply. If I understand you correctly, you are
> > suggesting permuting the input _characters_ to form words and then
> > seeing if they exist, as opposed to my approach of combining known
> > words and seeing if they are anagrams. (Permutations of words would
> > not help find anagrams as they merely change the word order). Here
> > is an attempt at that:
> 
> 
> You've interpreted me correctly.
> 
> However, I was thinking about this in the back of my mind, and
> decided it would probably be best to inhale /usr/share/dict/words (if
> on Linux), and pull out words of the corrects lengths (as separated
> by the blanks) over the correct (possible) alphabet, and permute
> Those, afterward checking if they form good anagrams of the original
> sentence.  This would probably be much faster, since English isn't
> that dense of a space.

If you look back at my original question, you'll see that's pretty much
what I've done. I didn't spell out all the details, but  I made a
dictionary of wordlength keys containing lists of all dictionary words
of that length made of the correct sub-alphabet.

But to to recap the problem: to produce non-redundant anagram phrases, I
need the cartesian product (not permutations) of these lists if each is
unique, but with a subroutine producing multiset combinations if a list
is repeated, i.e., if a particular length is called for more than once.
The version I have so far is correct but substantially slower than the
product-only one, which just goes ahead and produces all the redundant
results. This seems counter-intuitive, and my theory is that this is
because I am unable to "prune" the non-recursive combination algorithm
I currently have.

Regards,

--

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


Importing by file name

2013-11-23 Thread Chris Angelico
As part of a post on python-ideas, I wanted to knock together a quick
little script that "imports" a file based on its name, in the same way
that the Python interpreter will happily take an absolute pathname for
the main script. I'm sure there's a way to do it, but I don't know
how. Obviously the import statement can't do it, but I've been poking
around with __import__ and importlib without success. (Experiments are
being done on Python 3.3; if a different version would make the job
easier I'm happy to switch. This is just a curiosity tinkering.)

Here's my current attempts (tracebacks chomped as they aren't very
helpful here):

>>> import "/x.py"
SyntaxError: invalid syntax
>>> importlib.import_module("/x.py")
ImportError: No module named '/x'
>>> importlib.import_module("/x")
ImportError: No module named '/x'

The best I can come up with is manually execing the file contents:
>>> g={}
>>> exec("def __main__():\n\tprint('Hello, world!')\n",g)
>>> g["__main__"]()
Hello, world!

But that's not importing. Is there a way to do this as a module import?

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


Re: Importing by file name

2013-11-23 Thread Devin Jeanpierre
On Sat, Nov 23, 2013 at 7:41 PM, Chris Angelico  wrote:
> As part of a post on python-ideas, I wanted to knock together a quick
> little script that "imports" a file based on its name, in the same way
> that the Python interpreter will happily take an absolute pathname for
> the main script. I'm sure there's a way to do it, but I don't know
> how. Obviously the import statement can't do it, but I've been poking
> around with __import__ and importlib without success. (Experiments are
> being done on Python 3.3; if a different version would make the job
> easier I'm happy to switch. This is just a curiosity tinkering.)

The easiest way is probably to modify what directories python searches
- sys.path:

import os
import sys

def file_import(path):
dname, fname = os.path.split(path)
modname, _ext = os.path.splitext(fname)
sys.path.insert(0, dname)
try:
return __import__(modname)
finally:
del sys.path[0]

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


Re: Help me to print to screen as well as log

2013-11-23 Thread Himanshu Garg
I have simply opened file in append mode in linux.

script 1 :

file = open("output.log", "a")
file.write()
file.flush()

script 2:

file = open("output.log", "a")
file.write()
file.flush()

It writes properly to the file.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Devin Jeanpierre
On Sat, Nov 23, 2013 at 5:38 PM, Steven D'Aprano
 wrote:
> Thank you for the lesson in the virtues of bluntness, and why politeness
> and political correctness is a vice. Never let it be said that I'm not
> willing to learn from you Rick, so keeping everything you said in mind,
> let me say this:
>
> --[tirade of insults]--

No, please don't.

If Rick is that annoying and harmful to discussion (he is), rather
than blowing up at him, can we please ban him from the ML? I know that
usenet cannot be affected, but anyone that cares about productive
discussions can either maintain a killfile or use the mailing list.
The state of discussion here as it stands is absurd, what with the
trolling and irrelevant rants and subsequent explosions of hate.

This list needs stronger moderation. Please.

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 6:32 PM, Devin Jeanpierre
 wrote:
> On Sat, Nov 23, 2013 at 5:38 PM, Steven D'Aprano
>  wrote:
>> Thank you for the lesson in the virtues of bluntness, and why politeness
>> and political correctness is a vice. Never let it be said that I'm not
>> willing to learn from you Rick, so keeping everything you said in mind,
>> let me say this:
>>
>> --[tirade of insults]--
>
> No, please don't.
>
> If Rick is that annoying and harmful to discussion (he is), rather
> than blowing up at him, can we please ban him from the ML? I know that
> usenet cannot be affected, but anyone that cares about productive
> discussions can either maintain a killfile or use the mailing list.
> The state of discussion here as it stands is absurd, what with the
> trolling and irrelevant rants and subsequent explosions of hate.
>
> This list needs stronger moderation. Please.

I think this was a case of misrecognized humour... Rick was saying
that it's better to offend people than to let them be wrong, so Steven
took that style to its obvious extreme.

Also, Rick clearly went into Room 12, when he should have gone to 12A,
next door.[1]

ChrisA

[1] http://www.montypython.net/scripts/argument.php
-- 
https://mail.python.org/mailman/listinfo/python-list